Sorry, I forgot to attach patches. ________________________________ From: Kirill Makurin <maiddais...@outlook.com> Sent: Thursday, February 20, 2025 2:33 AM To: mingw-w64-public <mingw-w64-public@lists.sourceforge.net> Subject: winpthreads: a few more header file cleanups
Patch 1: remove old, commented out typedef for `pthread_t`. Patch 2: move `SIG_BLOCK`, `SIG_UNBLOCK` and `SIG_SETMASK` from pthread.h to pthread_signal.h. Also include pthread_signal.h from pthread.h when compiling with MSVC. Please note that pthread_signal.h is also included from mingw-w64's signal.h. Patch 3: remove macro `USE_SEM_CriticalSection_SpinCount` from semaphore.h. I do not know what was the use of this macro before, but it is not referenced anywhere in the source files. pthread.h seems to expose some internal functions, I could look more into it when I get time. I also took a look at `tests_pthread` subdirectory. All tests seem to be simple return-code based tests which can be integrated with Automake's `TESTS`. However, some of them do not compile with recent GCC because some warnings are errors now by default. Also, some tests do not compile with MSVC as they use `pthread_t` as if it was an old struct removed in patch 1. I don't know if anyone uses these tests the way the are now, so I think integrating them with Automake could be useful. - Kirill Makurin
From 4ca449c0c421c62c8d2bd39474da3a39e1a74e93 Mon Sep 17 00:00:00 2001 From: Kirill Makurin <maiddais...@outlook.com> Date: Thu, 20 Feb 2025 02:14:01 +0900 Subject: [PATCH 1/3] winpthreads: remove old typedef of pthread_t from pthread.h Signed-off-by: Kirill Makurin <maiddais...@outlook.com> --- mingw-w64-libraries/winpthreads/include/pthread.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/mingw-w64-libraries/winpthreads/include/pthread.h b/mingw-w64-libraries/winpthreads/include/pthread.h index bc9735924..7b295ae7f 100644 --- a/mingw-w64-libraries/winpthreads/include/pthread.h +++ b/mingw-w64-libraries/winpthreads/include/pthread.h @@ -166,16 +166,6 @@ typedef unsigned pthread_key_t; typedef void *pthread_barrierattr_t; typedef int pthread_condattr_t; typedef int pthread_rwlockattr_t; - -/* -struct _pthread_v; - -typedef struct pthread_t { - struct _pthread_v *p; - int x; -} pthread_t; -*/ - typedef uintptr_t pthread_t; typedef struct _pthread_cleanup _pthread_cleanup; -- 2.46.1.windows.1
From 528640523d59f32e16de4b50991a740a783c9402 Mon Sep 17 00:00:00 2001 From: Kirill Makurin <maiddais...@outlook.com> Date: Thu, 20 Feb 2025 02:16:25 +0900 Subject: [PATCH 2/3] winpthreads: move SIG_* constants from pthread.h to pthread_signal.h Explicitly include pthread_signal.h from pthread.h when compiling with MSVC. Signed-off-by: Kirill Makurin <maiddais...@outlook.com> --- mingw-w64-libraries/winpthreads/include/pthread.h | 11 +---------- .../winpthreads/include/pthread_signal.h | 10 ++++++++++ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/mingw-w64-libraries/winpthreads/include/pthread.h b/mingw-w64-libraries/winpthreads/include/pthread.h index 7b295ae7f..c66b18347 100644 --- a/mingw-w64-libraries/winpthreads/include/pthread.h +++ b/mingw-w64-libraries/winpthreads/include/pthread.h @@ -72,6 +72,7 @@ #include "sched.h" #ifdef _MSC_VER +#include "pthread_signal.h" #include "pthread_time.h" #endif @@ -366,16 +367,6 @@ WINPTHREAD_API int pthread_rwlockattr_getpshared(pthread_rwlockattr_t *a, int *s WINPTHREAD_API int pthread_rwlockattr_init(pthread_rwlockattr_t *a); WINPTHREAD_API int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *a, int s); -#ifndef SIG_BLOCK -#define SIG_BLOCK 0 -#endif -#ifndef SIG_UNBLOCK -#define SIG_UNBLOCK 1 -#endif -#ifndef SIG_SETMASK -#define SIG_SETMASK 2 -#endif - #include <pthread_unistd.h> #undef _POSIX_THREAD_DESTRUCTOR_ITERATIONS diff --git a/mingw-w64-libraries/winpthreads/include/pthread_signal.h b/mingw-w64-libraries/winpthreads/include/pthread_signal.h index 42a50ae06..57e714fcf 100644 --- a/mingw-w64-libraries/winpthreads/include/pthread_signal.h +++ b/mingw-w64-libraries/winpthreads/include/pthread_signal.h @@ -23,6 +23,16 @@ #ifndef WIN_PTHREADS_SIGNAL_H #define WIN_PTHREADS_SIGNAL_H +#ifndef SIG_BLOCK +#define SIG_BLOCK 0 +#endif +#ifndef SIG_UNBLOCK +#define SIG_UNBLOCK 1 +#endif +#ifndef SIG_SETMASK +#define SIG_SETMASK 2 +#endif + /* Windows has rudimentary signals support. */ #define pthread_sigmask(H, S1, S2) 0 -- 2.46.1.windows.1
From 6620b74245416a22ca51a7b18ba0fbeb3a07652c Mon Sep 17 00:00:00 2001 From: Kirill Makurin <maiddais...@outlook.com> Date: Thu, 20 Feb 2025 02:18:15 +0900 Subject: [PATCH 3/3] winpthreads: remove unused macro USE_SEM_CriticalSection_SpinCount from semaphore.h Signed-off-by: Kirill Makurin <maiddais...@outlook.com> --- mingw-w64-libraries/winpthreads/include/semaphore.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/mingw-w64-libraries/winpthreads/include/semaphore.h b/mingw-w64-libraries/winpthreads/include/semaphore.h index 50630ea5e..b6cd13f16 100644 --- a/mingw-w64-libraries/winpthreads/include/semaphore.h +++ b/mingw-w64-libraries/winpthreads/include/semaphore.h @@ -29,9 +29,6 @@ extern "C" { #endif -/* Set this to 0 to disable it */ -#define USE_SEM_CriticalSection_SpinCount 100 - #define SEM_VALUE_MAX INT_MAX typedef void *sem_t; -- 2.46.1.windows.1
_______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public