[Mingw-w64-public] [PATCH 6/6] winpthreads: Don't use GCC __sync_synchronize

2023-12-28 Thread Antonin Décimo
The __sync_synchronize built-in function [1] is deprecated, and not defined with MSVC. Prefer MemoryBarrier [2] and _ReadWriteBarrier [3]. [1]: https://gcc.gnu.org/onlinedocs/gcc/_005f_005fsync-Builtins.html#index-_005f_005fsync_005fsynchronize [2]: https://learn.microsoft.com/en-us/windows/win3

[Mingw-w64-public] [PATCH 4/6] winpthreads: Use GetTickCount64 directly if available

2023-12-28 Thread Antonin Décimo
If we're compiling for Windows 6 (Vista, Server 2008) or later, the GetTickCount64 [1] function is available. Note that MSVC as of version 19.39 doesn't provide __attribute__((constructor)), or the __typeof__ extension. [1]: https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinf

[Mingw-w64-public] [PATCH 5/6] winpthreads: Replace GCC's __sync comparisons with WinAPI functions

2023-12-28 Thread Antonin Décimo
Legacy `__sync_*` GCC built-in functions for memory access [1] are deprecated and MSVC doesn't provide them. Consequently, use Windows' Interlocked Variable Access [2] functions instead. [1]: https://gcc.gnu.org/onlinedocs/gcc/_005f_005fsync-Builtins.html [2]: https://learn.microsoft.com/en-us/wi

[Mingw-w64-public] [PATCH 0/6] winpthreads: MSVC support without GCC extensions

2023-12-28 Thread Antonin Décimo
This patch series enables building winpthreads with MSVC. The missing steps were about removing uses of GCC extensions, in favor of using functions already provided by windows.h. MinGW also provides these functions, so there is no need for redefinitions in winpthreads. If there's interest, further

[Mingw-w64-public] [PATCH 3/6] winpthreads: Use YieldProcessor in pthread_spin_lock

2023-12-28 Thread Antonin Décimo
Use YieldProcessor which already has the best definition for all MSVC and MinGW supported architectures of the memory pause / yield instruction. Signed-off-by: Antonin Décimo --- mingw-w64-libraries/winpthreads/src/misc.h | 8 mingw-w64-libraries/winpthreads/src/spinlock.c | 8 +

[Mingw-w64-public] [PATCH 2/6] winpthreads: Fix pthread_create_wrapper type

2023-12-28 Thread Antonin Décimo
- Make pthread_create_wrapper return an unsigned; _beginthreadindex takes a function returning an unsigned. The variable holding the return value of pthread_create_wrapper is already an unsigned. - Make pthread_create_wrapper __stdcall. Co-authored-by: Samuel Hym Signed-off-by: Antonin Dé

[Mingw-w64-public] [PATCH 1/6] winpthreads: Check if requested stack size fits in an unsigned int

2023-12-28 Thread Antonin Décimo
The requested stack size is a `size_t`, whereas _beginthreadex takes an `unsigned int`. This provides a bit of input sanitation, and prevents a compiler warning. Co-authored-by: Samuel Hym Signed-off-by: Antonin Décimo --- mingw-w64-libraries/winpthreads/src/thread.c | 7 +-- 1 file changed