Yes, no problem. I also had a patch for Makefile.am which tried to solve the alias issue by copying `[lib]winpthreads[.dll].{lib|a}` as `[lib]pthread[.dll].{lib|a}` during installation. I can send it again.
I see. I could maintain a GitHub repository with a copy of winpthreads, but with Meson and possibly CMake build systems. I think this could be useful. ________________________________ From: Jonathan Yong <10wa...@gmail.com> Sent: Thursday, January 30, 2025 10:38 AM To: mingw-w64-public@lists.sourceforge.net <mingw-w64-public@lists.sourceforge.net> Subject: Re: [Mingw-w64-public] winpthreads and MSVC On 1/29/25 9:58 PM, Kirill Makurin wrote: > Hi, > > I was writing to the list a few months ago regarding building of winpthreads > with MSVC tools. I also sent a few patches back then, none of which were > pushed. The first two patches were fixing a syntax error in `src/thread.h` > and linking of `tests/t_nanosleep.c`. Other patches tried to fix issues with > `pthread[.dll].lib` alias. > > I think first two patches can be safely pushed. I regenerated (with `git > format-patch`, I hope this is fine) and attached them. > > This still does not fix issues with the alias (which makes `make` fail). I > took a look at winpthreads' `configure.ac` and `Makefile.am`, and they seem > to be quite simple. I wrote a `meson.build` for it and I wonder if the > project would be interested in this contribution. Besides handling of > `cl.exe` it also handles more unusual compilers like `clang-cl.exe`. Having > `meson.build` for winpthreads will allow to use it as a subproject, which > will allow projects to use POSIX threads even when building with MSVC. > > - Kirill Makurin > Can you attach the patches with .txt extension? Sourceforge blocked them. We strictly require the use of autotools for consistency with the rest of the project and avoid having build systems becoming out of sync. _______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
From be0eed37b448b3247432374928a1f22cbb467b57 Mon Sep 17 00:00:00 2001 From: Kirill Makurin <maiddais...@outlook.com> Date: Wed, 29 Jan 2025 12:50:44 +0900 Subject: [PATCH 1/2] headers: Fix mingw-w64-libraries/winpthreads/src/thread.h Move WINPTHREAD_API left to return type of __pth_gpointer_locked so cl.exe does not choke with C2059 (syntax error). Signed-off-by: Kirill Makurin <maiddais...@outlook.com> --- mingw-w64-libraries/winpthreads/src/thread.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mingw-w64-libraries/winpthreads/src/thread.h b/mingw-w64-libraries/winpthreads/src/thread.h index 5b88226e9..1603bae58 100644 --- a/mingw-w64-libraries/winpthreads/src/thread.h +++ b/mingw-w64-libraries/winpthreads/src/thread.h @@ -74,6 +74,6 @@ void thread_print_set(int state); void thread_print(volatile pthread_t t, char *txt); #endif int __pthread_shallcancel(void); -struct _pthread_v *WINPTHREAD_API __pth_gpointer_locked (pthread_t id); +WINPTHREAD_API struct _pthread_v * __pth_gpointer_locked (pthread_t id); #endif -- 2.46.1.windows.1
From 1235915e2f3fba75ec1f296c4c7b1b1b505e0877 Mon Sep 17 00:00:00 2001 From: Kirill Makurin <maiddais...@outlook.com> Date: Thu, 30 Jan 2025 06:27:07 +0900 Subject: [PATCH 2/2] Make mingw-w64-libraries/winpthreads/tests/t_nanosleep.c link with MSVC Define getntptimeofday as a static function when compiling with MSVC tools. Implement it in terms of timespec_get if TIME_UTC is defined, otherwise in terms of winpthreads' own clock_gettime. Signed-off-by: Kirill Makurin <maiddais...@outlook.com> --- mingw-w64-libraries/winpthreads/tests/t_nanosleep.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/mingw-w64-libraries/winpthreads/tests/t_nanosleep.c b/mingw-w64-libraries/winpthreads/tests/t_nanosleep.c index 21c0ceb8d..83ac90b69 100644 --- a/mingw-w64-libraries/winpthreads/tests/t_nanosleep.c +++ b/mingw-w64-libraries/winpthreads/tests/t_nanosleep.c @@ -8,7 +8,20 @@ #define POW10_3 1000 #define POW10_6 1000000 +#if defined(__MINGW32__) || defined(__MINGW64__) extern int __cdecl getntptimeofday(struct timespec *tp, struct timezone *tz); +#else +# ifdef TIME_UTC +static int getntptimeofday(struct timespec *tp, struct timezone *tz) { + return timespec_get(tp, TIME_UTC); +} +# else /* !TIME_UTC */ +#include "pthread_time.h" +static int getntptimeofday(struct timespec *tp, struct timezone *tz) { + return clock_gettime(CLOCK_REALTIME, tp); +} +# endif /* TIME_UTC */ +#endif __int64 timespec_diff_as_ms(struct timespec *__old, struct timespec *__new) { -- 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