summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--implement.h274
-rw-r--r--pthread.h889
-rw-r--r--pthread_cond_wait.c124
-rw-r--r--sched.h10
-rw-r--r--semaphore.h22
5 files changed, 671 insertions, 648 deletions
diff --git a/implement.h b/implement.h
index 34eb826..ae8f32e 100644
--- a/implement.h
+++ b/implement.h
@@ -83,14 +83,14 @@ typedef enum {
* The thread is still "alive" if the numeric value of the
* state is greater or equal "PThreadStateRunning".
*/
- PThreadStateInitial = 0, /* Thread not running */
- PThreadStateRunning, /* Thread alive & kicking */
- PThreadStateSuspended, /* Thread alive but suspended */
- PThreadStateCanceling, /* Thread alive but is */
- /* in the process of terminating */
- /* due to a cancellation request */
- PThreadStateException, /* Thread alive but exiting */
- /* due to an exception */
+ PThreadStateInitial = 0, /* Thread not running */
+ PThreadStateRunning, /* Thread alive & kicking */
+ PThreadStateSuspended, /* Thread alive but suspended */
+ PThreadStateCanceling, /* Thread alive but is */
+ /* in the process of terminating */
+ /* due to a cancellation request */
+ PThreadStateException, /* Thread alive but exiting */
+ /* due to an exception */
PThreadStateLast
}
PThreadState;
@@ -101,11 +101,11 @@ typedef enum {
* This enumeration represents the reason why a thread has
* terminated/is terminating.
*/
- PThreadDemisePeaceful = 0, /* Death due natural causes */
- PThreadDemiseCancelled, /* Death due to user cancel */
- PThreadDemiseException, /* Death due to unhandled */
- /* exception */
- PThreadDemiseNotDead /* I'm not dead! */
+ PThreadDemisePeaceful = 0, /* Death due natural causes */
+ PThreadDemiseCancelled, /* Death due to user cancel */
+ PThreadDemiseException, /* Death due to unhandled */
+ /* exception */
+ PThreadDemiseNotDead /* I'm not dead! */
}
PThreadDemise;
@@ -168,9 +168,9 @@ struct pthread_attr_t_ {
struct sem_t_ {
#ifdef NEED_SEM
- unsigned int value;
+ unsigned int value;
CRITICAL_SECTION sem_lock_cs;
- HANDLE event;
+ HANDLE event;
#else /* NEED_SEM */
HANDLE sem;
#endif /* NEED_SEM */
@@ -180,19 +180,19 @@ struct sem_t_ {
#define PTW32_OBJECT_INVALID NULL
struct pthread_mutex_t_ {
- LONG lock_idx; /* Provides exclusive access to mutex state
- via the Interlocked* mechanism, as well
- as a count of the number of threads
- waiting on the mutex. */
- int recursive_count; /* Number of unlocks a thread needs to perform
- before the lock is released (recursive
- mutexes only). */
- int kind; /* Mutex type. */
+ LONG lock_idx; /* Provides exclusive access to mutex state
+ via the Interlocked* mechanism, as well
+ as a count of the number of threads
+ waiting on the mutex. */
+ int recursive_count; /* Number of unlocks a thread needs to perform
+ before the lock is released (recursive
+ mutexes only). */
+ int kind; /* Mutex type. */
pthread_t ownerThread;
- sem_t wait_sema; /* Mutex release notification to waiting
- threads. */
+ sem_t wait_sema; /* Mutex release notification to waiting
+ threads. */
CRITICAL_SECTION wait_cs; /* Serialise lock_idx decrement after mutex
- timeout. */
+ timeout. */
};
struct pthread_mutexattr_t_ {
@@ -222,10 +222,10 @@ struct pthread_mutexattr_t_ {
#define PTW32_SPIN_USE_MUTEX (3)
struct pthread_spinlock_t_ {
- long interlock; /* Locking element for multi-cpus. */
+ long interlock; /* Locking element for multi-cpus. */
union {
- int cpus; /* No. of cpus if multi cpus, or */
- pthread_mutex_t mutex; /* mutex if single cpu. */
+ int cpus; /* No. of cpus if multi cpus, or */
+ pthread_mutex_t mutex; /* mutex if single cpu. */
} u;
};
@@ -260,18 +260,18 @@ struct ThreadParms {
struct pthread_cond_t_ {
- long nWaitersBlocked; /* Number of threads blocked */
- long nWaitersGone; /* Number of threads timed out */
- long nWaitersToUnblock; /* Number of threads to unblock */
- sem_t semBlockQueue; /* Queue up threads waiting for the */
- /* condition to become signalled */
- sem_t semBlockLock; /* Semaphore that guards access to */
- /* | waiters blocked count/block queue */
- /* +-> Mandatory Sync.LEVEL-1 */
- pthread_mutex_t mtxUnblockLock; /* Mutex that guards access to */
- /* | waiters (to)unblock(ed) counts */
- /* +-> Optional* Sync.LEVEL-2 */
- pthread_cond_t next; /* Doubly linked list */
+ long nWaitersBlocked; /* Number of threads blocked */
+ long nWaitersGone; /* Number of threads timed out */
+ long nWaitersToUnblock; /* Number of threads to unblock */
+ sem_t semBlockQueue; /* Queue up threads waiting for the */
+ /* condition to become signalled */
+ sem_t semBlockLock; /* Semaphore that guards access to */
+ /* | waiters blocked count/block queue */
+ /* +-> Mandatory Sync.LEVEL-1 */
+ pthread_mutex_t mtxUnblockLock; /* Mutex that guards access to */
+ /* | waiters (to)unblock(ed) counts */
+ /* +-> Optional* Sync.LEVEL-2 */
+ pthread_cond_t next; /* Doubly linked list */
pthread_cond_t prev;
};
@@ -286,65 +286,65 @@ struct pthread_rwlock_t_ {
pthread_mutex_t mtxExclusiveAccess;
pthread_mutex_t mtxSharedAccessCompleted;
pthread_cond_t cndSharedAccessCompleted;
- int nSharedAccessCount;
- int nExclusiveAccessCount;
- int nCompletedSharedAccessCount;
- int nMagic;
+ int nSharedAccessCount;
+ int nExclusiveAccessCount;
+ int nCompletedSharedAccessCount;
+ int nMagic;
};
struct pthread_rwlockattr_t_ {
- int pshared;
+ int pshared;
};
struct ThreadKeyAssoc {
/*
* Purpose:
- * This structure creates an association between a
- * thread and a key.
- * It is used to implement the implicit invocation
- * of a user defined destroy routine for thread
- * specific data registered by a user upon exiting a
- * thread.
+ * This structure creates an association between a
+ * thread and a key.
+ * It is used to implement the implicit invocation
+ * of a user defined destroy routine for thread
+ * specific data registered by a user upon exiting a
+ * thread.
*
* Attributes:
- * lock
- * protects access to the rest of the structure
+ * lock
+ * protects access to the rest of the structure
*
- * thread
- * reference to the thread that owns the association.
- * As long as this is not NULL, the association remains
- * referenced by the pthread_t.
+ * thread
+ * reference to the thread that owns the association.
+ * As long as this is not NULL, the association remains
+ * referenced by the pthread_t.
*
- * key
- * reference to the key that owns the association.
- * As long as this is not NULL, the association remains
- * referenced by the pthread_key_t.
+ * key
+ * reference to the key that owns the association.
+ * As long as this is not NULL, the association remains
+ * referenced by the pthread_key_t.
*
- * nextKey
- * The pthread_t->keys attribute is the head of a
- * chain of associations that runs through the nextKey
- * link. This chain provides the 1 to many relationship
- * between a pthread_t and all pthread_key_t on which
- * it called pthread_setspecific.
+ * nextKey
+ * The pthread_t->keys attribute is the head of a
+ * chain of associations that runs through the nextKey
+ * link. This chain provides the 1 to many relationship
+ * between a pthread_t and all pthread_key_t on which
+ * it called pthread_setspecific.
*
- * nextThread
- * The pthread_key_t->threads attribute is the head of
- * a chain of assoctiations that runs through the
- * nextThreads link. This chain provides the 1 to many
- * relationship between a pthread_key_t and all the
- * PThreads that have called pthread_setspecific for
- * this pthread_key_t.
+ * nextThread
+ * The pthread_key_t->threads attribute is the head of
+ * a chain of assoctiations that runs through the
+ * nextThreads link. This chain provides the 1 to many
+ * relationship between a pthread_key_t and all the
+ * PThreads that have called pthread_setspecific for
+ * this pthread_key_t.
*
*
* Notes:
- * 1) As long as one of the attributes, thread or key, is
- * not NULL, the association is being referenced; once
- * both are NULL, the association must be released.
+ * 1) As long as one of the attributes, thread or key, is
+ * not NULL, the association is being referenced; once
+ * both are NULL, the association must be released.
*
- * 2) Under WIN32, an association is only created by
- * pthread_setspecific if the user provided a
- * destroyRoutine when they created the key.
+ * 2) Under WIN32, an association is only created by
+ * pthread_setspecific if the user provided a
+ * destroyRoutine when they created the key.
*
*
*/
@@ -360,30 +360,30 @@ struct ThreadKeyAssoc {
/*
* --------------------------------------------------------------
* MAKE_SOFTWARE_EXCEPTION
- * This macro constructs a software exception code following
- * the same format as the standard Win32 error codes as defined
- * in WINERROR.H
+ * This macro constructs a software exception code following
+ * the same format as the standard Win32 error codes as defined
+ * in WINERROR.H
* Values are 32 bit values layed out as follows:
*
* 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
* +---+-+-+-----------------------+-------------------------------+
- * |Sev|C|R| Facility | Code |
+ * |Sev|C|R| Facility | Code |
* +---+-+-+-----------------------+-------------------------------+
*
* Severity Values:
*/
-#define SE_SUCCESS 0x00
-#define SE_INFORMATION 0x01
-#define SE_WARNING 0x02
-#define SE_ERROR 0x03
+#define SE_SUCCESS 0x00
+#define SE_INFORMATION 0x01
+#define SE_WARNING 0x02
+#define SE_ERROR 0x03
#define MAKE_SOFTWARE_EXCEPTION( _severity, _facility, _exception ) \
-( (DWORD) ( ( (_severity) << 30 ) | /* Severity code */ \
- ( 1 << 29 ) | /* MS=0, User=1 */ \
- ( 0 << 28 ) | /* Reserved */ \
- ( (_facility) << 16 ) | /* Facility Code */ \
- ( (_exception) << 0 ) /* Exception Code */ \
- ) )
+( (DWORD) ( ( (_severity) << 30 ) | /* Severity code */ \
+ ( 1 << 29 ) | /* MS=0, User=1 */ \
+ ( 0 << 28 ) | /* Reserved */ \
+ ( (_facility) << 16 ) | /* Facility Code */ \
+ ( (_exception) << 0 ) /* Exception Code */ \
+ ) )
/*
* We choose one specific Facility/Error code combination to
@@ -391,13 +391,13 @@ struct ThreadKeyAssoc {
* We store our actual component and error code within
* the optional information array.
*/
-#define EXCEPTION_PTW32_SERVICES \
+#define EXCEPTION_PTW32_SERVICES \
MAKE_SOFTWARE_EXCEPTION( SE_ERROR, \
- PTW32_SERVICES_FACILITY, \
- PTW32_SERVICES_ERROR )
+ PTW32_SERVICES_FACILITY, \
+ PTW32_SERVICES_ERROR )
-#define PTW32_SERVICES_FACILITY 0xBAD
-#define PTW32_SERVICES_ERROR 0xDEED
+#define PTW32_SERVICES_FACILITY 0xBAD
+#define PTW32_SERVICES_ERROR 0xDEED
#endif /* __CLEANUP_SEH */
@@ -407,25 +407,25 @@ struct ThreadKeyAssoc {
* generic exception selectors.
*/
-#define PTW32_EPS_EXIT (1)
-#define PTW32_EPS_CANCEL (2)
+#define PTW32_EPS_EXIT (1)
+#define PTW32_EPS_CANCEL (2)
/* Mutex constants */
enum {
- PTW32_MUTEX_LOCK_IDX_INIT = -1,
+ PTW32_MUTEX_LOCK_IDX_INIT = -1,
PTW32_MUTEX_OWNER_ANONYMOUS = 1
};
/* Useful macros */
-#define PTW32_MAX(a,b) ((a)<(b)?(b):(a))
-#define PTW32_MIN(a,b) ((a)>(b)?(b):(a))
+#define PTW32_MAX(a,b) ((a)<(b)?(b):(a))
+#define PTW32_MIN(a,b) ((a)>(b)?(b):(a))
/* Declared in global.c */
extern PTW32_INTERLOCKED_LONG (WINAPI *ptw32_interlocked_compare_exchange)(PTW32_INTERLOCKED_LPLONG,
- PTW32_INTERLOCKED_LONG,
- PTW32_INTERLOCKED_LONG);
+ PTW32_INTERLOCKED_LONG,
+ PTW32_INTERLOCKED_LONG);
/* Thread Reuse stack bottom marker. Must not be NULL or any valid pointer to memory. */
#define PTW32_THREAD_REUSE_BOTTOM ((pthread_t) 1)
@@ -481,8 +481,8 @@ int ptw32_rwlock_check_need_init(pthread_rwlock_t *rwlock);
PTW32_INTERLOCKED_LONG WINAPI
ptw32_InterlockedCompareExchange(PTW32_INTERLOCKED_LPLONG location,
- PTW32_INTERLOCKED_LONG value,
- PTW32_INTERLOCKED_LONG comparand);
+ PTW32_INTERLOCKED_LONG value,
+ PTW32_INTERLOCKED_LONG comparand);
int ptw32_processInitialize (void);
@@ -504,6 +504,8 @@ int ptw32_setthreadpriority (pthread_t thread,
int policy,
int priority);
+void ptw32_rwlock_cancelwrwait(void * arg);
+
#if ! defined (__MINGW32__) || defined (__MSVCRT__)
unsigned __stdcall
#else
@@ -514,8 +516,8 @@ ptw32_threadStart (void * vthreadParms);
void ptw32_callUserDestroyRoutines (pthread_t thread);
int ptw32_tkAssocCreate (ThreadKeyAssoc ** assocP,
- pthread_t thread,
- pthread_key_t key);
+ pthread_t thread,
+ pthread_key_t key);
void ptw32_tkAssocDestroy (ThreadKeyAssoc * assoc);
@@ -523,7 +525,7 @@ void ptw32_tkAssocDestroy (ThreadKeyAssoc * assoc);
#ifdef NEED_SEM
void ptw32_decrease_semaphore(sem_t * sem);
BOOL ptw32_increase_semaphore(sem_t * sem,
- unsigned int n);
+ unsigned int n);
#endif /* NEED_SEM */
#ifdef NEED_FTIME
@@ -537,19 +539,19 @@ void ptw32_filetime_to_timespec(const FILETIME *ft, struct timespec *ts);
#ifdef _UWIN_
-# ifdef _MT
-# ifdef __cplusplus
- extern "C" {
-# endif
- _CRTIMP unsigned long __cdecl _beginthread (void (__cdecl *) (void *),
- unsigned, void *);
- _CRTIMP void __cdecl _endthread(void);
- _CRTIMP unsigned long __cdecl _beginthreadex(void *, unsigned,
- unsigned (__stdcall *) (void *), void *, unsigned, unsigned *);
- _CRTIMP void __cdecl _endthreadex(unsigned);
-# ifdef __cplusplus
- }
-# endif
+# ifdef _MT
+# ifdef __cplusplus
+ extern "C" {
+# endif
+ _CRTIMP unsigned long __cdecl _beginthread (void (__cdecl *) (void *),
+ unsigned, void *);
+ _CRTIMP void __cdecl _endthread(void);
+ _CRTIMP unsigned long __cdecl _beginthreadex(void *, unsigned,
+ unsigned (__stdcall *) (void *), void *, unsigned, unsigned *);
+ _CRTIMP void __cdecl _endthreadex(unsigned);
+# ifdef __cplusplus
+ }
+# endif
# endif
#else
# include <process.h>
@@ -570,17 +572,17 @@ void ptw32_filetime_to_timespec(const FILETIME *ft, struct timespec *ts);
*/
#define _beginthreadex(security, \
- stack_size, \
- start_proc, \
- arg, \
- flags, \
- pid) \
- CreateThread(security, \
- stack_size, \
- (LPTHREAD_START_ROUTINE) start_proc, \
- arg, \
- flags, \
- pid)
+ stack_size, \
+ start_proc, \
+ arg, \
+ flags, \
+ pid) \
+ CreateThread(security, \
+ stack_size, \
+ (LPTHREAD_START_ROUTINE) start_proc, \
+ arg, \
+ flags, \
+ pid)
#define _endthreadex ExitThread
diff --git a/pthread.h b/pthread.h
index 35b2828..34cacc0 100644
--- a/pthread.h
+++ b/pthread.h
@@ -61,7 +61,7 @@
#ifdef _UWIN
# define HAVE_STRUCT_TIMESPEC 1
-# define HAVE_SIGNAL_H 1
+# define HAVE_SIGNAL_H 1
# undef HAVE_CONFIG_H
# pragma comment(lib, "pthread")
#endif
@@ -73,68 +73,68 @@
* Module: pthread.h
*
* Purpose:
- * Provides an implementation of PThreads based upon the
- * standard:
+ * Provides an implementation of PThreads based upon the
+ * standard:
*
- * POSIX 1003.1-2001
+ * POSIX 1003.1-2001
* and
* The Single Unix Specification version 3
*
* (these two are equivalent)
*
- * in order to enhance code portability between Windows,
+ * in order to enhance code portability between Windows,
* various commercial Unix implementations, and Linux.
*
- * See the ANNOUNCE file for a full list of conforming
- * routines and defined constants, and a list of missing
- * routines and constants not defined in this implementation.
+ * See the ANNOUNCE file for a full list of conforming
+ * routines and defined constants, and a list of missing
+ * routines and constants not defined in this implementation.
*
* Authors:
- * There have been many contributors to this library.
- * The initial implementation was contributed by
- * John Bossom, and several others have provided major
- * sections or revisions of parts of the implementation.
- * Often significant effort has been contributed to
- * find and fix important bugs and other problems to
- * improve the reliability of the library, which sometimes
- * is not reflected in the amount of code which changed as
- * result.
- * As much as possible, the contributors are acknowledged
- * in the ChangeLog file in the source code distribution
- * where their changes are noted in detail.
+ * There have been many contributors to this library.
+ * The initial implementation was contributed by
+ * John Bossom, and several others have provided major
+ * sections or revisions of parts of the implementation.
+ * Often significant effort has been contributed to
+ * find and fix important bugs and other problems to
+ * improve the reliability of the library, which sometimes
+ * is not reflected in the amount of code which changed as
+ * result.
+ * As much as possible, the contributors are acknowledged
+ * in the ChangeLog file in the source code distribution
+ * where their changes are noted in detail.
*
- * Contributors are listed in the CONTRIBUTORS file.
+ * Contributors are listed in the CONTRIBUTORS file.
*
- * As usual, all bouquets go to the contributors, and all
- * brickbats go to the project maintainer.
+ * As usual, all bouquets go to the contributors, and all
+ * brickbats go to the project maintainer.
*
* Maintainer:
- * The code base for this project is coordinated and
- * eventually pre-tested, packaged, and made available by
+ * The code base for this project is coordinated and
+ * eventually pre-tested, packaged, and made available by
*
- * Ross Johnson <rpj@ise.canberra.edu.au>
+ * Ross Johnson <rpj@ise.canberra.edu.au>
*
* QA Testers:
- * Ultimately, the library is tested in the real world by
- * a host of competent and demanding scientists and
- * engineers who report bugs and/or provide solutions
- * which are then fixed or incorporated into subsequent
- * versions of the library. Each time a bug is fixed, a
- * test case is written to prove the fix and ensure
- * that later changes to the code don't reintroduce the
- * same error. The number of test cases is slowly growing
- * and therefore so is the code reliability.
+ * Ultimately, the library is tested in the real world by
+ * a host of competent and demanding scientists and
+ * engineers who report bugs and/or provide solutions
+ * which are then fixed or incorporated into subsequent
+ * versions of the library. Each time a bug is fixed, a
+ * test case is written to prove the fix and ensure
+ * that later changes to the code don't reintroduce the
+ * same error. The number of test cases is slowly growing
+ * and therefore so is the code reliability.
*
* Compliance:
- * See the file ANNOUNCE for the list of implemented
- * and not-implemented routines and defined options.
- * Of course, these are all defined is this file as well.
+ * See the file ANNOUNCE for the list of implemented
+ * and not-implemented routines and defined options.
+ * Of course, these are all defined is this file as well.
*
* Web site:
- * The source code and other information about this library
- * are available from
+ * The source code and other information about this library
+ * are available from
*
- * http://sources.redhat.com/pthreads-win32/
+ * http://sources.redhat.com/pthreads-win32/
*
* -------------------------------------------------------------
*/
@@ -269,8 +269,8 @@ enum {
#ifndef HAVE_STRUCT_TIMESPEC
struct timespec {
- long tv_sec;
- long tv_nsec;
+ long tv_sec;
+ long tv_nsec;
};
#endif /* HAVE_STRUCT_TIMESPEC */
@@ -289,7 +289,7 @@ struct timespec {
#ifdef __cplusplus
extern "C"
{
-#endif /* __cplusplus */
+#endif /* __cplusplus */
/*
* -------------------------------------------------------------
@@ -298,108 +298,108 @@ extern "C"
* =========================
*
* _POSIX_THREADS (set)
- * If set, you can use threads
+ * If set, you can use threads
*
* _POSIX_THREAD_ATTR_STACKSIZE (set)
- * If set, you can control the size of a thread's
- * stack
- * pthread_attr_getstacksize
- * pthread_attr_setstacksize
+ * If set, you can control the size of a thread's
+ * stack
+ * pthread_attr_getstacksize
+ * pthread_attr_setstacksize
*
* _POSIX_THREAD_ATTR_STACKADDR (not set)
- * If set, you can allocate and control a thread's
- * stack. If not supported, the following functions
- * will return ENOSYS, indicating they are not
- * supported:
- * pthread_attr_getstackaddr
- * pthread_attr_setstackaddr
+ * If set, you can allocate and control a thread's
+ * stack. If not supported, the following functions
+ * will return ENOSYS, indicating they are not
+ * supported:
+ * pthread_attr_getstackaddr
+ * pthread_attr_setstackaddr
*
* _POSIX_THREAD_PRIORITY_SCHEDULING (set)
- * If set, you can use realtime scheduling.
- * Indicates the availability of:
- * pthread_attr_getinheritsched
- * pthread_attr_getschedparam
- * pthread_attr_getschedpolicy
- * pthread_attr_getscope
- * pthread_attr_setinheritsched
- * pthread_attr_setschedparam
- * pthread_attr_setschedpolicy
- * pthread_attr_setscope
- * pthread_getschedparam
- * pthread_setschedparam
- * sched_get_priority_max
- * sched_get_priority_min
- * sched_rr_set_interval
+ * If set, you can use realtime scheduling.
+ * Indicates the availability of:
+ * pthread_attr_getinheritsched
+ * pthread_attr_getschedparam
+ * pthread_attr_getschedpolicy
+ * pthread_attr_getscope
+ * pthread_attr_setinheritsched
+ * pthread_attr_setschedparam
+ * pthread_attr_setschedpolicy
+ * pthread_attr_setscope
+ * pthread_getschedparam
+ * pthread_setschedparam
+ * sched_get_priority_max
+ * sched_get_priority_min
+ * sched_rr_set_interval
*
* _POSIX_THREAD_PRIO_INHERIT (not set)
- * If set, you can create priority inheritance
- * mutexes.
- * pthread_mutexattr_getprotocol +
- * pthread_mutexattr_setprotocol +
+ * If set, you can create priority inheritance
+ * mutexes.
+ * pthread_mutexattr_getprotocol +
+ * pthread_mutexattr_setprotocol +
*
* _POSIX_THREAD_PRIO_PROTECT (not set)
- * If set, you can create priority ceiling mutexes
- * Indicates the availability of:
- * pthread_mutex_getprioceiling
- * pthread_mutex_setprioceiling
- * pthread_mutexattr_getprioceiling
- * pthread_mutexattr_getprotocol +
- * pthread_mutexattr_setprioceiling
- * pthread_mutexattr_setprotocol +
+ * If set, you can create priority ceiling mutexes
+ * Indicates the availability of:
+ * pthread_mutex_getprioceiling
+ * pthread_mutex_setprioceiling
+ * pthread_mutexattr_getprioceiling
+ * pthread_mutexattr_getprotocol +
+ * pthread_mutexattr_setprioceiling
+ * pthread_mutexattr_setprotocol +
*
* _POSIX_THREAD_PROCESS_SHARED (not set)
- * If set, you can create mutexes and condition
- * variables that can be shared with another
- * process.If set, indicates the availability
- * of:
- * pthread_mutexattr_getpshared
- * pthread_mutexattr_setpshared
- * pthread_condattr_getpshared
- * pthread_condattr_setpshared
+ * If set, you can create mutexes and condition
+ * variables that can be shared with another
+ * process.If set, indicates the availability
+ * of:
+ * pthread_mutexattr_getpshared
+ * pthread_mutexattr_setpshared
+ * pthread_condattr_getpshared
+ * pthread_condattr_setpshared
*
* _POSIX_THREAD_SAFE_FUNCTIONS (set)
- * If set you can use the special *_r library
- * functions that provide thread-safe behaviour
+ * If set you can use the special *_r library
+ * functions that provide thread-safe behaviour
*
* _POSIX_READER_WRITER_LOCKS (set)
- * If set, you can use read/write locks
+ * If set, you can use read/write locks
*
* _POSIX_SPIN_LOCKS (set)
- * If set, you can use spin locks
+ * If set, you can use spin locks
*
* _POSIX_BARRIERS (set)
- * If set, you can use barriers
+ * If set, you can use barriers
*
- * + These functions provide both 'inherit' and/or
- * 'protect' protocol, based upon these macro
- * settings.
+ * + These functions provide both 'inherit' and/or
+ * 'protect' protocol, based upon these macro
+ * settings.
*
* POSIX 1003.1-2001 Limits
* ===========================
*
* PTHREAD_DESTRUCTOR_ITERATIONS
- * Maximum number of attempts to destroy
- * a thread's thread-specific data on
- * termination (must be at least 4)
+ * Maximum number of attempts to destroy
+ * a thread's thread-specific data on
+ * termination (must be at least 4)
*
* PTHREAD_KEYS_MAX
- * Maximum number of thread-specific data keys
- * available per process (must be at least 128)
+ * Maximum number of thread-specific data keys
+ * available per process (must be at least 128)
*
* PTHREAD_STACK_MIN
- * Minimum supported stack size for a thread
+ * Minimum supported stack size for a thread
*
* PTHREAD_THREADS_MAX
- * Maximum number of threads supported per
- * process (must be at least 64).
+ * Maximum number of threads supported per
+ * process (must be at least 64).
*
* _POSIX_SEM_NSEMS_MAX
- * The maximum number of semaphores a process can have.
- * (only defined if not already defined)
+ * The maximum number of semaphores a process can have.
+ * (only defined if not already defined)
*
* _POSIX_SEM_VALUE_MAX
- * The maximum value a semaphore can have.
- * (only defined if not already defined)
+ * The maximum value a semaphore can have.
+ * (only defined if not already defined)
*
* -------------------------------------------------------------
*/
@@ -436,47 +436,47 @@ extern "C"
#define _POSIX_THREAD_PRIO_PROTECT
#define _POSIX_THREAD_PROCESS_SHARED
-#endif /* KLUDGE */
+#endif /* KLUDGE */
/*
* POSIX Limits
*
- * PTHREAD_DESTRUCTOR_ITERATIONS
- * Standard states this must be at least
- * 4.
+ * PTHREAD_DESTRUCTOR_ITERATIONS
+ * Standard states this must be at least
+ * 4.
*
- * PTHREAD_KEYS_MAX
- * WIN32 permits only 64 TLS keys per process.
- * This limitation could be worked around by
- * simply simulating keys.
+ * PTHREAD_KEYS_MAX
+ * WIN32 permits only 64 TLS keys per process.
+ * This limitation could be worked around by
+ * simply simulating keys.
*
- * PTHREADS_STACK_MIN
- * POSIX specifies 0 which is also the value WIN32
- * interprets as allowing the system to
- * set the size to that of the main thread. The
- * maximum stack size in Win32 is 1Meg. WIN32
- * allocates more stack as required up to the 1Meg
- * limit.
+ * PTHREADS_STACK_MIN
+ * POSIX specifies 0 which is also the value WIN32
+ * interprets as allowing the system to
+ * set the size to that of the main thread. The
+ * maximum stack size in Win32 is 1Meg. WIN32
+ * allocates more stack as required up to the 1Meg
+ * limit.
*
- * PTHREAD_THREADS_MAX
- * Not documented by WIN32. Wrote a test program
- * that kept creating threads until it failed
- * revealed this approximate number (Windows NT).
- * This number is somewhat less for Windows 9x
- * and is effectively less than 64. Perhaps this
- * constant should be set at DLL load time.
+ * PTHREAD_THREADS_MAX
+ * Not documented by WIN32. Wrote a test program
+ * that kept creating threads until it failed
+ * revealed this approximate number (Windows NT).
+ * This number is somewhat less for Windows 9x
+ * and is effectively less than 64. Perhaps this
+ * constant should be set at DLL load time.
*
*/
-#define PTHREAD_DESTRUCTOR_ITERATIONS 4
-#define PTHREAD_KEYS_MAX 64
-#define PTHREAD_STACK_MIN 0
-#define PTHREAD_THREADS_MAX 2019
+#define PTHREAD_DESTRUCTOR_ITERATIONS 4
+#define PTHREAD_KEYS_MAX 64
+#define PTHREAD_STACK_MIN 0
+#define PTHREAD_THREADS_MAX 2019
#ifndef _POSIX_SEM_NSEMS_MAX
/* Not used and only an arbitrary value. */
-# define _POSIX_SEM_NSEMS_MAX 1024
+# define _POSIX_SEM_NSEMS_MAX 1024
#endif
#ifndef _POSIX_SEM_VALUE_MAX
-# define _POSIX_SEM_VALUE_MAX (INT_MAX/2)
+# define _POSIX_SEM_VALUE_MAX (INT_MAX/2)
#endif
#if __GNUC__ && ! defined (__declspec)
@@ -497,8 +497,19 @@ extern "C"
# endif
#endif
+/*
+ * The Open Watcom C/C++ compiler uses a non-standard calling convention
+ * that passes function args in registers unless __cdecl is explicitly specified
+ * in function prototypes.
+ *
+ * We force all calls to cdecl even though this will slow Watcom code down
+ * slightly. If you know that the Watcom compiler will be used to build both
+ * the DLL and application, then you could probably define this as a null string.
+ */
+#define PTW32_CDECL __cdecl
+
#if defined(_UWIN) && PTW32_LEVEL >= PTW32_LEVEL_MAX
-# include <sys/types.h>
+# include <sys/types.h>
#else
typedef struct pthread_t_ *pthread_t;
typedef struct pthread_attr_t_ *pthread_attr_t;
@@ -527,39 +538,39 @@ enum {
/*
* pthread_attr_{get,set}detachstate
*/
- PTHREAD_CREATE_JOINABLE = 0, /* Default */
- PTHREAD_CREATE_DETACHED = 1,
+ PTHREAD_CREATE_JOINABLE = 0, /* Default */
+ PTHREAD_CREATE_DETACHED = 1,
/*
* pthread_attr_{get,set}inheritsched
*/
- PTHREAD_INHERIT_SCHED = 0,
- PTHREAD_EXPLICIT_SCHED = 1, /* Default */
+ PTHREAD_INHERIT_SCHED = 0,
+ PTHREAD_EXPLICIT_SCHED = 1, /* Default */
/*
* pthread_{get,set}scope
*/
- PTHREAD_SCOPE_PROCESS = 0,
- PTHREAD_SCOPE_SYSTEM = 1, /* Default */
+ PTHREAD_SCOPE_PROCESS = 0,
+ PTHREAD_SCOPE_SYSTEM = 1, /* Default */
/*
* pthread_setcancelstate paramters
*/
- PTHREAD_CANCEL_ENABLE = 0, /* Default */
- PTHREAD_CANCEL_DISABLE = 1,
+ PTHREAD_CANCEL_ENABLE = 0, /* Default */
+ PTHREAD_CANCEL_DISABLE = 1,
/*
* pthread_setcanceltype parameters
*/
- PTHREAD_CANCEL_ASYNCHRONOUS = 0,
- PTHREAD_CANCEL_DEFERRED = 1, /* Default */
+ PTHREAD_CANCEL_ASYNCHRONOUS = 0,
+ PTHREAD_CANCEL_DEFERRED = 1, /* Default */
/*
* pthread_mutexattr_{get,set}pshared
* pthread_condattr_{get,set}pshared
*/
- PTHREAD_PROCESS_PRIVATE = 0,
- PTHREAD_PROCESS_SHARED = 1,
+ PTHREAD_PROCESS_PRIVATE = 0,
+ PTHREAD_PROCESS_SHARED = 1,
/*
* pthread_barrier_wait
@@ -584,13 +595,13 @@ enum {
* ====================
* ====================
*/
-#define PTHREAD_ONCE_INIT { PTW32_FALSE, -1 }
+#define PTHREAD_ONCE_INIT { PTW32_FALSE, -1 }
struct pthread_once_t_
{
- int done; /* indicates if user function executed */
- long started; /* First thread to increment this value */
- /* to zero executes the user function */
+ int done; /* indicates if user function executed */
+ long started; /* First thread to increment this value */
+ /* to zero executes the user function */
};
@@ -668,7 +679,17 @@ enum
#endif
typedef struct ptw32_cleanup_t ptw32_cleanup_t;
-typedef void (__cdecl *ptw32_cleanup_callback_t)(void *);
+
+#if defined(_MSC_VER)
+/* Disable MSVC 'anachronism used' warning */
+#pragma warning( disable : 4229 )
+#endif
+
+typedef void (* PTW32_CDECL ptw32_cleanup_callback_t)(void *);
+
+#if defined(_MSC_VER)
+#pragma warning( default : 4229 )
+#endif
struct ptw32_cleanup_t
{
@@ -678,125 +699,125 @@ struct ptw32_cleanup_t
};
#ifdef __CLEANUP_SEH
- /*
- * WIN32 SEH version of cancel cleanup.
- */
+ /*
+ * WIN32 SEH version of cancel cleanup.
+ */
#define pthread_cleanup_push( _rout, _arg ) \
- { \
- ptw32_cleanup_t _cleanup; \
- \
- _cleanup.routine = (ptw32_cleanup_callback_t)(_rout); \
- _cleanup.arg = (_arg); \
- __try \
- { \
+ { \
+ ptw32_cleanup_t _cleanup; \
+ \
+ _cleanup.routine = (ptw32_cleanup_callback_t)(_rout); \
+ _cleanup.arg = (_arg); \
+ __try \
+ { \
#define pthread_cleanup_pop( _execute ) \
- } \
- __finally \
- { \
- if( _execute || AbnormalTermination()) \
- { \
- (*(_cleanup.routine))( _cleanup.arg ); \
- } \
- } \
- }
+ } \
+ __finally \
+ { \
+ if( _execute || AbnormalTermination()) \
+ { \
+ (*(_cleanup.routine))( _cleanup.arg ); \
+ } \
+ } \
+ }
#else /* __CLEANUP_SEH */
#ifdef __CLEANUP_C
- /*
- * C implementation of PThreads cancel cleanup
- */
+ /*
+ * C implementation of PThreads cancel cleanup
+ */
#define pthread_cleanup_push( _rout, _arg ) \
- { \
- ptw32_cleanup_t _cleanup; \
- \
- ptw32_push_cleanup( &_cleanup, (ptw32_cleanup_callback_t) (_rout), (_arg) ); \
+ { \
+ ptw32_cleanup_t _cleanup; \
+ \
+ ptw32_push_cleanup( &_cleanup, (ptw32_cleanup_callback_t) (_rout), (_arg) ); \
#define pthread_cleanup_pop( _execute ) \
- (void) ptw32_pop_cleanup( _execute ); \
- }
+ (void) ptw32_pop_cleanup( _execute ); \
+ }
#else /* __CLEANUP_C */
#ifdef __CLEANUP_CXX
- /*
- * C++ version of cancel cleanup.
- * - John E. Bossom.
- */
-
- class PThreadCleanup {
- /*
- * PThreadCleanup
- *
- * Purpose
- * This class is a C++ helper class that is
- * used to implement pthread_cleanup_push/
- * pthread_cleanup_pop.
- * The destructor of this class automatically
- * pops the pushed cleanup routine regardless
- * of how the code exits the scope
- * (i.e. such as by an exception)
- */
+ /*
+ * C++ version of cancel cleanup.
+ * - John E. Bossom.
+ */
+
+ class PThreadCleanup {
+ /*
+ * PThreadCleanup
+ *
+ * Purpose
+ * This class is a C++ helper class that is
+ * used to implement pthread_cleanup_push/
+ * pthread_cleanup_pop.
+ * The destructor of this class automatically
+ * pops the pushed cleanup routine regardless
+ * of how the code exits the scope
+ * (i.e. such as by an exception)
+ */
ptw32_cleanup_callback_t cleanUpRout;
- void * obj;
- int executeIt;
-
- public:
- PThreadCleanup() :
- cleanUpRout( 0 ),
- obj( 0 ),
- executeIt( 0 )
- /*
- * No cleanup performed
- */
- {
- }
-
- PThreadCleanup(
- ptw32_cleanup_callback_t routine,
- void * arg ) :
- cleanUpRout( routine ),
- obj( arg ),
- executeIt( 1 )
- /*
- * Registers a cleanup routine for 'arg'
- */
- {
- }
-
- ~PThreadCleanup()
- {
- if ( executeIt && ((void *) cleanUpRout != (void *) 0) )
- {
- (void) (*cleanUpRout)( obj );
- }
- }
-
- void execute( int exec )
- {
- executeIt = exec;
- }
- };
-
- /*
- * C++ implementation of PThreads cancel cleanup;
- * This implementation takes advantage of a helper
- * class who's destructor automatically calls the
- * cleanup routine if we exit our scope weirdly
- */
+ void * obj;
+ int executeIt;
+
+ public:
+ PThreadCleanup() :
+ cleanUpRout( 0 ),
+ obj( 0 ),
+ executeIt( 0 )
+ /*
+ * No cleanup performed
+ */
+ {
+ }
+
+ PThreadCleanup(
+ ptw32_cleanup_callback_t routine,
+ void * arg ) :
+ cleanUpRout( routine ),
+ obj( arg ),
+ executeIt( 1 )
+ /*
+ * Registers a cleanup routine for 'arg'
+ */
+ {
+ }
+
+ ~PThreadCleanup()
+ {
+ if ( executeIt && ((void *) cleanUpRout != (void *) 0) )
+ {
+ (void) (*cleanUpRout)( obj );
+ }
+ }
+
+ void execute( int exec )
+ {
+ executeIt = exec;
+ }
+ };
+
+ /*
+ * C++ implementation of PThreads cancel cleanup;
+ * This implementation takes advantage of a helper
+ * class who's destructor automatically calls the
+ * cleanup routine if we exit our scope weirdly
+ */
#define pthread_cleanup_push( _rout, _arg ) \
- { \
- PThreadCleanup cleanup((ptw32_cleanup_callback_t)(_rout), \
- (void *) (_arg) );
+ { \
+ PThreadCleanup cleanup((ptw32_cleanup_callback_t)(_rout), \
+ (void *) (_arg) );
#define pthread_cleanup_pop( _execute ) \
- cleanup.execute( _execute ); \
- }
+ cleanup.execute( _execute ); \
+ }
#else
@@ -819,259 +840,259 @@ struct ptw32_cleanup_t
/*
* PThread Attribute Functions
*/
-PTW32_DLLPORT int pthread_attr_init (pthread_attr_t * attr);
+PTW32_DLLPORT int PTW32_CDECL pthread_attr_init (pthread_attr_t * attr);
-PTW32_DLLPORT int pthread_attr_destroy (pthread_attr_t * attr);
+PTW32_DLLPORT int PTW32_CDECL pthread_attr_destroy (pthread_attr_t * attr);
-PTW32_DLLPORT int pthread_attr_getdetachstate (const pthread_attr_t * attr,
- int *detachstate);
+PTW32_DLLPORT int PTW32_CDECL pthread_attr_getdetachstate (const pthread_attr_t * attr,
+ int *detachstate);
-PTW32_DLLPORT int pthread_attr_getstackaddr (const pthread_attr_t * attr,
- void **stackaddr);
+PTW32_DLLPORT int PTW32_CDECL pthread_attr_getstackaddr (const pthread_attr_t * attr,
+ void **stackaddr);
-PTW32_DLLPORT int pthread_attr_getstacksize (const pthread_attr_t * attr,
- size_t * stacksize);
+PTW32_DLLPORT int PTW32_CDECL pthread_attr_getstacksize (const pthread_attr_t * attr,
+ size_t * stacksize);
-PTW32_DLLPORT int pthread_attr_setdetachstate (pthread_attr_t * attr,
- int detachstate);
+PTW32_DLLPORT int PTW32_CDECL pthread_attr_setdetachstate (pthread_attr_t * attr,
+ int detachstate);
-PTW32_DLLPORT int pthread_attr_setstackaddr (pthread_attr_t * attr,
- void *stackaddr);
+PTW32_DLLPORT int PTW32_CDECL pthread_attr_setstackaddr (pthread_attr_t * attr,
+ void *stackaddr);
-PTW32_DLLPORT int pthread_attr_setstacksize (pthread_attr_t * attr,
- size_t stacksize);
+PTW32_DLLPORT int PTW32_CDECL pthread_attr_setstacksize (pthread_attr_t * attr,
+ size_t stacksize);
-PTW32_DLLPORT int pthread_attr_getschedparam (const pthread_attr_t *attr,
- struct sched_param *param);
+PTW32_DLLPORT int PTW32_CDECL pthread_attr_getschedparam (const pthread_attr_t *attr,
+ struct sched_param *param);
-PTW32_DLLPORT int pthread_attr_setschedparam (pthread_attr_t *attr,
- const struct sched_param *param);
+PTW32_DLLPORT int PTW32_CDECL pthread_attr_setschedparam (pthread_attr_t *attr,
+ const struct sched_param *param);
-PTW32_DLLPORT int pthread_attr_setschedpolicy (pthread_attr_t *,
- int);
+PTW32_DLLPORT int PTW32_CDECL pthread_attr_setschedpolicy (pthread_attr_t *,
+ int);
-PTW32_DLLPORT int pthread_attr_getschedpolicy (pthread_attr_t *,
- int *);
+PTW32_DLLPORT int PTW32_CDECL pthread_attr_getschedpolicy (pthread_attr_t *,
+ int *);
-PTW32_DLLPORT int pthread_attr_setinheritsched(pthread_attr_t * attr,
- int inheritsched);
+PTW32_DLLPORT int PTW32_CDECL pthread_attr_setinheritsched(pthread_attr_t * attr,
+ int inheritsched);
-PTW32_DLLPORT int pthread_attr_getinheritsched(pthread_attr_t * attr,
- int * inheritsched);
+PTW32_DLLPORT int PTW32_CDECL pthread_attr_getinheritsched(pthread_attr_t * attr,
+ int * inheritsched);
-PTW32_DLLPORT int pthread_attr_setscope (pthread_attr_t *,
- int);
+PTW32_DLLPORT int PTW32_CDECL pthread_attr_setscope (pthread_attr_t *,
+ int);
-PTW32_DLLPORT int pthread_attr_getscope (const pthread_attr_t *,
- int *);
+PTW32_DLLPORT int PTW32_CDECL pthread_attr_getscope (const pthread_attr_t *,
+ int *);
/*
* PThread Functions
*/
-PTW32_DLLPORT int pthread_create (pthread_t * tid,
- const pthread_attr_t * attr,
- void *(*start) (void *),
- void *arg);
+PTW32_DLLPORT int PTW32_CDECL pthread_create (pthread_t * tid,
+ const pthread_attr_t * attr,
+ void *(*start) (void *),
+ void *arg);
-PTW32_DLLPORT int pthread_detach (pthread_t tid);
+PTW32_DLLPORT int PTW32_CDECL pthread_detach (pthread_t tid);
-PTW32_DLLPORT int pthread_equal (pthread_t t1,
- pthread_t t2);
+PTW32_DLLPORT int PTW32_CDECL pthread_equal (pthread_t t1,
+ pthread_t t2);
-PTW32_DLLPORT void pthread_exit (void *value_ptr);
+PTW32_DLLPORT void PTW32_CDECL pthread_exit (void *value_ptr);
-PTW32_DLLPORT int pthread_join (pthread_t thread,
- void **value_ptr);
+PTW32_DLLPORT int PTW32_CDECL pthread_join (pthread_t thread,
+ void **value_ptr);
-PTW32_DLLPORT pthread_t pthread_self (void);
+PTW32_DLLPORT pthread_t PTW32_CDECL pthread_self (void);
-PTW32_DLLPORT int pthread_cancel (pthread_t thread);
+PTW32_DLLPORT int PTW32_CDECL pthread_cancel (pthread_t thread);
-PTW32_DLLPORT int pthread_setcancelstate (int state,
- int *oldstate);
+PTW32_DLLPORT int PTW32_CDECL pthread_setcancelstate (int state,
+ int *oldstate);
-PTW32_DLLPORT int pthread_setcanceltype (int type,
- int *oldtype);
+PTW32_DLLPORT int PTW32_CDECL pthread_setcanceltype (int type,
+ int *oldtype);
-PTW32_DLLPORT void pthread_testcancel (void);
+PTW32_DLLPORT void PTW32_CDECL pthread_testcancel (void);
-PTW32_DLLPORT int pthread_once (pthread_once_t * once_control,
- void (*init_routine) (void));
+PTW32_DLLPORT int PTW32_CDECL pthread_once (pthread_once_t * once_control,
+ void (*init_routine) (void));
#if PTW32_LEVEL >= PTW32_LEVEL_MAX
-PTW32_DLLPORT ptw32_cleanup_t *ptw32_pop_cleanup (int execute);
+PTW32_DLLPORT ptw32_cleanup_t * PTW32_CDECL ptw32_pop_cleanup (int execute);
-PTW32_DLLPORT void ptw32_push_cleanup (ptw32_cleanup_t * cleanup,
- void (*routine) (void *),
- void *arg);
+PTW32_DLLPORT void PTW32_CDECL ptw32_push_cleanup (ptw32_cleanup_t * cleanup,
+ void (*routine) (void *),
+ void *arg);
#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */
/*
* Thread Specific Data Functions
*/
-PTW32_DLLPORT int pthread_key_create (pthread_key_t * key,
- void (*destructor) (void *));
+PTW32_DLLPORT int PTW32_CDECL pthread_key_create (pthread_key_t * key,
+ void (*destructor) (void *));
-PTW32_DLLPORT int pthread_key_delete (pthread_key_t key);
+PTW32_DLLPORT int PTW32_CDECL pthread_key_delete (pthread_key_t key);
-PTW32_DLLPORT int pthread_setspecific (pthread_key_t key,
- const void *value);
+PTW32_DLLPORT int PTW32_CDECL pthread_setspecific (pthread_key_t key,
+ const void *value);
-PTW32_DLLPORT void *pthread_getspecific (pthread_key_t key);
+PTW32_DLLPORT void * PTW32_CDECL pthread_getspecific (pthread_key_t key);
/*
* Mutex Attribute Functions
*/
-PTW32_DLLPORT int pthread_mutexattr_init (pthread_mutexattr_t * attr);
+PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_init (pthread_mutexattr_t * attr);
-PTW32_DLLPORT int pthread_mutexattr_destroy (pthread_mutexattr_t * attr);
+PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_destroy (pthread_mutexattr_t * attr);
-PTW32_DLLPORT int pthread_mutexattr_getpshared (const pthread_mutexattr_t
- * attr,
- int *pshared);
+PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_getpshared (const pthread_mutexattr_t
+ * attr,
+ int *pshared);
-PTW32_DLLPORT int pthread_mutexattr_setpshared (pthread_mutexattr_t * attr,
- int pshared);
+PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_setpshared (pthread_mutexattr_t * attr,
+ int pshared);
-PTW32_DLLPORT int pthread_mutexattr_settype (pthread_mutexattr_t * attr, int kind);
-PTW32_DLLPORT int pthread_mutexattr_gettype (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);
/*
* Barrier Attribute Functions
*/
-PTW32_DLLPORT int pthread_barrierattr_init (pthread_barrierattr_t * attr);
+PTW32_DLLPORT int PTW32_CDECL pthread_barrierattr_init (pthread_barrierattr_t * attr);
-PTW32_DLLPORT int pthread_barrierattr_destroy (pthread_barrierattr_t * attr);
+PTW32_DLLPORT int PTW32_CDECL pthread_barrierattr_destroy (pthread_barrierattr_t * attr);
-PTW32_DLLPORT int pthread_barrierattr_getpshared (const pthread_barrierattr_t
- * attr,
- int *pshared);
+PTW32_DLLPORT int PTW32_CDECL pthread_barrierattr_getpshared (const pthread_barrierattr_t
+ * attr,
+ int *pshared);
-PTW32_DLLPORT int pthread_barrierattr_setpshared (pthread_barrierattr_t * attr,
- int pshared);
+PTW32_DLLPORT int PTW32_CDECL pthread_barrierattr_setpshared (pthread_barrierattr_t * attr,
+ int pshared);
/*
* Mutex Functions
*/
-PTW32_DLLPORT int pthread_mutex_init (pthread_mutex_t * mutex,
- const pthread_mutexattr_t * attr);
+PTW32_DLLPORT int PTW32_CDECL pthread_mutex_init (pthread_mutex_t * mutex,
+ const pthread_mutexattr_t * attr);
-PTW32_DLLPORT int pthread_mutex_destroy (pthread_mutex_t * mutex);
+PTW32_DLLPORT int PTW32_CDECL pthread_mutex_destroy (pthread_mutex_t * mutex);
-PTW32_DLLPORT int pthread_mutex_lock (pthread_mutex_t * mutex);
+PTW32_DLLPORT int PTW32_CDECL pthread_mutex_lock (pthread_mutex_t * mutex);
-PTW32_DLLPORT int pthread_mutex_timedlock(pthread_mutex_t *mutex,
- const struct timespec *abstime);
+PTW32_DLLPORT int PTW32_CDECL pthread_mutex_timedlock(pthread_mutex_t *mutex,
+ const struct timespec *abstime);
-PTW32_DLLPORT int pthread_mutex_trylock (pthread_mutex_t * mutex);
+PTW32_DLLPORT int PTW32_CDECL pthread_mutex_trylock (pthread_mutex_t * mutex);
-PTW32_DLLPORT int pthread_mutex_unlock (pthread_mutex_t * mutex);
+PTW32_DLLPORT int PTW32_CDECL pthread_mutex_unlock (pthread_mutex_t * mutex);
/*
* Spinlock Functions
*/
-PTW32_DLLPORT int pthread_spin_init (pthread_spinlock_t * lock, int pshared);
+PTW32_DLLPORT int PTW32_CDECL pthread_spin_init (pthread_spinlock_t * lock, int pshared);
-PTW32_DLLPORT int pthread_spin_destroy (pthread_spinlock_t * lock);
+PTW32_DLLPORT int PTW32_CDECL pthread_spin_destroy (pthread_spinlock_t * lock);
-PTW32_DLLPORT int pthread_spin_lock (pthread_spinlock_t * lock);
+PTW32_DLLPORT int PTW32_CDECL pthread_spin_lock (pthread_spinlock_t * lock);
-PTW32_DLLPORT int pthread_spin_trylock (pthread_spinlock_t * lock);
+PTW32_DLLPORT int PTW32_CDECL pthread_spin_trylock (pthread_spinlock_t * lock);
-PTW32_DLLPORT int pthread_spin_unlock (pthread_spinlock_t * lock);
+PTW32_DLLPORT int PTW32_CDECL pthread_spin_unlock (pthread_spinlock_t * lock);
/*
* Barrier Functions
*/
-PTW32_DLLPORT int pthread_barrier_init (pthread_barrier_t * barrier,
- const pthread_barrierattr_t * attr,
- unsigned int count);
+PTW32_DLLPORT int PTW32_CDECL pthread_barrier_init (pthread_barrier_t * barrier,
+ const pthread_barrierattr_t * attr,
+ unsigned int count);
-PTW32_DLLPORT int pthread_barrier_destroy (pthread_barrier_t * barrier);
+PTW32_DLLPORT int PTW32_CDECL pthread_barrier_destroy (pthread_barrier_t * barrier);
-PTW32_DLLPORT int pthread_barrier_wait (pthread_barrier_t * barrier);
+PTW32_DLLPORT int PTW32_CDECL pthread_barrier_wait (pthread_barrier_t * barrier);
/*
* Condition Variable Attribute Functions
*/
-PTW32_DLLPORT int pthread_condattr_init (pthread_condattr_t * attr);
+PTW32_DLLPORT int PTW32_CDECL pthread_condattr_init (pthread_condattr_t * attr);
-PTW32_DLLPORT int pthread_condattr_destroy (pthread_condattr_t * attr);
+PTW32_DLLPORT int PTW32_CDECL pthread_condattr_destroy (pthread_condattr_t * attr);
-PTW32_DLLPORT int pthread_condattr_getpshared (const pthread_condattr_t * attr,
- int *pshared);
+PTW32_DLLPORT int PTW32_CDECL pthread_condattr_getpshared (const pthread_condattr_t * attr,
+ int *pshared);
-PTW32_DLLPORT int pthread_condattr_setpshared (pthread_condattr_t * attr,
- int pshared);
+PTW32_DLLPORT int PTW32_CDECL pthread_condattr_setpshared (pthread_condattr_t * attr,
+ int pshared);
/*
* Condition Variable Functions
*/
-PTW32_DLLPORT int pthread_cond_init (pthread_cond_t * cond,
- const pthread_condattr_t * attr);
+PTW32_DLLPORT int PTW32_CDECL pthread_cond_init (pthread_cond_t * cond,
+ const pthread_condattr_t * attr);
-PTW32_DLLPORT int pthread_cond_destroy (pthread_cond_t * cond);
+PTW32_DLLPORT int PTW32_CDECL pthread_cond_destroy (pthread_cond_t * cond);
-PTW32_DLLPORT int pthread_cond_wait (pthread_cond_t * cond,
- pthread_mutex_t * mutex);
+PTW32_DLLPORT int PTW32_CDECL pthread_cond_wait (pthread_cond_t * cond,
+ pthread_mutex_t * mutex);
-PTW32_DLLPORT int pthread_cond_timedwait (pthread_cond_t * cond,
- pthread_mutex_t * mutex,
- const struct timespec *abstime);
+PTW32_DLLPORT int PTW32_CDECL pthread_cond_timedwait (pthread_cond_t * cond,
+ pthread_mutex_t * mutex,
+ const struct timespec *abstime);
-PTW32_DLLPORT int pthread_cond_signal (pthread_cond_t * cond);
+PTW32_DLLPORT int PTW32_CDECL pthread_cond_signal (pthread_cond_t * cond);
-PTW32_DLLPORT int pthread_cond_broadcast (pthread_cond_t * cond);
+PTW32_DLLPORT int PTW32_CDECL pthread_cond_broadcast (pthread_cond_t * cond);
/*
* Scheduling
*/
-PTW32_DLLPORT int pthread_setschedparam (pthread_t thread,
- int policy,
- const struct sched_param *param);
+PTW32_DLLPORT int PTW32_CDECL pthread_setschedparam (pthread_t thread,
+ int policy,
+ const struct sched_param *param);
-PTW32_DLLPORT int pthread_getschedparam (pthread_t thread,
- int *policy,
- struct sched_param *param);
+PTW32_DLLPORT int PTW32_CDECL pthread_getschedparam (pthread_t thread,
+ int *policy,
+ struct sched_param *param);
-PTW32_DLLPORT int pthread_setconcurrency (int);
+PTW32_DLLPORT int PTW32_CDECL pthread_setconcurrency (int);
-PTW32_DLLPORT int pthread_getconcurrency (void);
+PTW32_DLLPORT int PTW32_CDECL pthread_getconcurrency (void);
/*
* Read-Write Lock Functions
*/
-PTW32_DLLPORT int pthread_rwlock_init(pthread_rwlock_t *lock,
- const pthread_rwlockattr_t *attr);
+PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_init(pthread_rwlock_t *lock,
+ const pthread_rwlockattr_t *attr);
-PTW32_DLLPORT int pthread_rwlock_destroy(pthread_rwlock_t *lock);
+PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_destroy(pthread_rwlock_t *lock);
-PTW32_DLLPORT int pthread_rwlock_tryrdlock(pthread_rwlock_t *);
+PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_tryrdlock(pthread_rwlock_t *);
-PTW32_DLLPORT int pthread_rwlock_trywrlock(pthread_rwlock_t *);
+PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_trywrlock(pthread_rwlock_t *);
-PTW32_DLLPORT int pthread_rwlock_rdlock(pthread_rwlock_t *lock);
+PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_rdlock(pthread_rwlock_t *lock);
-PTW32_DLLPORT int pthread_rwlock_timedrdlock(pthread_rwlock_t *lock,
- const struct timespec *abstime);
+PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_timedrdlock(pthread_rwlock_t *lock,
+ const struct timespec *abstime);
-PTW32_DLLPORT int pthread_rwlock_wrlock(pthread_rwlock_t *lock);
+PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_wrlock(pthread_rwlock_t *lock);
-PTW32_DLLPORT int pthread_rwlock_timedwrlock(pthread_rwlock_t *lock,
- const struct timespec *abstime);
+PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_timedwrlock(pthread_rwlock_t *lock,
+ const struct timespec *abstime);
-PTW32_DLLPORT int pthread_rwlock_unlock(pthread_rwlock_t *lock);
+PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_unlock(pthread_rwlock_t *lock);
-PTW32_DLLPORT int pthread_rwlockattr_init (pthread_rwlockattr_t * attr);
+PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_init (pthread_rwlockattr_t * attr);
-PTW32_DLLPORT int pthread_rwlockattr_destroy (pthread_rwlockattr_t * attr);
+PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_destroy (pthread_rwlockattr_t * attr);
-PTW32_DLLPORT int pthread_rwlockattr_getpshared (const pthread_rwlockattr_t * attr,
- int *pshared);
+PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_getpshared (const pthread_rwlockattr_t * attr,
+ int *pshared);
-PTW32_DLLPORT int pthread_rwlockattr_setpshared (pthread_rwlockattr_t * attr,
- int pshared);
+PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_setpshared (pthread_rwlockattr_t * attr,
+ int pshared);
#if PTW32_LEVEL >= PTW32_LEVEL_MAX - 1
@@ -1079,7 +1100,7 @@ PTW32_DLLPORT int pthread_rwlockattr_setpshared (pthread_rwlockattr_t * attr,
* Signal Functions. Should be defined in <signal.h> but MSVC and MinGW32
* already have signal.h that don't define these.
*/
-PTW32_DLLPORT int pthread_kill(pthread_t thread, int sig);
+PTW32_DLLPORT int PTW32_CDECL pthread_kill(pthread_t thread, int sig);
/*
* Non-portable functions
@@ -1088,25 +1109,25 @@ PTW32_DLLPORT int pthread_kill(pthread_t thread, int sig);
/*
* Compatibility with Linux.
*/
-PTW32_DLLPORT int pthread_mutexattr_setkind_np(pthread_mutexattr_t * attr,
- int kind);
-PTW32_DLLPORT int pthread_mutexattr_getkind_np(pthread_mutexattr_t * attr,
- int *kind);
+PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_setkind_np(pthread_mutexattr_t * attr,
+ int kind);
+PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_getkind_np(pthread_mutexattr_t * attr,
+ int *kind);
/*
* Possibly supported by other POSIX threads implementations
*/
-PTW32_DLLPORT int pthread_delay_np (struct timespec * interval);
-PTW32_DLLPORT int pthread_num_processors_np(void);
+PTW32_DLLPORT int PTW32_CDECL pthread_delay_np (struct timespec * interval);
+PTW32_DLLPORT int PTW32_CDECL pthread_num_processors_np(void);
/*
* Useful if an application wants to statically link
* the lib rather than load the DLL at run-time.
*/
-PTW32_DLLPORT int pthread_win32_process_attach_np(void);
-PTW32_DLLPORT int pthread_win32_process_detach_np(void);
-PTW32_DLLPORT int pthread_win32_thread_attach_np(void);
-PTW32_DLLPORT int pthread_win32_thread_detach_np(void);
+PTW32_DLLPORT int PTW32_CDECL pthread_win32_process_attach_np(void);
+PTW32_DLLPORT int PTW32_CDECL pthread_win32_process_detach_np(void);
+PTW32_DLLPORT int PTW32_CDECL pthread_win32_thread_attach_np(void);
+PTW32_DLLPORT int PTW32_CDECL pthread_win32_thread_detach_np(void);
/*
* Register a system time change with the library.
@@ -1116,7 +1137,7 @@ PTW32_DLLPORT int pthread_win32_thread_detach_np(void);
* WM_TIMECHANGE message. It can be passed directly to
* pthread_create() as a new thread if desired.
*/
-PTW32_DLLPORT void * pthread_timechange_handler_np(void *);
+PTW32_DLLPORT void * PTW32_CDECL pthread_timechange_handler_np(void *);
#endif /*PTW32_LEVEL >= PTW32_LEVEL_MAX - 1 */
@@ -1125,7 +1146,7 @@ PTW32_DLLPORT void * pthread_timechange_handler_np(void *);
/*
* Returns the Win32 HANDLE for the POSIX thread.
*/
-PTW32_DLLPORT HANDLE pthread_getw32threadhandle_np(pthread_t thread);
+PTW32_DLLPORT HANDLE PTW32_CDECL pthread_getw32threadhandle_np(pthread_t thread);
/*
@@ -1136,16 +1157,16 @@ PTW32_DLLPORT HANDLE pthread_getw32threadhandle_np(pthread_t thread);
* This function allows the caller to hook into the
* PThreads cancel mechanism. It is implemented using
*
- * WaitForMultipleObjects
+ * WaitForMultipleObjects
*
* on 'waitHandle' and a manually reset WIN32 Event
* used to implement pthread_cancel. The 'timeout'
* argument to TimedWait is simply passed to
* WaitForMultipleObjects.
*/
-PTW32_DLLPORT int pthreadCancelableWait (HANDLE waitHandle);
-PTW32_DLLPORT int pthreadCancelableTimedWait (HANDLE waitHandle,
- DWORD timeout);
+PTW32_DLLPORT int PTW32_CDECL pthreadCancelableWait (HANDLE waitHandle);
+PTW32_DLLPORT int PTW32_CDECL pthreadCancelableTimedWait (HANDLE waitHandle,
+ DWORD timeout);
#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */
@@ -1154,12 +1175,12 @@ PTW32_DLLPORT int pthreadCancelableTimedWait (HANDLE waitHandle,
*/
#ifndef _UWIN
# if defined(NEED_ERRNO)
- PTW32_DLLPORT int * _errno( void );
+ PTW32_DLLPORT int * PTW32_CDECL _errno( void );
# else
# ifndef errno
# if (defined(_MT) || defined(_DLL))
- __declspec(dllimport) extern int * __cdecl _errno(void);
-# define errno (*_errno())
+ __declspec(dllimport) extern int * __cdecl _errno(void);
+# define errno (*_errno())
# endif
# endif
# endif
@@ -1176,27 +1197,27 @@ PTW32_DLLPORT int pthreadCancelableTimedWait (HANDLE waitHandle,
#if !defined(__MINGW32__)
#define strtok_r( _s, _sep, _lasts ) \
- ( *(_lasts) = strtok( (_s), (_sep) ) )
+ ( *(_lasts) = strtok( (_s), (_sep) ) )
#endif /* !__MINGW32__ */
#define asctime_r( _tm, _buf ) \
- ( strcpy( (_buf), asctime( (_tm) ) ), \
- (_buf) )
+ ( strcpy( (_buf), asctime( (_tm) ) ), \
+ (_buf) )
#define ctime_r( _clock, _buf ) \
- ( strcpy( (_buf), ctime( (_clock) ) ), \
- (_buf) )
+ ( strcpy( (_buf), ctime( (_clock) ) ), \
+ (_buf) )
#define gmtime_r( _clock, _result ) \
- ( *(_result) = *gmtime( (_clock) ), \
- (_result) )
+ ( *(_result) = *gmtime( (_clock) ), \
+ (_result) )
#define localtime_r( _clock, _result ) \
- ( *(_result) = *localtime( (_clock) ), \
- (_result) )
+ ( *(_result) = *localtime( (_clock) ), \
+ (_result) )
#define rand_r( _seed ) \
- ( _seed == _seed? rand() : rand() )
+ ( _seed == _seed? rand() : rand() )
#ifdef __cplusplus
@@ -1216,7 +1237,7 @@ class ptw32_exception_exit : public ptw32_exception {};
/*
* Get internal SEH tag
*/
-PTW32_DLLPORT DWORD ptw32_get_exception_services_code(void);
+PTW32_DLLPORT DWORD PTW32_CDECL ptw32_get_exception_services_code(void);
#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */
@@ -1229,8 +1250,8 @@ PTW32_DLLPORT DWORD ptw32_get_exception_services_code(void);
* propagate our internal exceptions up to the library's internal handlers.
*/
#define __except( E ) \
- __except( ( GetExceptionCode() == ptw32_get_exception_services_code() ) \
- ? EXCEPTION_CONTINUE_SEARCH : ( E ) )
+ __except( ( GetExceptionCode() == ptw32_get_exception_services_code() ) \
+ ? EXCEPTION_CONTINUE_SEARCH : ( E ) )
#endif /* __CLEANUP_SEH */
@@ -1241,10 +1262,10 @@ PTW32_DLLPORT DWORD ptw32_get_exception_services_code(void);
* propagate our internal exceptions up to the library's internal handlers.
*/
#ifdef _MSC_VER
- /*
- * WARNING: Replace any 'catch( ... )' with 'PtW32CatchAll'
- * if you want Pthread-Win32 cancelation and pthread_exit to work.
- */
+ /*
+ * WARNING: Replace any 'catch( ... )' with 'PtW32CatchAll'
+ * if you want Pthread-Win32 cancelation and pthread_exit to work.
+ */
#ifndef PtW32NoCatchWarn
@@ -1260,22 +1281,22 @@ PTW32_DLLPORT DWORD ptw32_get_exception_services_code(void);
#pragma message(" #else")
#pragma message(" catch(...)")
#pragma message(" #endif")
-#pragma message(" {")
-#pragma message(" /* Catchall block processing */")
-#pragma message(" }")
+#pragma message(" {")
+#pragma message(" /* Catchall block processing */")
+#pragma message(" }")
#pragma message("------------------------------------------------------------------")
#endif
#define PtW32CatchAll \
- catch( ptw32_exception & ) { throw; } \
- catch( ... )
+ catch( ptw32_exception & ) { throw; } \
+ catch( ... )
#else /* _MSC_VER */
#define catch( E ) \
- catch( ptw32_exception & ) { throw; } \
- catch( E )
+ catch( ptw32_exception & ) { throw; } \
+ catch( E )
#endif /* _MSC_VER */
@@ -1284,8 +1305,8 @@ PTW32_DLLPORT DWORD ptw32_get_exception_services_code(void);
#endif /* ! PTW32_BUILD */
#ifdef __cplusplus
-} /* End of extern "C" */
-#endif /* __cplusplus */
+} /* End of extern "C" */
+#endif /* __cplusplus */
#ifdef PTW32__HANDLE_DEF
# undef HANDLE
diff --git a/pthread_cond_wait.c b/pthread_cond_wait.c
index cfd1ee8..57fc978 100644
--- a/pthread_cond_wait.c
+++ b/pthread_cond_wait.c
@@ -265,19 +265,21 @@
* Arguments for cond_wait_cleanup, since we can only pass a
* single void * to it.
*/
-typedef struct {
- pthread_mutex_t * mutexPtr;
+typedef struct
+{
+ pthread_mutex_t *mutexPtr;
pthread_cond_t cv;
- int * resultPtr;
+ int *resultPtr;
int signaled;
} ptw32_cond_wait_cleanup_args_t;
-static void
-ptw32_cond_wait_cleanup(void * args)
+static void PTW32_CDECL
+ptw32_cond_wait_cleanup (void *args)
{
- ptw32_cond_wait_cleanup_args_t * cleanup_args = (ptw32_cond_wait_cleanup_args_t *) args;
+ ptw32_cond_wait_cleanup_args_t *cleanup_args =
+ (ptw32_cond_wait_cleanup_args_t *) args;
pthread_cond_t cv = cleanup_args->cv;
- int * resultPtr = cleanup_args->resultPtr;
+ int *resultPtr = cleanup_args->resultPtr;
int nSignalsWasLeft;
int result;
@@ -287,72 +289,71 @@ ptw32_cond_wait_cleanup(void * args)
* longer waiting. The waiter is responsible for adjusting waiters
* (to)unblock(ed) counts (protected by unblock lock).
*/
- if ((result = pthread_mutex_lock(&(cv->mtxUnblockLock))) != 0)
+ if ((result = pthread_mutex_lock (&(cv->mtxUnblockLock))) != 0)
{
*resultPtr = result;
return;
}
- if ( 0 != (nSignalsWasLeft = cv->nWaitersToUnblock) )
+ if (0 != (nSignalsWasLeft = cv->nWaitersToUnblock))
{
--(cv->nWaitersToUnblock);
}
- else if ( INT_MAX/2 == ++(cv->nWaitersGone) )
+ else if (INT_MAX / 2 == ++(cv->nWaitersGone))
{
- if (sem_wait( &(cv->semBlockLock) ) != 0)
- {
- *resultPtr = errno;
- /*
- * This is a fatal error for this CV,
- * so we deliberately don't unlock
- * cv->mtxUnblockLock before returning.
- */
- return;
- }
+ if (sem_wait (&(cv->semBlockLock)) != 0)
+ {
+ *resultPtr = errno;
+ /*
+ * This is a fatal error for this CV,
+ * so we deliberately don't unlock
+ * cv->mtxUnblockLock before returning.
+ */
+ return;
+ }
cv->nWaitersBlocked -= cv->nWaitersGone;
- if (sem_post( &(cv->semBlockLock) ) != 0)
- {
- *resultPtr = errno;
- /*
- * This is a fatal error for this CV,
- * so we deliberately don't unlock
- * cv->mtxUnblockLock before returning.
- */
- return;
- }
+ if (sem_post (&(cv->semBlockLock)) != 0)
+ {
+ *resultPtr = errno;
+ /*
+ * This is a fatal error for this CV,
+ * so we deliberately don't unlock
+ * cv->mtxUnblockLock before returning.
+ */
+ return;
+ }
cv->nWaitersGone = 0;
}
- if ((result = pthread_mutex_unlock(&(cv->mtxUnblockLock))) != 0)
+ if ((result = pthread_mutex_unlock (&(cv->mtxUnblockLock))) != 0)
{
*resultPtr = result;
return;
}
- if ( 1 == nSignalsWasLeft )
+ if (1 == nSignalsWasLeft)
{
- if (sem_post(&(cv->semBlockLock)) != 0)
- {
- *resultPtr = errno;
- return;
- }
+ if (sem_post (&(cv->semBlockLock)) != 0)
+ {
+ *resultPtr = errno;
+ return;
+ }
}
/*
* XSH: Upon successful return, the mutex has been locked and is owned
* by the calling thread
*/
- if ((result = pthread_mutex_lock(cleanup_args->mutexPtr)) != 0)
+ if ((result = pthread_mutex_lock (cleanup_args->mutexPtr)) != 0)
{
*resultPtr = result;
}
-} /* ptw32_cond_wait_cleanup */
+} /* ptw32_cond_wait_cleanup */
static INLINE int
-ptw32_cond_timedwait (pthread_cond_t * cond,
- pthread_mutex_t * mutex,
- const struct timespec *abstime)
+ptw32_cond_timedwait (pthread_cond_t * cond,
+ pthread_mutex_t * mutex, const struct timespec *abstime)
{
int result = 0;
pthread_cond_t cv;
@@ -371,7 +372,7 @@ ptw32_cond_timedwait (pthread_cond_t * cond,
*/
if (*cond == PTHREAD_COND_INITIALIZER)
{
- result = ptw32_cond_check_need_init(cond);
+ result = ptw32_cond_check_need_init (cond);
}
if (result != 0 && result != EBUSY)
@@ -381,14 +382,14 @@ ptw32_cond_timedwait (pthread_cond_t * cond,
cv = *cond;
- if (sem_wait(&(cv->semBlockLock)) != 0)
+ if (sem_wait (&(cv->semBlockLock)) != 0)
{
return errno;
}
++(cv->nWaitersBlocked);
- if (sem_post(&(cv->semBlockLock)) != 0)
+ if (sem_post (&(cv->semBlockLock)) != 0)
{
return errno;
}
@@ -409,12 +410,12 @@ ptw32_cond_timedwait (pthread_cond_t * cond,
#ifdef _MSC_VER
#pragma inline_depth(0)
#endif
- pthread_cleanup_push(ptw32_cond_wait_cleanup, (void *) &cleanup_args);
+ pthread_cleanup_push (ptw32_cond_wait_cleanup, (void *) &cleanup_args);
/*
* Now we can release 'mutex' and...
*/
- if ((result = pthread_mutex_unlock(mutex)) == 0)
+ if ((result = pthread_mutex_unlock (mutex)) == 0)
{
/*
@@ -433,10 +434,10 @@ ptw32_cond_timedwait (pthread_cond_t * cond,
* re-lock the mutex and adjust (to)unblock(ed) waiters
* counts if we are cancelled, timed out or signalled.
*/
- if (sem_timedwait(&(cv->semBlockQueue), abstime) != 0)
- {
- result = errno;
- }
+ if (sem_timedwait (&(cv->semBlockQueue), abstime) != 0)
+ {
+ result = errno;
+ }
}
/*
@@ -447,7 +448,7 @@ ptw32_cond_timedwait (pthread_cond_t * cond,
/*
* Always cleanup
*/
- pthread_cleanup_pop(1);
+ pthread_cleanup_pop (1);
#ifdef _MSC_VER
#pragma inline_depth()
#endif
@@ -457,12 +458,11 @@ ptw32_cond_timedwait (pthread_cond_t * cond,
*/
return result;
-} /* ptw32_cond_timedwait */
+} /* ptw32_cond_timedwait */
int
-pthread_cond_wait (pthread_cond_t * cond,
- pthread_mutex_t * mutex)
+pthread_cond_wait (pthread_cond_t * cond, pthread_mutex_t * mutex)
/*
* ------------------------------------------------------
* DOCPUBLIC
@@ -514,15 +514,15 @@ pthread_cond_wait (pthread_cond_t * cond,
/*
* The NULL abstime arg means INFINITE waiting.
*/
- return (ptw32_cond_timedwait(cond, mutex, NULL));
+ return (ptw32_cond_timedwait (cond, mutex, NULL));
-} /* pthread_cond_wait */
+} /* pthread_cond_wait */
int
-pthread_cond_timedwait (pthread_cond_t * cond,
- pthread_mutex_t * mutex,
- const struct timespec *abstime)
+pthread_cond_timedwait (pthread_cond_t * cond,
+ pthread_mutex_t * mutex,
+ const struct timespec *abstime)
/*
* ------------------------------------------------------
* DOCPUBLIC
@@ -573,6 +573,6 @@ pthread_cond_timedwait (pthread_cond_t * cond,
return EINVAL;
}
- return (ptw32_cond_timedwait(cond, mutex, abstime));
+ return (ptw32_cond_timedwait (cond, mutex, abstime));
-} /* pthread_cond_timedwait */
+} /* pthread_cond_timedwait */
diff --git a/sched.h b/sched.h
index 9208a52..e6a0ee1 100644
--- a/sched.h
+++ b/sched.h
@@ -139,15 +139,15 @@ extern "C"
{
#endif /* __cplusplus */
-PTW32_DLLPORT int sched_yield (void);
+PTW32_DLLPORT int __cdecl sched_yield (void);
-PTW32_DLLPORT int sched_get_priority_min (int policy);
+PTW32_DLLPORT int __cdecl sched_get_priority_min (int policy);
-PTW32_DLLPORT int sched_get_priority_max (int policy);
+PTW32_DLLPORT int __cdecl sched_get_priority_max (int policy);
-PTW32_DLLPORT int sched_setscheduler (pid_t pid, int policy);
+PTW32_DLLPORT int __cdecl sched_setscheduler (pid_t pid, int policy);
-PTW32_DLLPORT int sched_getscheduler (pid_t pid);
+PTW32_DLLPORT int __cdecl sched_getscheduler (pid_t pid);
/*
* Note that this macro returns ENOTSUP rather than
diff --git a/semaphore.h b/semaphore.h
index 73bc45d..f26417e 100644
--- a/semaphore.h
+++ b/semaphore.h
@@ -123,34 +123,34 @@ typedef unsigned int mode_t;
typedef struct sem_t_ * sem_t;
-PTW32_DLLPORT int sem_init (sem_t * sem,
+PTW32_DLLPORT int __cdecl sem_init (sem_t * sem,
int pshared,
unsigned int value);
-PTW32_DLLPORT int sem_destroy (sem_t * sem);
+PTW32_DLLPORT int __cdecl sem_destroy (sem_t * sem);
-PTW32_DLLPORT int sem_trywait (sem_t * sem);
+PTW32_DLLPORT int __cdecl sem_trywait (sem_t * sem);
-PTW32_DLLPORT int sem_wait (sem_t * sem);
+PTW32_DLLPORT int __cdecl sem_wait (sem_t * sem);
-PTW32_DLLPORT int sem_timedwait (sem_t * sem,
+PTW32_DLLPORT int __cdecl sem_timedwait (sem_t * sem,
const struct timespec * abstime);
-PTW32_DLLPORT int sem_post (sem_t * sem);
+PTW32_DLLPORT int __cdecl sem_post (sem_t * sem);
-PTW32_DLLPORT int sem_post_multiple (sem_t * sem,
+PTW32_DLLPORT int __cdecl sem_post_multiple (sem_t * sem,
int count);
-PTW32_DLLPORT int sem_open (const char * name,
+PTW32_DLLPORT int __cdecl sem_open (const char * name,
int oflag,
mode_t mode,
unsigned int value);
-PTW32_DLLPORT int sem_close (sem_t * sem);
+PTW32_DLLPORT int __cdecl sem_close (sem_t * sem);
-PTW32_DLLPORT int sem_unlink (const char * name);
+PTW32_DLLPORT int __cdecl sem_unlink (const char * name);
-PTW32_DLLPORT int sem_getvalue (sem_t * sem,
+PTW32_DLLPORT int __cdecl sem_getvalue (sem_t * sem,
int * sval);
#ifdef __cplusplus