13
0

A few extra changes needed to support the latest version of libpthread for Windows

This commit is contained in:
John Emmas 2021-01-30 13:59:22 +00:00
parent b496a71d2e
commit 66d63dde89
3 changed files with 171 additions and 165 deletions

View File

@ -42,8 +42,8 @@
* See the README file for an explanation of the pthreads-win32 version * See the README file for an explanation of the pthreads-win32 version
* numbering scheme and how the DLL is named etc. * numbering scheme and how the DLL is named etc.
*/ */
#define PTW32_VERSION 2,8,0,0 #define PTW32_VERSION 2,9,1,0
#define PTW32_VERSION_STRING "2, 8, 0, 0\0" #define PTW32_VERSION_STRING "2, 9, 1, 0\0"
/* There are three implementations of cancel cleanup. /* There are three implementations of cancel cleanup.
* Note that pthread.h is included in both application * Note that pthread.h is included in both application
@ -86,7 +86,7 @@
/* /*
* Stop here if we are being included by the resource compiler. * Stop here if we are being included by the resource compiler.
*/ */
#ifndef RC_INVOKED #if !defined(RC_INVOKED)
#undef PTW32_LEVEL #undef PTW32_LEVEL
@ -109,15 +109,15 @@
#define PTW32_LEVEL_MAX 3 #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 #define PTW32_LEVEL PTW32_LEVEL_MAX
/* Include everything */ /* Include everything */
#endif #endif
#ifdef _UWIN #if defined(_UWIN)
# define HAVE_STRUCT_TIMESPEC 1 # define HAVE_STRUCT_TIMESPEC 1
# define HAVE_SIGNAL_H 1 # define HAVE_SIGNAL_H 1
# undef HAVE_CONFIG_H # undef HAVE_PTW32_CONFIG_H
# pragma comment(lib, "pthread") # pragma comment(lib, "pthread")
#endif #endif
@ -195,11 +195,11 @@
*/ */
/* Try to avoid including windows.h */ /* Try to avoid including windows.h */
#if defined(__MINGW32__) && defined(__cplusplus) #if (defined(__MINGW64__) || defined(__MINGW32__)) && defined(__cplusplus)
#define PTW32_INCLUDE_WINDOWS_H #define PTW32_INCLUDE_WINDOWS_H
#endif #endif
#ifdef PTW32_INCLUDE_WINDOWS_H #if defined(PTW32_INCLUDE_WINDOWS_H)
#include <windows.h> #include <windows.h>
#endif #endif
@ -208,6 +208,7 @@
* VC++6.0 or early compiler's header has no DWORD_PTR type. * VC++6.0 or early compiler's header has no DWORD_PTR type.
*/ */
typedef unsigned long DWORD_PTR; typedef unsigned long DWORD_PTR;
typedef unsigned long ULONG_PTR;
#endif #endif
/* /*
* ----------------- * -----------------
@ -215,21 +216,20 @@ typedef unsigned long DWORD_PTR;
* ----------------- * -----------------
*/ */
#if HAVE_CONFIG_H #if defined(HAVE_PTW32_CONFIG_H)
#include "config.h" #include "config.h"
#endif /* HAVE_CONFIG_H */ #endif /* HAVE_PTW32_CONFIG_H */
#ifndef NEED_FTIME #if !defined(NEED_FTIME)
#include <time.h> #include <time.h>
#else /* NEED_FTIME */ #else /* NEED_FTIME */
/* use native WIN32 time API */ /* use native WIN32 time API */
#endif /* NEED_FTIME */ #endif /* NEED_FTIME */
#if HAVE_SIGNAL_H #if defined(HAVE_SIGNAL_H)
#include <signal.h> #include <signal.h>
#endif /* HAVE_SIGNAL_H */ #endif /* HAVE_SIGNAL_H */
#include <setjmp.h>
#include <limits.h> #include <limits.h>
/* /*
@ -245,12 +245,15 @@ enum {
* which is only used when building the pthread-win32 libraries. * which is only used when building the pthread-win32 libraries.
*/ */
#ifndef PTW32_CONFIG_H #if !defined(PTW32_CONFIG_H)
# if defined(WINCE) # if defined(WINCE)
# define NEED_ERRNO # define NEED_ERRNO
# define NEED_SEM # define NEED_SEM
# endif # 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 # define HAVE_MODE_T
# endif # endif
#endif #endif
@ -260,7 +263,7 @@ enum {
*/ */
#if PTW32_LEVEL >= PTW32_LEVEL_MAX #if PTW32_LEVEL >= PTW32_LEVEL_MAX
#ifdef NEED_ERRNO #if defined(NEED_ERRNO)
#include "need_errno.h" #include "need_errno.h"
#else #else
#include <errno.h> #include <errno.h>
@ -270,66 +273,75 @@ enum {
/* /*
* Several systems don't define some error numbers. * Several systems don't define some error numbers.
*/ */
#ifndef ENOTSUP #if !defined(ENOTSUP)
# define ENOTSUP 48 /* This is the value in Solaris. */ # define ENOTSUP 48 /* This is the value in Solaris. */
#endif #endif
#ifndef ETIMEDOUT #if !defined(ETIMEDOUT)
# define ETIMEDOUT 10060 /* This is the value in winsock.h. */ # define ETIMEDOUT 10060 /* Same as WSAETIMEDOUT */
#endif #endif
#ifndef ENOSYS #if !defined(ENOSYS)
# define ENOSYS 140 /* Semi-arbitrary value */ # define ENOSYS 140 /* Semi-arbitrary value */
#endif #endif
#ifndef EDEADLK #if !defined(EDEADLK)
# ifdef EDEADLOCK # if defined(EDEADLOCK)
# define EDEADLK EDEADLOCK # define EDEADLK EDEADLOCK
# else # else
# define EDEADLK 36 /* This is the value in MSVC. */ # define EDEADLK 36 /* This is the value in MSVC. */
# endif # endif
#endif #endif
#include <ardourext/sched.h> /* POSIX 2008 - related to robust mutexes */
#if !defined(EOWNERDEAD)
# define EOWNERDEAD 43
#endif
#if !defined(ENOTRECOVERABLE)
# define ENOTRECOVERABLE 44
#endif
#include <sched.h>
/* /*
* To avoid including windows.h we define only those things that we * To avoid including windows.h we define only those things that we
* actually need from it. * actually need from it.
*/ */
#ifndef PTW32_INCLUDE_WINDOWS_H #if !defined(PTW32_INCLUDE_WINDOWS_H)
#ifndef HANDLE #if !defined(HANDLE)
# define PTW32__HANDLE_DEF # define PTW32__HANDLE_DEF
# define HANDLE void * # define HANDLE void *
#endif #endif
#ifndef DWORD #if !defined(DWORD)
# define PTW32__DWORD_DEF # define PTW32__DWORD_DEF
# define DWORD unsigned long # define DWORD unsigned long
#endif #endif
#endif #endif
#ifndef HAVE_STRUCT_TIMESPEC #if !defined(HAVE_STRUCT_TIMESPEC)
#if defined(_MSC_VER) && (_MSC_VER < 1900) #define HAVE_STRUCT_TIMESPEC
#define HAVE_STRUCT_TIMESPEC 1 #if !defined(_TIMESPEC_DEFINED)
#define _TIMESPEC_DEFINED
struct timespec { struct timespec {
long tv_sec; time_t tv_sec;
long tv_nsec; long tv_nsec;
}; };
#endif /* _MSC_VER */ #endif /* _TIMESPEC_DEFINED */
#endif /* HAVE_STRUCT_TIMESPEC */ #endif /* HAVE_STRUCT_TIMESPEC */
#ifndef SIG_BLOCK #if !defined(SIG_BLOCK)
#define SIG_BLOCK 0 #define SIG_BLOCK 0
#endif /* SIG_BLOCK */ #endif /* SIG_BLOCK */
#ifndef SIG_UNBLOCK #if !defined(SIG_UNBLOCK)
#define SIG_UNBLOCK 1 #define SIG_UNBLOCK 1
#endif /* SIG_UNBLOCK */ #endif /* SIG_UNBLOCK */
#ifndef SIG_SETMASK #if !defined(SIG_SETMASK)
#define SIG_SETMASK 2 #define SIG_SETMASK 2
#endif /* SIG_SETMASK */ #endif /* SIG_SETMASK */
#ifdef __cplusplus #if defined(__cplusplus)
extern "C" extern "C"
{ {
#endif /* __cplusplus */ #endif /* __cplusplus */
@ -425,22 +437,22 @@ extern "C"
* POSIX Options * POSIX Options
*/ */
#undef _POSIX_THREADS #undef _POSIX_THREADS
#define _POSIX_THREADS 200112L #define _POSIX_THREADS 200809L
#undef _POSIX_READER_WRITER_LOCKS #undef _POSIX_READER_WRITER_LOCKS
#define _POSIX_READER_WRITER_LOCKS 200112L #define _POSIX_READER_WRITER_LOCKS 200809L
#undef _POSIX_SPIN_LOCKS #undef _POSIX_SPIN_LOCKS
#define _POSIX_SPIN_LOCKS 200112L #define _POSIX_SPIN_LOCKS 200809L
#undef _POSIX_BARRIERS #undef _POSIX_BARRIERS
#define _POSIX_BARRIERS 200112L #define _POSIX_BARRIERS 200809L
#undef _POSIX_THREAD_SAFE_FUNCTIONS #undef _POSIX_THREAD_SAFE_FUNCTIONS
#define _POSIX_THREAD_SAFE_FUNCTIONS 200112L #define _POSIX_THREAD_SAFE_FUNCTIONS 200809L
#undef _POSIX_THREAD_ATTR_STACKSIZE #undef _POSIX_THREAD_ATTR_STACKSIZE
#define _POSIX_THREAD_ATTR_STACKSIZE 200112L #define _POSIX_THREAD_ATTR_STACKSIZE 200809L
/* /*
* The following options are not supported * The following options are not supported
@ -530,18 +542,18 @@ extern "C"
#define SEM_VALUE_MAX INT_MAX #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. # error Please upgrade your GNU compiler to one that supports __declspec.
#endif #endif
/* /*
* When building the DLL code, you should define PTW32_BUILD so that * When building the library, you should define PTW32_BUILD so that
* the variables/functions are exported correctly. When using the DLL, * the variables/functions are exported correctly. When using the library,
* do NOT define PTW32_BUILD, and then the variables/functions will * do NOT define PTW32_BUILD, and then the variables/functions will
* be imported correctly. * be imported correctly.
*/ */
#ifndef PTW32_STATIC_LIB #if !defined(PTW32_STATIC_LIB)
# ifdef PTW32_BUILD # if defined(PTW32_BUILD)
# define PTW32_DLLPORT __declspec (dllexport) # define PTW32_DLLPORT __declspec (dllexport)
# else # else
# define PTW32_DLLPORT __declspec (dllimport) # define PTW32_DLLPORT __declspec (dllimport)
@ -636,6 +648,12 @@ enum {
PTHREAD_PROCESS_PRIVATE = 0, PTHREAD_PROCESS_PRIVATE = 0,
PTHREAD_PROCESS_SHARED = 1, PTHREAD_PROCESS_SHARED = 1,
/*
* pthread_mutexattr_{get,set}robust
*/
PTHREAD_MUTEX_STALLED = 0, /* Default */
PTHREAD_MUTEX_ROBUST = 1,
/* /*
* pthread_barrier_wait * 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_MUTEX_INITIALIZER ((pthread_mutex_t)(size_t) -1)
#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER ((pthread_mutex_t) -2) #define PTHREAD_RECURSIVE_MUTEX_INITIALIZER ((pthread_mutex_t)(size_t) -2)
#define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER ((pthread_mutex_t) -3) #define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER ((pthread_mutex_t)(size_t) -3)
/* /*
* Compatibility with LinuxThreads * Compatibility with LinuxThreads
@ -687,11 +705,11 @@ struct pthread_once_t_
#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP PTHREAD_RECURSIVE_MUTEX_INITIALIZER #define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP PTHREAD_RECURSIVE_MUTEX_INITIALIZER
#define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP PTHREAD_ERRORCHECK_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; struct ptw32_cleanup_t *prev;
}; };
#ifdef __CLEANUP_SEH #if defined(__CLEANUP_SEH)
/* /*
* WIN32 SEH version of cancel cleanup. * WIN32 SEH version of cancel cleanup.
*/ */
@ -760,7 +778,7 @@ struct ptw32_cleanup_t
#else /* __CLEANUP_SEH */ #else /* __CLEANUP_SEH */
#ifdef __CLEANUP_C #if defined(__CLEANUP_C)
/* /*
* C implementation of PThreads cancel cleanup * C implementation of PThreads cancel cleanup
@ -778,7 +796,7 @@ struct ptw32_cleanup_t
#else /* __CLEANUP_C */ #else /* __CLEANUP_C */
#ifdef __CLEANUP_CXX #if defined(__CLEANUP_CXX)
/* /*
* C++ version of cancel cleanup. * 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 *, PTW32_DLLPORT int PTW32_CDECL pthread_attr_setschedpolicy (pthread_attr_t *,
int); 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 *); int *);
PTW32_DLLPORT int PTW32_CDECL pthread_attr_setinheritsched(pthread_attr_t * attr, PTW32_DLLPORT int PTW32_CDECL pthread_attr_setinheritsched(pthread_attr_t * attr,
int inheritsched); 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); int * inheritsched);
PTW32_DLLPORT int PTW32_CDECL pthread_attr_setscope (pthread_attr_t *, 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, PTW32_DLLPORT int PTW32_CDECL pthread_create (pthread_t * tid,
const pthread_attr_t * attr, const pthread_attr_t * attr,
void *(*start) (void *), void *(PTW32_CDECL *start) (void *),
void *arg); void *arg);
PTW32_DLLPORT int PTW32_CDECL pthread_detach (pthread_t tid); 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 void PTW32_CDECL pthread_testcancel (void);
PTW32_DLLPORT int PTW32_CDECL pthread_once (pthread_once_t * once_control, 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 #if PTW32_LEVEL >= PTW32_LEVEL_MAX
PTW32_DLLPORT ptw32_cleanup_t * PTW32_CDECL ptw32_pop_cleanup (int execute); PTW32_DLLPORT ptw32_cleanup_t * PTW32_CDECL ptw32_pop_cleanup (int execute);
PTW32_DLLPORT void PTW32_CDECL ptw32_push_cleanup (ptw32_cleanup_t * cleanup, PTW32_DLLPORT void PTW32_CDECL ptw32_push_cleanup (ptw32_cleanup_t * cleanup,
void (*routine) (void *), ptw32_cleanup_callback_t routine,
void *arg); void *arg);
#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ #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 * Thread Specific Data Functions
*/ */
PTW32_DLLPORT int PTW32_CDECL pthread_key_create (pthread_key_t * key, 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); 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); int pshared);
PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_settype (pthread_mutexattr_t * attr, int kind); 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 * 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_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); const struct timespec *abstime);
PTW32_DLLPORT int PTW32_CDECL pthread_mutex_trylock (pthread_mutex_t * mutex); 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_unlock (pthread_mutex_t * mutex);
PTW32_DLLPORT int PTW32_CDECL pthread_mutex_consistent (pthread_mutex_t * mutex);
/* /*
* Spinlock Functions * 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_delay_np (struct timespec * interval);
PTW32_DLLPORT int PTW32_CDECL pthread_num_processors_np(void); 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 * 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. * Returns the Win32 HANDLE for the POSIX thread.
*/ */
PTW32_DLLPORT HANDLE PTW32_CDECL pthread_getw32threadhandle_np(pthread_t 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. * Thread-Safe C Runtime Library Mappings.
*/ */
#ifndef _UWIN #if !defined(_UWIN)
# if defined(NEED_ERRNO) # if defined(NEED_ERRNO)
PTW32_DLLPORT int * PTW32_CDECL _errno( void ); PTW32_DLLPORT int * PTW32_CDECL _errno( void );
# else # else
# ifndef errno # if !defined(errno)
# if (defined(_MT) || defined(_DLL)) # if (defined(_MT) || defined(_DLL))
__declspec(dllimport) extern int * __cdecl _errno(void); __declspec(dllimport) extern int * __cdecl _errno(void);
# define errno (*_errno()) # define errno (*_errno())
@ -1230,40 +1262,6 @@ PTW32_DLLPORT int PTW32_CDECL pthreadCancelableTimedWait (HANDLE waitHandle,
# endif # endif
#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. * Some compiler environments don't define some things.
*/ */
@ -1272,7 +1270,7 @@ PTW32_DLLPORT int PTW32_CDECL pthreadCancelableTimedWait (HANDLE waitHandle,
# define _timeb timeb # define _timeb timeb
#endif #endif
#ifdef __cplusplus #if defined(__cplusplus)
/* /*
* Internal exceptions * Internal exceptions
@ -1293,9 +1291,9 @@ PTW32_DLLPORT DWORD PTW32_CDECL ptw32_get_exception_services_code(void);
#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ #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 * 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 */ #endif /* __CLEANUP_SEH */
#ifdef __CLEANUP_CXX #if defined(__CLEANUP_CXX)
/* /*
* Redefine the C++ catch keyword to ensure that applications * Redefine the C++ catch keyword to ensure that applications
* propagate our internal exceptions up to the library's internal handlers. * propagate our internal exceptions up to the library's internal handlers.
*/ */
#ifdef _MSC_VER #if defined(_MSC_VER)
/* /*
* WARNING: Replace any 'catch( ... )' with 'PtW32CatchAll' * WARNING: Replace any 'catch( ... )' with 'PtW32CatchAll'
* if you want Pthread-Win32 cancelation and pthread_exit to work. * 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("Specify \"/DPtW32NoCatchWarn\" compiler flag to skip this message.")
#pragma 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(" with 'PtW32CatchAll' or 'CATCHALL' if you want POSIX thread")
#pragma message(" cancelation and pthread_exit to work. For example:") #pragma message(" cancelation and pthread_exit to work. For example:")
#pragma message("") #pragma message("")
#pragma message(" #ifdef PtW32CatchAll") #pragma message(" #if defined(PtW32CatchAll)")
#pragma message(" PtW32CatchAll") #pragma message(" PtW32CatchAll")
#pragma message(" #else") #pragma message(" #else")
#pragma message(" catch(...)") #pragma message(" catch(...)")
@ -1356,14 +1354,14 @@ PTW32_DLLPORT DWORD PTW32_CDECL ptw32_get_exception_services_code(void);
#endif /* ! PTW32_BUILD */ #endif /* ! PTW32_BUILD */
#ifdef __cplusplus #if defined(__cplusplus)
} /* End of extern "C" */ } /* End of extern "C" */
#endif /* __cplusplus */ #endif /* __cplusplus */
#ifdef PTW32__HANDLE_DEF #if defined(PTW32__HANDLE_DEF)
# undef HANDLE # undef HANDLE
#endif #endif
#ifdef PTW32__DWORD_DEF #if defined(PTW32__DWORD_DEF)
# undef DWORD # undef DWORD
#endif #endif

View File

@ -36,53 +36,53 @@
* if not, write to the Free Software Foundation, Inc., * if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifndef SCHED_H #ifndef _SCHED_H
#ifdef _SCHED_H // Test added by JE - 12-12-2009 #ifdef SCHED_H // Test added by JE - 12-12-2009
#error "ardourext/sched.h conflicts with an existing pthread library" #error "ardourext/sched.h conflicts with an existing pthread library"
#endif #endif
// Now make sure we can't accidentally include a conflicting library !! // Now make sure we can't accidentally include a conflicting library !!
#define _SCHED_H
#define SCHED_H #define SCHED_H
#define _SCHED_H
#undef PTW32_LEVEL #undef PTW32_SCHED_LEVEL
#if defined(_POSIX_SOURCE) #if defined(_POSIX_SOURCE)
#define PTW32_LEVEL 0 #define PTW32_SCHED_LEVEL 0
/* Early POSIX */ /* Early POSIX */
#endif #endif
#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309 #if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309
#undef PTW32_LEVEL #undef PTW32_SCHED_LEVEL
#define PTW32_LEVEL 1 #define PTW32_SCHED_LEVEL 1
/* Include 1b, 1c and 1d */ /* Include 1b, 1c and 1d */
#endif #endif
#if defined(INCLUDE_NP) #if defined(INCLUDE_NP)
#undef PTW32_LEVEL #undef PTW32_SCHED_LEVEL
#define PTW32_LEVEL 2 #define PTW32_SCHED_LEVEL 2
/* Include Non-Portable extensions */ /* Include Non-Portable extensions */
#endif #endif
#define PTW32_LEVEL_MAX 3 #define PTW32_SCHED_LEVEL_MAX 3
#if !defined(PTW32_LEVEL) #if ( defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112 ) || !defined(PTW32_SCHED_LEVEL)
#define PTW32_LEVEL PTW32_LEVEL_MAX #define PTW32_SCHED_LEVEL PTW32_SCHED_LEVEL_MAX
/* Include everything */ /* Include everything */
#endif #endif
#if __GNUC__ && ! defined (__declspec) #if defined(__GNUC__) && !defined(__declspec)
# error Please upgrade your GNU compiler to one that supports __declspec. # error Please upgrade your GNU compiler to one that supports __declspec.
#endif #endif
/* /*
* When building the DLL code, you should define PTW32_BUILD so that * When building the library, you should define PTW32_BUILD so that
* the variables/functions are exported correctly. When using the DLL, * the variables/functions are exported correctly. When using the library,
* do NOT define PTW32_BUILD, and then the variables/functions will * do NOT define PTW32_BUILD, and then the variables/functions will
* be imported correctly. * be imported correctly.
*/ */
#ifndef PTW32_STATIC_LIB #if !defined(PTW32_STATIC_LIB)
# ifdef PTW32_BUILD # if defined(PTW32_BUILD)
# define PTW32_DLLPORT __declspec (dllexport) # define PTW32_DLLPORT __declspec (dllexport)
# else # else
# define PTW32_DLLPORT __declspec (dllimport) # define PTW32_DLLPORT __declspec (dllimport)
@ -96,12 +96,15 @@
* which is only used when building the pthread-win32 libraries. * which is only used when building the pthread-win32 libraries.
*/ */
#ifndef PTW32_CONFIG_H #if !defined(PTW32_CONFIG_H)
# if defined(WINCE) # if defined(WINCE)
# define NEED_ERRNO # define NEED_ERRNO
# define NEED_SEM # define NEED_SEM
# endif # 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 # define HAVE_MODE_T
# endif # endif
#endif #endif
@ -110,23 +113,25 @@
* *
*/ */
#if PTW32_LEVEL >= PTW32_LEVEL_MAX #if PTW32_SCHED_LEVEL >= PTW32_SCHED_LEVEL_MAX
#ifdef NEED_ERRNO #if defined(NEED_ERRNO)
#include "need_errno.h" #include "need_errno.h"
#else #else
#include <errno.h> #include <errno.h>
#endif #endif
#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ #endif /* PTW32_SCHED_LEVEL >= PTW32_SCHED_LEVEL_MAX */
#if defined(__MINGW32__) || defined(_UWIN) #if (defined(__MINGW64__) || defined(__MINGW32__)) || defined(_UWIN)
#if PTW32_LEVEL >= PTW32_LEVEL_MAX # if PTW32_SCHED_LEVEL >= PTW32_SCHED_LEVEL_MAX
/* For pid_t */ /* For pid_t */
# include <sys/types.h> # include <sys/types.h>
/* Required by Unix 98 */ /* Required by Unix 98 */
# include <time.h> # include <time.h>
#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ # else
typedef int pid_t;
# endif
#else #else
typedef int pid_t; typedef int pid_t;
#endif #endif
/* Thread scheduling policies */ /* Thread scheduling policies */
@ -143,7 +148,7 @@ struct sched_param {
int sched_priority; int sched_priority;
}; };
#ifdef __cplusplus #if defined(__cplusplus)
extern "C" extern "C"
{ {
#endif /* __cplusplus */ #endif /* __cplusplus */
@ -172,12 +177,12 @@ PTW32_DLLPORT int __cdecl sched_getscheduler (pid_t pid);
( errno = ENOTSUP, (int) -1 ) ( errno = ENOTSUP, (int) -1 )
#ifdef __cplusplus #if defined(__cplusplus)
} /* End of extern "C" */ } /* End of extern "C" */
#endif /* __cplusplus */ #endif /* __cplusplus */
#undef PTW32_LEVEL #undef PTW32_SCHED_LEVEL
#undef PTW32_LEVEL_MAX #undef PTW32_SCHED_LEVEL_MAX
#endif /* !SCHED_H */ #endif /* !_SCHED_H */

View File

@ -44,44 +44,44 @@
#define _SEMAPHORE_H #define _SEMAPHORE_H
#define SEMAPHORE_H #define SEMAPHORE_H
#undef PTW32_LEVEL #undef PTW32_SEMAPHORE_LEVEL
#if defined(_POSIX_SOURCE) #if defined(_POSIX_SOURCE)
#define PTW32_LEVEL 0 #define PTW32_SEMAPHORE_LEVEL 0
/* Early POSIX */ /* Early POSIX */
#endif #endif
#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309 #if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309
#undef PTW32_LEVEL #undef PTW32_SEMAPHORE_LEVEL
#define PTW32_LEVEL 1 #define PTW32_SEMAPHORE_LEVEL 1
/* Include 1b, 1c and 1d */ /* Include 1b, 1c and 1d */
#endif #endif
#if defined(INCLUDE_NP) #if defined(INCLUDE_NP)
#undef PTW32_LEVEL #undef PTW32_SEMAPHORE_LEVEL
#define PTW32_LEVEL 2 #define PTW32_SEMAPHORE_LEVEL 2
/* Include Non-Portable extensions */ /* Include Non-Portable extensions */
#endif #endif
#define PTW32_LEVEL_MAX 3 #define PTW32_SEMAPHORE_LEVEL_MAX 3
#if !defined(PTW32_LEVEL) #if !defined(PTW32_SEMAPHORE_LEVEL)
#define PTW32_LEVEL PTW32_LEVEL_MAX #define PTW32_SEMAPHORE_LEVEL PTW32_SEMAPHORE_LEVEL_MAX
/* Include everything */ /* Include everything */
#endif #endif
#if __GNUC__ && ! defined (__declspec) #if defined(__GNUC__) && ! defined (__declspec)
# error Please upgrade your GNU compiler to one that supports __declspec. # error Please upgrade your GNU compiler to one that supports __declspec.
#endif #endif
/* /*
* When building the DLL code, you should define PTW32_BUILD so that * When building the library, you should define PTW32_BUILD so that
* the variables/functions are exported correctly. When using the DLL, * the variables/functions are exported correctly. When using the library,
* do NOT define PTW32_BUILD, and then the variables/functions will * do NOT define PTW32_BUILD, and then the variables/functions will
* be imported correctly. * be imported correctly.
*/ */
#ifndef PTW32_STATIC_LIB #if !defined(PTW32_STATIC_LIB)
# ifdef PTW32_BUILD # if defined(PTW32_BUILD)
# define PTW32_DLLPORT __declspec (dllexport) # define PTW32_DLLPORT __declspec (dllexport)
# else # else
# define PTW32_DLLPORT __declspec (dllimport) # define PTW32_DLLPORT __declspec (dllimport)
@ -95,12 +95,15 @@
* which is only used when building the pthread-win32 libraries. * which is only used when building the pthread-win32 libraries.
*/ */
#ifndef PTW32_CONFIG_H #if !defined(PTW32_CONFIG_H)
# if defined(WINCE) # if defined(WINCE)
# define NEED_ERRNO # define NEED_ERRNO
# define NEED_SEM # define NEED_SEM
# endif # 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 # define HAVE_MODE_T
# endif # endif
#endif #endif
@ -109,22 +112,22 @@
* *
*/ */
#if PTW32_LEVEL >= PTW32_LEVEL_MAX #if PTW32_SEMAPHORE_LEVEL >= PTW32_SEMAPHORE_LEVEL_MAX
#ifdef NEED_ERRNO #if defined(NEED_ERRNO)
#include "need_errno.h" #include "need_errno.h"
#else #else
#include <errno.h> #include <errno.h>
#endif #endif
#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ #endif /* PTW32_SEMAPHORE_LEVEL >= PTW32_SEMAPHORE_LEVEL_MAX */
#define _POSIX_SEMAPHORES #define _POSIX_SEMAPHORES
#ifdef __cplusplus #if defined(__cplusplus)
extern "C" extern "C"
{ {
#endif /* __cplusplus */ #endif /* __cplusplus */
#ifndef HAVE_MODE_T #if !defined(HAVE_MODE_T)
typedef unsigned int mode_t; typedef unsigned int mode_t;
#endif #endif
@ -161,11 +164,11 @@ PTW32_DLLPORT int __cdecl sem_unlink (const char * name);
PTW32_DLLPORT int __cdecl sem_getvalue (sem_t * sem, PTW32_DLLPORT int __cdecl sem_getvalue (sem_t * sem,
int * sval); int * sval);
#ifdef __cplusplus #if defined(__cplusplus)
} /* End of extern "C" */ } /* End of extern "C" */
#endif /* __cplusplus */ #endif /* __cplusplus */
#undef PTW32_LEVEL #undef PTW32_SEMAPHORE_LEVEL
#undef PTW32_LEVEL_MAX #undef PTW32_SEMAPHORE_LEVEL_MAX
#endif /* !SEMAPHORE_H */ #endif /* !SEMAPHORE_H */