I think the idea of including pthread_time.h through pthread_compat.h from 
pthread.h is to make `clock_gettime` and other time functions available for 
MSVC users without explicitly including pthread_time.h, which is a non-standard 
header file.

Declaration of `clockid_t` in pthread_compat.h may be removed since it is also 
declared in both pthread_time.h and pthread.h anyway. Some functions in 
pthread.h and sched.h have an argument of type `pid_t` and this type is not 
declared in Microsoft header files.

We could move definition of `WINPTHREAD_API ` in pthread.h just above `#include 
"pthread_compat.h"` to not duplicate it in pthread_time.h, but I think it could 
be useful to make pthread_time.h usable on its own.

- Kirill Makurin

________________________________
From: LIU Hao <lh_mo...@126.com>
Sent: Sunday, February 9, 2025 12:43:20 AM
To: mingw-w64-public@lists.sourceforge.net 
<mingw-w64-public@lists.sourceforge.net>; Kirill Makurin 
<maiddais...@outlook.com>
Subject: Re: [Mingw-w64-public] make sure WINPTHREAD_API is correctly defined 
in pthread_time.h

在 2025-02-08 01:06, Kirill Makurin 写道:
> From 87951029ce19f763ebf28262bf0bb3a48fbed0c2 Mon Sep 17 00:00:00 2001
> From: Kirill Makurin<maiddais...@outlook.com>
> Date: Sat, 8 Feb 2025 01:45:40 +0900
> Subject: [PATCH] winpthreads: make sure WINPTHREAD_API is correctly defined in
> pthread_time.h
>
> When building with MSVC, pthread_time.h is included from pthread.h before
> WINPTHREAD_API macro is defined. This may lead to functions declared in
> pthread_time.h not being exported from the DLL.
>
> Use same logic to define WINPTHREAD_API as in pthread.h.
>
> Signed-off-by: Kirill Makurin<maiddais...@outlook.com>
> ---
> .../winpthreads/include/pthread_time.h | 18 +++++++++++++-----
> 1 file changed, 13 insertions(+), 5 deletions(-)

Can we just get rid of these superfluous declarations? They are defined 
elsewhere and do not seem to
do anything in that header.



diff --git a/mingw-w64-libraries/winpthreads/include/pthread_compat.h
b/mingw-w64-libraries/winpthreads/include/pthread_compat.h
index 63f5f495f..901bf421c 100644
--- a/mingw-w64-libraries/winpthreads/include/pthread_compat.h
+++ b/mingw-w64-libraries/winpthreads/include/pthread_compat.h
@@ -68,15 +68,6 @@

#elif _MSC_VER

-#include "pthread_time.h"
-
-#ifdef _WIN64
-typedef __int64 pid_t;
-#else
-typedef int pid_t;
-#endif
-typedef int clockid_t;
-
#define WINPTHREADS_INLINE __inline
#define WINPTHREADS_ATTRIBUTE(X) __declspec X
#define WINPTHREADS_SECTION(X) allocate(X)



--
Best regards,
LIU Hao


_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to