From 66d63dde89bf675c0d80df64438a78c91e848654 Mon Sep 17 00:00:00 2001 From: John Emmas Date: Sat, 30 Jan 2021 13:59:22 +0000 Subject: [PATCH] A few extra changes needed to support the latest version of libpthread for Windows --- .../ardourext/ptw32/pthread.h.input | 218 +++++++++--------- msvc_extra_headers/ardourext/sched.h.input | 67 +++--- .../ardourext/semaphore.h.input | 51 ++-- 3 files changed, 171 insertions(+), 165 deletions(-) diff --git a/msvc_extra_headers/ardourext/ptw32/pthread.h.input b/msvc_extra_headers/ardourext/ptw32/pthread.h.input index b8646c321b..3ac3e174f8 100644 --- a/msvc_extra_headers/ardourext/ptw32/pthread.h.input +++ b/msvc_extra_headers/ardourext/ptw32/pthread.h.input @@ -42,8 +42,8 @@ * See the README file for an explanation of the pthreads-win32 version * numbering scheme and how the DLL is named etc. */ -#define PTW32_VERSION 2,8,0,0 -#define PTW32_VERSION_STRING "2, 8, 0, 0\0" +#define PTW32_VERSION 2,9,1,0 +#define PTW32_VERSION_STRING "2, 9, 1, 0\0" /* There are three implementations of cancel cleanup. * Note that pthread.h is included in both application @@ -86,7 +86,7 @@ /* * Stop here if we are being included by the resource compiler. */ -#ifndef RC_INVOKED +#if !defined(RC_INVOKED) #undef PTW32_LEVEL @@ -109,15 +109,15 @@ #define PTW32_LEVEL_MAX 3 -#if !defined(PTW32_LEVEL) +#if ( defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112 ) || !defined(PTW32_LEVEL) #define PTW32_LEVEL PTW32_LEVEL_MAX /* Include everything */ #endif -#ifdef _UWIN +#if defined(_UWIN) # define HAVE_STRUCT_TIMESPEC 1 # define HAVE_SIGNAL_H 1 -# undef HAVE_CONFIG_H +# undef HAVE_PTW32_CONFIG_H # pragma comment(lib, "pthread") #endif @@ -195,11 +195,11 @@ */ /* Try to avoid including windows.h */ -#if defined(__MINGW32__) && defined(__cplusplus) +#if (defined(__MINGW64__) || defined(__MINGW32__)) && defined(__cplusplus) #define PTW32_INCLUDE_WINDOWS_H #endif -#ifdef PTW32_INCLUDE_WINDOWS_H +#if defined(PTW32_INCLUDE_WINDOWS_H) #include #endif @@ -208,6 +208,7 @@ * VC++6.0 or early compiler's header has no DWORD_PTR type. */ typedef unsigned long DWORD_PTR; +typedef unsigned long ULONG_PTR; #endif /* * ----------------- @@ -215,21 +216,20 @@ typedef unsigned long DWORD_PTR; * ----------------- */ -#if HAVE_CONFIG_H +#if defined(HAVE_PTW32_CONFIG_H) #include "config.h" -#endif /* HAVE_CONFIG_H */ +#endif /* HAVE_PTW32_CONFIG_H */ -#ifndef NEED_FTIME +#if !defined(NEED_FTIME) #include #else /* NEED_FTIME */ /* use native WIN32 time API */ #endif /* NEED_FTIME */ -#if HAVE_SIGNAL_H +#if defined(HAVE_SIGNAL_H) #include #endif /* HAVE_SIGNAL_H */ -#include #include /* @@ -245,12 +245,15 @@ enum { * which is only used when building the pthread-win32 libraries. */ -#ifndef PTW32_CONFIG_H +#if !defined(PTW32_CONFIG_H) # if defined(WINCE) # define NEED_ERRNO # define NEED_SEM # endif -# if defined(_UWIN) || defined(__MINGW32__) +# if defined(__MINGW64__) +# define HAVE_STRUCT_TIMESPEC +# define HAVE_MODE_T +# elif defined(_UWIN) || defined(__MINGW32__) # define HAVE_MODE_T # endif #endif @@ -260,7 +263,7 @@ enum { */ #if PTW32_LEVEL >= PTW32_LEVEL_MAX -#ifdef NEED_ERRNO +#if defined(NEED_ERRNO) #include "need_errno.h" #else #include @@ -270,66 +273,75 @@ enum { /* * Several systems don't define some error numbers. */ -#ifndef ENOTSUP +#if !defined(ENOTSUP) # define ENOTSUP 48 /* This is the value in Solaris. */ #endif -#ifndef ETIMEDOUT -# define ETIMEDOUT 10060 /* This is the value in winsock.h. */ +#if !defined(ETIMEDOUT) +# define ETIMEDOUT 10060 /* Same as WSAETIMEDOUT */ #endif -#ifndef ENOSYS +#if !defined(ENOSYS) # define ENOSYS 140 /* Semi-arbitrary value */ #endif -#ifndef EDEADLK -# ifdef EDEADLOCK +#if !defined(EDEADLK) +# if defined(EDEADLOCK) # define EDEADLK EDEADLOCK # else # define EDEADLK 36 /* This is the value in MSVC. */ # endif #endif -#include +/* POSIX 2008 - related to robust mutexes */ +#if !defined(EOWNERDEAD) +# define EOWNERDEAD 43 +#endif +#if !defined(ENOTRECOVERABLE) +# define ENOTRECOVERABLE 44 +#endif + +#include /* * To avoid including windows.h we define only those things that we * actually need from it. */ -#ifndef PTW32_INCLUDE_WINDOWS_H -#ifndef HANDLE +#if !defined(PTW32_INCLUDE_WINDOWS_H) +#if !defined(HANDLE) # define PTW32__HANDLE_DEF # define HANDLE void * #endif -#ifndef DWORD +#if !defined(DWORD) # define PTW32__DWORD_DEF # define DWORD unsigned long #endif #endif -#ifndef HAVE_STRUCT_TIMESPEC -#if defined(_MSC_VER) && (_MSC_VER < 1900) -#define HAVE_STRUCT_TIMESPEC 1 +#if !defined(HAVE_STRUCT_TIMESPEC) +#define HAVE_STRUCT_TIMESPEC +#if !defined(_TIMESPEC_DEFINED) +#define _TIMESPEC_DEFINED struct timespec { - long tv_sec; + time_t tv_sec; long tv_nsec; }; -#endif /* _MSC_VER */ +#endif /* _TIMESPEC_DEFINED */ #endif /* HAVE_STRUCT_TIMESPEC */ -#ifndef SIG_BLOCK +#if !defined(SIG_BLOCK) #define SIG_BLOCK 0 #endif /* SIG_BLOCK */ -#ifndef SIG_UNBLOCK +#if !defined(SIG_UNBLOCK) #define SIG_UNBLOCK 1 #endif /* SIG_UNBLOCK */ -#ifndef SIG_SETMASK +#if !defined(SIG_SETMASK) #define SIG_SETMASK 2 #endif /* SIG_SETMASK */ -#ifdef __cplusplus +#if defined(__cplusplus) extern "C" { #endif /* __cplusplus */ @@ -425,22 +437,22 @@ extern "C" * POSIX Options */ #undef _POSIX_THREADS -#define _POSIX_THREADS 200112L +#define _POSIX_THREADS 200809L #undef _POSIX_READER_WRITER_LOCKS -#define _POSIX_READER_WRITER_LOCKS 200112L +#define _POSIX_READER_WRITER_LOCKS 200809L #undef _POSIX_SPIN_LOCKS -#define _POSIX_SPIN_LOCKS 200112L +#define _POSIX_SPIN_LOCKS 200809L #undef _POSIX_BARRIERS -#define _POSIX_BARRIERS 200112L +#define _POSIX_BARRIERS 200809L #undef _POSIX_THREAD_SAFE_FUNCTIONS -#define _POSIX_THREAD_SAFE_FUNCTIONS 200112L +#define _POSIX_THREAD_SAFE_FUNCTIONS 200809L #undef _POSIX_THREAD_ATTR_STACKSIZE -#define _POSIX_THREAD_ATTR_STACKSIZE 200112L +#define _POSIX_THREAD_ATTR_STACKSIZE 200809L /* * The following options are not supported @@ -530,18 +542,18 @@ extern "C" #define SEM_VALUE_MAX INT_MAX -#if __GNUC__ && ! defined (__declspec) +#if defined(__GNUC__) && !defined(__declspec) # error Please upgrade your GNU compiler to one that supports __declspec. #endif /* - * When building the DLL code, you should define PTW32_BUILD so that - * the variables/functions are exported correctly. When using the DLL, + * When building the library, you should define PTW32_BUILD so that + * the variables/functions are exported correctly. When using the library, * do NOT define PTW32_BUILD, and then the variables/functions will * be imported correctly. */ -#ifndef PTW32_STATIC_LIB -# ifdef PTW32_BUILD +#if !defined(PTW32_STATIC_LIB) +# if defined(PTW32_BUILD) # define PTW32_DLLPORT __declspec (dllexport) # else # define PTW32_DLLPORT __declspec (dllimport) @@ -636,6 +648,12 @@ enum { PTHREAD_PROCESS_PRIVATE = 0, PTHREAD_PROCESS_SHARED = 1, +/* + * pthread_mutexattr_{get,set}robust + */ + PTHREAD_MUTEX_STALLED = 0, /* Default */ + PTHREAD_MUTEX_ROBUST = 1, + /* * pthread_barrier_wait */ @@ -649,7 +667,7 @@ enum { * ==================== * ==================== */ -#define PTHREAD_CANCELED ((void *) -1) +#define PTHREAD_CANCELED ((void *)(size_t) -1) /* @@ -677,9 +695,9 @@ struct pthread_once_t_ * ==================== * ==================== */ -#define PTHREAD_MUTEX_INITIALIZER ((pthread_mutex_t) -1) -#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER ((pthread_mutex_t) -2) -#define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER ((pthread_mutex_t) -3) +#define PTHREAD_MUTEX_INITIALIZER ((pthread_mutex_t)(size_t) -1) +#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER ((pthread_mutex_t)(size_t) -2) +#define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER ((pthread_mutex_t)(size_t) -3) /* * Compatibility with LinuxThreads @@ -687,11 +705,11 @@ struct pthread_once_t_ #define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP PTHREAD_RECURSIVE_MUTEX_INITIALIZER #define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP PTHREAD_ERRORCHECK_MUTEX_INITIALIZER -#define PTHREAD_COND_INITIALIZER ((pthread_cond_t) -1) +#define PTHREAD_COND_INITIALIZER ((pthread_cond_t)(size_t) -1) -#define PTHREAD_RWLOCK_INITIALIZER ((pthread_rwlock_t) -1) +#define PTHREAD_RWLOCK_INITIALIZER ((pthread_rwlock_t)(size_t) -1) -#define PTHREAD_SPINLOCK_INITIALIZER ((pthread_spinlock_t) -1) +#define PTHREAD_SPINLOCK_INITIALIZER ((pthread_spinlock_t)(size_t) -1) /* @@ -733,7 +751,7 @@ struct ptw32_cleanup_t struct ptw32_cleanup_t *prev; }; -#ifdef __CLEANUP_SEH +#if defined(__CLEANUP_SEH) /* * WIN32 SEH version of cancel cleanup. */ @@ -760,7 +778,7 @@ struct ptw32_cleanup_t #else /* __CLEANUP_SEH */ -#ifdef __CLEANUP_C +#if defined(__CLEANUP_C) /* * C implementation of PThreads cancel cleanup @@ -778,7 +796,7 @@ struct ptw32_cleanup_t #else /* __CLEANUP_C */ -#ifdef __CLEANUP_CXX +#if defined(__CLEANUP_CXX) /* * C++ version of cancel cleanup. @@ -906,13 +924,13 @@ PTW32_DLLPORT int PTW32_CDECL pthread_attr_setschedparam (pthread_attr_t *attr, PTW32_DLLPORT int PTW32_CDECL pthread_attr_setschedpolicy (pthread_attr_t *, int); -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getschedpolicy (pthread_attr_t *, +PTW32_DLLPORT int PTW32_CDECL pthread_attr_getschedpolicy (const pthread_attr_t *, int *); PTW32_DLLPORT int PTW32_CDECL pthread_attr_setinheritsched(pthread_attr_t * attr, int inheritsched); -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getinheritsched(pthread_attr_t * attr, +PTW32_DLLPORT int PTW32_CDECL pthread_attr_getinheritsched(const pthread_attr_t * attr, int * inheritsched); PTW32_DLLPORT int PTW32_CDECL pthread_attr_setscope (pthread_attr_t *, @@ -926,7 +944,7 @@ PTW32_DLLPORT int PTW32_CDECL pthread_attr_getscope (const pthread_attr_t *, */ PTW32_DLLPORT int PTW32_CDECL pthread_create (pthread_t * tid, const pthread_attr_t * attr, - void *(*start) (void *), + void *(PTW32_CDECL *start) (void *), void *arg); PTW32_DLLPORT int PTW32_CDECL pthread_detach (pthread_t tid); @@ -952,13 +970,13 @@ PTW32_DLLPORT int PTW32_CDECL pthread_setcanceltype (int type, PTW32_DLLPORT void PTW32_CDECL pthread_testcancel (void); PTW32_DLLPORT int PTW32_CDECL pthread_once (pthread_once_t * once_control, - void (*init_routine) (void)); + void (PTW32_CDECL *init_routine) (void)); #if PTW32_LEVEL >= PTW32_LEVEL_MAX PTW32_DLLPORT ptw32_cleanup_t * PTW32_CDECL ptw32_pop_cleanup (int execute); PTW32_DLLPORT void PTW32_CDECL ptw32_push_cleanup (ptw32_cleanup_t * cleanup, - void (*routine) (void *), + ptw32_cleanup_callback_t routine, void *arg); #endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ @@ -966,7 +984,7 @@ PTW32_DLLPORT void PTW32_CDECL ptw32_push_cleanup (ptw32_cleanup_t * cleanup, * Thread Specific Data Functions */ PTW32_DLLPORT int PTW32_CDECL pthread_key_create (pthread_key_t * key, - void (*destructor) (void *)); + void (PTW32_CDECL *destructor) (void *)); PTW32_DLLPORT int PTW32_CDECL pthread_key_delete (pthread_key_t key); @@ -991,7 +1009,14 @@ PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_setpshared (pthread_mutexattr_t int pshared); PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_settype (pthread_mutexattr_t * attr, int kind); -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_gettype (pthread_mutexattr_t * attr, int *kind); +PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_gettype (const pthread_mutexattr_t * attr, int *kind); + +PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_setrobust( + pthread_mutexattr_t *attr, + int robust); +PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_getrobust( + const pthread_mutexattr_t * attr, + int * robust); /* * Barrier Attribute Functions @@ -1017,13 +1042,15 @@ PTW32_DLLPORT int PTW32_CDECL pthread_mutex_destroy (pthread_mutex_t * mutex); PTW32_DLLPORT int PTW32_CDECL pthread_mutex_lock (pthread_mutex_t * mutex); -PTW32_DLLPORT int PTW32_CDECL pthread_mutex_timedlock(pthread_mutex_t *mutex, +PTW32_DLLPORT int PTW32_CDECL pthread_mutex_timedlock(pthread_mutex_t * mutex, const struct timespec *abstime); PTW32_DLLPORT int PTW32_CDECL pthread_mutex_trylock (pthread_mutex_t * mutex); PTW32_DLLPORT int PTW32_CDECL pthread_mutex_unlock (pthread_mutex_t * mutex); +PTW32_DLLPORT int PTW32_CDECL pthread_mutex_consistent (pthread_mutex_t * mutex); + /* * Spinlock Functions */ @@ -1154,6 +1181,7 @@ PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_getkind_np(pthread_mutexattr_t * */ PTW32_DLLPORT int PTW32_CDECL pthread_delay_np (struct timespec * interval); PTW32_DLLPORT int PTW32_CDECL pthread_num_processors_np(void); +PTW32_DLLPORT unsigned __int64 PTW32_CDECL pthread_getunique_np(pthread_t thread); /* * Useful if an application wants to statically link @@ -1191,6 +1219,10 @@ PTW32_DLLPORT void * PTW32_CDECL pthread_timechange_handler_np(void *); * Returns the Win32 HANDLE for the POSIX thread. */ PTW32_DLLPORT HANDLE PTW32_CDECL pthread_getw32threadhandle_np(pthread_t thread); +/* + * Returns the win32 thread ID for POSIX thread. + */ +PTW32_DLLPORT DWORD PTW32_CDECL pthread_getw32threadid_np (pthread_t thread); /* @@ -1217,11 +1249,11 @@ PTW32_DLLPORT int PTW32_CDECL pthreadCancelableTimedWait (HANDLE waitHandle, /* * Thread-Safe C Runtime Library Mappings. */ -#ifndef _UWIN +#if !defined(_UWIN) # if defined(NEED_ERRNO) PTW32_DLLPORT int * PTW32_CDECL _errno( void ); # else -# ifndef errno +# if !defined(errno) # if (defined(_MT) || defined(_DLL)) __declspec(dllimport) extern int * __cdecl _errno(void); # define errno (*_errno()) @@ -1230,40 +1262,6 @@ PTW32_DLLPORT int PTW32_CDECL pthreadCancelableTimedWait (HANDLE waitHandle, # endif #endif -/* - * WIN32 C runtime library had been made thread-safe - * without affecting the user interface. Provide - * mappings from the UNIX thread-safe versions to - * the standard C runtime library calls. - * Only provide function mappings for functions that - * actually exist on WIN32. - */ - -#if !defined(__MINGW32__) -#define strtok_r( _s, _sep, _lasts ) \ - ( *(_lasts) = strtok( (_s), (_sep) ) ) -#endif /* !__MINGW32__ */ - -#define asctime_r( _tm, _buf ) \ - ( strcpy( (_buf), asctime( (_tm) ) ), \ - (_buf) ) - -#define ctime_r( _clock, _buf ) \ - ( strcpy( (_buf), ctime( (_clock) ) ), \ - (_buf) ) - -#define gmtime_r( _clock, _result ) \ - ( *(_result) = *gmtime( (_clock) ), \ - (_result) ) - -#define localtime_r( _clock, _result ) \ - ( *(_result) = *localtime( (_clock) ), \ - (_result) ) - -#define rand_r( _seed ) \ - ( _seed == _seed? rand() : rand() ) - - /* * Some compiler environments don't define some things. */ @@ -1272,7 +1270,7 @@ PTW32_DLLPORT int PTW32_CDECL pthreadCancelableTimedWait (HANDLE waitHandle, # define _timeb timeb #endif -#ifdef __cplusplus +#if defined(__cplusplus) /* * Internal exceptions @@ -1293,9 +1291,9 @@ PTW32_DLLPORT DWORD PTW32_CDECL ptw32_get_exception_services_code(void); #endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ -#ifndef PTW32_BUILD +#if !defined(PTW32_BUILD) -#ifdef __CLEANUP_SEH +#if defined(__CLEANUP_SEH) /* * Redefine the SEH __except keyword to ensure that applications @@ -1307,19 +1305,19 @@ PTW32_DLLPORT DWORD PTW32_CDECL ptw32_get_exception_services_code(void); #endif /* __CLEANUP_SEH */ -#ifdef __CLEANUP_CXX +#if defined(__CLEANUP_CXX) /* * Redefine the C++ catch keyword to ensure that applications * propagate our internal exceptions up to the library's internal handlers. */ -#ifdef _MSC_VER +#if defined(_MSC_VER) /* * WARNING: Replace any 'catch( ... )' with 'PtW32CatchAll' * if you want Pthread-Win32 cancelation and pthread_exit to work. */ -#ifndef PtW32NoCatchWarn +#if !defined(PtW32NoCatchWarn) #pragma message("Specify \"/DPtW32NoCatchWarn\" compiler flag to skip this message.") #pragma message("------------------------------------------------------------------") @@ -1328,7 +1326,7 @@ PTW32_DLLPORT DWORD PTW32_CDECL ptw32_get_exception_services_code(void); #pragma message(" with 'PtW32CatchAll' or 'CATCHALL' if you want POSIX thread") #pragma message(" cancelation and pthread_exit to work. For example:") #pragma message("") -#pragma message(" #ifdef PtW32CatchAll") +#pragma message(" #if defined(PtW32CatchAll)") #pragma message(" PtW32CatchAll") #pragma message(" #else") #pragma message(" catch(...)") @@ -1356,14 +1354,14 @@ PTW32_DLLPORT DWORD PTW32_CDECL ptw32_get_exception_services_code(void); #endif /* ! PTW32_BUILD */ -#ifdef __cplusplus +#if defined(__cplusplus) } /* End of extern "C" */ #endif /* __cplusplus */ -#ifdef PTW32__HANDLE_DEF +#if defined(PTW32__HANDLE_DEF) # undef HANDLE #endif -#ifdef PTW32__DWORD_DEF +#if defined(PTW32__DWORD_DEF) # undef DWORD #endif diff --git a/msvc_extra_headers/ardourext/sched.h.input b/msvc_extra_headers/ardourext/sched.h.input index e7f4ab0a52..579a942b6c 100644 --- a/msvc_extra_headers/ardourext/sched.h.input +++ b/msvc_extra_headers/ardourext/sched.h.input @@ -36,53 +36,53 @@ * if not, write to the Free Software Foundation, Inc., * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#ifndef SCHED_H -#ifdef _SCHED_H // Test added by JE - 12-12-2009 +#ifndef _SCHED_H +#ifdef SCHED_H // Test added by JE - 12-12-2009 #error "ardourext/sched.h conflicts with an existing pthread library" #endif // Now make sure we can't accidentally include a conflicting library !! -#define _SCHED_H #define SCHED_H +#define _SCHED_H -#undef PTW32_LEVEL +#undef PTW32_SCHED_LEVEL #if defined(_POSIX_SOURCE) -#define PTW32_LEVEL 0 +#define PTW32_SCHED_LEVEL 0 /* Early POSIX */ #endif #if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309 -#undef PTW32_LEVEL -#define PTW32_LEVEL 1 +#undef PTW32_SCHED_LEVEL +#define PTW32_SCHED_LEVEL 1 /* Include 1b, 1c and 1d */ #endif #if defined(INCLUDE_NP) -#undef PTW32_LEVEL -#define PTW32_LEVEL 2 +#undef PTW32_SCHED_LEVEL +#define PTW32_SCHED_LEVEL 2 /* Include Non-Portable extensions */ #endif -#define PTW32_LEVEL_MAX 3 +#define PTW32_SCHED_LEVEL_MAX 3 -#if !defined(PTW32_LEVEL) -#define PTW32_LEVEL PTW32_LEVEL_MAX +#if ( defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112 ) || !defined(PTW32_SCHED_LEVEL) +#define PTW32_SCHED_LEVEL PTW32_SCHED_LEVEL_MAX /* Include everything */ #endif -#if __GNUC__ && ! defined (__declspec) +#if defined(__GNUC__) && !defined(__declspec) # error Please upgrade your GNU compiler to one that supports __declspec. #endif /* - * When building the DLL code, you should define PTW32_BUILD so that - * the variables/functions are exported correctly. When using the DLL, + * When building the library, you should define PTW32_BUILD so that + * the variables/functions are exported correctly. When using the library, * do NOT define PTW32_BUILD, and then the variables/functions will * be imported correctly. */ -#ifndef PTW32_STATIC_LIB -# ifdef PTW32_BUILD +#if !defined(PTW32_STATIC_LIB) +# if defined(PTW32_BUILD) # define PTW32_DLLPORT __declspec (dllexport) # else # define PTW32_DLLPORT __declspec (dllimport) @@ -96,12 +96,15 @@ * which is only used when building the pthread-win32 libraries. */ -#ifndef PTW32_CONFIG_H +#if !defined(PTW32_CONFIG_H) # if defined(WINCE) # define NEED_ERRNO # define NEED_SEM # endif -# if defined(_UWIN) || defined(__MINGW32__) +# if defined(__MINGW64__) +# define HAVE_STRUCT_TIMESPEC +# define HAVE_MODE_T +# elif defined(_UWIN) || defined(__MINGW32__) # define HAVE_MODE_T # endif #endif @@ -110,23 +113,25 @@ * */ -#if PTW32_LEVEL >= PTW32_LEVEL_MAX -#ifdef NEED_ERRNO +#if PTW32_SCHED_LEVEL >= PTW32_SCHED_LEVEL_MAX +#if defined(NEED_ERRNO) #include "need_errno.h" #else #include #endif -#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ +#endif /* PTW32_SCHED_LEVEL >= PTW32_SCHED_LEVEL_MAX */ -#if defined(__MINGW32__) || defined(_UWIN) -#if PTW32_LEVEL >= PTW32_LEVEL_MAX +#if (defined(__MINGW64__) || defined(__MINGW32__)) || defined(_UWIN) +# if PTW32_SCHED_LEVEL >= PTW32_SCHED_LEVEL_MAX /* For pid_t */ # include /* Required by Unix 98 */ # include -#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ +# else + typedef int pid_t; +# endif #else -typedef int pid_t; + typedef int pid_t; #endif /* Thread scheduling policies */ @@ -143,7 +148,7 @@ struct sched_param { int sched_priority; }; -#ifdef __cplusplus +#if defined(__cplusplus) extern "C" { #endif /* __cplusplus */ @@ -172,12 +177,12 @@ PTW32_DLLPORT int __cdecl sched_getscheduler (pid_t pid); ( errno = ENOTSUP, (int) -1 ) -#ifdef __cplusplus +#if defined(__cplusplus) } /* End of extern "C" */ #endif /* __cplusplus */ -#undef PTW32_LEVEL -#undef PTW32_LEVEL_MAX +#undef PTW32_SCHED_LEVEL +#undef PTW32_SCHED_LEVEL_MAX -#endif /* !SCHED_H */ +#endif /* !_SCHED_H */ diff --git a/msvc_extra_headers/ardourext/semaphore.h.input b/msvc_extra_headers/ardourext/semaphore.h.input index c06373fd77..fd6740f2ff 100644 --- a/msvc_extra_headers/ardourext/semaphore.h.input +++ b/msvc_extra_headers/ardourext/semaphore.h.input @@ -44,44 +44,44 @@ #define _SEMAPHORE_H #define SEMAPHORE_H -#undef PTW32_LEVEL +#undef PTW32_SEMAPHORE_LEVEL #if defined(_POSIX_SOURCE) -#define PTW32_LEVEL 0 +#define PTW32_SEMAPHORE_LEVEL 0 /* Early POSIX */ #endif #if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309 -#undef PTW32_LEVEL -#define PTW32_LEVEL 1 +#undef PTW32_SEMAPHORE_LEVEL +#define PTW32_SEMAPHORE_LEVEL 1 /* Include 1b, 1c and 1d */ #endif #if defined(INCLUDE_NP) -#undef PTW32_LEVEL -#define PTW32_LEVEL 2 +#undef PTW32_SEMAPHORE_LEVEL +#define PTW32_SEMAPHORE_LEVEL 2 /* Include Non-Portable extensions */ #endif -#define PTW32_LEVEL_MAX 3 +#define PTW32_SEMAPHORE_LEVEL_MAX 3 -#if !defined(PTW32_LEVEL) -#define PTW32_LEVEL PTW32_LEVEL_MAX +#if !defined(PTW32_SEMAPHORE_LEVEL) +#define PTW32_SEMAPHORE_LEVEL PTW32_SEMAPHORE_LEVEL_MAX /* Include everything */ #endif -#if __GNUC__ && ! defined (__declspec) +#if defined(__GNUC__) && ! defined (__declspec) # error Please upgrade your GNU compiler to one that supports __declspec. #endif /* - * When building the DLL code, you should define PTW32_BUILD so that - * the variables/functions are exported correctly. When using the DLL, + * When building the library, you should define PTW32_BUILD so that + * the variables/functions are exported correctly. When using the library, * do NOT define PTW32_BUILD, and then the variables/functions will * be imported correctly. */ -#ifndef PTW32_STATIC_LIB -# ifdef PTW32_BUILD +#if !defined(PTW32_STATIC_LIB) +# if defined(PTW32_BUILD) # define PTW32_DLLPORT __declspec (dllexport) # else # define PTW32_DLLPORT __declspec (dllimport) @@ -95,12 +95,15 @@ * which is only used when building the pthread-win32 libraries. */ -#ifndef PTW32_CONFIG_H +#if !defined(PTW32_CONFIG_H) # if defined(WINCE) # define NEED_ERRNO # define NEED_SEM # endif -# if defined(_UWIN) || defined(__MINGW32__) +# if defined(__MINGW64__) +# define HAVE_STRUCT_TIMESPEC +# define HAVE_MODE_T +# elif defined(_UWIN) || defined(__MINGW32__) # define HAVE_MODE_T # endif #endif @@ -109,22 +112,22 @@ * */ -#if PTW32_LEVEL >= PTW32_LEVEL_MAX -#ifdef NEED_ERRNO +#if PTW32_SEMAPHORE_LEVEL >= PTW32_SEMAPHORE_LEVEL_MAX +#if defined(NEED_ERRNO) #include "need_errno.h" #else #include #endif -#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ +#endif /* PTW32_SEMAPHORE_LEVEL >= PTW32_SEMAPHORE_LEVEL_MAX */ #define _POSIX_SEMAPHORES -#ifdef __cplusplus +#if defined(__cplusplus) extern "C" { #endif /* __cplusplus */ -#ifndef HAVE_MODE_T +#if !defined(HAVE_MODE_T) typedef unsigned int mode_t; #endif @@ -161,11 +164,11 @@ PTW32_DLLPORT int __cdecl sem_unlink (const char * name); PTW32_DLLPORT int __cdecl sem_getvalue (sem_t * sem, int * sval); -#ifdef __cplusplus +#if defined(__cplusplus) } /* End of extern "C" */ #endif /* __cplusplus */ -#undef PTW32_LEVEL -#undef PTW32_LEVEL_MAX +#undef PTW32_SEMAPHORE_LEVEL +#undef PTW32_SEMAPHORE_LEVEL_MAX #endif /* !SEMAPHORE_H */