winpthreads: Ensure `struct _timespec{32,64}` are defined before use
We have declarations such as
WINPTHREAD_API int sem_timedwait64(sem_t * sem, const struct _timespec64 *t);
When `struct _timespec64` is not forward-declared, this function declaration
declares a new struct whose scope is limited to that function. In this case it
is not the same type as the one in file scope, which causes errors like
C:/MSYS64/mingw64/include/semaphore.h: In function 'sem_timedwait':
C:/MSYS64/mingw64/include/semaphore.h:53:32: error: passing argument 2 of 'sem_timedwait64' from incompatible pointer type [-Wincompatible-pointer-types]
53 | return sem_timedwait64 (sem, (const struct _timespec64 *) t);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| |
| const struct _timespec64 *
C:/MSYS64/mingw64/include/semaphore.h:47:75: note: expected 'const struct _timespec64 *' but argument is of type 'const struct _timespec64 *'
47 | WINPTHREAD_API int sem_timedwait64(sem_t * sem, const struct _timespec64 *t);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~^
We include <sys/timeb.h> so those function declarations reference the global
types and do not declare their own.
Reported-by: Jeremy Lainé <jeremy.laine@m4x.org>
Signed-off-by: LIU Hao <lh_mouse@126.com>
diff --git a/mingw-w64-libraries/winpthreads/include/pthread_time.h b/mingw-w64-libraries/winpthreads/include/pthread_time.h
index ac014ae..27f7566 100644
--- a/mingw-w64-libraries/winpthreads/include/pthread_time.h
+++ b/mingw-w64-libraries/winpthreads/include/pthread_time.h
@@ -23,6 +23,7 @@
#ifndef WIN_PTHREADS_TIME_H
#define WIN_PTHREADS_TIME_H
+#include <sys/timeb.h>
#include "pthread_compat.h"
/* Posix timers are supported */
diff --git a/mingw-w64-libraries/winpthreads/include/semaphore.h b/mingw-w64-libraries/winpthreads/include/semaphore.h
index 649583f..9a6c211 100644
--- a/mingw-w64-libraries/winpthreads/include/semaphore.h
+++ b/mingw-w64-libraries/winpthreads/include/semaphore.h
@@ -23,6 +23,7 @@
#ifndef WIN_PTHREADS_SEMAPHORE_H
#define WIN_PTHREADS_SEMAPHORE_H
+#include <sys/timeb.h>
#include "pthread_compat.h"
#ifdef __cplusplus