diff --git a/libfreerdp/utils/smartcard_operations.c b/libfreerdp/utils/smartcard_operations.c index fd7be8210..1d03b92db 100644 --- a/libfreerdp/utils/smartcard_operations.c +++ b/libfreerdp/utils/smartcard_operations.c @@ -801,7 +801,7 @@ LONG smartcard_irp_device_control_decode(wStream* s, UINT32 CompletionId, UINT32 if (Stream_GetPosition(s) < Stream_Length(s)) { - SIZE_T difference = 0; + size_t difference = 0; difference = Stream_Length(s) - Stream_GetPosition(s); WLog_WARN(TAG, "IRP was not fully parsed %s (%s [0x%08" PRIX32 "]): Actual: %" PRIuz @@ -814,7 +814,7 @@ LONG smartcard_irp_device_control_decode(wStream* s, UINT32 CompletionId, UINT32 if (Stream_GetPosition(s) > Stream_Length(s)) { - SIZE_T difference = 0; + size_t difference = 0; difference = Stream_GetPosition(s) - Stream_Length(s); WLog_WARN(TAG, "IRP was parsed beyond its end %s (0x%08" PRIX32 "): Actual: %" PRIuz diff --git a/winpr/CMakeLists.txt b/winpr/CMakeLists.txt index 5a87cb865..17b4ba2cc 100644 --- a/winpr/CMakeLists.txt +++ b/winpr/CMakeLists.txt @@ -158,6 +158,10 @@ else() set(WINPR_VERSION_FULL "${WINPR_VERSION}") endif() +include(CheckTypeSize) +check_type_size(ssize_t SSIZE_T) +set(WINPR_HAVE_SSIZE_T ${HAVE_SSIZE_T}) + if(NOT IOS) CHECK_SYMBOL_EXISTS(strndup string.h WINPR_HAVE_STRNDUP) check_include_files(unistd.h WINPR_HAVE_UNISTD_H) diff --git a/winpr/include/config/config.h.in b/winpr/include/config/config.h.in index 0e6959bdb..0d53e7749 100644 --- a/winpr/include/config/config.h.in +++ b/winpr/include/config/config.h.in @@ -23,6 +23,7 @@ #cmakedefine WINPR_HAVE_GETPWUID_R #cmakedefine WINPR_HAVE_STRNDUP #cmakedefine WINPR_HAVE_UNWIND_H +#cmakedefine WINPR_HAVE_SSIZE_T #cmakedefine WINPR_WITH_PNG #cmakedefine WINPR_HAVE_STRERROR_R /** @since version 3.3.0 */ diff --git a/winpr/include/config/wtypes.h.in b/winpr/include/config/wtypes.h.in index 67aee9404..e34f1cd35 100644 --- a/winpr/include/config/wtypes.h.in +++ b/winpr/include/config/wtypes.h.in @@ -331,8 +331,13 @@ typedef __uint3264 ULONG_PTR, typedef __uint3264 DWORD_PTR, *PDWORD_PTR; // NOLINT(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp) -typedef ULONG_PTR SIZE_T, *PSIZE_T; +typedef ULONG_PTR SIZE_T, *PSIZE_T; /** deprecated */ +#if defined(WINPR_HAVE_SSIZE_T) +#include +typedef ssize_t SSIZE_T, *PSSIZE_T; +#else typedef LONG_PTR SSIZE_T, *PSSIZE_T; +#endif typedef float FLOAT; diff --git a/winpr/include/winpr/crt.h b/winpr/include/winpr/crt.h index e1a3d3cc5..8375b6fdf 100644 --- a/winpr/include/winpr/crt.h +++ b/winpr/include/winpr/crt.h @@ -129,7 +129,7 @@ extern "C" { #endif - WINPR_API PVOID SecureZeroMemory(PVOID ptr, SIZE_T cnt); + WINPR_API PVOID SecureZeroMemory(PVOID ptr, size_t cnt); #ifdef __cplusplus } diff --git a/winpr/include/winpr/memory.h b/winpr/include/winpr/memory.h index 09f83bddc..431778aa9 100644 --- a/winpr/include/winpr/memory.h +++ b/winpr/include/winpr/memory.h @@ -55,13 +55,13 @@ extern "C" WINPR_API LPVOID MapViewOfFile(HANDLE hFileMappingObject, DWORD dwDesiredAccess, DWORD dwFileOffsetHigh, DWORD dwFileOffsetLow, - SIZE_T dwNumberOfBytesToMap); + size_t dwNumberOfBytesToMap); WINPR_API LPVOID MapViewOfFileEx(HANDLE hFileMappingObject, DWORD dwDesiredAccess, DWORD dwFileOffsetHigh, DWORD dwFileOffsetLow, - SIZE_T dwNumberOfBytesToMap, LPVOID lpBaseAddress); + size_t dwNumberOfBytesToMap, LPVOID lpBaseAddress); - WINPR_API BOOL FlushViewOfFile(LPCVOID lpBaseAddress, SIZE_T dwNumberOfBytesToFlush); + WINPR_API BOOL FlushViewOfFile(LPCVOID lpBaseAddress, size_t dwNumberOfBytesToFlush); WINPR_API BOOL UnmapViewOfFile(LPCVOID lpBaseAddress); diff --git a/winpr/include/winpr/pool.h b/winpr/include/winpr/pool.h index efc467c5b..da3aa90d4 100644 --- a/winpr/include/winpr/pool.h +++ b/winpr/include/winpr/pool.h @@ -38,8 +38,8 @@ typedef struct S_TP_POOL TP_POOL, *PTP_POOL; typedef struct { - SIZE_T StackReserve; - SIZE_T StackCommit; + size_t StackReserve; + size_t StackCommit; } TP_POOL_STACK_INFORMATION, *PTP_POOL_STACK_INFORMATION; typedef struct S_TP_CLEANUP_GROUP TP_CLEANUP_GROUP, *PTP_CLEANUP_GROUP; diff --git a/winpr/include/winpr/sspicli.h b/winpr/include/winpr/sspicli.h index bea9e9a7b..64727c30a 100644 --- a/winpr/include/winpr/sspicli.h +++ b/winpr/include/winpr/sspicli.h @@ -44,11 +44,11 @@ typedef struct { - SIZE_T PagedPoolLimit; - SIZE_T NonPagedPoolLimit; - SIZE_T MinimumWorkingSetSize; - SIZE_T MaximumWorkingSetSize; - SIZE_T PagefileLimit; + size_t PagedPoolLimit; + size_t NonPagedPoolLimit; + size_t MinimumWorkingSetSize; + size_t MaximumWorkingSetSize; + size_t PagefileLimit; LARGE_INTEGER TimeLimit; } QUOTA_LIMITS, *PQUOTA_LIMITS; diff --git a/winpr/include/winpr/synch.h b/winpr/include/winpr/synch.h index c59c97981..6d24a0cb9 100644 --- a/winpr/include/winpr/synch.h +++ b/winpr/include/winpr/synch.h @@ -194,7 +194,7 @@ extern "C" WINPR_API VOID WakeByAddressAll(PVOID Address); WINPR_API VOID WakeByAddressSingle(PVOID Address); - WINPR_API BOOL WaitOnAddress(VOID volatile* Address, PVOID CompareAddress, SIZE_T AddressSize, + WINPR_API BOOL WaitOnAddress(VOID volatile* Address, PVOID CompareAddress, size_t AddressSize, DWORD dwMilliseconds); /* Wait */ diff --git a/winpr/include/winpr/thread.h b/winpr/include/winpr/thread.h index f31b17238..5a9b77cc0 100644 --- a/winpr/include/winpr/thread.h +++ b/winpr/include/winpr/thread.h @@ -231,13 +231,13 @@ extern "C" #define STACK_SIZE_PARAM_IS_A_RESERVATION 0x00010000 WINPR_ATTR_MALLOC(CloseHandle, 1) - WINPR_API HANDLE CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize, + WINPR_API HANDLE CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, size_t dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId); WINPR_ATTR_MALLOC(CloseHandle, 1) WINPR_API HANDLE CreateRemoteThread(HANDLE hProcess, LPSECURITY_ATTRIBUTES lpThreadAttributes, - SIZE_T dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress, + size_t dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId); diff --git a/winpr/libwinpr/crt/memory.c b/winpr/libwinpr/crt/memory.c index 40c6c859c..ffe62bff2 100644 --- a/winpr/libwinpr/crt/memory.c +++ b/winpr/libwinpr/crt/memory.c @@ -26,7 +26,7 @@ #ifndef _WIN32 -PVOID SecureZeroMemory(PVOID ptr, SIZE_T cnt) +PVOID SecureZeroMemory(PVOID ptr, size_t cnt) { volatile BYTE* p = ptr; diff --git a/winpr/libwinpr/crt/test/TestTypes.c b/winpr/libwinpr/crt/test/TestTypes.c index 906032638..1d9a0346a 100644 --- a/winpr/libwinpr/crt/test/TestTypes.c +++ b/winpr/libwinpr/crt/test/TestTypes.c @@ -36,7 +36,7 @@ #define EXPECTED_SIZEOF_ULARGE_INTEGER 8 #define EXPECTED_SIZEOF_GUID 16 #define EXPECTED_SIZEOF_SYSTEMTIME 16 -#define EXPECTED_SIZEOF_SIZE_T sizeof(void*) +#define EXPECTED_SIZEOF_size_t sizeof(void*) #define EXPECTED_SIZEOF_INT_PTR sizeof(void*) #define EXPECTED_SIZEOF_UINT_PTR sizeof(void*) #define EXPECTED_SIZEOF_DWORD_PTR sizeof(void*) @@ -104,7 +104,7 @@ int TestTypes(int argc, char* argv[]) TEST_SIZEOF_TYPE(GUID) TEST_SIZEOF_TYPE(SYSTEMTIME) - TEST_SIZEOF_TYPE(SIZE_T) + TEST_SIZEOF_TYPE(size_t) TEST_SIZEOF_TYPE(INT_PTR) TEST_SIZEOF_TYPE(UINT_PTR) TEST_SIZEOF_TYPE(DWORD_PTR) diff --git a/winpr/libwinpr/memory/memory.c b/winpr/libwinpr/memory/memory.c index 83f4c0782..5c6f5e042 100644 --- a/winpr/libwinpr/memory/memory.c +++ b/winpr/libwinpr/memory/memory.c @@ -104,18 +104,18 @@ HANDLE OpenFileMappingW(DWORD dwDesiredAccess, BOOL bInheritHandle, LPCWSTR lpNa } LPVOID MapViewOfFile(HANDLE hFileMappingObject, DWORD dwDesiredAccess, DWORD dwFileOffsetHigh, - DWORD dwFileOffsetLow, SIZE_T dwNumberOfBytesToMap) + DWORD dwFileOffsetLow, size_t dwNumberOfBytesToMap) { return NULL; } LPVOID MapViewOfFileEx(HANDLE hFileMappingObject, DWORD dwDesiredAccess, DWORD dwFileOffsetHigh, - DWORD dwFileOffsetLow, SIZE_T dwNumberOfBytesToMap, LPVOID lpBaseAddress) + DWORD dwFileOffsetLow, size_t dwNumberOfBytesToMap, LPVOID lpBaseAddress) { return NULL; } -BOOL FlushViewOfFile(LPCVOID lpBaseAddress, SIZE_T dwNumberOfBytesToFlush) +BOOL FlushViewOfFile(LPCVOID lpBaseAddress, size_t dwNumberOfBytesToFlush) { return TRUE; } diff --git a/winpr/libwinpr/synch/address.c b/winpr/libwinpr/synch/address.c index d6d074b5f..c6b10abc4 100644 --- a/winpr/libwinpr/synch/address.c +++ b/winpr/libwinpr/synch/address.c @@ -37,7 +37,7 @@ VOID WakeByAddressSingle(PVOID Address) { } -BOOL WaitOnAddress(VOID volatile* Address, PVOID CompareAddress, SIZE_T AddressSize, +BOOL WaitOnAddress(VOID volatile* Address, PVOID CompareAddress, size_t AddressSize, DWORD dwMilliseconds) { return TRUE; diff --git a/winpr/libwinpr/thread/thread.c b/winpr/libwinpr/thread/thread.c index 747843da6..f1b239f8c 100644 --- a/winpr/libwinpr/thread/thread.c +++ b/winpr/libwinpr/thread/thread.c @@ -678,7 +678,7 @@ BOOL SetThreadPriority(HANDLE hThread, int nPriority) #endif } -HANDLE CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize, +HANDLE CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, size_t dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId) { @@ -814,7 +814,7 @@ BOOL ThreadCloseHandle(HANDLE handle) } HANDLE CreateRemoteThread(HANDLE hProcess, LPSECURITY_ATTRIBUTES lpThreadAttributes, - SIZE_T dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress, + size_t dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId) { WLog_ERR(TAG, "not implemented"); diff --git a/winpr/libwinpr/thread/thread.h b/winpr/libwinpr/thread/thread.h index 92d05d3ca..d6a9009c3 100644 --- a/winpr/libwinpr/thread/thread.h +++ b/winpr/libwinpr/thread/thread.h @@ -54,7 +54,7 @@ struct winpr_thread WINPR_ALIGN64 BOOL exited; WINPR_ALIGN64 DWORD dwExitCode; WINPR_ALIGN64 pthread_t thread; - WINPR_ALIGN64 SIZE_T dwStackSize; + WINPR_ALIGN64 size_t dwStackSize; WINPR_ALIGN64 LPVOID lpParameter; WINPR_ALIGN64 pthread_mutex_t mutex; mux_condition_bundle isRunning;