aboutsummaryrefslogtreecommitdiff
path: root/pthreads
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2013-02-13 10:41:10 +0100
committermarha <marha@users.sourceforge.net>2013-02-13 10:41:10 +0100
commitb41f74438672dd682bc01ae818cb3da654f22c1e (patch)
tree07674ef1368a5427a75080528d8cee74234f6b28 /pthreads
parentaaf21968deb85b635cb6aa6544df233ea5981346 (diff)
downloadvcxsrv-b41f74438672dd682bc01ae818cb3da654f22c1e.tar.gz
vcxsrv-b41f74438672dd682bc01ae818cb3da654f22c1e.tar.bz2
vcxsrv-b41f74438672dd682bc01ae818cb3da654f22c1e.zip
Updated to latest CVS version of pthreads
Diffstat (limited to 'pthreads')
-rw-r--r--pthreads/ANNOUNCE62
-rw-r--r--pthreads/Bmakefile210
-rw-r--r--pthreads/CONTRIBUTORS4
-rw-r--r--pthreads/COPYING7
-rwxr-xr-x[-rw-r--r--]pthreads/COPYING.FSF (renamed from pthreads/COPYING.LIB)0
-rw-r--r--pthreads/ChangeLog352
-rw-r--r--pthreads/FAQ902
-rw-r--r--pthreads/GNUmakefile645
-rw-r--r--pthreads/Makefile569
-rw-r--r--pthreads/NEWS160
-rw-r--r--pthreads/Nmakefile8
-rw-r--r--pthreads/README477
-rw-r--r--pthreads/README.CV12
-rw-r--r--pthreads/README.NONPORTABLE58
-rw-r--r--pthreads/TODO16
-rw-r--r--pthreads/autostatic.c74
-rw-r--r--pthreads/builddmc.bat4
-rw-r--r--pthreads/cleanup.c13
-rwxr-xr-xpthreads/common.mk309
-rw-r--r--pthreads/condvar.c1
-rw-r--r--pthreads/config.h6
-rw-r--r--pthreads/context.h9
-rw-r--r--pthreads/create.c102
-rw-r--r--pthreads/dll.c25
-rw-r--r--pthreads/errno.c200
-rw-r--r--pthreads/global.c23
-rw-r--r--pthreads/implement.h193
-rw-r--r--pthreads/manual/ChangeLog17
-rwxr-xr-xpthreads/manual/cpu_set.html119
-rw-r--r--pthreads/manual/index.html318
-rw-r--r--pthreads/manual/pthread_create.html206
-rw-r--r--pthreads/manual/pthread_join.html271
-rwxr-xr-xpthreads/manual/sched_setaffinity.html143
-rw-r--r--pthreads/misc.c3
-rw-r--r--pthreads/mutex.c1
-rw-r--r--pthreads/nonportable.c1
-rw-r--r--pthreads/private.c8
-rw-r--r--pthreads/pthread.c254
-rw-r--r--pthreads/pthread.h249
-rw-r--r--pthreads/pthread_attr_destroy.c13
-rw-r--r--pthreads/pthread_attr_getdetachstate.c177
-rw-r--r--pthreads/pthread_attr_getinheritsched.c107
-rw-r--r--pthreads/pthread_attr_getschedparam.c13
-rw-r--r--pthreads/pthread_attr_getschedpolicy.c118
-rw-r--r--pthreads/pthread_attr_getscope.c13
-rw-r--r--pthreads/pthread_attr_getstackaddr.c13
-rw-r--r--pthreads/pthread_attr_getstacksize.c13
-rw-r--r--pthreads/pthread_attr_init.c13
-rw-r--r--pthreads/pthread_attr_setdetachstate.c13
-rw-r--r--pthreads/pthread_attr_setinheritsched.c13
-rw-r--r--pthreads/pthread_attr_setschedparam.c13
-rw-r--r--pthreads/pthread_attr_setschedpolicy.c13
-rw-r--r--pthreads/pthread_attr_setscope.c13
-rw-r--r--pthreads/pthread_attr_setstackaddr.c13
-rw-r--r--pthreads/pthread_attr_setstacksize.c13
-rw-r--r--pthreads/pthread_barrier_destroy.c13
-rw-r--r--pthreads/pthread_barrier_init.c143
-rw-r--r--pthreads/pthread_barrier_wait.c13
-rw-r--r--pthreads/pthread_barrierattr_destroy.c13
-rw-r--r--pthreads/pthread_barrierattr_getpshared.c13
-rw-r--r--pthreads/pthread_barrierattr_init.c13
-rw-r--r--pthreads/pthread_barrierattr_setpshared.c13
-rw-r--r--pthreads/pthread_cancel.c21
-rw-r--r--pthreads/pthread_cond_destroy.c21
-rw-r--r--pthreads/pthread_cond_init.c17
-rw-r--r--pthreads/pthread_cond_signal.c17
-rw-r--r--pthreads/pthread_cond_wait.c30
-rw-r--r--pthreads/pthread_condattr_destroy.c13
-rw-r--r--pthreads/pthread_condattr_getpshared.c13
-rw-r--r--pthreads/pthread_condattr_init.c13
-rw-r--r--pthreads/pthread_condattr_setpshared.c13
-rw-r--r--pthreads/pthread_delay_np.c19
-rw-r--r--pthreads/pthread_detach.c19
-rw-r--r--pthreads/pthread_equal.c13
-rw-r--r--pthreads/pthread_exit.c15
-rw-r--r--pthreads/pthread_getconcurrency.c13
-rw-r--r--pthreads/pthread_getschedparam.c19
-rw-r--r--pthreads/pthread_getspecific.c179
-rw-r--r--pthreads/pthread_getunique_np.c13
-rw-r--r--pthreads/pthread_getw32threadhandle_np.c135
-rw-r--r--pthreads/pthread_join.c17
-rw-r--r--pthreads/pthread_key_create.c15
-rw-r--r--pthreads/pthread_key_delete.c13
-rw-r--r--pthreads/pthread_kill.c13
-rw-r--r--pthreads/pthread_mutex_consistent.c33
-rw-r--r--pthreads/pthread_mutex_destroy.c13
-rw-r--r--pthreads/pthread_mutex_init.c13
-rw-r--r--pthreads/pthread_mutex_lock.c13
-rw-r--r--pthreads/pthread_mutex_timedlock.c38
-rw-r--r--pthreads/pthread_mutex_trylock.c13
-rw-r--r--pthreads/pthread_mutex_unlock.c13
-rw-r--r--pthreads/pthread_mutexattr_destroy.c13
-rw-r--r--pthreads/pthread_mutexattr_getkind_np.c13
-rw-r--r--pthreads/pthread_mutexattr_getpshared.c13
-rw-r--r--pthreads/pthread_mutexattr_getrobust.c13
-rw-r--r--pthreads/pthread_mutexattr_gettype.c117
-rw-r--r--pthreads/pthread_mutexattr_init.c14
-rw-r--r--pthreads/pthread_mutexattr_setkind_np.c13
-rw-r--r--pthreads/pthread_mutexattr_setpshared.c13
-rw-r--r--pthreads/pthread_mutexattr_setrobust.c13
-rw-r--r--pthreads/pthread_mutexattr_settype.c13
-rw-r--r--pthreads/pthread_num_processors_np.c13
-rw-r--r--pthreads/pthread_once.c21
-rw-r--r--pthreads/pthread_rwlock_destroy.c13
-rw-r--r--pthreads/pthread_rwlock_init.c223
-rw-r--r--pthreads/pthread_rwlock_rdlock.c209
-rw-r--r--pthreads/pthread_rwlock_timedrdlock.c223
-rw-r--r--pthreads/pthread_rwlock_timedwrlock.c19
-rw-r--r--pthreads/pthread_rwlock_tryrdlock.c209
-rw-r--r--pthreads/pthread_rwlock_trywrlock.c249
-rw-r--r--pthreads/pthread_rwlock_unlock.c191
-rw-r--r--pthreads/pthread_rwlock_wrlock.c19
-rw-r--r--pthreads/pthread_rwlockattr_destroy.c173
-rw-r--r--pthreads/pthread_rwlockattr_getpshared.c199
-rw-r--r--pthreads/pthread_rwlockattr_init.c171
-rw-r--r--pthreads/pthread_rwlockattr_setpshared.c245
-rw-r--r--pthreads/pthread_self.c132
-rwxr-xr-xpthreads/pthread_setaffinity.c225
-rw-r--r--pthreads/pthread_setcancelstate.c13
-rw-r--r--pthreads/pthread_setcanceltype.c15
-rw-r--r--pthreads/pthread_setconcurrency.c13
-rw-r--r--pthreads/pthread_setschedparam.c13
-rw-r--r--pthreads/pthread_setspecific.c13
-rw-r--r--pthreads/pthread_spin_destroy.c13
-rw-r--r--pthreads/pthread_spin_init.c13
-rw-r--r--pthreads/pthread_spin_lock.c13
-rw-r--r--pthreads/pthread_spin_trylock.c13
-rw-r--r--pthreads/pthread_spin_unlock.c13
-rw-r--r--pthreads/pthread_testcancel.c13
-rw-r--r--pthreads/pthread_timechange_handler_np.c13
-rwxr-xr-xpthreads/pthread_timedjoin_np.c188
-rwxr-xr-xpthreads/pthread_tryjoin_np.c173
-rw-r--r--pthreads/pthread_win32_attach_detach_np.c35
-rw-r--r--pthreads/ptw32_MCS_lock.c17
-rw-r--r--pthreads/ptw32_callUserDestroyRoutines.c13
-rw-r--r--pthreads/ptw32_calloc.c13
-rw-r--r--pthreads/ptw32_cond_check_need_init.c13
-rw-r--r--pthreads/ptw32_getprocessors.c13
-rw-r--r--pthreads/ptw32_is_attr.c13
-rw-r--r--pthreads/ptw32_mutex_check_need_init.c17
-rw-r--r--pthreads/ptw32_new.c20
-rw-r--r--pthreads/ptw32_processInitialize.c13
-rw-r--r--pthreads/ptw32_processTerminate.c13
-rw-r--r--pthreads/ptw32_relmillisecs.c23
-rw-r--r--pthreads/ptw32_reuse.c13
-rw-r--r--pthreads/ptw32_rwlock_cancelwrwait.c13
-rw-r--r--pthreads/ptw32_rwlock_check_need_init.c13
-rw-r--r--pthreads/ptw32_semwait.c19
-rw-r--r--pthreads/ptw32_spinlock_check_need_init.c13
-rw-r--r--pthreads/ptw32_threadDestroy.c15
-rw-r--r--pthreads/ptw32_threadStart.c169
-rw-r--r--pthreads/ptw32_throw.c41
-rw-r--r--pthreads/ptw32_timespec.c13
-rw-r--r--pthreads/ptw32_tkAssocCreate.c13
-rw-r--r--pthreads/ptw32_tkAssocDestroy.c13
-rw-r--r--pthreads/rwlock.c2
-rw-r--r--pthreads/sched.h123
-rw-r--r--pthreads/sched_get_priority_max.c15
-rw-r--r--pthreads/sched_get_priority_min.c15
-rw-r--r--pthreads/sched_getscheduler.c17
-rwxr-xr-xpthreads/sched_setaffinity.c352
-rw-r--r--pthreads/sched_setscheduler.c19
-rw-r--r--pthreads/sched_yield.c13
-rw-r--r--pthreads/sem_close.c15
-rw-r--r--pthreads/sem_destroy.c15
-rw-r--r--pthreads/sem_getvalue.c53
-rw-r--r--pthreads/sem_init.c15
-rw-r--r--pthreads/sem_open.c15
-rw-r--r--pthreads/sem_post.c88
-rw-r--r--pthreads/sem_post_multiple.c15
-rw-r--r--pthreads/sem_timedwait.c23
-rw-r--r--pthreads/sem_trywait.c17
-rw-r--r--pthreads/sem_unlink.c15
-rw-r--r--pthreads/sem_wait.c23
-rw-r--r--pthreads/semaphore.h51
-rw-r--r--pthreads/signal.c15
-rw-r--r--pthreads/spin.c1
-rw-r--r--pthreads/tests/Bmakefile26
-rw-r--r--pthreads/tests/ChangeLog201
-rw-r--r--pthreads/tests/GNUmakefile448
-rw-r--r--pthreads/tests/Makefile488
-rw-r--r--pthreads/tests/SIZES.GC21
-rw-r--r--pthreads/tests/SIZES.GCE21
-rw-r--r--pthreads/tests/SIZES.VC21
-rw-r--r--pthreads/tests/SIZES.VCE21
-rw-r--r--pthreads/tests/SIZES.VSE21
-rw-r--r--pthreads/tests/Wmakefile28
-rwxr-xr-xpthreads/tests/affinity1.c111
-rwxr-xr-xpthreads/tests/affinity2.c102
-rwxr-xr-xpthreads/tests/affinity3.c100
-rwxr-xr-xpthreads/tests/affinity4.c70
-rwxr-xr-xpthreads/tests/affinity5.c103
-rw-r--r--pthreads/tests/barrier1.c9
-rw-r--r--pthreads/tests/barrier2.c9
-rw-r--r--pthreads/tests/barrier3.c9
-rw-r--r--pthreads/tests/barrier4.c9
-rw-r--r--pthreads/tests/barrier5.c9
-rw-r--r--pthreads/tests/barrier6.c235
-rw-r--r--pthreads/tests/benchlib.c9
-rw-r--r--pthreads/tests/benchtest.h9
-rw-r--r--pthreads/tests/benchtest1.c10
-rw-r--r--pthreads/tests/benchtest2.c10
-rw-r--r--pthreads/tests/benchtest3.c10
-rw-r--r--pthreads/tests/benchtest4.c10
-rw-r--r--pthreads/tests/benchtest5.c10
-rw-r--r--pthreads/tests/cancel1.c35
-rw-r--r--pthreads/tests/cancel2.c59
-rw-r--r--pthreads/tests/cancel3.c19
-rw-r--r--pthreads/tests/cancel4.c21
-rw-r--r--pthreads/tests/cancel5.c17
-rw-r--r--pthreads/tests/cancel6a.c10
-rw-r--r--pthreads/tests/cancel6d.c10
-rw-r--r--pthreads/tests/cancel7.c11
-rw-r--r--pthreads/tests/cancel8.c11
-rw-r--r--pthreads/tests/cancel9.c15
-rw-r--r--pthreads/tests/cleanup0.c17
-rw-r--r--pthreads/tests/cleanup1.c45
-rw-r--r--pthreads/tests/cleanup2.c15
-rw-r--r--pthreads/tests/cleanup3.c15
-rwxr-xr-xpthreads/tests/common.mk53
-rw-r--r--pthreads/tests/condvar1.c9
-rw-r--r--pthreads/tests/condvar1_1.c9
-rw-r--r--pthreads/tests/condvar1_2.c9
-rw-r--r--pthreads/tests/condvar2.c17
-rw-r--r--pthreads/tests/condvar2_1.c9
-rw-r--r--pthreads/tests/condvar3.c9
-rw-r--r--pthreads/tests/condvar3_1.c9
-rw-r--r--pthreads/tests/condvar3_2.c9
-rw-r--r--pthreads/tests/condvar3_3.c9
-rw-r--r--pthreads/tests/condvar4.c9
-rw-r--r--pthreads/tests/condvar5.c9
-rw-r--r--pthreads/tests/condvar6.c11
-rw-r--r--pthreads/tests/condvar7.c13
-rw-r--r--pthreads/tests/condvar8.c11
-rw-r--r--pthreads/tests/condvar9.c15
-rw-r--r--pthreads/tests/context1.c284
-rwxr-xr-xpthreads/tests/context2.c157
-rw-r--r--pthreads/tests/count1.c9
-rw-r--r--pthreads/tests/create1.c9
-rw-r--r--pthreads/tests/create2.c9
-rwxr-xr-xpthreads/tests/create3.c110
-rw-r--r--pthreads/tests/delay1.c9
-rw-r--r--pthreads/tests/delay2.c9
-rw-r--r--pthreads/tests/detach1.c9
-rw-r--r--pthreads/tests/equal1.c9
-rw-r--r--pthreads/tests/errno1.c11
-rw-r--r--pthreads/tests/exception1.c15
-rw-r--r--pthreads/tests/exception2.c24
-rw-r--r--pthreads/tests/exception3.c41
-rwxr-xr-xpthreads/tests/exception3_0.c187
-rw-r--r--pthreads/tests/exit1.c12
-rw-r--r--pthreads/tests/exit2.c9
-rw-r--r--pthreads/tests/exit3.c9
-rw-r--r--pthreads/tests/exit4.c11
-rw-r--r--pthreads/tests/exit5.c11
-rw-r--r--pthreads/tests/eyal1.c16
-rw-r--r--pthreads/tests/inherit1.c9
-rw-r--r--pthreads/tests/join0.c9
-rw-r--r--pthreads/tests/join1.c9
-rw-r--r--pthreads/tests/join2.c9
-rw-r--r--pthreads/tests/join3.c9
-rwxr-xr-xpthreads/tests/join4.c87
-rw-r--r--pthreads/tests/kill1.c9
-rw-r--r--pthreads/tests/mutex1.c9
-rw-r--r--pthreads/tests/mutex1e.c9
-rw-r--r--pthreads/tests/mutex1n.c9
-rw-r--r--pthreads/tests/mutex1r.c9
-rw-r--r--pthreads/tests/mutex2.c9
-rw-r--r--pthreads/tests/mutex2e.c9
-rw-r--r--pthreads/tests/mutex2r.c9
-rw-r--r--pthreads/tests/mutex3.c9
-rw-r--r--pthreads/tests/mutex3e.c9
-rw-r--r--pthreads/tests/mutex3r.c9
-rw-r--r--pthreads/tests/mutex4.c9
-rw-r--r--pthreads/tests/mutex5.c9
-rw-r--r--pthreads/tests/mutex6.c12
-rw-r--r--pthreads/tests/mutex6e.c12
-rw-r--r--pthreads/tests/mutex6es.c12
-rw-r--r--pthreads/tests/mutex6n.c16
-rw-r--r--pthreads/tests/mutex6r.c12
-rw-r--r--pthreads/tests/mutex6rs.c12
-rw-r--r--pthreads/tests/mutex6s.c12
-rw-r--r--pthreads/tests/mutex7.c12
-rw-r--r--pthreads/tests/mutex7e.c12
-rw-r--r--pthreads/tests/mutex7n.c12
-rw-r--r--pthreads/tests/mutex7r.c12
-rw-r--r--pthreads/tests/mutex8.c1
-rw-r--r--pthreads/tests/mutex8e.c1
-rw-r--r--pthreads/tests/mutex8n.c1
-rw-r--r--pthreads/tests/mutex8r.c1
-rw-r--r--pthreads/tests/once1.c9
-rw-r--r--pthreads/tests/once2.c22
-rw-r--r--pthreads/tests/once3.c40
-rw-r--r--pthreads/tests/once4.c32
-rw-r--r--pthreads/tests/openmp1.c8
-rw-r--r--pthreads/tests/priority1.c9
-rw-r--r--pthreads/tests/priority2.c9
-rw-r--r--pthreads/tests/reuse1.c9
-rw-r--r--pthreads/tests/reuse2.c9
-rw-r--r--pthreads/tests/robust1.c9
-rw-r--r--pthreads/tests/robust2.c9
-rw-r--r--pthreads/tests/robust3.c9
-rw-r--r--pthreads/tests/robust4.c9
-rw-r--r--pthreads/tests/robust5.c9
-rwxr-xr-xpthreads/tests/runorder.mk149
-rw-r--r--pthreads/tests/rwlock1.c9
-rw-r--r--pthreads/tests/rwlock2.c9
-rw-r--r--pthreads/tests/rwlock2_t.c9
-rw-r--r--pthreads/tests/rwlock3.c9
-rw-r--r--pthreads/tests/rwlock3_t.c9
-rw-r--r--pthreads/tests/rwlock4.c9
-rw-r--r--pthreads/tests/rwlock4_t.c9
-rw-r--r--pthreads/tests/rwlock5.c9
-rw-r--r--pthreads/tests/rwlock5_t.c9
-rw-r--r--pthreads/tests/rwlock6.c9
-rw-r--r--pthreads/tests/rwlock6_t.c9
-rw-r--r--pthreads/tests/rwlock6_t2.c9
-rw-r--r--pthreads/tests/self1.c139
-rw-r--r--pthreads/tests/self2.c9
-rw-r--r--pthreads/tests/semaphore1.c23
-rw-r--r--pthreads/tests/semaphore2.c9
-rw-r--r--pthreads/tests/semaphore3.c61
-rw-r--r--pthreads/tests/semaphore4.c9
-rw-r--r--pthreads/tests/semaphore4t.c9
-rw-r--r--pthreads/tests/semaphore5.c207
-rw-r--r--pthreads/tests/sequence1.c9
-rw-r--r--pthreads/tests/spin1.c9
-rw-r--r--pthreads/tests/spin2.c9
-rw-r--r--pthreads/tests/spin3.c9
-rw-r--r--pthreads/tests/spin4.c9
-rw-r--r--pthreads/tests/stress1.c9
-rw-r--r--pthreads/tests/test.h20
-rw-r--r--pthreads/tests/tryentercs.c9
-rw-r--r--pthreads/tests/tryentercs2.c9
-rw-r--r--pthreads/tests/tsd1.c9
-rw-r--r--pthreads/tests/tsd2.c9
-rw-r--r--pthreads/tests/valid1.c9
-rw-r--r--pthreads/tests/valid2.c9
-rw-r--r--pthreads/version.rc792
-rw-r--r--pthreads/w32_CancelableWait.c13
340 files changed, 10819 insertions, 7361 deletions
diff --git a/pthreads/ANNOUNCE b/pthreads/ANNOUNCE
index 3fa6232c1..b5a096e3f 100644
--- a/pthreads/ANNOUNCE
+++ b/pthreads/ANNOUNCE
@@ -1,8 +1,8 @@
- PTHREADS-WIN32 RELEASE 2.9.0 (2007-??-??)
- -----------------------------------------
- Web Site: http://sources.redhat.com/pthreads-win32/
- FTP Site: ftp://sources.redhat.com/pub/pthreads-win32
- Maintainer: Ross Johnson <rpj@callisto.canberra.edu.au>
+PTHREADS-WIN32 RELEASE 2.9.1 (2012-05-27)
+-----------------------------------------
+Web Site: http://sourceware.org/pthreads-win32/
+FTP Site: ftp://sourceware.org/pub/pthreads-win32
+Maintainer: Ross Johnson <ross.johnson@loungebythelake.net>
We are pleased to announce the availability of a new release of
@@ -12,6 +12,11 @@ Win32 environment. Some functions from other sections of POSIX
1003.1 2001 are also supported including semaphores and scheduling
functions.
+This release replaces an extremely brief 2.9.0 release and adds
+some last minute non-code changes were made to embed better
+descriptive properties in the dlls to indicate target architecture
+and build environments.
+
Some common non-portable functions are also implemented for
additional compatibility, as are a few functions specific
to pthreads-win32 for easier integration with Win32 applications.
@@ -23,7 +28,7 @@ General Public License (LGPL).
Acknowledgements
----------------
This library is based originally on a Win32 pthreads
-implementation contributed by John Bossom <John.Bossom@cognos.com>.
+implementation contributed by John Bossom.
The implementation of Condition Variables uses algorithms developed
by Alexander Terekhov and Louis Thomas.
@@ -50,7 +55,7 @@ were extracted from it.
There is also a separate CONTRIBUTORS file. This file and others are
on the web site:
- http://sources.redhat.com/pthreads-win32
+ http://sourceware.org/pthreads-win32
As much as possible, the ChangeLog file acknowledges contributions to the
code base in more detail.
@@ -70,7 +75,7 @@ These are now documented in the BUGS file.
Level of standards conformance
------------------------------
-The following POSIX 1003.1 2001 options are defined and set to 200112L:
+The following POSIX options are defined and set to 200809L:
_POSIX_THREADS
_POSIX_THREAD_SAFE_FUNCTIONS
@@ -81,8 +86,7 @@ The following POSIX 1003.1 2001 options are defined and set to 200112L:
_POSIX_SPIN_LOCKS
_POSIX_BARRIERS
-
-The following POSIX 1003.1 2001 options are defined and set to -1:
+The following POSIX options are defined and set to -1:
_POSIX_THREAD_ATTR_STACKADDR
_POSIX_THREAD_PRIO_INHERIT
@@ -90,7 +94,7 @@ The following POSIX 1003.1 2001 options are defined and set to -1:
_POSIX_THREAD_PROCESS_SHARED
-The following POSIX 1003.1 2001 limits are defined and set:
+The following POSIX limits are defined and set:
_POSIX_THREAD_THREADS_MAX
_POSIX_SEM_VALUE_MAX
@@ -249,6 +253,8 @@ The following functions are implemented:
sched_get_priority_max
sched_get_priority_min
sched_rr_get_interval (returns an error ENOTSUP)
+ sched_getaffinity
+ sched_setaffinity
sched_setscheduler (only supports SCHED_OTHER)
sched_getscheduler (only supports SCHED_OTHER)
sched_yield
@@ -263,10 +269,14 @@ The following functions are implemented:
---------------------------
Non-portable routines (see the README.NONPORTABLE file for usage)
---------------------------
+ pthread_timedjoin_np
+ pthread_tryjoin_np
pthread_getw32threadhandle_np
pthread_timechange_handler_np
pthread_delay_np
pthread_getunique_np
+ pthread_getaffinity_np
+ pthread_setaffinity_np
pthread_mutexattr_getkind_np
pthread_mutexattr_setkind_np (types: PTHREAD_MUTEX_FAST_NP,
PTHREAD_MUTEX_ERRORCHECK_NP,
@@ -274,14 +284,15 @@ The following functions are implemented:
PTHREAD_MUTEX_ADAPTIVE_NP,
PTHREAD_MUTEX_TIMED_NP)
pthread_num_processors_np
- pthread_win32_process_attach_np (Required when statically linking
- the library)
- pthread_win32_process_detach_np (Required when statically linking
- the library)
- pthread_win32_thread_attach_np (Required when statically linking
- the library)
- pthread_win32_thread_detach_np (Required when statically linking
- the library)
+ (The following four routines may be required when linking statically.
+ The process_* routines should not be needed for MSVC or GCC.)
+ pthread_win32_process_attach_np
+ pthread_win32_process_detach_np
+ (The following routines should only be needed to manage implicit
+ POSIX handles i.e. when Win native threads call POSIX thread routines
+ (other than pthread_create))
+ pthread_win32_thread_attach_np
+ pthread_win32_thread_detach_np
---------------------------
Static Initializers
@@ -296,6 +307,19 @@ The following functions are implemented:
PTHREAD_RWLOCK_INITIALIZER
PTHREAD_SPINLOCK_INITIALIZER
+ ---------------------------
+ CPU Affinity Mask Support
+ ---------------------------
+ CPU_ZERO
+ CPU_EQUAL
+ CPU_COUNT
+ CPU_SET
+ CPU_CLR
+ CPU_ISSET
+ CPU_AND
+ CPU_OR
+ CPU_XOR
+
The library includes two non-API functions for creating cancellation
points in applications and libraries:
diff --git a/pthreads/Bmakefile b/pthreads/Bmakefile
index ea25dec4f..c6bcf93d4 100644
--- a/pthreads/Bmakefile
+++ b/pthreads/Bmakefile
@@ -21,195 +21,16 @@ OPTIM = /O2
RC = brcc32
RCFLAGS = -i.
-CFLAGS = /q /I. /D_WIN32_WINNT=0x400 /DHAVE_PTW32_CONFIG_H=1 /4 /tWD /tWM \
+CFLAGS = /q /I. /DHAVE_CONFIG_H=1 /4 /tWD /tWM \
/w-aus /w-asc /w-par
#C cleanup code
BCFLAGS = $(PTW32_FLAGS) $(CFLAGS)
-# Agregate modules for inlinability
-DLL_OBJS = \
- attr.obj \
- barrier.obj \
- cancel.obj \
- cleanup.obj \
- condvar.obj \
- create.obj \
- dll.obj \
- errno.obj \
- exit.obj \
- fork.obj \
- global.obj \
- misc.obj \
- mutex.obj \
- nonportable.obj \
- private.obj \
- rwlock.obj \
- sched.obj \
- semaphore.obj \
- signal.obj \
- spin.obj \
- sync.obj \
- tsd.obj
-
-INCL = config.h implement.h semaphore.h pthread.h need_errno.h
-
-ATTR_SRCS = \
- pthread_attr_init.c \
- pthread_attr_destroy.c \
- pthread_attr_getdetachstate.c \
- pthread_attr_setdetachstate.c \
- pthread_attr_getstackaddr.c \
- pthread_attr_setstackaddr.c \
- pthread_attr_getstacksize.c \
- pthread_attr_setstacksize.c \
- pthread_attr_getscope.c \
- pthread_attr_setscope.c
-
-BARRIER_SRCS = \
- pthread_barrier_init.c \
- pthread_barrier_destroy.c \
- pthread_barrier_wait.c \
- pthread_barrierattr_init.c \
- pthread_barrierattr_destroy.c \
- pthread_barrierattr_setpshared.c \
- pthread_barrierattr_getpshared.c
-
-CANCEL_SRCS = \
- pthread_setcancelstate.c \
- pthread_setcanceltype.c \
- pthread_testcancel.c \
- pthread_cancel.c
-
-CONDVAR_SRCS = \
- ptw32_cond_check_need_init.c \
- pthread_condattr_destroy.c \
- pthread_condattr_getpshared.c \
- pthread_condattr_init.c \
- pthread_condattr_setpshared.c \
- pthread_cond_destroy.c \
- pthread_cond_init.c \
- pthread_cond_signal.c \
- pthread_cond_wait.c
-
-EXIT_SRCS = \
- pthread_exit.c
-
-MISC_SRCS = \
- pthread_equal.c \
- pthread_getconcurrency.c \
- pthread_once.c \
- pthread_self.c \
- pthread_setconcurrency.c \
- ptw32_calloc.c \
- ptw32_MCS_lock.c \
- ptw32_new.c \
- w32_CancelableWait.c
-
-MUTEX_SRCS = \
- ptw32_mutex_check_need_init.c \
- pthread_mutex_init.c \
- pthread_mutex_destroy.c \
- pthread_mutexattr_init.c \
- pthread_mutexattr_destroy.c \
- pthread_mutexattr_getpshared.c \
- pthread_mutexattr_setpshared.c \
- pthread_mutexattr_settype.c \
- pthread_mutexattr_gettype.c \
- pthread_mutexattr_setrobust.c \
- pthread_mutexattr_getrobust.c \
- pthread_mutex_lock.c \
- pthread_mutex_timedlock.c \
- pthread_mutex_unlock.c \
- pthread_mutex_trylock.c \
- pthread_mutex_consistent.c
-
-NONPORTABLE_SRCS = \
- pthread_mutexattr_setkind_np.c \
- pthread_mutexattr_getkind_np.c \
- pthread_getw32threadhandle_np.c \
- pthread_delay_np.c \
- pthread_num_processors_np.c \
- pthread_win32_attach_detach_np.c \
- pthread_timechange_handler_np.c
-
-PRIVATE_SRCS = \
- ptw32_is_attr.c \
- ptw32_processInitialize.c \
- ptw32_processTerminate.c \
- ptw32_threadStart.c \
- ptw32_threadDestroy.c \
- ptw32_tkAssocCreate.c \
- ptw32_tkAssocDestroy.c \
- ptw32_callUserDestroyRoutines.c \
- ptw32_timespec.c \
- ptw32_relmillisecs.c \
- ptw32_throw.c \
- ptw32_getprocessors.c
-
-RWLOCK_SRCS = \
- ptw32_rwlock_check_need_init.c \
- ptw32_rwlock_cancelwrwait.c \
- pthread_rwlock_init.c \
- pthread_rwlock_destroy.c \
- pthread_rwlockattr_init.c \
- pthread_rwlockattr_destroy.c \
- pthread_rwlockattr_getpshared.c \
- pthread_rwlockattr_setpshared.c \
- pthread_rwlock_rdlock.c \
- pthread_rwlock_timedrdlock.c \
- pthread_rwlock_wrlock.c \
- pthread_rwlock_timedwrlock.c \
- pthread_rwlock_unlock.c \
- pthread_rwlock_tryrdlock.c \
- pthread_rwlock_trywrlock.c
-
-SCHED_SRCS = \
- pthread_attr_setschedpolicy.c \
- pthread_attr_getschedpolicy.c \
- pthread_attr_setschedparam.c \
- pthread_attr_getschedparam.c \
- pthread_attr_setinheritsched.c \
- pthread_attr_getinheritsched.c \
- pthread_setschedparam.c \
- pthread_getschedparam.c \
- sched_get_priority_max.c \
- sched_get_priority_min.c \
- sched_setscheduler.c \
- sched_getscheduler.c \
- sched_yield.c
-
-SEMAPHORE_SRCS = \
- sem_init.c \
- sem_destroy.c \
- sem_trywait.c \
- sem_timedwait.c \
- sem_wait.c \
- sem_post.c \
- sem_post_multiple.c \
- sem_getvalue.c \
- sem_open.c \
- sem_close.c \
- sem_unlink.c
-
-SPIN_SRCS = \
- ptw32_spinlock_check_need_init.c \
- pthread_spin_init.c \
- pthread_spin_destroy.c \
- pthread_spin_lock.c \
- pthread_spin_unlock.c \
- pthread_spin_trylock.c
-
-SYNC_SRCS = \
- pthread_detach.c \
- pthread_join.c
-
-TSD_SRCS = \
- pthread_key_create.c \
- pthread_key_delete.c \
- pthread_setspecific.c \
- pthread_getspecific.c
-
+OBJEXT = obj
+RESEXT = res
+
+include common.mk
all: clean $(DLLS)
@@ -238,31 +59,14 @@ install: $(DLLS)
copy pthread*.dll $(DLLDEST)
copy pthread*.lib $(LIBDEST)
-$(DLLS): $(DLL_OBJS) version.res
+$(DLLS): $(DLL_OBJS) $(RESOURCE_OBJS)
ilink32 /Tpd /Gi c0d32x.obj $(DLL_OBJS), \
$@, ,\
cw32mti.lib import32.lib, ,\
- version.res
+ $(RESOURCE_OBJS)
.c.obj:
$(CC) $(OPTIM) $(BCFLAGS) -c $<
.rc.res:
$(RC) $(RCFLAGS) $<
-
-attr.obj: attr.c $(ATTR_SRCS) $(INCL)
-barrier.obj: barrier.c $(BARRIER_SRCS) $(INCL)
-cancel.obj: cancel.c $(CANCEL_SRCS) $(INCL)
-condvar.obj: condvar.c $(CONDVAR_SRCS) $(INCL)
-exit.obj: exit.c $(EXIT_SRCS) $(INCL)
-misc.obj: misc.c $(MISC_SRCS) $(INCL)
-mutex.obj: mutex.c $(MUTEX_SRCS) $(INCL)
-nonportable.obj: nonportable.c $(NONPORTABLE_SRCS) $(INCL)
-private.obj: private.c $(PRIVATE_SRCS) $(INCL)
-rwlock.obj: rwlock.c $(RWLOCK_SRCS) $(INCL)
-sched.obj: sched.c $(SCHED_SRCS) $(INCL)
-semaphore.obj: semaphore.c $(SEMAPHORE_SRCS) $(INCL)
-spin.obj: spin.c $(SPIN_SRCS) $(INCL)
-sync.obj: sync.c $(SYNC_SRCS) $(INCL)
-tsd.obj: tsd.c $(TSD_SRCS) $(INCL)
-version.res: version.rc $(INCL)
diff --git a/pthreads/CONTRIBUTORS b/pthreads/CONTRIBUTORS
index da31ff266..72a7ea260 100644
--- a/pthreads/CONTRIBUTORS
+++ b/pthreads/CONTRIBUTORS
@@ -55,7 +55,7 @@ Rich Peters rpeters at micro-magic dot com
Todd Owen towen at lucidcalm dot dropbear dot id dot au
Bug fixes to dll loading.
Jason Nye jnye at nbnet dot nb dot ca
- Implementation of async cancelation.
+ Implementation of async cancellation.
Fred Forester fforest at eticomm dot net
Kevin D. Clark kclark at cabletron dot com
David Baggett dmb at itasoftware dot com
@@ -116,7 +116,7 @@ Makoto Kato raven at oldskool dot jp
Panagiotis E. Hadjidoukas peh at hpclab dot ceid dot upatras dot gr
phadjido at cs dot uoi dot gr
Contributed the QueueUserAPCEx package which
- makes preemptive async cancelation possible.
+ makes preemptive async cancellation possible.
Will Bryant will dot bryant at ecosm dot com
Borland compiler patch and makefile.
Anuj Goyal anuj dot goyal at gmail dot com
diff --git a/pthreads/COPYING b/pthreads/COPYING
index 5cfea0d0e..c9cc51e10 100644
--- a/pthreads/COPYING
+++ b/pthreads/COPYING
@@ -6,7 +6,7 @@ This file is Copyrighted
This file is covered under the following Copyright:
- Copyright (C) 2001,2006 Ross P. Johnson
+ Copyright (C) 2001,2012 Ross P. Johnson
All rights reserved.
Everyone is permitted to copy and distribute verbatim copies
@@ -32,7 +32,7 @@ Pthreads-win32 is covered by the GNU Lesser General Public License
A copy of the GNU Lesser General Public License is distributed with
pthreads-win32 under the filename:
- COPYING.LIB
+ COPYING.FSF
You should have received a copy of the version 2.1 GNU Lesser General
Public License with pthreads-win32; if not, write to:
@@ -45,7 +45,8 @@ Pthreads-win32 is covered by the GNU Lesser General Public License
The contact addresses for pthreads-win32 is as follows:
- Web: http://sources.redhat.com/pthreads-win32
+ Homepage1: http://sourceware.org/pthreads-win32/
+ Homepage2: http://sourceforge.net/projects/pthreads4w/
Email: Ross Johnson
Please use: Firstname.Lastname@homemail.com.au
diff --git a/pthreads/COPYING.LIB b/pthreads/COPYING.FSF
index b1e3f5a26..b1e3f5a26 100644..100755
--- a/pthreads/COPYING.LIB
+++ b/pthreads/COPYING.FSF
diff --git a/pthreads/ChangeLog b/pthreads/ChangeLog
index b2396ebf4..fcd364b8b 100644
--- a/pthreads/ChangeLog
+++ b/pthreads/ChangeLog
@@ -1,3 +1,303 @@
+2012-10-16 Ross Johnson <ross dot johnson at homemail dot com dot au>
+
+ * Makefile: Remove SDK environment setting; now needs to be done
+ explicitly before running any nmake.
+ * GNUmakefile: Move per command-line ARCH setting to TESTS_ENV.
+
+2012-10-04 Ross Johnson <ross dot johnson at homemail dot com dot au>
+
+ * pthread_tryjoin_np.c: New API
+ * pthread.c (pthread_try_join_np): Added.
+ * common.mk (pthread_tryjoin_np): Added.
+ * pthread.h (pthread_tryjoin_np): Added.
+ * NEWS: Updated.
+ * README: Updated.
+ * ANNOUNCE: Updated.
+
+2012-10-02 Ross Johnson <ross dot johnson at homemail dot com dot au>
+
+ * sched.h (cpu_set_t): Redefined.
+ * implement.h (_sched_cpu_set_vector_): Created as the private equivalent
+ of cpu_set.
+ (pthread_thread_t_.cpuset): Type change.
+ * sched_setaffinity.c: Reflect changes to cpu_set_t and _sched_cpu_set_vector_.
+ * pthread_setaffinity.c: Likewise.
+ * create.c: Likewise.
+ * pthread_self.c: Likewise.
+ * ptw32_new.c: Likewise.
+
+2012-09-28 Ross Johnson <ross dot johnson at homemail dot com dot au>
+
+ * pthread.c: pulls all individual source modules into a single
+ translation unit.
+ * common.mk: Remove everything related to the non-inlined dll targets.
+ This removes all the intermediate .c files that #include other .c files
+ except for pthread.c.
+ * Makefile: Remove and rename targets; remove or edit variables. All
+ of this is to remove the intermediate translation unit aggregation
+ source files.
+ * GNUmakefile: Likewise.
+ * attr.c: Removed.
+ * barrier.c: Removed.
+ * cancel.c: Removed.
+ * condvar.c: Removed.
+ * exit.c: Removed.
+ * fork.c: Removed.
+ * misc.c: Removed.
+ * mutex.c: Removed.
+ * nonportable.c: Removed.
+ * private.c: Removed.
+ * rwlock.c: Removed.
+ * sched.c: Removed.
+ * spin.c: Removed.
+ * sync.c: Removed.
+ * tsd.c: Removed.
+
+2012-09-28 Ross Johnson <ross dot johnson at homemail dot com dot au>
+
+ * Makefile: expand on rudimentary install target; add DEST_LIB_NAME
+ variable defaulting to "pthread.lib".
+ * GNUmakefile: Add install target similar to Makefile with DEST_LIB_NAME
+ defaulting to "libpthread.a".
+
+2012-09-28 Daniel Richard. G <danielg at teragram dot com>
+
+ * all: #include<config.h>; renamed HAVE_PTW32_CONFIG_H define in
+ build files to HAVE_CONFIG_H since we no longer need a
+ uniquely-named symbol for this.
+ * Bmakefile: Removed _WIN32_WINNT assignment from build files since
+ this is now handled in source.
+ * Wmakefile: Likewise.
+ * Makefile: Added mkdir invocations to "install" target.
+ * common.mk: Elaborated the pthread.$(OBJEXT) dependency list.
+ * pthread.h: Removed the #include"config.h" bit.
+
+2012-09-23 Ross Johnson <ross dot johnson at homemail dot com dot au>
+
+ * GNUmakefile: Modify "all-tests" to use new targets in tests
+ GNUmakefile.
+ * Makefile: Similarly.
+
+2012-09-22 Daniel Richard. G <danielg at teragram dot com>
+
+ * GNUmakefile: Reordered the command lines in the "help" target
+ to match the ordering of the targets in the makefile, which IMO
+ is nicer to the eye; tweaked some of the parentheticals for better
+ clarity; delete *.manifest files, in case the user just finished
+ doing an MSVC build.
+ * Makefile: Use *.static_stamp for the static targets instead of
+ *.static; added a note re VC++6 and /EHs vs. /EHa; reordered the
+ targets, and added a number of new ones (e.g. VSE-small-static);
+ added a note recommending *-inlined and *-small-static to make
+ things a little easier for users bewildered by the large number of
+ targets; reworked the all-tests[-cflags] targets so that (1) more
+ useful targets are built first (the small-static targets make it
+ easier to track down compilation errors), (2) *-debug build and
+ test targets can be used, (3) less-useful build/test permutations
+ are enabled only if EXHAUSTIVE and/or MORE_EXHAUSTIVE is defined,
+ and (4) /MDd and /MTd are covered too; "nmake all-tests-cflags
+ EXHAUSTIVE=1 MORE_EXHAUSTIVE=1" takes a few hours to run; moved
+ some of the VCE targets up, since the pattern in the file was
+ already to list VCE targets first, then VSE, then VC; actually
+ touch the stamp file in the stamp targets.
+ * README.NONPORTABLE: It's "DllMain", not "dllMain".
+ * common.mk: Start of an attempt to define dependencies for
+ pthread.$(OBJEXT).
+ * implement.h: Generalized PTW32_BROKEN_ERRNO into
+ PTW32_USES_SEPARATE_CRT; don't do the autostatic-anchoring thing
+ if we're not building the library!
+ * pthread.h: Moved the PTW32_CDECL bit into sched.h. pthread.h
+ already #includes sched.h, so the latter is a good place to put
+ definitions that need to be shared in common; severely simplified
+ the errno declaration for Open Watcom, made it applicable only to
+ Open Watcom, and made the comment less ambiguous; updated the long
+ comment describing PTW32_BROK^WPTW32_USES_SEPARATE_CRT; added
+ (conditional) declaration of pthread_win32_set_terminate_np(), as
+ well as ptw32_terminate_handler (so that eh.h doesn't have to get
+ involved).
+ * pthread_cond_wait.c: Missed a couple of errno conversions.
+ * pthread_mutex_consistent.c: Visual Studio (either 2010 or 2008
+ Express, don't recall now) actually errored out due to charset
+ issues in this file, so I've replaced non-ASCII characters with
+ ASCII approximations.
+ * ptw32_threadStart.c: Big rewrite of ptw32_threadStart().
+ Everything passes with this, except for GCE (and I can't figure
+ out why).
+ * sched.h: Moved the PTW32_CDECL section here (and made it
+ idempotent); need to #include <stdlib.h> for size_t (one of the test
+ programs #includes sched.h as the very first thing); moved the
+ DWORD_PTR definition up, since it groups better with the pid_t
+ definition; also need ULONG_PTR, don't need PDWORD_PTR; can't use
+ PTW32_CONFIG_MSVC6, because if you only #include sched.h you
+ don't get that bit in pthread.h; use a cpp symbol
+ (PTW32_HAVE_DWORD_PTR) to inhibit defining *_PTR if needed. Note
+ that this isn't #defined inside the conditional, because there are
+ no other instances of these typedefs that need to be disabled, and
+ sched.h itself is already protected against multiple inclusion;
+ DWORD_PTR can't be size_t, because (on MSVC6) the former is "unsigned
+ long" and the latter is "unsigned int" and C++ doesn't see them as
+ interchangeable; minor edit to the comment... I don't like saying
+ "VC++" without the "Microsoft" qualifier; use PTW32_CDECL instead of
+ a literal __cdecl (this was why I moved the PTW32_CDECL bit into this
+ file).
+ * semaphore.h: Put in another idempotentized PTW32_CDECL bit here;
+ use PTW32_CDECL instead of __cdecl, and fixed indentation of function
+ formal parameters.
+
+2012-09-21 Ross Johnson <ross dot johnson at homemail dot com dot au>
+
+ * create.c: Major changes to incorporate CPU affinity inheritance.
+ * pthread_self.c: Likewise.
+ * ptw32_new.c (cpuset): Initialise new pthread_thread_t element.
+ * pthread.h (DWORD_PTR): Conditional definition moved to sched.h.
+ * sched.h (DWORD_PTR): As above; other changes.
+ * sem_post.c: Fix errno handling and restructure.
+ * sem_getvalue.c: Fix return value and restructure.
+
+2012-09-18 Ross Johnson <ross dot johnson at homemail dot com dot au>
+
+ * sched_setaffinity.c: New API to set process CPU affinity in POSIX
+ context; compatibility with Linux.
+ * pthread_setaffinity.c: Likewise.
+ * implement.h (pthread_t_): Added cpuset element.
+ * sched.h: Added new prototypes.
+ * sched.h (cpu_set_t): Support for new process and thread affinity API.
+ * pthread.h: Added new prototypes.
+
+2012-09-16 Ross Johnson <ross dot johnson at homemail dot com dot au>
+
+ * README (Version numbering): Changes back to major.minor.micro.
+ * README.NONPORTABLE: Updated description around process/thread
+ attach/detach routines.
+
+2012-09-05 Daniel Richard. G <danielg at teragram dot com>
+
+ * implement.h: whitespace adjustment.
+ * dll.c: Facilitate PTW32_STATIC_LIB being defined in a header file.
+
+2012-09-04 Ross Johnson <ross dot johnson at homemail dot com dot au>
+
+ * Makefile (VCEFLAGS): Changed from /EHsc to /EHs which fixed a problem
+ in tests/once3.c which was causing it to hang.
+
+2012-09-03 Ross Johnson <ross dot johnson at homemail dot com dot au>
+
+ * Makefile: Remove descriptive info from help target, just list the
+ available targets. Output tends to be poorly formatted and cluttered
+ otherwise.
+ (VCE-static): Add VC++ static build target.
+ (VCE-small-static): Likewise.
+ (VCE-small-static-debug): Likewise.
+ (VCE-small-static-debug): Likewise.
+
+2012-09-02 Ross Johnson <ross dot johnson at homemail dot com dot au>
+
+ * All: correct spelling to 'cancellation'.
+
+2012-08-31 Ross Johnson <ross dot johnson at homemail dot com dot au>
+
+ * pthread_attr_getschedpolicy.c: Remove pedantic arg check.
+ * pthread_getschedparam.c: Likewise.
+ * pthread_mutex_timelock.c: Restructure to address unreached final
+ return statement.
+
+2012-08-31 Daniel Richard. G <danielg at teragram dot com>
+
+ * implement.h (INLINE): only define if building the inlined make targets. G++
+ complained about undefined reference to ptw32_robust_mutex_remove() because it
+ appears in separate compilation units for "make GCE".
+
+2012-08-29 Ross Johnson <ross dot johnson at homemail dot com dot au>
+
+ * ptw32_MCS_lock.c (ptw32_mcs_flag_wait): Fix cast in first 'if' statement.
+ * pthread_mutex_consistent.c (comment): Fix awkward grammar.
+ * pthread_mutexattr_init.c: Initialize robustness element.
+
+2012-08-29 Daniel Richard. G <danielg at teragram dot com>
+
+ * implement.h (PTW32_INTERLOCKED_SIZE): Define as long or LONGLONG.
+ (PTW32_INTERLOCKED_SIZEPTR): Define as long* or LONGLONG*.
+ * pthread_attr_getschedpolicy.c (SCHED_MAX): Fix cast.
+ * ptw32_mutex_check_need_init.c: Fix static mutexattr_t struct initializations.
+ * ptw32_threadStart.c (ExceptionFilter): Add cast.
+ * ptw32_throw.c: Add cast.
+
+2012-08-18 Ross Johnson <ross dot johnson at homemail dot com dot au>
+
+ * pthread_timedjoin_np.c: New non-portable function.
+ * common.mk (pthread_timedjoin_np): Add new function.
+ * nonportable.c (pthread_timedjoin_np): Likewise.
+
+2012-08-16 Daniel Richard. G <danielg at teragram dot com>
+
+ * pthread.h (PTW32_CONFIG_MINGW): Defined to simplify complex macro combination.
+ * (PTW32_CONFIG_MSVC6): Likewise.
+ * (PTW32_CONFIG_MSVC8): Likewise.
+ * autostatic.c: Substitute new macros.
+ * create.c: Likewise.
+ * pthread_cond_wait.c: Likewise.
+ * pthread_exit.c: Likewise.
+ * pthread_once.c: Likewise.
+ * pthread_rwlock_timedwrlock.c: Likewise.
+ * pthread_rwlock_wrlock.c: Likewise.
+ * pthread_win32_attach_detach_np.c: Likewise.
+ * ptw32_relmillisecs.c: Likewise.
+ * ptw32_threadDestroy.c: Likewise.
+ * ptw32_threadStart.c: Likewise.
+ * ptw32_throw.c: Likewise.
+ * sem_timedwait.c: Likewise.
+ * sem_wait.c: Likewise.
+ * implement.h: Likewise.
+ * sched.h: Likewise.
+
+2012-08-11 Ross Johnson <ross dot johnson at homemail dot com dot au>
+
+ * common.mk (default_target): restore previous behaviour of outputing
+ useful help when "make" is run without a target argument.
+
+2012-08-11 Daniel Richard. G <danielg at teragram dot com>
+
+ * autostatic.c (ptw32_autostatic_anchor): new function; other
+ changes aimed at de-abstracting functionality.
+ * impliment.h (ptw32_autostatic_anchor): dummy reference to
+ ensure that autostatic.o is always linked into static applications.
+ * GNUmakefile: Various improvements.
+ * Makefile: Likewise.
+
+2012-03-19 Ross Johnson <ross dot johnson at homemail dot com dot au>
+
+ * implement.h: Fix interlocked pointer casting under VC++ x64.
+
+2012-03-19 Ross Johnson <ross dot johnson at homemail dot com dot au>
+
+ * implement.h (ptw32_spinlock_check_need_init): added missing
+ forward declaration.
+
+2012-07-19 Daniel Richard. G <danielg at teragram dot com>
+
+ * common.mk: New; macros common to all build environment makefiles.
+ * Bmakefile: Include new common.mk
+ * Makefile: Likewise; various fixes; added normal and small objects
+ static build.
+ * GNUmakefile: Likewise.
+
+2012-03-18 Ross Johnson <ross dot johnson at homemail dot com dot au>
+
+ * create.c (pthread_create): add __cdecl attribute to thread routine
+ arg
+ * implement.h (pthread_key_t): add __cdecl attribute to destructor
+ element
+ (ThreadParms): likewise for start element
+ * pthread.h (pthread_create): add __cdecl to prototype start arg
+ (pthread_once): likewise for init_routine arg
+ (pthread_key_create): likewise for destructor arg
+ (ptw32_cleanup_push): replace type of routine arg with previously
+ defined ptw32_cleanup_callback_t
+ * pthread_key_create.c: add __cdecl attribute to destructor arg
+ * pthread_once.c: add __cdecl attribute to init_routine arg
+ * ptw32_threadStart.c (start): add __cdecl to start variable type
+
+
2011-07-06 Ross Johnson <ross dot johnson at homemail dot com dot au>
* pthread_cond_wait.c (pragma inline_depth): this is almost redundant
@@ -345,7 +645,7 @@
2007-01-06 Romano Paolo Tenca <rotenca at telvia dot it>
* pthread_cond_destroy.c: Replace sem_wait() with non-cancelable
- ptw32_semwait() since pthread_cond_destroy() is not a cancelation
+ ptw32_semwait() since pthread_cond_destroy() is not a cancellation
point.
* implement.h (ptw32_spinlock_check_need_init): Add prototype.
* ptw32_MCS_lock.c: Reverse order of includes.
@@ -627,11 +927,11 @@
This uses late initialisation similar to the technique already used for
pthreads-win32 mutexes and semaphores (from Alexander Terekhov).
- The subsequent cancelation cleanup additions (by rpj) could not be implemented
+ The subsequent cancellation cleanup additions (by rpj) could not be implemented
without sacrificing some of the efficiency in Gottlob's design. In particular,
although each once_control uses it's own event to block on, a global CS is
required to manage it - since the event must be either re-usable or
- re-creatable under cancelation. This is not needed in the non-cancelable
+ re-creatable under cancellation. This is not needed in the non-cancelable
design because it is able to mark the event as closed (forever).
When uncontested, a CS operation is equivalent to an Interlocked operation
@@ -746,7 +1046,7 @@
'PThreadStateCancelPending' state as short cut to avoid entering
kernel space via WaitForSingleObject() call. This was obviated
by user space sema acquisition in sem_wait() and sem_timedwait(),
- which are also cancelation points. A call to pthread_testcancel()
+ which are also cancellation points. A call to pthread_testcancel()
was required, which introduced a kernel call, effectively nullifying
any gains made by the user space sem acquisition checks.
* pthread_cancel.c (pthread_cancel): Set new thread
@@ -768,7 +1068,7 @@
being the address of the thread struct. The new pthread_t retains
the reuse stack but provides virtually unique thread IDs.
* sem_wait.c (ptw32_sem_wait_cleanup): New routine used for
- cancelation cleanup.
+ cancellation cleanup.
* sem_timedwait.c (ptw32_sem_timedwait_cleanup): Likewise.
2004-10-22 Ross Johnson <rpj at callisto.canberra.edu.au>
@@ -808,12 +1108,12 @@
keeps it's own counter. Although the motivation to do this has existed
for a long time, credit goes to Alexander Terekhov for providing
the logic. I have deviated slightly from AT's logic to add the waiters
- count, which has made the code more complicated by adding cancelation
+ count, which has made the code more complicated by adding cancellation
cleanup. This also appears to have broken the VCE (C++ EH) version of
the library (the same problem as previously reported - see BUGS #2),
only apparently not fixable using the usual workaround, nor by turning
all optimisation off. The GCE version works fine, so it is presumed to
- be a bug in MSVC++ 6.0. The cancelation exception is thrown and caught
+ be a bug in MSVC++ 6.0. The cancellation exception is thrown and caught
correctly, but the cleanup class destructor is never called. The failing
test is tests\semaphore4.c.
* sem_wait.c (sem_wait): Implemented user space check model.
@@ -1016,15 +1316,15 @@
* pthread_cancel.c (pthread_cancel): Adapted to use auto-detected
QueueUserAPCEx features at run-time.
- (ptw32_RegisterCancelation): Drop in replacement for QueueUserAPCEx()
+ (ptw32_Registercancellation): Drop in replacement for QueueUserAPCEx()
if it can't be used. Provides older style non-preemptive async
- cancelation.
+ cancellation.
* pthread_win32_attach_detach_np.c (pthread_win32_attach_np):
Auto-detect quserex.dll and the availability of alertdrv.sys;
initialise and close on process attach/detach.
- * global.c (ptw32_register_cancelation): Pointer to either
- QueueUserAPCEx() or ptw32_RegisterCancelation() depending on
- availability. QueueUserAPCEx makes pre-emptive async cancelation
+ * global.c (ptw32_register_cancellation): Pointer to either
+ QueueUserAPCEx() or ptw32_Registercancellation() depending on
+ availability. QueueUserAPCEx makes pre-emptive async cancellation
possible.
* implement.h: Add definitions and prototypes related to QueueUserAPC.
@@ -1034,7 +1334,7 @@
APC feature.
* pthread_cancel.c (pthread_cancel): Initial integration of
QueueUserAPCEx into pthreads-win32 to provide true pre-emptive
- async cancelation of threads, including blocked threads.
+ async cancellation of threads, including blocked threads.
2004-05-06 Makoto Kato <raven at oldskool.jp>
@@ -1141,7 +1441,7 @@
2003-09-03 Ross Johnson <rpj at callisto.canberra.edu.au>
- * w32_cancelableWait.c (ptw32_cancelable_wait): Allow cancelation
+ * w32_cancelableWait.c (ptw32_cancelable_wait): Allow cancellation
of implicit POSIX threads as well.
2003-09-02 Ross Johnson <rpj at callisto.canberra.edu.au>
@@ -1557,7 +1857,7 @@
2002-02-07 Alexander Terekhov<TEREKHOV at de.ibm.com>
* nonportable.c (pthread_delay_np): Make a true
- cancelation point. Deferred cancels will interrupt the
+ cancellation point. Deferred cancels will interrupt the
wait.
2002-02-07 Ross Johnson <rpj at setup1.ise.canberra.edu.au
@@ -1666,8 +1966,8 @@
2002-02-02 Ross Johnson <rpj at setup1.ise.canberra.edu.au>
* cancel.c: Rearranged some code and introduced checks
- to disable cancelation at the start of a thread's cancelation
- run to prevent double cancelation. The main problem
+ to disable cancellation at the start of a thread's cancellation
+ run to prevent double cancellation. The main problem
arises if a thread is canceling and then receives a subsequent
async cancel request.
* private.c: Likewise.
@@ -1732,7 +2032,7 @@
* pthread.h: Unless the build explicitly defines __CLEANUP_SEH,
__CLEANUP_CXX, or __CLEANUP_C, then the build defaults to
__CLEANUP_C style cleanup. This style uses setjmp/longjmp
- in the cancelation and thread exit implementations and therefore
+ in the cancellation and thread exit implementations and therefore
won't do stack unwinding if linked to applications that have it
(e.g. C++ apps). This is currently consistent with most/all
commercial Unix POSIX threads implementations.
@@ -1919,7 +2219,7 @@
2001-07-15 Ross Johnson <rpj at setup1.ise.canberra.edu.au>
* rwlock.c (pthread_rwlock_wrlock): Is allowed to be
- a cancelation point; re-enable deferred cancelability
+ a cancellation point; re-enable deferred cancelability
around the CV call.
2001-07-10 Ross Johnson <rpj at setup1.ise.canberra.edu.au>
@@ -1982,8 +2282,8 @@
for this object.
* pthread.h (PTHREAD_BARRIER_INITIALIZER): Removed.
* rwlock.c (pthread_rwlock_wrlock): This routine is
- not a cancelation point - disable deferred
- cancelation around call to pthread_cond_wait().
+ not a cancellation point - disable deferred
+ cancellation around call to pthread_cond_wait().
2001-07-05 Ross Johnson <rpj at setup1.ise.canberra.edu.au>
@@ -2235,7 +2535,7 @@
* (pthread_mutex_lock): Likewise.
* (pthread_mutex_trylock): Likewise.
* (pthread_mutex_unlock): Likewise.
- * Use longjmp/setjmp to implement cancelation when building the library
+ * Use longjmp/setjmp to implement cancellation when building the library
using a C compiler which doesn't support exceptions, e.g. gcc -x c (note
that gcc -x c++ uses exceptions).
* Also fixed some of the same typos and eliminated PT_STDCALL as
@@ -2563,7 +2863,7 @@
* pthread.h: Add compile-time message when using
MSC_VER compiler and C++ EH to warn application
programmers to use PtW32Catch instead of catch(...)
- if they want cancelation and pthread_exit to work.
+ if they want cancellation and pthread_exit to work.
* implement.h: Remove #include <semaphore.h>; we
use our own local semaphore.h.
@@ -2611,7 +2911,7 @@
* pthread.h (PtW32CatchAll): Add macro. When compiling
applications using VC++ with C++ EH rather than SEH
'PtW32CatchAll' must be used in place of any 'catch( ... )'
- if the application wants pthread cancelation or
+ if the application wants pthread cancellation or
pthread_exit() to work.
2000-08-03 Ross Johnson <rpj at special.ise.canberra.edu.au>
@@ -2845,7 +3145,7 @@
1999-11-10 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
- * sync.c (pthread_join): Make it a deferred cancelation point.
+ * sync.c (pthread_join): Make it a deferred cancellation point.
* misc.c (pthread_self): Explicitly initialise implicitly
created thread state to default values.
@@ -4574,7 +4874,7 @@ Sun Jul 26 00:09:59 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
a part of making the eventual pthreads DLL binary compatible
through version changes.
- * condvar.c (cond_wait): Add cancelation point. This applies the
+ * condvar.c (cond_wait): Add cancellation point. This applies the
point to both pthread_cond_wait() and pthread_cond_timedwait().
* exit.c (pthread_exit): Rename "this" to "us".
diff --git a/pthreads/FAQ b/pthreads/FAQ
index d7399c3ef..be19609ce 100644
--- a/pthreads/FAQ
+++ b/pthreads/FAQ
@@ -1,451 +1,451 @@
- =========================================
- PTHREADS-WIN32 Frequently Asked Questions
- =========================================
-
-INDEX
------
-
-Q 1 What is it?
-
-Q 2 Which of the several dll versions do I use?
- or,
- What are all these pthread*.dll and pthread*.lib files?
-
-Q 3 What is the library naming convention?
-
-Q 4 Cleanup code default style or: it used to work when I built
- the library myself, but now it doesn't - why?
-
-Q 5 Why is the default library version now less exception-friendly?
-
-Q 6 Should I use Cygwin or Mingw32 as a development environment?
-
-Q 7 Now that pthreads-win32 builds under Mingw32, why do I get
- memory access violations (segfaults)?
-
-Q 8 How do I use pthread.dll for Win32 (Visual C++ 5.0)
-
-Q 9 Cancelation doesn't work for me, why?
-
-Q 10 How do I generate pthreadGCE.dll and libpthreadw32.a for use
- with Mingw32?
-
-Q 11 Why isn't pthread_t defined as a scalar (e.g. pointer or int)
- like it is for other POSIX threads implementations?
-
-=============================================================================
-
-Q 1 What is it?
----
-
-Pthreads-win32 is an Open Source Software implementation of the
-Threads component of the POSIX 1003.1c 1995 Standard for Microsoft's
-Win32 environment. Some functions from POSIX 1003.1b are also
-supported including semaphores. Other related functions include
-the set of read-write lock functions. The library also supports
-some of the functionality of the Open Group's Single Unix
-specification, version 2, namely mutex types.
-
-See the file "ANNOUNCE" for more information including standards
-conformance details and list of supported routines.
-
-
-------------------------------------------------------------------------------
-
-Q 2 Which of the several dll versions do I use?
---- or,
- What are all these pthread*.dll and pthread*.lib files?
-
-Simply, you only use one of them, but you need to choose carefully.
-
-The most important choice you need to make is whether to use a
-version that uses exceptions internally, or not (there are versions
-of the library that use exceptions as part of the thread
-cancelation and cleanup implementation, and one that uses
-setjmp/longjmp instead).
-
-There is some contension amongst POSIX threads experts as
-to how POSIX threads cancelation and exit should work
-with languages that include exceptions and handlers, e.g.
-C++ and even C (Microsoft's Structured Exceptions).
-
-The issue is: should cancelation of a thread in, say,
-a C++ application cause object destructors and C++ exception
-handlers to be invoked as the stack unwinds during thread
-exit, or not?
-
-There seems to be more opinion in favour of using the
-standard C version of the library (no EH) with C++ applications
-since this appears to be the assumption commercial pthreads
-implementations make. Therefore, if you use an EH version
-of pthreads-win32 then you may be under the illusion that
-your application will be portable, when in fact it is likely to
-behave very differently linked with other pthreads libraries.
-
-Now you may be asking: why have you kept the EH versions of
-the library?
-
-There are a couple of reasons:
-- there is division amongst the experts and so the code may
- be needed in the future. (Yes, it's in the repository and we
- can get it out anytime in the future, but ...)
-- pthreads-win32 is one of the few implementations, and possibly
- the only freely available one, that has EH versions. It may be
- useful to people who want to play with or study application
- behaviour under these conditions.
-
-
-------------------------------------------------------------------------------
-
-Q 3 What is the library naming convention?
----
-
-Because the library is being built using various exception
-handling schemes and compilers - and because the library
-may not work reliably if these are mixed in an application,
-each different version of the library has it's own name.
-
-Note 1: the incompatibility is really between EH implementations
-of the different compilers. It should be possible to use the
-standard C version from either compiler with C++ applications
-built with a different compiler. If you use an EH version of
-the library, then you must use the same compiler for the
-application. This is another complication and dependency that
-can be avoided by using only the standard C library version.
-
-Note 2: if you use a standard C pthread*.dll with a C++
-application, then any functions that you define that are
-intended to be called via pthread_cleanup_push() must be
-__cdecl.
-
-Note 3: the intention is to also name either the VC or GC
-version (it should be arbitrary) as pthread.dll, including
-pthread.lib and libpthread.a as appropriate.
-
-In general:
- pthread[VG]{SE,CE,C}.dll
- pthread[VG]{SE,CE,C}.lib
-
-where:
- [VG] indicates the compiler
- V - MS VC
- G - GNU C
-
- {SE,CE,C} indicates the exception handling scheme
- SE - Structured EH
- CE - C++ EH
- C - no exceptions - uses setjmp/longjmp
-
-For example:
- pthreadVSE.dll (MSVC/SEH)
- pthreadGCE.dll (GNUC/C++ EH)
- pthreadGC.dll (GNUC/not dependent on exceptions)
-
-The GNU library archive file names have changed to:
-
- libpthreadGCE.a
- libpthreadGC.a
-
-
-------------------------------------------------------------------------------
-
-Q 4 Cleanup code default style or: it used to work when I built
---- the library myself, but now it doesn't - why?
-
-Up to and including snapshot 2001-07-12, if not defined, the cleanup
-style was determined automatically from the compiler used, and one
-of the following was defined accordingly:
-
- __CLEANUP_SEH MSVC only
- __CLEANUP_CXX C++, including MSVC++, GNU G++
- __CLEANUP_C C, including GNU GCC, not MSVC
-
-These defines determine the style of cleanup (see pthread.h) and,
-most importantly, the way that cancelation and thread exit (via
-pthread_exit) is performed (see the routine ptw32_throw() in private.c).
-
-In short, the exceptions versions of the library throw an exception
-when a thread is canceled or exits (via pthread_exit()), which is
-caught by a handler in the thread startup routine, so that the
-the correct stack unwinding occurs regardless of where the thread
-is when it's canceled or exits via pthread_exit().
-
-After snapshot 2001-07-12, unless your build explicitly defines (e.g.
-via a compiler option) __CLEANUP_SEH, __CLEANUP_CXX, or __CLEANUP_C, then
-the build now ALWAYS defaults to __CLEANUP_C style cleanup. This style
-uses setjmp/longjmp in the cancelation and pthread_exit implementations,
-and therefore won't do stack unwinding even when linked to applications
-that have it (e.g. C++ apps). This is for consistency with most/all
-commercial Unix POSIX threads implementations.
-
-Although it was not clearly documented before, it is still necessary to
-build your application using the same __CLEANUP_* define as was
-used for the version of the library that you link with, so that the
-correct parts of pthread.h are included. That is, the possible
-defines require the following library versions:
-
- __CLEANUP_SEH pthreadVSE.dll
- __CLEANUP_CXX pthreadVCE.dll or pthreadGCE.dll
- __CLEANUP_C pthreadVC.dll or pthreadGC.dll
-
-THE POINT OF ALL THIS IS: if you have not been defining one of these
-explicitly, then the defaults have been set according to the compiler
-and language you are using, as described at the top of this
-section.
-
-THIS NOW CHANGES, as has been explained above. For example:
-
-If you were building your application with MSVC++ i.e. using C++
-exceptions (rather than SEH) and not explicitly defining one of
-__CLEANUP_*, then __CLEANUP_C++ was defined for you in pthread.h.
-You should have been linking with pthreadVCE.dll, which does
-stack unwinding.
-
-If you now build your application as you had before, pthread.h will now
-set __CLEANUP_C as the default style, and you will need to link
-with pthreadVC.dll. Stack unwinding will now NOT occur when a
-thread is canceled, nor when the thread calls pthread_exit().
-
-Your application will now most likely behave differently to previous
-versions, and in non-obvious ways. Most likely is that local
-objects may not be destroyed or cleaned up after a thread
-is canceled.
-
-If you want the same behaviour as before, then you must now define
-__CLEANUP_C++ explicitly using a compiler option and link with
-pthreadVCE.dll as you did before.
-
-
-------------------------------------------------------------------------------
-
-Q 5 Why is the default library version now less exception-friendly?
----
-
-Because most commercial Unix POSIX threads implementations don't allow you to
-choose to have stack unwinding. (Compaq's TRU64 Unix is possibly an exception.)
-
-Therefore, providing it in pthread-win32 as a default could be dangerous
-and non-portable. We still provide the choice but you must now consciously
-make it.
-
-WHY NOT REMOVE THE EXCEPTIONS VERSIONS OF THE LIBRARY ALTOGETHER?
-There are a few reasons:
-- because there are well respected POSIX threads people who believe
- that POSIX threads implementations should be exceptions-aware and
- do the expected thing in that context. (There are equally respected
- people who believe it should not be easily accessible, if it's there
- at all.)
-- because pthreads-win32 is one of the few implementations that has
- the choice, perhaps the only freely available one, and so offers
- a laboratory to people who may want to explore the effects;
-- although the code will always be around somewhere for anyone who
- wants it, once it's removed from the current version it will not be
- nearly as visible to people who may have a use for it.
-
-
-------------------------------------------------------------------------------
-
-Q 6 Should I use Cygwin or Mingw32 as a development environment?
----
-
-Important: see Q7 also.
-
-Use Mingw32 with the MSVCRT library to build applications that use
-the pthreads DLL.
-
-Cygwin's own internal support for POSIX threads is growing.
-Consult that project's documentation for more information.
-
-------------------------------------------------------------------------------
-
-Q 7 Now that pthreads-win32 builds under Mingw32, why do I get
---- memory access violations (segfaults)?
-
-The latest Mingw32 package has thread-safe exception handling (see Q10).
-Also, see Q6 above.
-
-------------------------------------------------------------------------------
-
-Q 8 How do I use pthread.dll for Win32 (Visual C++ 5.0)
----
-
->
-> I'm a "rookie" when it comes to your pthread implementation. I'm currently
-> desperately trying to install the prebuilt .dll file into my MSVC compiler.
-> Could you please provide me with explicit instructions on how to do this (or
-> direct me to a resource(s) where I can acquire such information)?
->
-> Thank you,
->
-
-You should have a .dll, .lib, .def, and three .h files. It is recommended
-that you use pthreadVC.dll, rather than pthreadVCE.dll or pthreadVSE.dll
-(see Q2 above).
-
-The .dll can go in any directory listed in your PATH environment
-variable, so putting it into C:\WINDOWS should work.
-
-The .lib file can go in any directory listed in your LIB environment
-variable.
-
-The .h files can go in any directory listed in your INCLUDE
-environment variable.
-
-Or you might prefer to put the .lib and .h files into a new directory
-and add its path to LIB and INCLUDE. You can probably do this easiest
-by editing the file:-
-
-C:\Program Files\DevStudio\vc\bin\vcvars32.bat
-
-The .def file isn't used by anything in the pre-compiled version but
-is included for information.
-
-Cheers.
-Ross
-
-------------------------------------------------------------------------------
-
-Q 9 Cancelation doesn't work for me, why?
----
-
-> I'm investigating a problem regarding thread cancelation. The thread I want
-> to cancel has PTHREAD_CANCEL_ASYNCHRONOUS, however, this piece of code
-> blocks on the join():
->
-> if ((retv = Pthread_cancel( recvThread )) == 0)
-> {
-> retv = Pthread_join( recvThread, 0 );
-> }
->
-> Pthread_* are just macro's; they call pthread_*.
->
-> The thread recvThread seems to block on a select() call. It doesn't get
-> cancelled.
->
-> Two questions:
->
-> 1) is this normal behaviour?
->
-> 2) if not, how does the cancel mechanism work? I'm not very familliar to
-> win32 programming, so I don't really understand how the *Event() family of
-> calls work.
-
-The answer to your first question is, normal POSIX behaviour would
-be to asynchronously cancel the thread. However, even that doesn't
-guarantee cancelation as the standard only says it should be
-cancelled as soon as possible.
-
-Snapshot 99-11-02 or earlier only partially supports asynchronous cancellation.
-Snapshots since then simulate async cancelation by poking the address of
-a cancelation routine into the PC of the threads context. This requires
-the thread to be resumed in some way for the cancelation to actually
-proceed. This is not true async cancelation, but it is as close as we've
-been able to get to it.
-
-If the thread you're trying to cancel is blocked (for instance, it could be
-waiting for data from the network), it will only get cancelled when it unblocks
-(when the data arrives). For true pre-emptive cancelation in these cases,
-pthreads-win32 from snapshot 2004-05-16 can automatically recognise and use the
-QueueUserAPCEx package by Panagiotis E. Hadjidoukas. This package is available
-from the pthreads-win32 ftp site and is included in the pthreads-win32
-self-unpacking zip from 2004-05-16 onwards.
-
-Using deferred cancelation would normally be the way to go, however,
-even though the POSIX threads standard lists a number of C library
-functions that are defined as deferred cancelation points, there is
-no hookup between those which are provided by Windows and the
-pthreads-win32 library.
-
-Incidently, it's worth noting for code portability that the older POSIX
-threads standards cancelation point lists didn't include "select" because
-(as I read in Butenhof) it wasn't part of POSIX. However, it does appear in
-the SUSV3.
-
-Effectively, the only mandatory cancelation points that pthreads-win32
-recognises are those the library implements itself, ie.
-
- pthread_testcancel
- pthread_cond_wait
- pthread_cond_timedwait
- pthread_join
- sem_wait
- sem_timedwait
- pthread_delay_np
-
-The following routines from the non-mandatory list in SUSV3 are
-cancelation points in pthreads-win32:
-
- pthread_rwlock_wrlock
- pthread_rwlock_timedwrlock
-
-The following routines from the non-mandatory list in SUSV3 are not
-cancelation points in pthreads-win32:
-
- pthread_rwlock_rdlock
- pthread_rwlock_timedrdlock
-
-Pthreads-win32 also provides two functions that allow you to create
-cancelation points within your application, but only for cases where
-a thread is going to block on a Win32 handle. These are:
-
- pthreadCancelableWait(HANDLE waitHandle) /* Infinite wait */
-
- pthreadCancelableTimedWait(HANDLE waitHandle, DWORD timeout)
-
-------------------------------------------------------------------------------
-
-
-Q 10 How do I create thread-safe applications using
----- pthreadGCE.dll, libpthreadw32.a and Mingw32?
-
-This should not be a problem with recent versions of MinGW32.
-
-For early versions, see Thomas Pfaff's email at:
-http://sources.redhat.com/ml/pthreads-win32/2002/msg00000.html
-------------------------------------------------------------------------------
-
-Q 11 Why isn't pthread_t defined as a scalar (e.g. pointer or int)
- like it is for other POSIX threads implementations?
-----
-
-Originally pthread_t was defined as a pointer (to the opaque pthread_t_
-struct) and later it was changed to a struct containing the original
-pointer plus a sequence counter. This is allowed under both the original
-POSIX Threads Standard and the current Single Unix Specification.
-
-When pthread_t is a simple pointer to a struct some very difficult to
-debug problems arise from the process of freeing and later allocing
-thread structs because new pthread_t handles can acquire the identity of
-previously detached threads. The change to a struct was made, along with
-some changes to their internal managment, in order to guarantee (for
-practical applications) that the pthread_t handle will be unique over the
-life of the running process.
-
-Where application code attempts to compare one pthread_t against another
-directly, a compiler error will be emitted because structs can't be
-compared at that level. This should signal a potentially serious problem
-in the code design, which would go undetected if pthread_t was a scalar.
-
-The POSIX Threading API provides a function named pthread_equal() to
-compare pthread_t thread handles.
-
-Other pthreads implementations, such as Sun's, use an int as the handle
-but do guarantee uniqueness within the process scope. Win32 scalar typed
-thread handles also guarantee uniqueness in system scope. It wasn't clear
-how well the internal management of these handles would scale as the
-number of threads and the fragmentation of the sequence numbering
-increased for applications where thousands or millions of threads are
-created and detached over time. The current management of threads within
-pthreads-win32 using structs for pthread_t, and reusing without ever
-freeing them, reduces the management time overheads to a constant, which
-could be important given that pthreads-win32 threads are built on top of
-Win32 threads and will therefore include that management overhead on top
-of their own. The cost is that the memory resources used for thread
-handles will remain at the peak level until the process exits.
-
-While it may be inconvenient for developers to be forced away from making
-assumptions about the internals of pthread_t, the advantage for the
-future development of pthread-win32, as well as those applications that
-use it and other pthread implementations, is that the library is free to
-change pthread_t internals and management as better methods arise.
-
+ =========================================
+ PTHREADS-WIN32 Frequently Asked Questions
+ =========================================
+
+INDEX
+-----
+
+Q 1 What is it?
+
+Q 2 Which of the several dll versions do I use?
+ or,
+ What are all these pthread*.dll and pthread*.lib files?
+
+Q 3 What is the library naming convention?
+
+Q 4 Cleanup code default style or: it used to work when I built
+ the library myself, but now it doesn't - why?
+
+Q 5 Why is the default library version now less exception-friendly?
+
+Q 6 Should I use Cygwin or Mingw32 as a development environment?
+
+Q 7 Now that pthreads-win32 builds under Mingw32, why do I get
+ memory access violations (segfaults)?
+
+Q 8 How do I use pthread.dll for Win32 (Visual C++ 5.0)
+
+Q 9 cancellation doesn't work for me, why?
+
+Q 10 How do I generate pthreadGCE.dll and libpthreadw32.a for use
+ with Mingw32?
+
+Q 11 Why isn't pthread_t defined as a scalar (e.g. pointer or int)
+ like it is for other POSIX threads implementations?
+
+=============================================================================
+
+Q 1 What is it?
+---
+
+Pthreads-win32 is an Open Source Software implementation of the
+Threads component of the POSIX 1003.1c 1995 Standard for Microsoft's
+Win32 environment. Some functions from POSIX 1003.1b are also
+supported including semaphores. Other related functions include
+the set of read-write lock functions. The library also supports
+some of the functionality of the Open Group's Single Unix
+specification, version 2, namely mutex types.
+
+See the file "ANNOUNCE" for more information including standards
+conformance details and list of supported routines.
+
+
+------------------------------------------------------------------------------
+
+Q 2 Which of the several dll versions do I use?
+--- or,
+ What are all these pthread*.dll and pthread*.lib files?
+
+Simply, you only use one of them, but you need to choose carefully.
+
+The most important choice you need to make is whether to use a
+version that uses exceptions internally, or not (there are versions
+of the library that use exceptions as part of the thread
+cancellation and cleanup implementation, and one that uses
+setjmp/longjmp instead).
+
+There is some contension amongst POSIX threads experts as
+to how POSIX threads cancellation and exit should work
+with languages that include exceptions and handlers, e.g.
+C++ and even C (Microsoft's Structured Exceptions).
+
+The issue is: should cancellation of a thread in, say,
+a C++ application cause object destructors and C++ exception
+handlers to be invoked as the stack unwinds during thread
+exit, or not?
+
+There seems to be more opinion in favour of using the
+standard C version of the library (no EH) with C++ applications
+since this appears to be the assumption commercial pthreads
+implementations make. Therefore, if you use an EH version
+of pthreads-win32 then you may be under the illusion that
+your application will be portable, when in fact it is likely to
+behave very differently linked with other pthreads libraries.
+
+Now you may be asking: why have you kept the EH versions of
+the library?
+
+There are a couple of reasons:
+- there is division amongst the experts and so the code may
+ be needed in the future. (Yes, it's in the repository and we
+ can get it out anytime in the future, but ...)
+- pthreads-win32 is one of the few implementations, and possibly
+ the only freely available one, that has EH versions. It may be
+ useful to people who want to play with or study application
+ behaviour under these conditions.
+
+
+------------------------------------------------------------------------------
+
+Q 3 What is the library naming convention?
+---
+
+Because the library is being built using various exception
+handling schemes and compilers - and because the library
+may not work reliably if these are mixed in an application,
+each different version of the library has it's own name.
+
+Note 1: the incompatibility is really between EH implementations
+of the different compilers. It should be possible to use the
+standard C version from either compiler with C++ applications
+built with a different compiler. If you use an EH version of
+the library, then you must use the same compiler for the
+application. This is another complication and dependency that
+can be avoided by using only the standard C library version.
+
+Note 2: if you use a standard C pthread*.dll with a C++
+application, then any functions that you define that are
+intended to be called via pthread_cleanup_push() must be
+__cdecl.
+
+Note 3: the intention is to also name either the VC or GC
+version (it should be arbitrary) as pthread.dll, including
+pthread.lib and libpthread.a as appropriate.
+
+In general:
+ pthread[VG]{SE,CE,C}.dll
+ pthread[VG]{SE,CE,C}.lib
+
+where:
+ [VG] indicates the compiler
+ V - MS VC
+ G - GNU C
+
+ {SE,CE,C} indicates the exception handling scheme
+ SE - Structured EH
+ CE - C++ EH
+ C - no exceptions - uses setjmp/longjmp
+
+For example:
+ pthreadVSE.dll (MSVC/SEH)
+ pthreadGCE.dll (GNUC/C++ EH)
+ pthreadGC.dll (GNUC/not dependent on exceptions)
+
+The GNU library archive file names have changed to:
+
+ libpthreadGCE.a
+ libpthreadGC.a
+
+
+------------------------------------------------------------------------------
+
+Q 4 Cleanup code default style or: it used to work when I built
+--- the library myself, but now it doesn't - why?
+
+Up to and including snapshot 2001-07-12, if not defined, the cleanup
+style was determined automatically from the compiler used, and one
+of the following was defined accordingly:
+
+ __CLEANUP_SEH MSVC only
+ __CLEANUP_CXX C++, including MSVC++, GNU G++
+ __CLEANUP_C C, including GNU GCC, not MSVC
+
+These defines determine the style of cleanup (see pthread.h) and,
+most importantly, the way that cancellation and thread exit (via
+pthread_exit) is performed (see the routine ptw32_throw() in private.c).
+
+In short, the exceptions versions of the library throw an exception
+when a thread is canceled or exits (via pthread_exit()), which is
+caught by a handler in the thread startup routine, so that the
+the correct stack unwinding occurs regardless of where the thread
+is when it's canceled or exits via pthread_exit().
+
+After snapshot 2001-07-12, unless your build explicitly defines (e.g.
+via a compiler option) __CLEANUP_SEH, __CLEANUP_CXX, or __CLEANUP_C, then
+the build now ALWAYS defaults to __CLEANUP_C style cleanup. This style
+uses setjmp/longjmp in the cancellation and pthread_exit implementations,
+and therefore won't do stack unwinding even when linked to applications
+that have it (e.g. C++ apps). This is for consistency with most/all
+commercial Unix POSIX threads implementations.
+
+Although it was not clearly documented before, it is still necessary to
+build your application using the same __CLEANUP_* define as was
+used for the version of the library that you link with, so that the
+correct parts of pthread.h are included. That is, the possible
+defines require the following library versions:
+
+ __CLEANUP_SEH pthreadVSE.dll
+ __CLEANUP_CXX pthreadVCE.dll or pthreadGCE.dll
+ __CLEANUP_C pthreadVC.dll or pthreadGC.dll
+
+THE POINT OF ALL THIS IS: if you have not been defining one of these
+explicitly, then the defaults have been set according to the compiler
+and language you are using, as described at the top of this
+section.
+
+THIS NOW CHANGES, as has been explained above. For example:
+
+If you were building your application with MSVC++ i.e. using C++
+exceptions (rather than SEH) and not explicitly defining one of
+__CLEANUP_*, then __CLEANUP_C++ was defined for you in pthread.h.
+You should have been linking with pthreadVCE.dll, which does
+stack unwinding.
+
+If you now build your application as you had before, pthread.h will now
+set __CLEANUP_C as the default style, and you will need to link
+with pthreadVC.dll. Stack unwinding will now NOT occur when a
+thread is canceled, nor when the thread calls pthread_exit().
+
+Your application will now most likely behave differently to previous
+versions, and in non-obvious ways. Most likely is that local
+objects may not be destroyed or cleaned up after a thread
+is canceled.
+
+If you want the same behaviour as before, then you must now define
+__CLEANUP_C++ explicitly using a compiler option and link with
+pthreadVCE.dll as you did before.
+
+
+------------------------------------------------------------------------------
+
+Q 5 Why is the default library version now less exception-friendly?
+---
+
+Because most commercial Unix POSIX threads implementations don't allow you to
+choose to have stack unwinding. (Compaq's TRU64 Unix is possibly an exception.)
+
+Therefore, providing it in pthread-win32 as a default could be dangerous
+and non-portable. We still provide the choice but you must now consciously
+make it.
+
+WHY NOT REMOVE THE EXCEPTIONS VERSIONS OF THE LIBRARY ALTOGETHER?
+There are a few reasons:
+- because there are well respected POSIX threads people who believe
+ that POSIX threads implementations should be exceptions-aware and
+ do the expected thing in that context. (There are equally respected
+ people who believe it should not be easily accessible, if it's there
+ at all.)
+- because pthreads-win32 is one of the few implementations that has
+ the choice, perhaps the only freely available one, and so offers
+ a laboratory to people who may want to explore the effects;
+- although the code will always be around somewhere for anyone who
+ wants it, once it's removed from the current version it will not be
+ nearly as visible to people who may have a use for it.
+
+
+------------------------------------------------------------------------------
+
+Q 6 Should I use Cygwin or Mingw32 as a development environment?
+---
+
+Important: see Q7 also.
+
+Use Mingw32 with the MSVCRT library to build applications that use
+the pthreads DLL.
+
+Cygwin's own internal support for POSIX threads is growing.
+Consult that project's documentation for more information.
+
+------------------------------------------------------------------------------
+
+Q 7 Now that pthreads-win32 builds under Mingw32, why do I get
+--- memory access violations (segfaults)?
+
+The latest Mingw32 package has thread-safe exception handling (see Q10).
+Also, see Q6 above.
+
+------------------------------------------------------------------------------
+
+Q 8 How do I use pthread.dll for Win32 (Visual C++ 5.0)
+---
+
+>
+> I'm a "rookie" when it comes to your pthread implementation. I'm currently
+> desperately trying to install the prebuilt .dll file into my MSVC compiler.
+> Could you please provide me with explicit instructions on how to do this (or
+> direct me to a resource(s) where I can acquire such information)?
+>
+> Thank you,
+>
+
+You should have a .dll, .lib, .def, and three .h files. It is recommended
+that you use pthreadVC.dll, rather than pthreadVCE.dll or pthreadVSE.dll
+(see Q2 above).
+
+The .dll can go in any directory listed in your PATH environment
+variable, so putting it into C:\WINDOWS should work.
+
+The .lib file can go in any directory listed in your LIB environment
+variable.
+
+The .h files can go in any directory listed in your INCLUDE
+environment variable.
+
+Or you might prefer to put the .lib and .h files into a new directory
+and add its path to LIB and INCLUDE. You can probably do this easiest
+by editing the file:-
+
+C:\Program Files\DevStudio\vc\bin\vcvars32.bat
+
+The .def file isn't used by anything in the pre-compiled version but
+is included for information.
+
+Cheers.
+Ross
+
+------------------------------------------------------------------------------
+
+Q 9 cancellation doesn't work for me, why?
+---
+
+> I'm investigating a problem regarding thread cancellation. The thread I want
+> to cancel has PTHREAD_CANCEL_ASYNCHRONOUS, however, this piece of code
+> blocks on the join():
+>
+> if ((retv = Pthread_cancel( recvThread )) == 0)
+> {
+> retv = Pthread_join( recvThread, 0 );
+> }
+>
+> Pthread_* are just macro's; they call pthread_*.
+>
+> The thread recvThread seems to block on a select() call. It doesn't get
+> cancelled.
+>
+> Two questions:
+>
+> 1) is this normal behaviour?
+>
+> 2) if not, how does the cancel mechanism work? I'm not very familliar to
+> win32 programming, so I don't really understand how the *Event() family of
+> calls work.
+
+The answer to your first question is, normal POSIX behaviour would
+be to asynchronously cancel the thread. However, even that doesn't
+guarantee cancellation as the standard only says it should be
+cancelled as soon as possible.
+
+Snapshot 99-11-02 or earlier only partially supports asynchronous cancellation.
+Snapshots since then simulate async cancellation by poking the address of
+a cancellation routine into the PC of the threads context. This requires
+the thread to be resumed in some way for the cancellation to actually
+proceed. This is not true async cancellation, but it is as close as we've
+been able to get to it.
+
+If the thread you're trying to cancel is blocked (for instance, it could be
+waiting for data from the network), it will only get cancelled when it unblocks
+(when the data arrives). For true pre-emptive cancellation in these cases,
+pthreads-win32 from snapshot 2004-05-16 can automatically recognise and use the
+QueueUserAPCEx package by Panagiotis E. Hadjidoukas. This package is available
+from the pthreads-win32 ftp site and is included in the pthreads-win32
+self-unpacking zip from 2004-05-16 onwards.
+
+Using deferred cancellation would normally be the way to go, however,
+even though the POSIX threads standard lists a number of C library
+functions that are defined as deferred cancellation points, there is
+no hookup between those which are provided by Windows and the
+pthreads-win32 library.
+
+Incidently, it's worth noting for code portability that the older POSIX
+threads standards cancellation point lists didn't include "select" because
+(as I read in Butenhof) it wasn't part of POSIX. However, it does appear in
+the SUSV3.
+
+Effectively, the only mandatory cancellation points that pthreads-win32
+recognises are those the library implements itself, ie.
+
+ pthread_testcancel
+ pthread_cond_wait
+ pthread_cond_timedwait
+ pthread_join
+ sem_wait
+ sem_timedwait
+ pthread_delay_np
+
+The following routines from the non-mandatory list in SUSV3 are
+cancellation points in pthreads-win32:
+
+ pthread_rwlock_wrlock
+ pthread_rwlock_timedwrlock
+
+The following routines from the non-mandatory list in SUSV3 are not
+cancellation points in pthreads-win32:
+
+ pthread_rwlock_rdlock
+ pthread_rwlock_timedrdlock
+
+Pthreads-win32 also provides two functions that allow you to create
+cancellation points within your application, but only for cases where
+a thread is going to block on a Win32 handle. These are:
+
+ pthreadCancelableWait(HANDLE waitHandle) /* Infinite wait */
+
+ pthreadCancelableTimedWait(HANDLE waitHandle, DWORD timeout)
+
+------------------------------------------------------------------------------
+
+
+Q 10 How do I create thread-safe applications using
+---- pthreadGCE.dll, libpthreadw32.a and Mingw32?
+
+This should not be a problem with recent versions of MinGW32.
+
+For early versions, see Thomas Pfaff's email at:
+http://sources.redhat.com/ml/pthreads-win32/2002/msg00000.html
+------------------------------------------------------------------------------
+
+Q 11 Why isn't pthread_t defined as a scalar (e.g. pointer or int)
+ like it is for other POSIX threads implementations?
+----
+
+Originally pthread_t was defined as a pointer (to the opaque pthread_t_
+struct) and later it was changed to a struct containing the original
+pointer plus a sequence counter. This is allowed under both the original
+POSIX Threads Standard and the current Single Unix Specification.
+
+When pthread_t is a simple pointer to a struct some very difficult to
+debug problems arise from the process of freeing and later allocing
+thread structs because new pthread_t handles can acquire the identity of
+previously detached threads. The change to a struct was made, along with
+some changes to their internal managment, in order to guarantee (for
+practical applications) that the pthread_t handle will be unique over the
+life of the running process.
+
+Where application code attempts to compare one pthread_t against another
+directly, a compiler error will be emitted because structs can't be
+compared at that level. This should signal a potentially serious problem
+in the code design, which would go undetected if pthread_t was a scalar.
+
+The POSIX Threading API provides a function named pthread_equal() to
+compare pthread_t thread handles.
+
+Other pthreads implementations, such as Sun's, use an int as the handle
+but do guarantee uniqueness within the process scope. Win32 scalar typed
+thread handles also guarantee uniqueness in system scope. It wasn't clear
+how well the internal management of these handles would scale as the
+number of threads and the fragmentation of the sequence numbering
+increased for applications where thousands or millions of threads are
+created and detached over time. The current management of threads within
+pthreads-win32 using structs for pthread_t, and reusing without ever
+freeing them, reduces the management time overheads to a constant, which
+could be important given that pthreads-win32 threads are built on top of
+Win32 threads and will therefore include that management overhead on top
+of their own. The cost is that the memory resources used for thread
+handles will remain at the peak level until the process exits.
+
+While it may be inconvenient for developers to be forced away from making
+assumptions about the internals of pthread_t, the advantage for the
+future development of pthread-win32, as well as those applications that
+use it and other pthread implementations, is that the library is free to
+change pthread_t internals and management as better methods arise.
+
diff --git a/pthreads/GNUmakefile b/pthreads/GNUmakefile
index a117dfe51..10ec13c91 100644
--- a/pthreads/GNUmakefile
+++ b/pthreads/GNUmakefile
@@ -3,9 +3,7 @@
#
# Pthreads-win32 - POSIX Threads Library for Win32
# Copyright(C) 1998 John E. Bossom
-# Copyright(C) 1999,2005 Pthreads-win32 contributors
-#
-# Contact Email: rpj@callisto.canberra.edu.au
+# Copyright(C) 1999,2012 Pthreads-win32 contributors
#
# The current list of contributors is contained
# in the file CONTRIBUTORS included with the source
@@ -29,41 +27,83 @@
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
-DLL_VER = 2
-DLL_VERD= $(DLL_VER)d
+DLL_VER = 2$(EXTRAVERSION)
-DEVROOT = C:\PTHREADS
+# See pthread.h and README for the description of version numbering.
+DLL_VERD= $(DLL_VER)d
-DLLDEST = $(DEVROOT)\DLL
-LIBDEST = $(DEVROOT)\DLL
+DESTROOT = ../PTHREADS-BUILT
+DEST_LIB_NAME = libpthread.a
+DLLDEST = $(DESTROOT)/bin
+LIBDEST = $(DESTROOT)/lib
+HDRDEST = $(DESTROOT)/include
# If Running MsysDTK
RM = rm -f
MV = mv -f
CP = cp -f
+MKDIR = mkdir -p
+ECHO = echo
+TESTNDIR = test ! -d
+TESTFILE = test -f
+AND = &&
# If not.
#RM = erase
#MV = rename
#CP = copy
+#MKDIR = mkdir
+#ECHO = echo
+#TESTNDIR = if exist
+#TESTFILE = if exist
+# AND =
# For cross compiling use e.g.
# make CROSS=x86_64-w64-mingw32- clean GC-inlined
CROSS =
-AR = $(CROSS)ar
+AR = $(CROSS)ar
DLLTOOL = $(CROSS)dlltool
CC = $(CROSS)gcc
CXX = $(CROSS)g++
RANLIB = $(CROSS)ranlib
-RC = $(CROSS)windres
-
-OPT = $(CLEANUP) -O3 # -finline-functions -findirect-inlining
-XOPT =
-
-RCFLAGS = --include-dir=.
+RC = $(CROSS)windres
+
+# Build for non-native architecture. E.g. "-m64" "-m32" etc.
+# Not fully tested fully, needs gcc built with "--enable-multilib"
+# Check your "gcc -v" output for the options used to build your gcc.
+# You can set this as a shell variable or on the make comand line.
+# You don't need to uncomment it here unless you want to hardwire
+# a value.
+#ARCH =
+
+ifeq ($(ARCH),-m32)
+RES_TARGET = --target pe-i386
+endif
+ifeq ($(ARCH),-m64)
+RES_TARGET = --target pe-x86-64
+endif
+
+OPT = $(CLEANUP) -O3 # -finline-functions -findirect-inlining
+XOPT =
+
+RCFLAGS = --include-dir=.
+LFLAGS = $(ARCH)
# Uncomment this if config.h defines RETAIN_WSALASTERROR
-#LFLAGS = -lws2_32
+#LFLAGS += -lws2_32
+#
+# Uncomment this next to link the GCC/C++ runtime libraries statically
+# (Be sure to read about these options and their associated caveats
+# at http://gcc.gnu.org/onlinedocs/gcc/Link-Options.html)
+#
+# NOTE 1: Doing this appears to break GCE:pthread_cleanup_*(), which
+# relies on C++ class destructors being called when leaving scope.
+#
+# NOTE 2: If you do this DO NOT distribute your pthreads DLLs with
+# the official filenaming, i.e. pthreadVC2.dll, etc. Instead, change DLL_VER
+# above to "2slgcc" for example, to build "pthreadGC2slgcc.dll", etc.
+#
+#LFLAGS += -static-libgcc -static-libstdc++
# ----------------------------------------------------------------------
# The library can be built with some alternative behaviour to
@@ -96,418 +136,137 @@ RCFLAGS = --include-dir=.
GC_CFLAGS = $(PTW32_FLAGS)
GCE_CFLAGS = $(PTW32_FLAGS) -mthreads
-## Mingw32
-MAKE ?= make
-CFLAGS = $(OPT) $(XOPT) -I. -DHAVE_PTW32_CONFIG_H -Wall
-
-DLL_INLINED_OBJS = \
- pthread.o \
- version.o
-
-# Agregate modules for inlinability
-DLL_OBJS = \
- attr.o \
- barrier.o \
- cancel.o \
- cleanup.o \
- condvar.o \
- create.o \
- dll.o \
- errno.o \
- exit.o \
- fork.o \
- global.o \
- misc.o \
- mutex.o \
- nonportable.o \
- private.o \
- rwlock.o \
- sched.o \
- semaphore.o \
- signal.o \
- spin.o \
- sync.o \
- tsd.o \
- version.o
-
-# Separate modules for minimum size statically linked images
-SMALL_STATIC_OBJS = \
- pthread_attr_init.o \
- pthread_attr_destroy.o \
- pthread_attr_getdetachstate.o \
- pthread_attr_setdetachstate.o \
- pthread_attr_getstackaddr.o \
- pthread_attr_setstackaddr.o \
- pthread_attr_getstacksize.o \
- pthread_attr_setstacksize.o \
- pthread_attr_getscope.o \
- pthread_attr_setscope.o \
- pthread_attr_setschedpolicy.o \
- pthread_attr_getschedpolicy.o \
- pthread_attr_setschedparam.o \
- pthread_attr_getschedparam.o \
- pthread_attr_setinheritsched.o \
- pthread_attr_getinheritsched.o \
- pthread_barrier_init.o \
- pthread_barrier_destroy.o \
- pthread_barrier_wait.o \
- pthread_barrierattr_init.o \
- pthread_barrierattr_destroy.o \
- pthread_barrierattr_setpshared.o \
- pthread_barrierattr_getpshared.o \
- pthread_setcancelstate.o \
- pthread_setcanceltype.o \
- pthread_testcancel.o \
- pthread_cancel.o \
- cleanup.o \
- pthread_condattr_destroy.o \
- pthread_condattr_getpshared.o \
- pthread_condattr_init.o \
- pthread_condattr_setpshared.o \
- pthread_cond_destroy.o \
- pthread_cond_init.o \
- pthread_cond_signal.o \
- pthread_cond_wait.o \
- create.o \
- dll.o \
- autostatic.o \
- errno.o \
- pthread_exit.o \
- fork.o \
- global.o \
- pthread_mutex_init.o \
- pthread_mutex_destroy.o \
- pthread_mutexattr_init.o \
- pthread_mutexattr_destroy.o \
- pthread_mutexattr_getpshared.o \
- pthread_mutexattr_setpshared.o \
- pthread_mutexattr_settype.o \
- pthread_mutexattr_gettype.o \
- pthread_mutexattr_setrobust.o \
- pthread_mutexattr_getrobust.o \
- pthread_mutex_lock.o \
- pthread_mutex_timedlock.o \
- pthread_mutex_unlock.o \
- pthread_mutex_trylock.o \
- pthread_mutex_consistent.o \
- pthread_mutexattr_setkind_np.o \
- pthread_mutexattr_getkind_np.o \
- pthread_getw32threadhandle_np.o \
- pthread_getunique_np.o \
- pthread_delay_np.o \
- pthread_num_processors_np.o \
- pthread_win32_attach_detach_np.o \
- pthread_equal.o \
- pthread_getconcurrency.o \
- pthread_once.o \
- pthread_self.o \
- pthread_setconcurrency.o \
- pthread_rwlock_init.o \
- pthread_rwlock_destroy.o \
- pthread_rwlockattr_init.o \
- pthread_rwlockattr_destroy.o \
- pthread_rwlockattr_getpshared.o \
- pthread_rwlockattr_setpshared.o \
- pthread_rwlock_rdlock.o \
- pthread_rwlock_wrlock.o \
- pthread_rwlock_unlock.o \
- pthread_rwlock_tryrdlock.o \
- pthread_rwlock_trywrlock.o \
- pthread_setschedparam.o \
- pthread_getschedparam.o \
- pthread_timechange_handler_np.o \
- ptw32_is_attr.o \
- ptw32_cond_check_need_init.o \
- ptw32_MCS_lock.o \
- ptw32_mutex_check_need_init.o \
- ptw32_processInitialize.o \
- ptw32_processTerminate.o \
- ptw32_threadStart.o \
- ptw32_threadDestroy.o \
- ptw32_tkAssocCreate.o \
- ptw32_tkAssocDestroy.o \
- ptw32_callUserDestroyRoutines.o \
- ptw32_timespec.o \
- ptw32_throw.o \
- ptw32_getprocessors.o \
- ptw32_calloc.o \
- ptw32_new.o \
- ptw32_reuse.o \
- ptw32_semwait.o \
- ptw32_relmillisecs.o \
- ptw32_rwlock_check_need_init.o \
- sched_get_priority_max.o \
- sched_get_priority_min.o \
- sched_setscheduler.o \
- sched_getscheduler.o \
- sched_yield.o \
- sem_init.o \
- sem_destroy.o \
- sem_trywait.o \
- sem_timedwait.o \
- sem_wait.o \
- sem_post.o \
- sem_post_multiple.o \
- sem_getvalue.o \
- sem_open.o \
- sem_close.o \
- sem_unlink.o \
- signal.o \
- pthread_kill.o \
- ptw32_spinlock_check_need_init.o \
- pthread_spin_init.o \
- pthread_spin_destroy.o \
- pthread_spin_lock.o \
- pthread_spin_unlock.o \
- pthread_spin_trylock.o \
- pthread_detach.o \
- pthread_join.o \
- pthread_key_create.o \
- pthread_key_delete.o \
- pthread_setspecific.o \
- pthread_getspecific.o \
- w32_CancelableWait.o \
- version.o
-
-INCL = \
- config.h \
- implement.h \
- semaphore.h \
- pthread.h \
- need_errno.h
-
-ATTR_SRCS = \
- pthread_attr_init.c \
- pthread_attr_destroy.c \
- pthread_attr_getdetachstate.c \
- pthread_attr_setdetachstate.c \
- pthread_attr_getstackaddr.c \
- pthread_attr_setstackaddr.c \
- pthread_attr_getstacksize.c \
- pthread_attr_setstacksize.c \
- pthread_attr_getscope.c \
- pthread_attr_setscope.c
-
-BARRIER_SRCS = \
- pthread_barrier_init.c \
- pthread_barrier_destroy.c \
- pthread_barrier_wait.c \
- pthread_barrierattr_init.c \
- pthread_barrierattr_destroy.c \
- pthread_barrierattr_setpshared.c \
- pthread_barrierattr_getpshared.c
-
-CANCEL_SRCS = \
- pthread_setcancelstate.c \
- pthread_setcanceltype.c \
- pthread_testcancel.c \
- pthread_cancel.c
-
-CONDVAR_SRCS = \
- ptw32_cond_check_need_init.c \
- pthread_condattr_destroy.c \
- pthread_condattr_getpshared.c \
- pthread_condattr_init.c \
- pthread_condattr_setpshared.c \
- pthread_cond_destroy.c \
- pthread_cond_init.c \
- pthread_cond_signal.c \
- pthread_cond_wait.c
-
-EXIT_SRCS = \
- pthread_exit.c
-
-MISC_SRCS = \
- pthread_equal.c \
- pthread_getconcurrency.c \
- pthread_kill.c \
- pthread_once.c \
- pthread_self.c \
- pthread_setconcurrency.c \
- ptw32_calloc.c \
- ptw32_MCS_lock.c \
- ptw32_new.c \
- ptw32_reuse.c \
- w32_CancelableWait.c
-
-MUTEX_SRCS = \
- ptw32_mutex_check_need_init.c \
- pthread_mutex_init.c \
- pthread_mutex_destroy.c \
- pthread_mutexattr_init.c \
- pthread_mutexattr_destroy.c \
- pthread_mutexattr_getpshared.c \
- pthread_mutexattr_setpshared.c \
- pthread_mutexattr_settype.c \
- pthread_mutexattr_gettype.c \
- pthread_mutexattr_setrobust.c \
- pthread_mutexattr_getrobust.c \
- pthread_mutex_lock.c \
- pthread_mutex_timedlock.c \
- pthread_mutex_unlock.c \
- pthread_mutex_trylock.c \
- pthread_mutex_consistent.c
-
-NONPORTABLE_SRCS = \
- pthread_mutexattr_setkind_np.c \
- pthread_mutexattr_getkind_np.c \
- pthread_getw32threadhandle_np.c \
- pthread_getunique_np.c \
- pthread_delay_np.c \
- pthread_num_processors_np.c \
- pthread_win32_attach_detach_np.c \
- pthread_timechange_handler_np.c
-
-PRIVATE_SRCS = \
- ptw32_is_attr.c \
- ptw32_processInitialize.c \
- ptw32_processTerminate.c \
- ptw32_threadStart.c \
- ptw32_threadDestroy.c \
- ptw32_tkAssocCreate.c \
- ptw32_tkAssocDestroy.c \
- ptw32_callUserDestroyRoutines.c \
- ptw32_semwait.c \
- ptw32_relmillisecs.c \
- ptw32_timespec.c \
- ptw32_throw.c \
- ptw32_getprocessors.c
-
-RWLOCK_SRCS = \
- ptw32_rwlock_check_need_init.c \
- ptw32_rwlock_cancelwrwait.c \
- pthread_rwlock_init.c \
- pthread_rwlock_destroy.c \
- pthread_rwlockattr_init.c \
- pthread_rwlockattr_destroy.c \
- pthread_rwlockattr_getpshared.c \
- pthread_rwlockattr_setpshared.c \
- pthread_rwlock_rdlock.c \
- pthread_rwlock_timedrdlock.c \
- pthread_rwlock_wrlock.c \
- pthread_rwlock_timedwrlock.c \
- pthread_rwlock_unlock.c \
- pthread_rwlock_tryrdlock.c \
- pthread_rwlock_trywrlock.c
-
-SCHED_SRCS = \
- pthread_attr_setschedpolicy.c \
- pthread_attr_getschedpolicy.c \
- pthread_attr_setschedparam.c \
- pthread_attr_getschedparam.c \
- pthread_attr_setinheritsched.c \
- pthread_attr_getinheritsched.c \
- pthread_setschedparam.c \
- pthread_getschedparam.c \
- sched_get_priority_max.c \
- sched_get_priority_min.c \
- sched_setscheduler.c \
- sched_getscheduler.c \
- sched_yield.c
-
-SEMAPHORE_SRCS = \
- sem_init.c \
- sem_destroy.c \
- sem_trywait.c \
- sem_timedwait.c \
- sem_wait.c \
- sem_post.c \
- sem_post_multiple.c \
- sem_getvalue.c \
- sem_open.c \
- sem_close.c \
- sem_unlink.c
-
-SPIN_SRCS = \
- ptw32_spinlock_check_need_init.c \
- pthread_spin_init.c \
- pthread_spin_destroy.c \
- pthread_spin_lock.c \
- pthread_spin_unlock.c \
- pthread_spin_trylock.c
-
-SYNC_SRCS = \
- pthread_detach.c \
- pthread_join.c
-
-TSD_SRCS = \
- pthread_key_create.c \
- pthread_key_delete.c \
- pthread_setspecific.c \
- pthread_getspecific.c
+## Mingw
+#MAKE ?= make
+CFLAGS = $(OPT) $(XOPT) $(ARCH) -I. -DHAVE_CONFIG_H -Wall
+OBJEXT = o
+RESEXT = o
+
+include common.mk
+
+DLL_OBJS += $(RESOURCE_OBJS)
+STATIC_OBJS += $(RESOURCE_OBJS)
GCE_DLL = pthreadGCE$(DLL_VER).dll
GCED_DLL= pthreadGCE$(DLL_VERD).dll
GCE_LIB = libpthreadGCE$(DLL_VER).a
GCED_LIB= libpthreadGCE$(DLL_VERD).a
-GCE_INLINED_STAMP = pthreadGCE$(DLL_VER).stamp
-GCED_INLINED_STAMP = pthreadGCE$(DLL_VERD).stamp
-GCE_STATIC_STAMP = libpthreadGCE$(DLL_VER).stamp
-GCED_STATIC_STAMP = libpthreadGCE$(DLL_VERD).stamp
GC_DLL = pthreadGC$(DLL_VER).dll
GCD_DLL = pthreadGC$(DLL_VERD).dll
GC_LIB = libpthreadGC$(DLL_VER).a
GCD_LIB = libpthreadGC$(DLL_VERD).a
-GC_INLINED_STAMP = pthreadGC$(DLL_VER).stamp
-GCD_INLINED_STAMP = pthreadGC$(DLL_VERD).stamp
-GC_STATIC_STAMP = libpthreadGC$(DLL_VER).stamp
-GCD_STATIC_STAMP = libpthreadGC$(DLL_VERD).stamp
+GC_INLINED_STATIC_STAMP = libpthreadGC$(DLL_VER).inlined_static_stamp
+GCD_INLINED_STATIC_STAMP = libpthreadGC$(DLL_VERD).inlined_static_stamp
+GCE_INLINED_STATIC_STAMP = libpthreadGCE$(DLL_VER).inlined_static_stamp
+GCED_INLINED_STATIC_STAMP = libpthreadGCE$(DLL_VERD).inlined_static_stamp
+GC_SMALL_STATIC_STAMP = libpthreadGC$(DLL_VER).small_static_stamp
+GCD_SMALL_STATIC_STAMP = libpthreadGC$(DLL_VERD).small_static_stamp
+GCE_SMALL_STATIC_STAMP = libpthreadGCE$(DLL_VER).small_static_stamp
+GCED_SMALL_STATIC_STAMP = libpthreadGCE$(DLL_VERD).small_static_stamp
PTHREAD_DEF = pthread.def
help:
@ echo "Run one of the following command lines:"
- @ echo "make clean GC (to build the GNU C dll with C cleanup code)"
- @ echo "make clean GCE (to build the GNU C dll with C++ exception handling)"
- @ echo "make clean GC-inlined (to build the GNU C inlined dll with C cleanup code)"
- @ echo "make clean GCE-inlined (to build the GNU C inlined dll with C++ exception handling)"
- @ echo "make clean GC-static (to build the GNU C inlined static lib with C cleanup code)"
- @ echo "make clean GC-debug (to build the GNU C debug dll with C cleanup code)"
- @ echo "make clean GCE-debug (to build the GNU C debug dll with C++ exception handling)"
- @ echo "make clean GC-inlined-debug (to build the GNU C inlined debug dll with C cleanup code)"
- @ echo "make clean GCE-inlined-debug (to build the GNU C inlined debug dll with C++ exception handling)"
- @ echo "make clean GC-static-debug (to build the GNU C inlined static debug lib with C cleanup code)"
+ @ echo "$(MAKE) clean GC (to build the GNU C dll with C cleanup code)"
+ @ echo "$(MAKE) clean GC-debug (to build the GNU C debug dll with C cleanup code)"
+ @ echo "$(MAKE) clean GCE (to build the GNU C dll with C++ exception handling)"
+ @ echo "$(MAKE) clean GCE-debug (to build the GNU C debug dll with C++ exception handling)"
+ @ echo "$(MAKE) clean GC-static (to build the GNU C static lib with C cleanup code)"
+ @ echo "$(MAKE) clean GC-static-debug (to build the GNU C static debug lib with C cleanup code)"
+ @ echo "$(MAKE) clean GCE-static (to build the GNU C++ static lib with C++ cleanup code)"
+ @ echo "$(MAKE) clean GCE-static-debug (to build the GNU C++ static debug lib with C++ cleanup code)"
+ @ echo "$(MAKE) clean GC-small-static (to build the GNU C static lib with C cleanup code)"
+ @ echo "$(MAKE) clean GC-small-static-debug (to build the GNU C static debug lib with C cleanup code)"
+ @ echo "$(MAKE) clean GCE-small-static (to build the GNU C++ static lib with C++ cleanup code)"
+ @ echo "$(MAKE) clean GCE-small-static-debug (to build the GNU C++ static debug lib with C++ cleanup code)"
all:
- @ $(MAKE) clean GCE
@ $(MAKE) clean GC
+ @ $(MAKE) clean GCE
+ @ $(MAKE) clean GC-static
+ @ $(MAKE) clean GCE-static
+
+TEST_ENV = PTW32_FLAGS="$(PTW32_FLAGS) -DNO_ERROR_DIALOGS" DLL_VER=$(DLL_VER) ARCH="$(ARCH)"
+
+all-tests:
+ $(MAKE) realclean GC-small-static
+ cd tests && $(MAKE) clean GC-small-static $(TEST_ENV) && $(MAKE) clean GCX-small-static $(TEST_ENV)
+ $(MAKE) realclean GCE-small-static
+ cd tests && $(MAKE) clean GCE-small-static $(TEST_ENV)
+ @ $(ECHO) "$@ completed successfully."
+ $(MAKE) realclean GC
+ cd tests && $(MAKE) clean GC $(TEST_ENV) && $(MAKE) clean GCX $(TEST_ENV)
+ $(MAKE) realclean GCE
+ cd tests && $(MAKE) clean GCE $(TEST_ENV)
+ $(MAKE) realclean GC-static
+ cd tests && $(MAKE) clean GC-static $(TEST_ENV) && $(MAKE) clean GCX-static $(TEST_ENV)
+ $(MAKE) realclean GCE-static
+ cd tests && $(MAKE) clean GCE-static $(TEST_ENV)
+ $(MAKE) realclean
+
+all-tests-cflags:
+ $(MAKE) all-tests PTW32_FLAGS="-Wall -Wextra"
+ @ $(ECHO) "$@ completed successfully."
GC:
- $(MAKE) CLEANUP=-D__CLEANUP_C XC_FLAGS="$(GC_CFLAGS)" OBJ="$(DLL_OBJS)" $(GC_DLL)
+ $(MAKE) XOPT="-DPTW32_BUILD_INLINED" CLEANUP=-D__CLEANUP_C XC_FLAGS="$(GC_CFLAGS)" OBJ="$(DLL_OBJS)" $(GC_DLL)
GC-debug:
- $(MAKE) CLEANUP=-D__CLEANUP_C XC_FLAGS="$(GC_CFLAGS)" OBJ="$(DLL_OBJS)" DLL_VER=$(DLL_VERD) OPT="-D__CLEANUP_C -g -O0" $(GCD_DLL)
+ $(MAKE) XOPT="-DPTW32_BUILD_INLINED" CLEANUP=-D__CLEANUP_C XC_FLAGS="$(GC_CFLAGS)" OBJ="$(DLL_OBJS)" DLL_VER=$(DLL_VERD) OPT="-D__CLEANUP_C -g -O0" $(GCD_DLL)
GCE:
- $(MAKE) CC=$(CXX) CLEANUP=-D__CLEANUP_CXX XC_FLAGS="$(GCE_CFLAGS)" OBJ="$(DLL_OBJS)" $(GCE_DLL)
+ $(MAKE) XOPT="-DPTW32_BUILD_INLINED" CC=$(CXX) CLEANUP=-D__CLEANUP_CXX XC_FLAGS="$(GCE_CFLAGS)" OBJ="$(DLL_OBJS)" $(GCE_DLL)
GCE-debug:
- $(MAKE) CC=$(CXX) CLEANUP=-D__CLEANUP_CXX XC_FLAGS="$(GCE_CFLAGS)" OBJ="$(DLL_OBJS)" DLL_VER=$(DLL_VERD) OPT="-D__CLEANUP_CXX -g -O0" $(GCED_DLL)
+ $(MAKE) XOPT="-DPTW32_BUILD_INLINED" CC=$(CXX) CLEANUP=-D__CLEANUP_CXX XC_FLAGS="$(GCE_CFLAGS)" OBJ="$(DLL_OBJS)" DLL_VER=$(DLL_VERD) OPT="-D__CLEANUP_CXX -g -O0" $(GCED_DLL)
+
+GC-static:
+ $(MAKE) XOPT="-DPTW32_BUILD_INLINED -DPTW32_STATIC_LIB" CLEANUP=-D__CLEANUP_C XC_FLAGS="$(GC_CFLAGS)" OBJ="$(DLL_OBJS)" $(GC_INLINED_STATIC_STAMP)
-GC-inlined:
- $(MAKE) XOPT="-DPTW32_BUILD_INLINED" CLEANUP=-D__CLEANUP_C XC_FLAGS="$(GC_CFLAGS)" OBJ="$(DLL_INLINED_OBJS)" $(GC_INLINED_STAMP)
+GC-static-debug:
+ $(MAKE) XOPT="-DPTW32_BUILD_INLINED -DPTW32_STATIC_LIB" CLEANUP=-D__CLEANUP_C XC_FLAGS="$(GC_CFLAGS)" OBJ="$(DLL_OBJS)" DLL_VER=$(DLL_VERD) OPT="-D__CLEANUP_C -g -O0" $(GCD_INLINED_STATIC_STAMP)
-GC-inlined-debug:
- $(MAKE) XOPT="-DPTW32_BUILD_INLINED" CLEANUP=-D__CLEANUP_C XC_FLAGS="$(GC_CFLAGS)" OBJ="$(DLL_INLINED_OBJS)" DLL_VER=$(DLL_VERD) OPT="-D__CLEANUP_C -g -O0" $(GCD_INLINED_STAMP)
+GC-small-static:
+ $(MAKE) XOPT="-DPTW32_STATIC_LIB" CLEANUP=-D__CLEANUP_C XC_FLAGS="$(GC_CFLAGS)" OBJ="$(STATIC_OBJS)" $(GC_SMALL_STATIC_STAMP)
-GCE-inlined:
- $(MAKE) CC=$(CXX) XOPT="-DPTW32_BUILD_INLINED" CLEANUP=-D__CLEANUP_CXX XC_FLAGS="$(GCE_CFLAGS)" OBJ="$(DLL_INLINED_OBJS)" $(GCE_INLINED_STAMP)
+GC-small-static-debug:
+ $(MAKE) XOPT="-DPTW32_STATIC_LIB" CLEANUP=-D__CLEANUP_C XC_FLAGS="$(GC_CFLAGS)" OBJ="$(STATIC_OBJS)" DLL_VER=$(DLL_VERD) OPT="-D__CLEANUP_C -g -O0" $(GCD_SMALL_STATIC_STAMP)
-GCE-inlined-debug:
- $(MAKE) CC=$(CXX) XOPT="-DPTW32_BUILD_INLINED" CLEANUP=-D__CLEANUP_CXX XC_FLAGS="$(GCE_CFLAGS)" OBJ="$(DLL_INLINED_OBJS)" DLL_VER=$(DLL_VERD) OPT="-D__CLEANUP_CXX -g -O0" $(GCED_INLINED_STAMP)
+GCE-static:
+ $(MAKE) XOPT="-DPTW32_BUILD_INLINED -DPTW32_STATIC_LIB" CC=$(CXX) CLEANUP=-D__CLEANUP_CXX XC_FLAGS="$(GCE_CFLAGS)" OBJ="$(DLL_OBJS)" $(GCE_INLINED_STATIC_STAMP)
-GC-static:
- $(MAKE) XOPT="-DPTW32_BUILD_INLINED -DPTW32_STATIC_LIB" CLEANUP=-D__CLEANUP_C XC_FLAGS="$(GC_CFLAGS)" OBJ="$(DLL_INLINED_OBJS)" $(GC_STATIC_STAMP)
+GCE-static-debug:
+ $(MAKE) XOPT="-DPTW32_BUILD_INLINED -DPTW32_STATIC_LIB" CC=$(CXX) CLEANUP=-D__CLEANUP_CXX XC_FLAGS="$(GCE_CFLAGS)" OBJ="$(DLL_OBJS)" DLL_VER=$(DLL_VERD) OPT="-D__CLEANUP_C -g -O0" $(GCED_INLINED_STATIC_STAMP)
-GC-static-debug:
- $(MAKE) XOPT="-DPTW32_BUILD_INLINED -DPTW32_STATIC_LIB" CLEANUP=-D__CLEANUP_C XC_FLAGS="$(GC_CFLAGS)" OBJ="$(DLL_INLINED_OBJS)" DLL_VER=$(DLL_VERD) OPT="-D__CLEANUP_C -g -O0" $(GCD_STATIC_STAMP)
+GCE-small-static:
+ $(MAKE) XOPT="-DPTW32_STATIC_LIB" CC=$(CXX) CLEANUP=-D__CLEANUP_CXX XC_FLAGS="$(GCE_CFLAGS)" OBJ="$(STATIC_OBJS)" $(GCE_SMALL_STATIC_STAMP)
+
+GCE-small-static-debug:
+ $(MAKE) XOPT="-DPTW32_STATIC_LIB" CC=$(CXX) CLEANUP=-D__CLEANUP_CXX XC_FLAGS="$(GCE_CFLAGS)" OBJ="$(STATIC_OBJS)" DLL_VER=$(DLL_VERD) OPT="-D__CLEANUP_C -g -O0" $(GCED_SMALL_STATIC_STAMP)
tests:
@ cd tests
@ $(MAKE) auto
+# Very basic install. It assumes "realclean" was done just prior to build target if
+# you want the installed $(DEVDEST_LIB_NAME) to match that build.
+install:
+ -$(TESTNDIR) $(DLLDEST) $(AND) $(MKDIR) $(DLLDEST)
+ -$(TESTNDIR) $(LIBDEST) $(AND) $(MKDIR) $(LIBDEST)
+ -$(TESTNDIR) $(HDRDEST) $(AND) $(MKDIR) $(HDRDEST)
+ $(CP) pthreadGC*.dll $(DLLDEST)
+ $(CP) libpthreadGC*.a $(LIBDEST)
+ $(CP) pthread.h $(HDRDEST)
+ $(CP) sched.h $(HDRDEST)
+ $(CP) semaphore.h $(HDRDEST)
+ -$(TESTFILE) libpthreadGC$(DLL_VER).a $(AND) $(CP) libpthreadGC$(DLL_VER).a $(LIBDEST)/$(DEST_LIB_NAME)
+ -$(TESTFILE) libpthreadGC$(DLL_VERD).a $(AND) $(CP) libpthreadGC$(DLL_VERD).a $(LIBDEST)/$(DEST_LIB_NAME)
+ -$(TESTFILE) libpthreadGCE$(DLL_VER).a $(AND) $(CP) libpthreadGCE$(DLL_VER).a $(LIBDEST)/$(DEST_LIB_NAME)
+ -$(TESTFILE) libpthreadGCE$(DLL_VERD).a $(AND) $(CP) libpthreadGCE$(DLL_VERD).a $(LIBDEST)/$(DEST_LIB_NAME)
+
%.pre: %.c
$(CC) -E -o $@ $(CFLAGS) $^
@@ -515,7 +274,7 @@ tests:
$(CC) -c $(CFLAGS) -DPTW32_BUILD_INLINED -Wa,-ahl $^ > $@
%.o: %.rc
- $(RC) $(RCFLAGS) $(CLEANUP) -o $@ $<
+ $(RC) $(RES_TARGET) $(RCFLAGS) $(CLEANUP) -o $@ -i $<
.SUFFIXES: .dll .rc .c .o
@@ -523,32 +282,24 @@ tests:
$(GC_DLL) $(GCD_DLL): $(DLL_OBJS)
- $(CC) $(OPT) -shared -o $(GC_DLL) $(DLL_OBJS) $(LFLAGS)
- $(DLLTOOL) -z pthread.def $(DLL_OBJS)
- $(DLLTOOL) -k --dllname $@ --output-lib $(GC_LIB) --def $(PTHREAD_DEF)
-
-$(GCE_DLL): $(DLL_OBJS)
- $(CC) $(OPT) -mthreads -shared -o $(GCE_DLL) $(DLL_OBJS) $(LFLAGS)
- $(DLLTOOL) -z pthread.def $(DLL_OBJS)
- $(DLLTOOL) -k --dllname $@ --output-lib $(GCE_LIB) --def $(PTHREAD_DEF)
-
-$(GC_INLINED_STAMP) $(GCD_INLINED_STAMP): $(DLL_INLINED_OBJS)
- $(CC) $(OPT) $(XOPT) -shared -o $(GC_DLL) $(DLL_INLINED_OBJS) $(LFLAGS)
- $(DLLTOOL) -z pthread.def $(DLL_INLINED_OBJS)
- $(DLLTOOL) -k --dllname $(GC_DLL) --output-lib $(GC_LIB) --def $(PTHREAD_DEF)
- echo touched > $(GC_INLINED_STAMP)
-
-$(GCE_INLINED_STAMP) $(GCED_INLINED_STAMP): $(DLL_INLINED_OBJS)
- $(CC) $(OPT) $(XOPT) -mthreads -shared -o $(GCE_DLL) $(DLL_INLINED_OBJS) $(LFLAGS)
- $(DLLTOOL) -z pthread.def $(DLL_INLINED_OBJS)
- $(DLLTOOL) -k --dllname $(GCE_DLL) --output-lib $(GCE_LIB) --def $(PTHREAD_DEF)
- echo touched > $(GCE_INLINED_STAMP)
-
-$(GC_STATIC_STAMP) $(GCD_STATIC_STAMP): $(DLL_INLINED_OBJS)
- $(RM) $(GC_LIB)
- $(AR) -rv $(GC_LIB) $(DLL_INLINED_OBJS)
- $(RANLIB) $(GC_LIB)
- echo touched > $(GC_STATIC_STAMP)
+ $(CC) $(OPT) -shared -o $@ $^ $(LFLAGS)
+ $(DLLTOOL) -z pthread.def $^
+ $(DLLTOOL) -k --dllname $@ --output-lib lib$(basename $@).a --def $(PTHREAD_DEF)
+
+$(GCE_DLL) $(GCED_DLL): $(DLL_OBJS)
+ $(CC) $(OPT) -mthreads -shared -o $@ $^ $(LFLAGS)
+ $(DLLTOOL) -z pthread.def $^
+ $(DLLTOOL) -k --dllname $@ --output-lib lib$(basename $@).a --def $(PTHREAD_DEF)
+
+$(GC_INLINED_STATIC_STAMP) $(GCE_INLINED_STATIC_STAMP) $(GCD_INLINED_STATIC_STAMP) $(GCED_INLINED_STATIC_STAMP): $(DLL_OBJS)
+ $(RM) $(basename $@).a
+ $(AR) -rsv $(basename $@).a $^
+ $(ECHO) touched > $@
+
+$(GC_SMALL_STATIC_STAMP) $(GCE_SMALL_STATIC_STAMP) $(GCD_SMALL_STATIC_STAMP) $(GCED_SMALL_STATIC_STAMP): $(STATIC_OBJS)
+ $(RM) $(basename $@).a
+ $(AR) -rsv $(basename $@).a $^
+ $(ECHO) touched > $@
clean:
-$(RM) *~
@@ -557,37 +308,35 @@ clean:
-$(RM) *.o
-$(RM) *.obj
-$(RM) *.exe
+ -$(RM) *.manifest
-$(RM) $(PTHREAD_DEF)
realclean: clean
- -$(RM) $(GC_LIB)
- -$(RM) $(GCE_LIB)
- -$(RM) $(GC_DLL)
- -$(RM) $(GCE_DLL)
- -$(RM) $(GC_INLINED_STAMP)
- -$(RM) $(GCE_INLINED_STAMP)
- -$(RM) $(GC_STATIC_STAMP)
- -$(RM) $(GCD_LIB)
- -$(RM) $(GCED_LIB)
- -$(RM) $(GCD_DLL)
- -$(RM) $(GCED_DLL)
- -$(RM) $(GCD_INLINED_STAMP)
- -$(RM) $(GCED_INLINED_STAMP)
- -$(RM) $(GCD_STATIC_STAMP)
-
-attr.o: attr.c $(ATTR_SRCS) $(INCL)
-barrier.o: barrier.c $(BARRIER_SRCS) $(INCL)
-cancel.o: cancel.c $(CANCEL_SRCS) $(INCL)
-condvar.o: condvar.c $(CONDVAR_SRCS) $(INCL)
-exit.o: exit.c $(EXIT_SRCS) $(INCL)
-misc.o: misc.c $(MISC_SRCS) $(INCL)
-mutex.o: mutex.c $(MUTEX_SRCS) $(INCL)
-nonportable.o: nonportable.c $(NONPORTABLE_SRCS) $(INCL)
-private.o: private.c $(PRIVATE_SRCS) $(INCL)
-rwlock.o: rwlock.c $(RWLOCK_SRCS) $(INCL)
-sched.o: sched.c $(SCHED_SRCS) $(INCL)
-semaphore.o: semaphore.c $(SEMAPHORE_SRCS) $(INCL)
-spin.o: spin.c $(SPIN_SRCS) $(INCL)
-sync.o: sync.c $(SYNC_SRCS) $(INCL)
-tsd.o: tsd.c $(TSD_SRCS) $(INCL)
-version.o: version.rc $(INCL)
+ -$(RM) lib*.a
+ -$(RM) *.lib
+ -$(RM) pthread*.dll
+ -$(RM) *_stamp
+ -cd tests && $(MAKE) clean
+
+var_check_list =
+
+define var_check_target
+var-check-$(1):
+ @for src in $($(1)); do \
+ fgrep -q "\"$$$$src\"" $(2) && continue; \
+ echo "$$$$src is in \$$$$($(1)), but not in $(2)"; \
+ exit 1; \
+ done
+ @grep '^# *include *".*\.c"' $(2) | cut -d'"' -f2 | while read src; do \
+ echo " $($(1)) " | fgrep -q " $$$$src " && continue; \
+ echo "$$$$src is in $(2), but not in \$$$$($(1))"; \
+ exit 1; \
+ done
+ @echo "$(1) <-> $(2): OK"
+
+var_check_list += var-check-$(1)
+endef
+
+$(eval $(call var_check_target,PTHREAD_SRCS,pthread.c))
+
+srcs-vars-check: $(var_check_list)
diff --git a/pthreads/Makefile b/pthreads/Makefile
index f1789976f..e13341751 100644
--- a/pthreads/Makefile
+++ b/pthreads/Makefile
@@ -1,31 +1,31 @@
-# This makefile is compatible with MS nmake and can be used as a
-# replacement for buildlib.bat. I've changed the target from an ordinary dll
-# (/LD) to a debugging dll (/LDd).
+# This makefile is compatible with MS nmake
#
# The variables $DLLDEST and $LIBDEST hold the destination directories for the
# dll and the lib, respectively. Probably all that needs to change is $DEVROOT.
-
# DLL_VER:
-# See pthread.h and README - This number is computed as 'current - age'
-DLL_VER = 2
+# See pthread.h and README for the description of version numbering.
+DLL_VER = 2$(EXTRAVERSION)
DLL_VERD= $(DLL_VER)d
-DEVROOT = C:\pthreads
+DESTROOT = ..\PTHREADS-BUILT
+DEST_LIB_NAME = pthread.lib
-DLLDEST = $(DEVROOT)\dll
-LIBDEST = $(DEVROOT)\lib
-HDRDEST = $(DEVROOT)\include
+DLLDEST = $(DESTROOT)\bin
+LIBDEST = $(DESTROOT)\lib
+HDRDEST = $(DESTROOT)\include
-DLLS = pthreadVCE$(DLL_VER).dll pthreadVSE$(DLL_VER).dll pthreadVC$(DLL_VER).dll \
- pthreadVCE$(DLL_VERD).dll pthreadVSE$(DLL_VERD).dll pthreadVC$(DLL_VERD).dll
-INLINED_STAMPS = pthreadVCE$(DLL_VER).stamp pthreadVSE$(DLL_VER).stamp pthreadVC$(DLL_VER).stamp \
- pthreadVCE$(DLL_VERD).stamp pthreadVSE$(DLL_VERD).stamp pthreadVC$(DLL_VERD).stamp
-STATIC_STAMPS = pthreadVCE$(DLL_VER).static pthreadVSE$(DLL_VER).static pthreadVC$(DLL_VER).static \
- pthreadVCE$(DLL_VERD).static pthreadVSE$(DLL_VERD).static pthreadVC$(DLL_VERD).static
+DLLS = pthreadVCE$(DLL_VER).dll pthreadVSE$(DLL_VER).dll pthreadVC$(DLL_VER).dll \
+ pthreadVCE$(DLL_VERD).dll pthreadVSE$(DLL_VERD).dll pthreadVC$(DLL_VERD).dll
+INLINED_STATIC_STAMPS = pthreadVCE$(DLL_VER).inlined_static_stamp pthreadVSE$(DLL_VER).inlined_static_stamp \
+ pthreadVC$(DLL_VER).inlined_static_stamp pthreadVCE$(DLL_VERD).inlined_static_stamp \
+ pthreadVSE$(DLL_VERD).inlined_static_stamp pthreadVC$(DLL_VERD).inlined_static_stamp
+SMALL_STATIC_STAMPS = pthreadVCE$(DLL_VER).small_static_stamp pthreadVSE$(DLL_VER).small_static_stamp \
+ pthreadVC$(DLL_VER).small_static_stamp pthreadVCE$(DLL_VERD).small_static_stamp \
+ pthreadVSE$(DLL_VERD).small_static_stamp pthreadVC$(DLL_VERD).small_static_stamp
CC = cl
-CPPFLAGS = /I. /DHAVE_PTW32_CONFIG_H
+CPPFLAGS = /I. /DHAVE_CONFIG_H
XCFLAGS = /W3 /MD /nologo
CFLAGS = /O2 /Ob2 $(XCFLAGS)
CFLAGSD = /Z7 $(XCFLAGS)
@@ -37,8 +37,10 @@ CFLAGSD = /Z7 $(XCFLAGS)
CLEANUP = __CLEANUP_C
# C++ Exceptions
-VCEFLAGS = /EHsc /TP $(CPPFLAGS) $(CFLAGS)
-VCEFLAGSD = /EHsc /TP $(CPPFLAGS) $(CFLAGSD)
+# (Note: If you are using Microsoft VC++6.0, the library needs to be built
+# with /EHa instead of /EHs or else cancellation won't work properly.)
+VCEFLAGS = /EHs /TP $(CPPFLAGS) $(CFLAGS)
+VCEFLAGSD = /EHs /TP $(CPPFLAGS) $(CFLAGSD)
#Structured Exceptions
VSEFLAGS = $(CPPFLAGS) $(CFLAGS)
VSEFLAGSD = $(CPPFLAGS) $(CFLAGSD)
@@ -46,415 +48,144 @@ VSEFLAGSD = $(CPPFLAGS) $(CFLAGSD)
VCFLAGS = $(CPPFLAGS) $(CFLAGS)
VCFLAGSD = $(CPPFLAGS) $(CFLAGSD)
-DLL_INLINED_OBJS = \
- pthread.obj \
- version.res
-
-# Aggregate modules for inlinability
-DLL_OBJS = \
- attr.obj \
- barrier.obj \
- cancel.obj \
- cleanup.obj \
- condvar.obj \
- create.obj \
- dll.obj \
- autostatic.obj \
- errno.obj \
- exit.obj \
- fork.obj \
- global.obj \
- misc.obj \
- mutex.obj \
- nonportable.obj \
- private.obj \
- rwlock.obj \
- sched.obj \
- semaphore.obj \
- signal.obj \
- spin.obj \
- sync.obj \
- tsd.obj \
- version.res
-
-# Separate modules for minimising the size of statically linked images
-SMALL_STATIC_OBJS = \
- pthread_attr_init.obj \
- pthread_attr_destroy.obj \
- pthread_attr_getdetachstate.obj \
- pthread_attr_setdetachstate.obj \
- pthread_attr_getstackaddr.obj \
- pthread_attr_setstackaddr.obj \
- pthread_attr_getstacksize.obj \
- pthread_attr_setstacksize.obj \
- pthread_attr_getscope.obj \
- pthread_attr_setscope.obj \
- pthread_attr_setschedpolicy.obj \
- pthread_attr_getschedpolicy.obj \
- pthread_attr_setschedparam.obj \
- pthread_attr_getschedparam.obj \
- pthread_attr_setinheritsched.obj \
- pthread_attr_getinheritsched.obj \
- pthread_barrier_init.obj \
- pthread_barrier_destroy.obj \
- pthread_barrier_wait.obj \
- pthread_barrierattr_init.obj \
- pthread_barrierattr_destroy.obj \
- pthread_barrierattr_setpshared.obj \
- pthread_barrierattr_getpshared.obj \
- pthread_setcancelstate.obj \
- pthread_setcanceltype.obj \
- pthread_testcancel.obj \
- pthread_cancel.obj \
- cleanup.obj \
- pthread_condattr_destroy.obj \
- pthread_condattr_getpshared.obj \
- pthread_condattr_init.obj \
- pthread_condattr_setpshared.obj \
- pthread_cond_destroy.obj \
- pthread_cond_init.obj \
- pthread_cond_signal.obj \
- pthread_cond_wait.obj \
- create.obj \
- dll.obj \
- autostatic.obj \
- errno.obj \
- pthread_exit.obj \
- fork.obj \
- global.obj \
- pthread_mutex_init.obj \
- pthread_mutex_destroy.obj \
- pthread_mutexattr_init.obj \
- pthread_mutexattr_destroy.obj \
- pthread_mutexattr_getpshared.obj \
- pthread_mutexattr_setpshared.obj \
- pthread_mutexattr_settype.obj \
- pthread_mutexattr_gettype.obj \
- pthread_mutexattr_setrobust.obj \
- pthread_mutexattr_getrobust.obj \
- pthread_mutex_lock.obj \
- pthread_mutex_timedlock.obj \
- pthread_mutex_unlock.obj \
- pthread_mutex_trylock.obj \
- pthread_mutex_consistent.obj \
- pthread_mutexattr_setkind_np.obj \
- pthread_mutexattr_getkind_np.obj \
- pthread_getw32threadhandle_np.obj \
- pthread_getunique_np.obj \
- pthread_delay_np.obj \
- pthread_num_processors_np.obj \
- pthread_win32_attach_detach_np.obj \
- pthread_equal.obj \
- pthread_getconcurrency.obj \
- pthread_once.obj \
- pthread_self.obj \
- pthread_setconcurrency.obj \
- pthread_rwlock_init.obj \
- pthread_rwlock_destroy.obj \
- pthread_rwlockattr_init.obj \
- pthread_rwlockattr_destroy.obj \
- pthread_rwlockattr_getpshared.obj \
- pthread_rwlockattr_setpshared.obj \
- pthread_rwlock_rdlock.obj \
- pthread_rwlock_wrlock.obj \
- pthread_rwlock_unlock.obj \
- pthread_rwlock_tryrdlock.obj \
- pthread_rwlock_trywrlock.obj \
- pthread_setschedparam.obj \
- pthread_getschedparam.obj \
- pthread_timechange_handler_np.obj \
- ptw32_is_attr.obj \
- ptw32_processInitialize.obj \
- ptw32_processTerminate.obj \
- ptw32_threadStart.obj \
- ptw32_threadDestroy.obj \
- ptw32_tkAssocCreate.obj \
- ptw32_tkAssocDestroy.obj \
- ptw32_callUserDestroyRoutines.obj \
- ptw32_timespec.obj \
- ptw32_throw.obj \
- ptw32_getprocessors.obj \
- ptw32_calloc.obj \
- ptw32_new.obj \
- ptw32_reuse.obj \
- ptw32_rwlock_check_need_init.obj \
- ptw32_cond_check_need_init.obj \
- ptw32_mutex_check_need_init.obj \
- ptw32_semwait.obj \
- ptw32_relmillisecs.obj \
- ptw32_MCS_lock.obj \
- sched_get_priority_max.obj \
- sched_get_priority_min.obj \
- sched_setscheduler.obj \
- sched_getscheduler.obj \
- sched_yield.obj \
- sem_init.obj \
- sem_destroy.obj \
- sem_trywait.obj \
- sem_timedwait.obj \
- sem_wait.obj \
- sem_post.obj \
- sem_post_multiple.obj \
- sem_getvalue.obj \
- sem_open.obj \
- sem_close.obj \
- sem_unlink.obj \
- signal.obj \
- pthread_kill.obj \
- ptw32_spinlock_check_need_init.obj \
- pthread_spin_init.obj \
- pthread_spin_destroy.obj \
- pthread_spin_lock.obj \
- pthread_spin_unlock.obj \
- pthread_spin_trylock.obj \
- pthread_detach.obj \
- pthread_join.obj \
- pthread_key_create.obj \
- pthread_key_delete.obj \
- pthread_setspecific.obj \
- pthread_getspecific.obj \
- w32_CancelableWait.obj \
- version.res
-
-INCL = config.h implement.h semaphore.h pthread.h need_errno.h
-
-ATTR_SRCS = \
- pthread_attr_init.c \
- pthread_attr_destroy.c \
- pthread_attr_getdetachstate.c \
- pthread_attr_setdetachstate.c \
- pthread_attr_getstackaddr.c \
- pthread_attr_setstackaddr.c \
- pthread_attr_getstacksize.c \
- pthread_attr_setstacksize.c \
- pthread_attr_getscope.c \
- pthread_attr_setscope.c
-
-BARRIER_SRCS = \
- pthread_barrier_init.c \
- pthread_barrier_destroy.c \
- pthread_barrier_wait.c \
- pthread_barrierattr_init.c \
- pthread_barrierattr_destroy.c \
- pthread_barrierattr_setpshared.c \
- pthread_barrierattr_getpshared.c
-
-CANCEL_SRCS = \
- pthread_setcancelstate.c \
- pthread_setcanceltype.c \
- pthread_testcancel.c \
- pthread_cancel.c
-
-CONDVAR_SRCS = \
- ptw32_cond_check_need_init.c \
- pthread_condattr_destroy.c \
- pthread_condattr_getpshared.c \
- pthread_condattr_init.c \
- pthread_condattr_setpshared.c \
- pthread_cond_destroy.c \
- pthread_cond_init.c \
- pthread_cond_signal.c \
- pthread_cond_wait.c
-
-EXIT_SRCS = \
- pthread_exit.c
-
-MISC_SRCS = \
- pthread_equal.c \
- pthread_getconcurrency.c \
- pthread_kill.c \
- pthread_once.c \
- pthread_self.c \
- pthread_setconcurrency.c \
- ptw32_calloc.c \
- ptw32_MCS_lock.c \
- ptw32_new.c \
- ptw32_reuse.c \
- ptw32_relmillisecs.c \
- w32_CancelableWait.c
-
-MUTEX_SRCS = \
- ptw32_mutex_check_need_init.c \
- pthread_mutex_init.c \
- pthread_mutex_destroy.c \
- pthread_mutexattr_init.c \
- pthread_mutexattr_destroy.c \
- pthread_mutexattr_getpshared.c \
- pthread_mutexattr_setpshared.c \
- pthread_mutexattr_settype.c \
- pthread_mutexattr_gettype.c \
- pthread_mutexattr_setrobust.c \
- pthread_mutexattr_getrobust.c \
- pthread_mutex_lock.c \
- pthread_mutex_timedlock.c \
- pthread_mutex_unlock.c \
- pthread_mutex_trylock.c \
- pthread_mutex_consistent.c
-
-NONPORTABLE_SRCS = \
- pthread_mutexattr_setkind_np.c \
- pthread_mutexattr_getkind_np.c \
- pthread_getw32threadhandle_np.c \
- pthread_getunique_np.c \
- pthread_delay_np.c \
- pthread_num_processors_np.c \
- pthread_win32_attach_detach_np.c \
- pthread_timechange_handler_np.c
-
-PRIVATE_SRCS = \
- ptw32_is_attr.c \
- ptw32_processInitialize.c \
- ptw32_processTerminate.c \
- ptw32_threadStart.c \
- ptw32_threadDestroy.c \
- ptw32_tkAssocCreate.c \
- ptw32_tkAssocDestroy.c \
- ptw32_callUserDestroyRoutines.c \
- ptw32_semwait.c \
- ptw32_timespec.c \
- ptw32_throw.c \
- ptw32_getprocessors.c
-
-RWLOCK_SRCS = \
- ptw32_rwlock_check_need_init.c \
- ptw32_rwlock_cancelwrwait.c \
- pthread_rwlock_init.c \
- pthread_rwlock_destroy.c \
- pthread_rwlockattr_init.c \
- pthread_rwlockattr_destroy.c \
- pthread_rwlockattr_getpshared.c \
- pthread_rwlockattr_setpshared.c \
- pthread_rwlock_rdlock.c \
- pthread_rwlock_timedrdlock.c \
- pthread_rwlock_wrlock.c \
- pthread_rwlock_timedwrlock.c \
- pthread_rwlock_unlock.c \
- pthread_rwlock_tryrdlock.c \
- pthread_rwlock_trywrlock.c
-
-SCHED_SRCS = \
- pthread_attr_setschedpolicy.c \
- pthread_attr_getschedpolicy.c \
- pthread_attr_setschedparam.c \
- pthread_attr_getschedparam.c \
- pthread_attr_setinheritsched.c \
- pthread_attr_getinheritsched.c \
- pthread_setschedparam.c \
- pthread_getschedparam.c \
- sched_get_priority_max.c \
- sched_get_priority_min.c \
- sched_setscheduler.c \
- sched_getscheduler.c \
- sched_yield.c
-
-SEMAPHORE_SRCS = \
- sem_init.c \
- sem_destroy.c \
- sem_trywait.c \
- sem_timedwait.c \
- sem_wait.c \
- sem_post.c \
- sem_post_multiple.c \
- sem_getvalue.c \
- sem_open.c \
- sem_close.c \
- sem_unlink.c
-
-SPIN_SRCS = \
- ptw32_spinlock_check_need_init.c \
- pthread_spin_init.c \
- pthread_spin_destroy.c \
- pthread_spin_lock.c \
- pthread_spin_unlock.c \
- pthread_spin_trylock.c
-
-SYNC_SRCS = \
- pthread_detach.c \
- pthread_join.c
-
-TSD_SRCS = \
- pthread_key_create.c \
- pthread_key_delete.c \
- pthread_setspecific.c \
- pthread_getspecific.c
+OBJEXT = obj
+RESEXT = res
+
+include common.mk
+DLL_OBJS = $(DLL_OBJS) $(RESOURCE_OBJS)
+STATIC_OBJS = $(STATIC_OBJS) $(RESOURCE_OBJS)
help:
@ echo Run one of the following command lines:
- @ echo nmake clean VCE (to build the MSVC dll with C++ exception handling)
- @ echo nmake clean VSE (to build the MSVC dll with structured exception handling)
- @ echo nmake clean VC (to build the MSVC dll with C cleanup code)
- @ echo nmake clean VCE-inlined (to build the MSVC inlined dll with C++ exception handling)
- @ echo nmake clean VSE-inlined (to build the MSVC inlined dll with structured exception handling)
- @ echo nmake clean VC-inlined (to build the MSVC inlined dll with C cleanup code)
- @ echo nmake clean VC-static (to build the MSVC static lib with C cleanup code)
- @ echo nmake clean VCE-debug (to build the debug MSVC dll with C++ exception handling)
- @ echo nmake clean VSE-debug (to build the debug MSVC dll with structured exception handling)
- @ echo nmake clean VC-debug (to build the debug MSVC dll with C cleanup code)
- @ echo nmake clean VCE-inlined-debug (to build the debug MSVC inlined dll with C++ exception handling)
- @ echo nmake clean VSE-inlined-debug (to build the debug MSVC inlined dll with structured exception handling)
- @ echo nmake clean VC-inlined-debug (to build the debug MSVC inlined dll with C cleanup code)
- @ echo nmake clean VC-static-debug (to build the debug MSVC static lib with C cleanup code)
+ @ echo nmake clean VC
+ @ echo nmake clean VC-debug
+ @ echo nmake clean VC-static
+ @ echo nmake clean VC-static-debug
+ @ echo nmake clean VC-small-static
+ @ echo nmake clean VC-small-static-debug
+ @ echo nmake clean VCE
+ @ echo nmake clean VCE-debug
+ @ echo nmake clean VCE-static
+ @ echo nmake clean VCE-static-debug
+ @ echo nmake clean VCE-small-static
+ @ echo nmake clean VCE-small-static-debug
+ @ echo nmake clean VSE
+ @ echo nmake clean VSE-debug
+ @ echo nmake clean VSE-static
+ @ echo nmake clean VSE-static-debug
+ @ echo nmake clean VSE-small-static
+ @ echo nmake clean VSE-small-static-debug
all:
- @ $(MAKE) /E clean VCE-inlined
- @ $(MAKE) /E clean VSE-inlined
- @ $(MAKE) /E clean VC-inlined
- @ $(MAKE) /E clean VCE-inlined-debug
- @ $(MAKE) /E clean VSE-inlined-debug
- @ $(MAKE) /E clean VC-inlined-debug
+ $(MAKE) /E clean VCE
+ $(MAKE) /E clean VSE
+ $(MAKE) /E clean VC
+ $(MAKE) /E clean VCE-debug
+ $(MAKE) /E clean VSE-debug
+ $(MAKE) /E clean VC-debug
+
+TEST_ENV = CFLAGS="$(CFLAGS) /DNO_ERROR_DIALOGS"
+
+all-tests:
+ $(MAKE) /E realclean VC-small-static$(XDBG)
+ cd tests && $(MAKE) /E clean VC-small-static$(XDBG) $(TEST_ENV) && $(MAKE) /E clean VCX-small-static$(XDBG) $(TEST_ENV)
+ $(MAKE) /E realclean VCE-small-static$(XDBG)
+ cd tests && $(MAKE) /E clean VCE-small-static$(XDBG) $(TEST_ENV)
+ $(MAKE) /E realclean VSE-small-static$(XDBG)
+ cd tests && $(MAKE) /E clean VSE-small-static$(XDBG) $(TEST_ENV)
+ $(MAKE) /E realclean VC$(XDBG)
+ cd tests && $(MAKE) /E clean VC$(XDBG) $(TEST_ENV) && $(MAKE) /E clean VCX$(XDBG) $(TEST_ENV)
+ $(MAKE) /E realclean VCE$(XDBG)
+ cd tests && $(MAKE) /E clean VCE$(XDBG) $(TEST_ENV)
+ $(MAKE) /E realclean VSE$(XDBG)
+ cd tests && $(MAKE) /E clean VSE$(XDBG) $(TEST_ENV)
+!IF DEFINED(EXHAUSTIVE)
+ $(MAKE) /E realclean VC-static$(XDBG)
+ cd tests && $(MAKE) /E clean VC-static$(XDBG) $(TEST_ENV) && $(MAKE) /E clean VCX-static$(XDBG) $(TEST_ENV)
+ $(MAKE) /E realclean VCE-static$(XDBG)
+ cd tests && $(MAKE) /E clean VCE-static$(XDBG) $(TEST_ENV)
+ $(MAKE) /E realclean VSE-static$(XDBG)
+ cd tests && $(MAKE) /E clean VSE-static$(XDBG) $(TEST_ENV)
+!ENDIF
+ $(MAKE) realclean
+ @ echo $@ completed successfully.
+
+all-tests-cflags:
+ @ -$(SETENV)
+ $(MAKE) all-tests XCFLAGS="/W3 /WX /MD /nologo"
+ $(MAKE) all-tests XCFLAGS="/W3 /WX /MT /nologo"
+!IF DEFINED(MORE_EXHAUSTIVE)
+ $(MAKE) all-tests XCFLAGS="/W3 /WX /MDd /nologo" XDBG="-debug"
+ $(MAKE) all-tests XCFLAGS="/W3 /WX /MTd /nologo" XDBG="-debug"
+!ENDIF
+ @ echo $@ completed successfully.
VCE:
- @ $(MAKE) /E /nologo EHFLAGS="$(VCEFLAGS)" CLEANUP=__CLEANUP_CXX pthreadVCE$(DLL_VER).dll
+ @ $(MAKE) /E /nologo EHFLAGS="$(VCEFLAGS) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_CXX pthreadVCE$(DLL_VER).dll
VCE-debug:
- @ $(MAKE) /E /nologo EHFLAGS="$(VCEFLAGSD)" CLEANUP=__CLEANUP_CXX pthreadVCE$(DLL_VERD).dll
+ @ $(MAKE) /E /nologo EHFLAGS="$(VCEFLAGSD) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_CXX pthreadVCE$(DLL_VERD).dll
VSE:
- @ $(MAKE) /E /nologo EHFLAGS="$(VSEFLAGS)" CLEANUP=__CLEANUP_SEH pthreadVSE$(DLL_VER).dll
+ @ $(MAKE) /E /nologo EHFLAGS="$(VSEFLAGS) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_SEH pthreadVSE$(DLL_VER).dll
VSE-debug:
- @ $(MAKE) /E /nologo EHFLAGS="$(VSEFLAGSD)" CLEANUP=__CLEANUP_SEH pthreadVSE$(DLL_VERD).dll
+ @ $(MAKE) /E /nologo EHFLAGS="$(VSEFLAGSD) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_SEH pthreadVSE$(DLL_VERD).dll
VC:
- @ $(MAKE) /E /nologo EHFLAGS="$(VCFLAGS)" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VER).dll
+ @ $(MAKE) /E /nologo EHFLAGS="$(VCFLAGS) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VER).dll
VC-debug:
- @ $(MAKE) /E /nologo EHFLAGS="$(VCFLAGSD)" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VERD).dll
+ @ $(MAKE) /E /nologo EHFLAGS="$(VCFLAGSD) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VERD).dll
#
-# The so-called inlined DLL is just a single translation unit with
-# inlining optimisation turned on.
+# Static builds
#
-VCE-inlined:
- @ $(MAKE) /E /nologo EHFLAGS="$(VCEFLAGS) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_CXX pthreadVCE$(DLL_VER).stamp
+VCE-small-static:
+ @ $(MAKE) /E /nologo EHFLAGS="$(VCEFLAGS) /DPTW32_STATIC_LIB" CLEANUP=__CLEANUP_CXX pthreadVCE$(DLL_VER).small_static_stamp
+
+VCE-small-static-debug:
+ @ $(MAKE) /E /nologo EHFLAGS="$(VCEFLAGSD) /DPTW32_STATIC_LIB" CLEANUP=__CLEANUP_CXX pthreadVCE$(DLL_VERD).small_static_stamp
+
+VSE-small-static:
+ @ $(MAKE) /E /nologo EHFLAGS="$(VSEFLAGS) /DPTW32_STATIC_LIB" CLEANUP=__CLEANUP_SEH pthreadVSE$(DLL_VER).small_static_stamp
+
+VSE-small-static-debug:
+ @ $(MAKE) /E /nologo EHFLAGS="$(VSEFLAGSD) /DPTW32_STATIC_LIB" CLEANUP=__CLEANUP_SEH pthreadVSE$(DLL_VERD).small_static_stamp
+
+VC-small-static:
+ @ $(MAKE) /E /nologo EHFLAGS="$(VCFLAGS) /DPTW32_STATIC_LIB" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VER).small_static_stamp
-VCE-inlined-debug:
- @ $(MAKE) /E /nologo EHFLAGS="$(VCEFLAGSD) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_CXX pthreadVCE$(DLL_VERD).stamp
+VC-small-static-debug:
+ @ $(MAKE) /E /nologo EHFLAGS="$(VCFLAGSD) /DPTW32_STATIC_LIB" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VERD).small_static_stamp
-VSE-inlined:
- @ $(MAKE) /E /nologo EHFLAGS="$(VSEFLAGS) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_SEH pthreadVSE$(DLL_VER).stamp
+VCE-static:
+ @ $(MAKE) /E /nologo EHFLAGS="$(VCEFLAGS) /DPTW32_STATIC_LIB /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_CXX pthreadVCE$(DLL_VER).inlined_static_stamp
-VSE-inlined-debug:
- @ $(MAKE) /E /nologo EHFLAGS="$(VSEFLAGSD) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_SEH pthreadVSE$(DLL_VERD).stamp
+VCE-static-debug:
+ @ $(MAKE) /E /nologo EHFLAGS="$(VCEFLAGSD) /DPTW32_STATIC_LIB /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_CXX pthreadVCE$(DLL_VERD).inlined_static_stamp
-VC-inlined:
- @ $(MAKE) /E /nologo EHFLAGS="$(VCFLAGS) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VER).stamp
+VSE-static:
+ @ $(MAKE) /E /nologo EHFLAGS="$(VSEFLAGS) /DPTW32_STATIC_LIB /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_SEH pthreadVSE$(DLL_VER).inlined_static_stamp
-VC-inlined-debug:
- @ $(MAKE) /E /nologo EHFLAGS="$(VCFLAGSD) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VERD).stamp
+VSE-static-debug:
+ @ $(MAKE) /E /nologo EHFLAGS="$(VSEFLAGSD) /DPTW32_STATIC_LIB /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_SEH pthreadVSE$(DLL_VERD).inlined_static_stamp
VC-static:
- @ $(MAKE) /E /nologo EHFLAGS="$(VCFLAGS) /DPTW32_BUILD_INLINED /DPTW32_STATIC_LIB" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VER).static
+ @ $(MAKE) /E /nologo EHFLAGS="$(VCFLAGS) /DPTW32_STATIC_LIB /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VER).inlined_static_stamp
VC-static-debug:
- @ $(MAKE) /E /nologo EHFLAGS="$(VCFLAGSD) /DPTW32_BUILD_INLINED /DPTW32_STATIC_LIB" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VERD).static
+ @ $(MAKE) /E /nologo EHFLAGS="$(VCFLAGSD) /DPTW32_STATIC_LIB /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VERD).inlined_static_stamp
+
realclean: clean
- if exist pthread*.dll del pthread*.dll
- if exist pthread*.lib del pthread*.lib
+ if exist *.dll del *.dll
+ if exist *.lib del *.lib
+ if exist *.a del *.a
if exist *.manifest del *.manifest
- if exist *.stamp del *.stamp
+ if exist *_stamp del *_stamp
+ cd tests && $(MAKE) clean
clean:
if exist *.obj del *.obj
@@ -467,46 +198,44 @@ clean:
if exist *.i del *.i
if exist *.res del *.res
-
+# Very basic install. It assumes "realclean" was done just prior to build target if
+# you want the installed $(DEVDEST_LIB_NAME) to match that build.
install:
- copy pthread*.dll $(DLLDEST)
- copy pthread*.lib $(LIBDEST)
+ if not exist $(DLLDEST) mkdir $(DLLDEST)
+ if not exist $(LIBDEST) mkdir $(LIBDEST)
+ if not exist $(HDRDEST) mkdir $(HDRDEST)
+ if exist pthreadV*.dll copy pthreadV*.dll $(DLLDEST)
+ copy pthreadV*.lib $(LIBDEST)
copy pthread.h $(HDRDEST)
copy sched.h $(HDRDEST)
copy semaphore.h $(HDRDEST)
+ if exist pthreadVC$(DLL_VER).lib copy pthreadVC$(DLL_VER).lib $(LIBDEST)\$(DEST_LIB_NAME)
+ if exist pthreadVC$(DLL_VERD).lib copy pthreadVC$(DLL_VERD).lib $(LIBDEST)\$(DEST_LIB_NAME)
+ if exist pthreadVCE$(DLL_VER).lib copy pthreadVCE$(DLL_VER).lib $(LIBDEST)\$(DEST_LIB_NAME)
+ if exist pthreadVCE$(DLL_VERD).lib copy pthreadVCE$(DLL_VERD).lib $(LIBDEST)\$(DEST_LIB_NAME)
+ if exist pthreadVSE$(DLL_VER).lib copy pthreadVSE$(DLL_VER).lib $(LIBDEST)\$(DEST_LIB_NAME)
+ if exist pthreadVSE$(DLL_VERD).lib copy pthreadVSE$(DLL_VERD).lib $(LIBDEST)\$(DEST_LIB_NAME)
$(DLLS): $(DLL_OBJS)
$(CC) /LDd /Zi /nologo $(DLL_OBJS) /link /implib:$*.lib $(XLIBS) /out:$@
-$(INLINED_STAMPS): $(DLL_INLINED_OBJS)
- $(CC) /LDd /Zi /nologo $(DLL_INLINED_OBJS) /link /implib:$*.lib $(XLIBS) /out:$*.dll
+$(INLINED_STATIC_STAMPS): $(DLL_OBJS)
+ if exist $*.lib del $*.lib
+ lib $(DLL_OBJS) /out:$*.lib
+ echo. >$@
-$(STATIC_STAMPS): $(DLL_INLINED_OBJS)
+$(SMALL_STATIC_STAMPS): $(STATIC_OBJS)
if exist $*.lib del $*.lib
- lib $(DLL_INLINED_OBJS) /out:$*.lib
+ lib $(STATIC_OBJS) /out:$*.lib
+ echo. >$@
.c.obj:
$(CC) $(EHFLAGS) /D$(CLEANUP) -c $<
+# TARGET_CPU is an environment variable set by Visual Studio Command Prompt
+# as provided by the SDK
.rc.res:
- rc /dPTW32_RC_MSC /d$(CLEANUP) $<
+ rc /dPTW32_ARCH$(TARGET_CPU) /dPTW32_RC_MSC /d$(CLEANUP) $<
.c.i:
$(CC) /P /O2 /Ob1 $(VCFLAGS) $<
-
-attr.obj: attr.c $(ATTR_SRCS) $(INCL)
-barrier.obj: barrier.c $(BARRIER_SRCS) $(INCL)
-cancel.obj: cancel.c $(CANCEL_SRCS) $(INCL)
-condvar.obj: condvar.c $(CONDVAR_SRCS) $(INCL)
-exit.obj: exit.c $(EXIT_SRCS) $(INCL)
-misc.obj: misc.c $(MISC_SRCS) $(INCL)
-mutex.obj: mutex.c $(MUTEX_SRCS) $(INCL)
-nonportable.obj: nonportable.c $(NONPORTABLE_SRCS) $(INCL)
-private.obj: private.c $(PRIVATE_SRCS) $(INCL)
-rwlock.obj: rwlock.c $(RWLOCK_SRCS) $(INCL)
-sched.obj: sched.c $(SCHED_SRCS) $(INCL)
-semaphore.obj: semaphore.c $(SEMAPHORE_SRCS) $(INCL)
-spin.obj: spin.c $(SPIN_SRCS) $(INCL)
-sync.obj: sync.c $(SYNC_SRCS) $(INCL)
-tsd.obj: tsd.c $(TSD_SRCS) $(INCL)
-version.res: version.rc $(INCL)
diff --git a/pthreads/NEWS b/pthreads/NEWS
index 219fe4e23..44d3888a9 100644
--- a/pthreads/NEWS
+++ b/pthreads/NEWS
@@ -1,43 +1,119 @@
-CURRENT CVS HEAD Version
-RELEASE 2.9.0 pending
+RELEASE 2.10.0
+--------------
+(2099-99-99)
+
+General
+-------
+New bug fixes in all releases since 2.8.0 have NOT been applied to the
+1.x.x series.
+
+Some changes in CVS from 2011-02-26 onward may not be compatible with
+pre Windows 2000 systems.
+
+Testing and verification
+------------------------
+This version has been tested on SMP architecture (Intel x64 Hex Core)
+by completing the included test suite, as well as the stress and bench
+tests.
+
+Be sure to run your builds against the test suite. As of this release
+we are successfully passing the full test suite with all build
+configurations. If you see failures then please consider how your
+toolchains might be contributing to the failure. See the README file
+for more detailed descriptions of the toolchains and test systems that
+we have used to get the tests to pass successfully.
+
+New Features
+------------
+New routines:
+pthread_timedjoin_np()
+pthread_tryjoin_np()
+ - added for compatibility with Linux.
+sched_getaffinity()
+sched_setaffinity()
+pthread_getaffinity_np()
+pthread_getaffinity_np()
+ - added for compatibility with Linux and other libgcc-based systems.
+ The macros to manipulate cpu_set_t objects (the cpu affinity mask
+ vector) are also defined: CPU_ZERO, CPU_CLR, CPU_SET, CPU_EQUAL,
+ CPU_AND, CPU_OR, CPU_XOR, CPU_COUNT, CPU_ISSET.
+
+Builds:
+New makefile targets have been added and existing targets modified or
+removed. For example, targets to build and test all of the possible
+configurations of both dll and static libs.
+
+The makefiles now know how to build both 32 and 64 bit versions if
+the toolchain (MSVS or Mingw) allow it.
+
+Bug Fixes
+---------
+Small object file static linking now works. The autostatic.c code is
+required but nothing explicitly references this code so was getting
+optimised out.
+- Daniel Richard G.
+
+sem_getvalue() could return the errno value instead of setting errno
+and returning -1.
+- Ross Johnson
+
+Errno values were being lost if the library is statically linked
+with the runtime library, meaning also that the application used a
+separate runtime instance. This is still the case except a build
+switch has been added that allows more robust error status to be
+incorporated, i.e. allow the return code to be retrieved via
+GetLastError().
+- Daniel Richard G.
+
+Identified the cause of significant failures around cancelation
+and pthread_exit() for the GCE (GNU C++) build configuration as
+coming from Mingw32. Not sure if this is general or just when
+building 32 bit libraries and apps that run on 64 bit systems.
+These failures do not arise with Mingw64 32 bit builds running on
+64 bit systems.
+- Daniel Richard G. and Ross Johnson
+
+RELEASE 2.9.1
-------------
-(2011-??-??)
+(2012-05-27)
General
-------
New bug fixes in this release since 2.8.0 have NOT been applied to the
1.x.x series.
-Version 2.8.0 may be the last release for some older Windows systems.
+This release replaces an extremely brief 2.9.0 release and adds
+some last minute non-code changes were made to embed better
+descriptive properties in the dlls to indicate target architecture
+and build environments.
+
Some changes post 2011-02-26 in CVS may not be compatible with pre
Windows 2000 systems.
-Version 1 no longer maintained
-------------------------------
-The 1.x.x series is no longer maintained. However, if you really need a
-version 1, the differences between 1.11.0 and 2.7.0 are very small, mainly
-revolving around the pthread_once_t_ struct. Those differences applied
-as a patch to the current 2.x.x should work. Don't forget to change
-the version numbering in pthread.h before building. If you distribute
-such a version 1.x.x please bear in mind that your numbers may clash
-with those of others doing the same thing. Please consider also making
-identifying changes in version.rc to differentiate your build.
+Use of other than the "C" version of the library is now discouraged.
+That is, the "C++" version fails some tests and does not provide any
+additional functionality.
Testing and verification
------------------------
-The current CVS head version has been tested on an SMP architecture
-(AMD Phenom 9750 Quad Core) by running the MinGW32 (GCC) builds against
-the full test suite, stress tests and benchmarks.
+This version has been tested on SMP architecture (Intel x64 Hex Core)
+by completing the included test suite, stress and bench tests.
New Features
------------
+DLL properties now properly includes the target architecture, i.e.
+right-click on the file pthreadVC2.dll in explorer and choose the Detail
+tab will show the compiler and architecture in the description field, e.g.
+"MS C x64" or "MS C x86".
+- Ross Johnson
+
(MSC and GNU builds) The statically linked library now automatically
initialises and cleans up on program start/exit, i.e. statically linked
applications need not call the routines pthread_win32_process_attach_np()
and pthread_win32_process_detach_np() explicitly. The per-thread routine
pthread_win32_thread_detach_np() is also called at program exit to cleanup
-POSIX resources acquired by the primary Windows native thread (if I (RJ)
-understand the process correctly). Other Windows native threads that call
+POSIX resources acquired by the primary Windows native thread, if I (RJ)
+understand the process correctly. Other Windows native threads that call
POSIX API routines may need to call the thread detach routine on thread
exit if the application depends on reclaimed POSIX resources or running
POSIX TSD (TLS) destructors.
@@ -449,7 +525,7 @@ Bugs fixed
* pthread_setcancelstate() no longer checks for a pending
async cancel event if the library is using alertable async
cancel. See the README file (Prerequisites section) for info
-on adding alertable async cancelation.
+on adding alertable async cancellation.
New features
------------
@@ -615,7 +691,7 @@ Bug fixes
A segfault (memory access fault) will result, and no thread will be
created.
-* pthread_barrier_wait() no longer acts as a cancelation point.
+* pthread_barrier_wait() no longer acts as a cancellation point.
* Fix potential race condition in pthread_once()
- Tristan Savatier <tristan at mpegtv.com>
@@ -654,7 +730,7 @@ destruction/creation cycles.
New tests
---------
-* semaphore4.c: Tests cancelation of the new sem_wait().
+* semaphore4.c: Tests cancellation of the new sem_wait().
* semaphore4t.c: Likewise for sem_timedwait().
@@ -692,21 +768,21 @@ New features
* Ported to AMD64.
- Makoto Kato <raven at oldskool.jp>
-* True pre-emptive asynchronous cancelation of threads. This is optional
+* True pre-emptive asynchronous cancellation of threads. This is optional
and requires that Panagiotis E. Hadjidoukas's QueueUserAPCEx package be
installed. This package is included in the pthreads-win32 self-unpacking
Zip archive starting from this snapshot. See the README.txt file inside
the package for installation details.
-Note: If you don't use async cancelation in your application, or don't need
+Note: If you don't use async cancellation in your application, or don't need
to cancel threads that are blocked on system resources such as network I/O,
-then the default non-preemptive async cancelation is probably good enough.
+then the default non-preemptive async cancellation is probably good enough.
However, pthreads-win32 auto-detects the availability of these components
at run-time, so you don't need to rebuild the library from source if you
change your mind later.
All of the advice available in books and elsewhere on the undesirability
-of using async cancelation in any application still stands, but this
+of using async cancellation in any application still stands, but this
feature is a welcome addition with respect to the library's conformance to
the POSIX standard.
@@ -735,12 +811,12 @@ SNAPSHOT 2003-09-04
Bug fixes
---------
-* ptw32_cancelableWait() now allows cancelation of waiting implicit POSIX
+* ptw32_cancelableWait() now allows cancellation of waiting implicit POSIX
threads.
New test
--------
-* cancel8.c tests cancelation of Win32 threads waiting at a POSIX cancelation
+* cancel8.c tests cancellation of Win32 threads waiting at a POSIX cancellation
point.
@@ -755,13 +831,13 @@ DuplicateHandle failed instead of recycle it (very unlikely).
* pthread_exit() was neither freeing nor recycling the POSIX thread struct
for implicit POSIX threads.
-New feature - Cancelation of/by Win32 (non-POSIX) threads
+New feature - cancellation of/by Win32 (non-POSIX) threads
---------------------------------------------------------
Since John Bossom's original implementation, the library has allowed non-POSIX
initialised threads (Win32 threads) to call pthreads-win32 routines and
therefore interact with POSIX threads. This is done by creating an on-the-fly
POSIX thread ID for the Win32 thread that, once created, allows fully
-reciprical interaction. This did not extend to thread cancelation (async or
+reciprical interaction. This did not extend to thread cancellation (async or
deferred). Now it does.
Any thread can be canceled by any other thread (Win32 or POSIX) if the former
@@ -771,15 +847,15 @@ PTHREAD_CANCELED (retrieved with GetExitCodeThread()).
This allows a Win32 thread to, for example, call POSIX CV routines in the same way
that POSIX threads would/should, with pthread_cond_wait() cancelability and
-cleanup handlers (pthread_cond_wait() is a POSIX cancelation point).
+cleanup handlers (pthread_cond_wait() is a POSIX cancellation point).
-By adding cancelation, Win32 threads should now be able to call all POSIX
+By adding cancellation, Win32 threads should now be able to call all POSIX
threads routines that make sense including semaphores, mutexes, condition
variables, read/write locks, barriers, spinlocks, tsd, cleanup push/pop,
-cancelation, pthread_exit, scheduling, etc.
+cancellation, pthread_exit, scheduling, etc.
Note that these on-the-fly 'implicit' POSIX thread IDs are initialised as detached
-(not joinable) with deferred cancelation type. The POSIX thread ID will be created
+(not joinable) with deferred cancellation type. The POSIX thread ID will be created
automatically by any POSIX routines that need a POSIX handle (unless the routine
needs a pthread_t as a parameter of course). A Win32 thread can discover it's own
POSIX thread ID by calling pthread_self(), which will create the handle if
@@ -844,7 +920,7 @@ Bug fixes
* pthread_mutex_trylock() now returns correct error values.
pthread_mutex_destroy() will no longer destroy a recursively locked mutex.
-pthread_mutex_lock() is no longer inadvertantly behaving as a cancelation point.
+pthread_mutex_lock() is no longer inadvertantly behaving as a cancellation point.
- Thomas Pfaff <tpfaff@gmx.net>
* pthread_mutex_timedlock() no longer occasionally sets incorrect mutex
@@ -892,7 +968,7 @@ from the compiler/language, and one of the following was defined accordingly:
__CLEANUP_C C, including GNU GCC, not MSVC
These defines determine the style of cleanup (see pthread.h) and,
-most importantly, the way that cancelation and thread exit (via
+most importantly, the way that cancellation and thread exit (via
pthread_exit) is performed (see the routine ptw32_throw() in private.c).
In short, the exceptions versions of the library throw an exception
@@ -904,7 +980,7 @@ is when it's canceled or exits via pthread_exit().
In this and future snapshots, unless the build explicitly defines (e.g.
via a compiler option) __CLEANUP_SEH, __CLEANUP_CXX, or __CLEANUP_C, then
the build NOW always defaults to __CLEANUP_C style cleanup. This style
-uses setjmp/longjmp in the cancelation and pthread_exit implementations,
+uses setjmp/longjmp in the cancellation and pthread_exit implementations,
and therefore won't do stack unwinding even when linked to applications
that have it (e.g. C++ apps). This is for consistency with most
current commercial Unix POSIX threads implementations. Compaq's TRU64
@@ -1100,9 +1176,9 @@ with the C version, but AFAIK cleanup handlers would not then run in the
correct sequence with destructors and exception cleanup handlers when
an exception occurs.
-* Cancelation once started in a thread cannot now be inadvertantly
-double canceled. That is, once a thread begins it's cancelation run,
-cancelation is disabled and a subsequent cancel request will
+* cancellation once started in a thread cannot now be inadvertantly
+double canceled. That is, once a thread begins it's cancellation run,
+cancellation is disabled and a subsequent cancel request will
return an error (ESRCH).
* errno: An incorrect compiler directive caused a local version
@@ -1150,7 +1226,7 @@ SNAPSHOT 2000-08-10
-------------------
New:
-- asynchronous cancelation on X86 (Jason Nye)
+- asynchronous cancellation on X86 (Jason Nye)
- Makefile compatible with MS nmake to replace
buildlib.bat
- GNUmakefile for Mingw32
@@ -1190,7 +1266,7 @@ Some new tests have been added.
SNAPSHOT 1999-10-17
-------------------
-Bug fix - Cancelation of threads waiting on condition variables
+Bug fix - cancellation of threads waiting on condition variables
now works properly (Lorin Hochstein and Peter Slacik)
diff --git a/pthreads/Nmakefile b/pthreads/Nmakefile
index d9e5bf1bc..368a15179 100644
--- a/pthreads/Nmakefile
+++ b/pthreads/Nmakefile
@@ -2,10 +2,10 @@
* nmake file for uwin pthread library
*/
-VERSION = -
-CCFLAGS = -V -g $(CC.DLL)
-HAVE_PTW32_CONFIG_H == 1
-_MT == 1
+VERSION = -
+CCFLAGS = -V -g $(CC.DLL)
+HAVE_CONFIG_H == 1
+_MT == 1
_timeb == timeb
_ftime == ftime
_errno == _ast_errno
diff --git a/pthreads/README b/pthreads/README
index 545360bfa..9e9bb8103 100644
--- a/pthreads/README
+++ b/pthreads/README
@@ -10,15 +10,14 @@ specific to pthreads-win32, copyrights and the LGPL.
What is it?
-----------
-Pthreads-win32 is an Open Source Software implementation of the
-Threads component of the POSIX 1003.1c 1995 Standard (or later)
-for Microsoft's Win32 environment. Some functions from POSIX
-1003.1b are also supported including semaphores. Other related
-functions include the set of read-write lock functions. The
+Pthreads-win32 (a.k.a. pthreads4w) is an Open Source Software
+implementation of the Threads component of the POSIX 1003.1c 1995
+Standard (or later) for Microsoft's Windows environment. Some functions
+from POSIX 1003.1b are also supported, including semaphores. Other
+related functions include the set of read-write lock functions. The
library also supports some of the functionality of the Open
-Group's Single Unix specification, version 2, namely mutex types,
-plus some common and pthreads-win32 specific non-portable
-routines (see README.NONPORTABLE).
+Group's Single Unix specification, namely mutex types, plus some common
+and pthreads-win32 specific non-portable routines (see README.NONPORTABLE).
See the file "ANNOUNCE" for more information including standards
conformance details and the list of supported and unsupported
@@ -27,15 +26,15 @@ routines.
Prerequisites
-------------
-MSVC or GNU C (MinGW32 MSys development kit)
+MSVC or GNU C (MinGW32 or MinGW64 MSys development kit)
To build from source.
QueueUserAPCEx by Panagiotis E. Hadjidoukas
- To support any thread cancelation in C++ library builds or
- to support cancelation of blocked threads in any build.
+ To support any thread cancellation in C++ library builds or
+ to support cancellation of blocked threads in any build.
This library is not required otherwise.
- For true async cancelation of threads (including blocked threads).
+ For true async cancellation of threads (including blocked threads).
This is a DLL and Windows driver that provides pre-emptive APC
by forcing threads into an alertable state when the APC is queued.
Both the DLL and driver are provided with the pthreads-win32.exe
@@ -47,7 +46,7 @@ QueueUserAPCEx by Panagiotis E. Hadjidoukas
Pthreads-win32 will automatically detect if the QueueUserAPCEx DLL
QuserEx.DLL is available and whether the driver AlertDrv.sys is
loaded. If it is not available, pthreads-win32 will simulate async
- cancelation, which means that it can async cancel only threads that
+ cancellation, which means that it can async cancel only threads that
are runnable. The simulated async cancellation cannot cancel blocked
threads.
@@ -64,6 +63,11 @@ handling schemes and compilers - and because the library
may not work reliably if these are mixed in an application,
each different version of the library has it's own name.
+Please do not distribute your own modified versions of the library
+using names conforming to this description. You can use the
+makefile variable "EXTRAVERSION" to append your own suffix to the
+library names when building and testing your library.
+
Note 1: the incompatibility is really between EH implementations
of the different compilers. It should be possible to use the
standard C version from either compiler with C++ applications
@@ -82,80 +86,85 @@ version (it should be arbitrary) as pthread.dll, including
pthread.lib and libpthread.a as appropriate. This is no longer
likely to happen.
-Note 4: the compatibility number was added so that applications
-can differentiate between binary incompatible versions of the
-libs and dlls.
+Note 4: the compatibility number (major version number) was
+added so that applications can differentiate between binary
+incompatible versions of the libs and dlls.
-In general:
- pthread[VG]{SE,CE,C}[c].dll
- pthread[VG]{SE,CE,C}[c].lib
+In general the naming format used is:
+ pthread[VG]{SE,CE,C}[c][E].dll
+ pthread[VG]{SE,CE,C}[c][E].lib
where:
- [VG] indicates the compiler
- V - MS VC, or
- G - GNU C
+ [VG] indicates the compiler
+ V - MS VC, or
+ G - GNU C
- {SE,CE,C} indicates the exception handling scheme
- SE - Structured EH, or
- CE - C++ EH, or
- C - no exceptions - uses setjmp/longjmp
+ {SE,CE,C} indicates the exception handling scheme
+ SE - Structured EH, or
+ CE - C++ EH, or
+ C - no exceptions - uses setjmp/longjmp
- c - DLL compatibility number indicating ABI and API
- compatibility with applications built against
- a snapshot with the same compatibility number.
- See 'Version numbering' below.
+ c - DLL major version number indicating ABI
+ compatibility with applications built against
+ a snapshot with the same major version number.
+ See 'Version numbering' below.
+ E - EXTRAVERSION suffix.
The name may also be suffixed by a 'd' to indicate a debugging version
-of the library. E.g. pthreadVC2d.lib. Debugging versions contain
-additional information for debugging (symbols etc) and are often not
-optimised in any way (compiled with optimisation turned off).
+of the library. E.g. pthreadVC2d.lib. These will be created e.g. when
+the *-debug makefile targets are used.
Examples:
- pthreadVSE.dll (MSVC/SEH)
- pthreadGCE.dll (GNUC/C++ EH)
- pthreadGC.dll (GNUC/not dependent on exceptions)
- pthreadVC1.dll (MSVC/not dependent on exceptions - not binary
- compatible with pthreadVC.dll)
- pthreadVC2.dll (MSVC/not dependent on exceptions - not binary
- compatible with pthreadVC1.dll or pthreadVC.dll)
+ pthreadVC2.dll (MSVC/not dependent on exceptions - not binary
+ compatible with pthreadVC1.dll or pthreadVC.dll)
+ pthreadGC2-w32.dll (As built, e.g., by "make GC ARCH=-m32 EXTRAVERSION=-w32")
+ pthreadVC2-w64.dll (As built, e.g., by "nmake VC ARCH=-m64 EXTRAVERSION=-w64")
-The GNU library archive file names have correspondingly changed to:
+For information on ARCH (MinGW GNUmakefile) or TARGET_CPU (MSVS Makefile)
+see the respective "Building with ..." sections below.
- libpthreadGCEc.a
- libpthreadGCc.a
+The GNU library archive file names have correspondingly changed, e.g.:
+ libpthreadGCE2.a
+ libpthreadGC2.a
+ libpthreadGC2-w64.a
-Versioning numbering
---------------------
-Version numbering is separate from the snapshot dating system, and
-is the canonical version identification system embedded within the
-DLL using the Microsoft version resource system. The versioning
-system chosen follows the GNU Libtool system. See
-http://www.gnu.org/software/libtool/manual.html section 6.2.
+Version numbering
+-----------------
-See the resource file 'version.rc'.
+See pthread.h and the resource file 'version.rc'.
Microsoft version numbers use 4 integers:
0.0.0.0
-Pthreads-win32 uses the first 3 following the Libtool convention.
+Pthreads-win32 uses the first 3 following the standard major.minor.micro
+system. We had claimed to follow the Libtool convention but this has
+not been the case with recent releases. Binary compatibility and
+consequently library file naming has not changed over this time either
+so it should not cause any problems.
+
The fourth is commonly used for the build number, but will be reserved
for future use.
- current.revision.age.0
+ major.minor.micro.0
The numbers are changed as follows:
-1. If the library source code has changed at all since the last update,
- then increment revision (`c:r:a' becomes `c:r+1:a').
-2. If any interfaces have been added, removed, or changed since the last
- update, increment current, and set revision to 0.
-3. If any interfaces have been added since the last public release, then
- increment age.
-4. If any interfaces have been removed or changed since the last public
- release, then set age to 0.
+1. If the general binary interface (ABI) has changed at all since the
+ last update in a way that requires recompilation and relinking of
+ applications, then increment Major, and set both minor and micro to 0.
+ (`M:m:u' becomes `M+1:0:0')
+2. If the general API has changed at all since the last update or
+ there have been semantic/behaviour changes (bug fixes etc) but does
+ not require recompilation of existing applications, then increment
+ minor and set micro to 0.
+ (`M:m:u' becomes `M:m+1:0')
+3. If there have been no interface or semantic changes since the last
+ public release but a new release is deemed necessary for some reason,
+ then increment micro.
+ (`M:m:u' becomes `M:m:u+1')
DLL compatibility numbering is an attempt to ensure that applications
@@ -167,13 +176,10 @@ this inevitably requires incompatible versions of the same DLLs to have
different names.
Pthreads-win32 has adopted the Cygwin convention of appending a single
-integer number to the DLL name. The number used is based on the library
-version number and is computed as 'current' - 'age'.
-
-(See http://home.att.net/~perlspinr/libversioning.html for a nicely
-detailed explanation.)
+integer number to the DLL name. The number used is simply the library's
+major version number.
-Using this method, DLL name/s will only change when the DLL's
+Consequently, DLL name/s will only change when the DLL's
backwards compatibility changes. Note that the addition of new
'interfaces' will not of itself change the DLL's compatibility for older
applications.
@@ -186,51 +192,18 @@ or,
What are all these pthread*.dll and pthread*.lib files?
-------------------------------------------------------
-Simple, use either pthreadGCv.* if you use GCC, or pthreadVCv.* if you
-use MSVC - where 'v' is the DLL versioning (compatibility) number.
+Simple, use either pthreadGCc.* if you use GCC, or pthreadVCc.* if you
+use MSVC - where 'c' is the DLL versioning (compatibility) number.
Otherwise, you need to choose carefully and know WHY.
The most important choice you need to make is whether to use a
version that uses exceptions internally, or not. There are versions
of the library that use exceptions as part of the thread
-cancelation and exit implementation. The default version uses
+cancellation and exit implementation. The default version uses
setjmp/longjmp.
-There is some contension amongst POSIX threads experts as
-to how POSIX threads cancelation and exit should work
-with languages that use exceptions, e.g. C++ and even C
-(Microsoft's Structured Exceptions).
-
-The issue is: should cancelation of a thread in, say,
-a C++ application cause object destructors and C++ exception
-handlers to be invoked as the stack unwinds during thread
-exit, or not?
-
-There seems to be more opinion in favour of using the
-standard C version of the library (no EH) with C++ applications
-for the reason that this appears to be the assumption commercial
-pthreads implementations make. Therefore, if you use an EH version
-of pthreads-win32 then you may be under the illusion that
-your application will be portable, when in fact it is likely to
-behave differently when linked with other pthreads libraries.
-
-Now you may be asking: then why have you kept the EH versions of
-the library?
-
-There are a couple of reasons:
-- there is division amongst the experts and so the code may
- be needed in the future. Yes, it's in the repository and we
- can get it out anytime in the future, but it would be difficult
- to find.
-- pthreads-win32 is one of the few implementations, and possibly
- the only freely available one, that has EH versions. It may be
- useful to people who want to play with or study application
- behaviour under these conditions.
-
-Notes:
-
-[If you use either pthreadVCE or pthreadGCE]
+If you use either pthreadVCE or pthreadGCE:
1. [See also the discussion in the FAQ file - Q2, Q4, and Q5]
@@ -248,13 +221,9 @@ threads then you will need to replace the "catch(...)" with the macro
}
#endif
-Otherwise neither pthreads cancelation nor pthread_exit() will work
+Otherwise neither pthreads cancellation nor pthread_exit() will work
reliably when using versions of the library that use C++ exceptions
-for cancelation and thread exit.
-
-This is due to what is believed to be a C++ compliance error in VC++
-whereby you may not have multiple handlers for the same exception in
-the same try/catch block. GNU G++ doesn't have this restriction.
+for cancellation and thread exit.
Other name changes
@@ -285,7 +254,7 @@ from the compiler used, and one of the following was defined accordingly:
__CLEANUP_C C, including GNU GCC, not MSVC
These defines determine the style of cleanup (see pthread.h) and,
-most importantly, the way that cancelation and thread exit (via
+most importantly, the way that cancellation and thread exit (via
pthread_exit) is performed (see the routine ptw32_throw()).
In short, the exceptions versions of the library throw an exception
@@ -297,7 +266,7 @@ is when it's canceled or exits via pthread_exit().
In this snapshot, unless the build explicitly defines (e.g. via a
compiler option) __CLEANUP_SEH, __CLEANUP_CXX, or __CLEANUP_C, then
the build NOW always defaults to __CLEANUP_C style cleanup. This style
-uses setjmp/longjmp in the cancelation and pthread_exit implementations,
+uses setjmp/longjmp in the cancellation and pthread_exit implementations,
and therefore won't do stack unwinding even when linked to applications
that have it (e.g. C++ apps). This is for consistency with most/all
commercial Unix POSIX threads implementations.
@@ -329,104 +298,185 @@ now run or crash in similar ways irrespective of the pthreads platform
you use. Or at least this is the hope.
-Building under VC++ using C++ EH, Structured EH, or just C
-----------------------------------------------------------
+Development Build Toolchains and Configurations
+-----------------------------------------------
+
+As of Release 2.10 all build configurations pass the full test suite
+for the following toolchains and configurations:
+
+DLL and static library (full inlined and small) builds:
+VC, VCE, VSE
+GC, GCE
+
+MSVS:
+Intel Core i7 (6 Core HT)
+Windows 7 64 bit
+MSVS 2010 Express with SDK 7.1 (using the SDK command shell)
+TARGET_CPU = x64 and x86
+
+GNU:
+Intel Core i7 (6 Core HT)
+Windows 7 64 bit
+MinGW64 multilib enabled
+ARCH = -m32 and -m64
+
+
+Building with MS Visual Studio (C, VC++ using C++ EH, or Structured EH)
+-----------------------------------------------------------------------
From the source directory run nmake without any arguments to list
help information. E.g.
$ nmake
-Microsoft (R) Program Maintenance Utility Version 6.00.8168.0
-Copyright (C) Microsoft Corp 1988-1998. All rights reserved.
+As examples, as at Release 2.10 the pre-built DLLs and static libraries
+are built from the following command-lines:
+
+[Note: "setenv" comes with the SDK. "/2003" is used to override my build
+system which is Win7 (at the time of writing) for backwards compatibility.]
+
+$ setenv /x64 /2003 /Release
+$ nmake realclean VC
+$ nmake realclean VCE
+$ nmake realclean VSE
+$ nmake realclean VC-static
+$ nmake realclean VCE-static
+$ nmake realclean VSE-static
+$ setenv /x86 /2003 /Release
+$ nmake realclean VC
+$ nmake realclean VCE
+$ nmake realclean VSE
+$ nmake realclean VC-static
+$ nmake realclean VCE-static
+$ nmake realclean VSE-static
-Run one of the following command lines:
-nmake clean VCE (to build the MSVC dll with C++ exception handling)
-nmake clean VSE (to build the MSVC dll with structured exception handling)
-nmake clean VC (to build the MSVC dll with C cleanup code)
-nmake clean VCE-inlined (to build the MSVC inlined dll with C++ exception handling)
-nmake clean VSE-inlined (to build the MSVC inlined dll with structured exception handling)
-nmake clean VC-inlined (to build the MSVC inlined dll with C cleanup code)
-nmake clean VC-static (to build the MSVC static lib with C cleanup code)
-nmake clean VCE-debug (to build the debug MSVC dll with C++ exception handling)
-nmake clean VSE-debug (to build the debug MSVC dll with structured exception handling)
-nmake clean VC-debug (to build the debug MSVC dll with C cleanup code)
-nmake clean VCE-inlined-debug (to build the debug MSVC inlined dll with C++ exception handling)
-nmake clean VSE-inlined-debug (to build the debug MSVC inlined dll with structured exception handling)
-nmake clean VC-inlined-debug (to build the debug MSVC inlined dll with C cleanup code)
-nmake clean VC-static-debug (to build the debug MSVC static lib with C cleanup code)
+If you want to differentiate between libraries by their names you can use,
+e.g.:
+$ nmake realclean VC EXTRAVERSION="-w64"
-The pre-built dlls are normally built using the *-inlined targets.
+The string provided via the variable EXTRAVERSION is appended to the dll
+and .lib library names, e.g.:
+
+pthreadVC2-w64.dll
+pthreadVC2-w64.lib
+
+To build and test all DLLs and static lib compatibility versions
+(VC, VCE, VSE):
+
+[Note that the EXTRAVERSION="..." option is passed to the tests Makefile
+when you target "all-tests". If you change to the tests directory and
+run the tests you will need to repeat the option explicitly to the test
+"nmake" command-line.]
+
+$ setenv /x64 /2003 /release
+$ nmake all-tests
You can run the testsuite by changing to the "tests" directory and
running nmake. E.g.:
$ cd tests
-$ nmake
+$ nmake VC
+
+For failure analysis etc. individual tests can be built
+and run, e.g:
-Microsoft (R) Program Maintenance Utility Version 6.00.8168.0
-Copyright (C) Microsoft Corp 1988-1998. All rights reserved.
+$ cd tests
+$ nmake VC TESTS="foo bar"
+
+This builds and runs all prerequisite tests as well as the individual
+tests listed. Prerequisite tests are defined in tests\runorder.mk.
+
+To build and run only those tests listed use, i.e. without the
+additional prerequistite dependency tests:
-Run one of the following command lines:
-nmake clean VC (to test using VC dll with VC (no EH) applications)
-nmake clean VCX (to test using VC dll with VC++ (EH) applications)
-nmake clean VCE (to test using the VCE dll with VC++ EH applications)
-nmake clean VSE (to test using VSE dll with VC (SEH) applications)
-nmake clean VC-bench (to benchtest using VC dll with C bench app)
-nmake clean VCX-bench (to benchtest using VC dll with C++ bench app)
-nmake clean VCE-bench (to benchtest using VCE dll with C++ bench app)
-nmake clean VSE-bench (to benchtest using VSE dll with SEH bench app)
-nmake clean VC-static (to test using VC static lib with VC (no EH) applications)
+$ cd tests
+$ nmake VC NO_DEPS=1 TESTS="foo bar"
-Building under Mingw32
-----------------------
+Building with MinGW
+-------------------
-The dll can be built easily with recent versions of Mingw32.
-(The distributed versions are built using Mingw32 and MsysDTK
-from www.mingw32.org.)
+Please use Mingw64 to build either 64 or 32 bit variants of the DLL that will
+run on 64 bit systems. We have found that Mingw32 builds of the GCE library
+variants fail when run on 64 bit systems.
-From the source directory, run make for help information. E.g.:
+From the source directory, run 'make' without arguments for help information.
$ make
-Run one of the following command lines:
-make clean GC (to build the GNU C dll with C cleanup code)
-make clean GCE (to build the GNU C dll with C++ exception handling)
-make clean GC-inlined (to build the GNU C inlined dll with C cleanup code)
-make clean GCE-inlined (to build the GNU C inlined dll with C++ exception handling)
-make clean GC-static (to build the GNU C inlined static lib with C cleanup code)
-make clean GC-debug (to build the GNU C debug dll with C cleanup code)
-make clean GCE-debug (to build the GNU C debug dll with C++ exception handling)
-make clean GC-inlined-debug (to build the GNU C inlined debug dll with C cleanup code)
-make clean GCE-inlined-debug (to build the GNU C inlined debug dll with C++ exception handling)
-make clean GC-static-debug (to build the GNU C inlined static debug lib with C cleanup code)
+With MinGW64 multilib installed the following variables can be defined
+either on the make command line or in the shell environment:
+
+ARCH
+ - possible values are "-m64" and "-m32". You will probably recognise
+ these as gcc flags however the GNUmakefile also converts these into
+ the appropriate windres options when building version.o.
+
+As examples, as at Release 2.10 the pre-built DLLs and static libraries
+are built from the following command-lines:
-The pre-built dlls are normally built using the *-inlined targets.
+$ nmake realclean GC ARCH=-m64
+$ nmake realclean GC ARCH=-m32
+$ nmake realclean GCE ARCH=-m64
+$ nmake realclean GCE ARCH=-m32
+$ nmake realclean GC-static ARCH=-m64
+$ nmake realclean GC-static ARCH=-m32
+$ nmake realclean GCE-static ARCH=-m64
+$ nmake realclean GCE-static ARCH=-m32
+
+If you want to differentiate between libraries by their names you can use,
+e.g.:
+
+$ make realclean GC ARCH="-m64" EXTRAVERSION="-w64"
+
+The string provided via the variable EXTRAVERSION is appended to the dll
+and .a library names, e.g.:
+
+pthreadGC2-w64.dll
+libpthreadGC2-w64.a
+
+To build and test all DLLs and static lib compatibility variants (GC, GCE):
+
+Note that the ARCH="..." and/or EXTRAVERSION="..." options are passed to the
+tests GNUmakefile when you target "all-tests". If you change to the tests
+directory and run the tests you will need to repeat those options explicitly
+to the test "make" command-line.
+
+$ make all-tests
+or, with MinGW64 (multilib enabled):
+$ make all-tests ARCH=-m64
+$ make all-tests ARCH=-m32
You can run the testsuite by changing to the "tests" directory and
-running make for help information. E.g.:
+running make. E.g.:
$ cd tests
-$ make
-Run one of the following command lines:
-make clean GC (to test using GC dll with C (no EH) applications)
-make clean GCX (to test using GC dll with C++ (EH) applications)
-make clean GCE (to test using GCE dll with C++ (EH) applications)
-make clean GC-bench (to benchtest using GNU C dll with C cleanup code)
-make clean GCE-bench (to benchtest using GNU C dll with C++ exception handling)
-make clean GC-static (to test using GC static lib with C (no EH) applications)
+$ make GC
+
+For failure analysis etc. individual tests can be built and run, e.g:
+$ cd tests
+$ make GC TESTS="foo bar"
+
+This builds and runs all prerequisite tests as well as the individual
+tests listed. Prerequisite tests are defined in tests\runorder.mk.
-Building under Linux using the Mingw32 cross development tools
---------------------------------------------------------------
+To build and run only those tests listed use, i.e. without the additional
+prerequistite dependency tests:
-You can build the library without leaving Linux by using the Mingw32 cross
-development toolchain. See http://www.libsdl.org/extras/win32/cross/ for
-tools and info. The GNUmakefile contains some support for this, for example:
+$ cd tests
+$ make GC NO_DEPS=1 TESTS="foo bar"
-make CROSS=i386-mingw32msvc- clean GC-inlined
+
+Building under Linux using the MinGW cross development tools
+------------------------------------------------------------
+
+You can build the library on Linux by using the MinGW cross development
+toolchain. See http://www.libsdl.org/extras/win32/cross/ for tools and
+info. The GNUmakefile contains some support for this, for example:
+
+make CROSS=i386-mingw32msvc- clean GC
will build pthreadGCn.dll and libpthreadGCn.a (n=version#), provided your
cross-tools/bin directory is in your PATH (or use the cross-make.sh script
@@ -449,30 +499,12 @@ MinGW32 (creates libpthreadGCn.a as a static link lib):
make clean GC-static
-
-Define PTW32_STATIC_LIB when building your application. Also, your
-application must call a two non-portable routines to initialise the
-some state on startup and cleanup before exit. One other routine needs
-to be called to cleanup after any Win32 threads have called POSIX API
-routines. See README.NONPORTABLE or the html reference manual pages for
-details on these routines:
-
-BOOL pthread_win32_process_attach_np (void);
-BOOL pthread_win32_process_detach_np (void);
-BOOL pthread_win32_thread_attach_np (void); // Currently a no-op
-BOOL pthread_win32_thread_detach_np (void);
-
-
-The tests makefiles have the same targets but only check that the
-static library is statically linkable. They don't run the full
-testsuite. To run the full testsuite, build the dlls and run the
-dll test targets.
-
+Define PTW32_STATIC_LIB also when building your application.
Building the library under Cygwin
---------------------------------
-Cygwin is implementing it's own POSIX threads routines and these
+Cygwin implements it's own POSIX threads routines and these
will be the ones to use if you develop using Cygwin.
@@ -485,39 +517,34 @@ from the FTP site (see under "Availability" below):
pthread.h
semaphore.h
sched.h
- pthreadVC.dll - built with MSVC compiler using C setjmp/longjmp
- pthreadVC.lib
- pthreadVCE.dll - built with MSVC++ compiler using C++ EH
- pthreadVCE.lib
- pthreadVSE.dll - built with MSVC compiler using SEH
- pthreadVSE.lib
- pthreadGC.dll - built with Mingw32 GCC
- libpthreadGC.a - derived from pthreadGC.dll
- pthreadGCE.dll - built with Mingw32 G++
- libpthreadGCE.a - derived from pthreadGCE.dll
-
-As of August 2003 pthreads-win32 pthreadG* versions are built and tested
-using the MinGW + MsysDTK environment current as of that date or later.
-The following file MAY be needed for older MinGW environments.
-
- gcc.dll - needed to build and run applications that use
- pthreadGCE.dll.
-
+ pthreadVC2.dll - built with MSVC compiler using C setjmp/longjmp
+ pthreadVC2.lib
+ pthreadVCE2.dll - built with MSVC++ compiler using C++ EH
+ pthreadVCE2.lib
+ pthreadVSE2.dll - built with MSVC compiler using SEH
+ pthreadVSE2.lib
+ pthreadGC2.dll - built with Mingw32 GCC
+ libpthreadGC2.a - derived from pthreadGC.dll
+ pthreadGCE2.dll - built with Mingw32 G++
+ libpthreadGCE2.a - derived from pthreadGCE.dll
+
+You may also need to include runtime DLLs from your SDK when
+distributing your applications.
Building applications with GNU compilers
----------------------------------------
-If you're using pthreadGC.dll:
+If you're using pthreadGC2.dll:
-With the three header files, pthreadGC.dll and libpthreadGC.a in the
+With the three header files, pthreadGC2.dll and libpthreadGC2.a in the
same directory as your application myapp.c, you could compile, link
-and run myapp.c under Mingw32 as follows:
+and run myapp.c under MinGW as follows:
- gcc -o myapp.exe myapp.c -I. -L. -lpthreadGC
+ gcc -o myapp.exe myapp.c -I. -L. -lpthreadGC2
myapp
-Or put pthreadGC.dll in an appropriate directory in your PATH,
-put libpthreadGC.a in your system lib directory, and
+Or put pthreadGC2.dll in an appropriate directory in your PATH,
+put libpthreadGC2.a in your system lib directory, and
put the three header files in your system include directory,
then use:
@@ -525,13 +552,13 @@ then use:
myapp
-If you're using pthreadGCE.dll:
+If you're using pthreadGCE2.dll:
-With the three header files, pthreadGCE.dll, gcc.dll and libpthreadGCE.a
+With the three header files, pthreadGCE2.dll and libpthreadGCE2.a
in the same directory as your application myapp.c, you could compile,
link and run myapp.c under Mingw32 as follows:
- gcc -x c++ -o myapp.exe myapp.c -I. -L. -lpthreadGCE
+ gcc -x c++ -o myapp.exe myapp.c -I. -L. -lpthreadGCE2
myapp
Or put pthreadGCE.dll and gcc.dll in an appropriate directory in
diff --git a/pthreads/README.CV b/pthreads/README.CV
index 698728b95..735196c30 100644
--- a/pthreads/README.CV
+++ b/pthreads/README.CV
@@ -686,15 +686,15 @@ Sleep( 1 ); // @AT
* a timeout
*
* Note:
- * ptw32_sem_timedwait is a cancelation point,
+ * ptw32_sem_timedwait is a cancellation point,
* hence providing the
- * mechanism for making pthread_cond_wait a cancelation
+ * mechanism for making pthread_cond_wait a cancellation
* point. We use the cleanup mechanism to ensure we
* re-lock the mutex and decrement the waiters count
* if we are canceled.
*/
if (ptw32_sem_timedwait (&(cv->sema), abstime) == -1) {
- result = errno;
+ result = PTW32_GET_ERRNO();
}
}
@@ -1272,7 +1272,7 @@ ptw32_cond_wait_cleanup(void * args)
*/
if (sem_post(&(cv->semBlockLock)) != 0)
{(sem_post(&(cv->semBlockLock))
- *resultPtr = errno;
+ *resultPtr = PTW32_GET_ERRNO();
return;
}
}
@@ -1286,7 +1286,7 @@ ptw32_cond_wait_cleanup(void * args)
*/
if (sem_post(&(cv->semBlockQueue)) != 0)
{(sem_post(&(cv->semBlockQueue))
- *resultPtr = errno;
+ *resultPtr = PTW32_GET_ERRNO();
return;
}
}
@@ -1385,7 +1385,7 @@ ptw32_cond_timedwait (pthread_cond_t * cond,
*/
if (ptw32_sem_timedwait (&(cv->semBlockQueue), abstime) != 0)
{(ptw32_sem_timedwait
- result = errno;
+ result = PTW32_GET_ERRNO();
}
}
diff --git a/pthreads/README.NONPORTABLE b/pthreads/README.NONPORTABLE
index 0821104d8..9f94c6948 100644
--- a/pthreads/README.NONPORTABLE
+++ b/pthreads/README.NONPORTABLE
@@ -25,7 +25,7 @@ pthread_win32_test_features_np(int mask)
QUSEREX.DLL is available and the AlertDrv.sys
driver is loaded into Windows, providing
alertable (pre-emptive) asyncronous threads
- cancelation. If this feature returns FALSE
+ cancellation. If this feature returns FALSE
then the default async cancel scheme is in
use, which cannot cancel blocked threads.
@@ -111,7 +111,7 @@ pthread_mutexattr_getkind_np(pthread_mutexattr_t * attr, int *kind)
PTHREAD_MUTEX_RECURSIVE
int
-pthread_delay_np (const struct timespec *interval);
+pthread_delay_np (const struct timespec *interval)
This routine causes a thread to delay execution for a specific period of time.
This period ends at the current time plus the specified interval. The routine
@@ -121,9 +121,9 @@ pthread_delay_np (const struct timespec *interval);
Specifying an interval of zero (0) seconds and zero (0) nanoseconds is
allowed and can be used to force the thread to give up the processor or to
- deliver a pending cancelation request.
+ deliver a pending cancellation request.
- This routine is a cancelation point.
+ This routine is a cancellation point.
The timespec structure contains the following two fields:
@@ -139,6 +139,16 @@ pthread_delay_np (const struct timespec *interval);
[EINVAL] The value specified by interval is invalid.
int
+pthread_timedjoin_np (pthread_t thread, void **value_ptr, const struct timespec *abstime)
+
+int
+pthread_tryjoin_np (pthread_t thread, void **value_ptr)
+
+ These function is added for compatibility with Linux.
+
+
+
+int
pthread_num_processors_np (void)
This routine (found on HPUX systems) returns the number of processors
@@ -158,26 +168,18 @@ pthread_win32_thread_attach_np (void);
BOOL
pthread_win32_thread_detach_np (void);
- These functions contain the code normally run via dllMain
- when the library is used as a dll but which need to be
- called explicitly by an application when the library
- is statically linked. As of version 2.9.0 of the library, static
- builds using either MSC or GCC will call pthread_win32_process_*
- automatically at application startup and exit respectively.
-
- Otherwise, you will need to call pthread_win32_process_attach_np()
- before you can call any pthread routines when statically linking.
- You should call pthread_win32_process_detach_np() before
- exiting your application to clean up.
+ These functions contain the code normally run via DllMain
+ when the library is used as a dll. As of version 2.9.0 of the
+ library, static builds using either MSC or GCC will call
+ pthread_win32_process_* automatically at application startup and
+ exit respectively.
- pthread_win32_thread_attach_np() is currently a no-op, but
- pthread_win32_thread_detach_np() is needed to clean up
- the implicit pthread handle that is allocated to a Win32 thread if
- it calls any pthreads routines. Call this routine when the
- Win32 thread exits.
-
- Threads created through pthread_create() do not need to call
- pthread_win32_thread_detach_np().
+ pthread_win32_thread_attach_np() is currently a no-op.
+
+ pthread_win32_thread_detach_np() is not a no-op. It cleans up the
+ implicit pthread handle that is allocated to any thread not started
+ via pthread_create(). Such non-posix threads should call this routine
+ when they exit, or call pthread_exit() to both cleanup and exit.
These functions invariably return TRUE except for
pthread_win32_process_attach_np() which will return FALSE
@@ -402,7 +404,7 @@ pthread_hash()
A single more general purpose function could also be defined as a
basis for at least the last two of the above functions.
-First we need to list the freedoms and constraints with restpect
+First we need to list the freedoms and constraints with respect
to pthread_t so that we can be sure our solution is compatible with the
standard.
@@ -772,12 +774,14 @@ I have not provided any solution to the problem of handling extra values embedde
in pthread_t, e.g. debugging or trap information that an implementation is entitled
to include. Therefore none of this replaces the portability and flexibility of API
functions but what functions are needed? The threads standard is unlikely to
-include that can be implemented by a combination of existing features and more
-generic functions (several references in the threads rationale suggest this.
+include new functions that can be implemented by a combination of existing features
+and more generic functions (several references in the threads rationale suggest this).
Therefore I propose that the following function could replace the several functions
that have been suggested in conversations:
pthread_t * pthread_normalize(pthread_t * handle);
For most existing pthreads implementations this function, or macro, would reduce to
-a no-op with zero call overhead.
+a no-op with zero call overhead. Most of the other desired operations on pthread_t
+values (null, compare, hash, etc.) can be trivially derived from this and other
+standard functions.
diff --git a/pthreads/TODO b/pthreads/TODO
index fa9efc46e..e59205b4f 100644
--- a/pthreads/TODO
+++ b/pthreads/TODO
@@ -4,4 +4,20 @@
1. Implement PTHREAD_PROCESS_SHARED for semaphores, mutexes,
condition variables, read/write locks, barriers.
+2. For version 3 onwards: the following types need to change, resulting in an ABI
+ change:
+ a) ptw32_handle_t (a.k.a. pthread_t)
+ Change the reuse counter from unsigned int to size_t. Type "int" on 32 bit
+ and 64 bit Windows is 32 bits wide.
+
+ To give an indication of relative effectiveness of the current "unsigned int",
+ consider an application that creates and detaches threads at the rate of 1
+ per millisecond. At this rate the reuse counter will max out after 49 days.
+
+ After changing to "size_t" an application compiled for x64 and creating and
+ detaching a thread every nanosecond would max out after 584 years.
+
+ b) pthread_once_t
+ Remove unused elements.
+ \ No newline at end of file
diff --git a/pthreads/autostatic.c b/pthreads/autostatic.c
index 092aff2ae..3f7938881 100644
--- a/pthreads/autostatic.c
+++ b/pthreads/autostatic.c
@@ -8,9 +8,10 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
*
- * Contact Email: rpj@callisto.canberra.edu.au
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
*
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
@@ -34,36 +35,77 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
-#if defined(PTW32_STATIC_LIB)
-
-#if defined(__MINGW64__) || defined(__MINGW32__) || defined(_MSC_VER)
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
#include "pthread.h"
#include "implement.h"
-static void on_process_init(void)
+#if defined(PTW32_STATIC_LIB)
+
+#if defined(PTW32_CONFIG_MINGW) || defined(_MSC_VER)
+
+/* For an explanation of this code (at least the MSVC parts), refer to
+ *
+ * http://www.codeguru.com/cpp/misc/misc/threadsprocesses/article.php/c6945/
+ * ("Running Code Before and After Main")
+ *
+ * Compatibility with MSVC8 was cribbed from Boost:
+ *
+ * http://svn.boost.org/svn/boost/trunk/libs/thread/src/win32/tss_pe.cpp
+ *
+ * In addition to that, because we are in a static library, and the linker
+ * can't tell that the constructor/destructor functions are actually
+ * needed, we need a way to prevent the linker from optimizing away this
+ * module. The pthread_win32_autostatic_anchor() hack below (and in
+ * implement.h) does the job in a portable manner.
+ */
+
+static int on_process_init(void)
{
pthread_win32_process_attach_np ();
+ return 0;
}
-static void on_process_exit(void)
+static int on_process_exit(void)
{
pthread_win32_thread_detach_np ();
pthread_win32_process_detach_np ();
+ return 0;
}
-#if defined(__MINGW64__) || defined(__MINGW32__)
-# define attribute_section(a) __attribute__((section(a)))
+#if defined(PTW32_CONFIG_MINGW)
+__attribute__((section(".ctors"), used)) static int (*gcc_ctor)(void) = on_process_init;
+__attribute__((section(".dtors"), used)) static int (*gcc_dtor)(void) = on_process_exit;
#elif defined(_MSC_VER)
-# define attribute_section(a) __pragma(section(a,long,read)); __declspec(allocate(a))
+# if _MSC_VER >= 1400 /* MSVC8 */
+# pragma section(".CRT$XCU", long, read)
+# pragma section(".CRT$XPU", long, read)
+__declspec(allocate(".CRT$XCU")) static int (*msc_ctor)(void) = on_process_init;
+__declspec(allocate(".CRT$XPU")) static int (*msc_dtor)(void) = on_process_exit;
+# else
+# pragma data_seg(".CRT$XCU")
+static int (*msc_ctor)(void) = on_process_init;
+# pragma data_seg(".CRT$XPU")
+static int (*msc_dtor)(void) = on_process_exit;
+# pragma data_seg() /* reset data segment */
+# endif
#endif
-attribute_section(".ctors") void *gcc_ctor = on_process_init;
-attribute_section(".dtors") void *gcc_dtor = on_process_exit;
+#endif /* defined(PTW32_CONFIG_MINGW) || defined(_MSC_VER) */
-attribute_section(".CRT$XCU") void *msc_ctor = on_process_init;
-attribute_section(".CRT$XPU") void *msc_dtor = on_process_exit;
-
-#endif /* defined(__MINGW64__) || defined(__MINGW32__) || defined(_MSC_VER) */
+/* This dummy function exists solely to be referenced by other modules
+ * (specifically, in implement.h), so that the linker can't optimize away
+ * this module. Don't call it.
+ */
+void ptw32_autostatic_anchor(void) { abort(); }
#endif /* PTW32_STATIC_LIB */
+
+#if ! defined(PTW32_BUILD_INLINED)
+/*
+ * Avoid "translation unit is empty" warnings
+ */
+typedef int foo;
+#endif
diff --git a/pthreads/builddmc.bat b/pthreads/builddmc.bat
index bf813d816..18e328d76 100644
--- a/pthreads/builddmc.bat
+++ b/pthreads/builddmc.bat
@@ -3,7 +3,7 @@
set DMCDIR=c:\dm
; RELEASE
-%DMCDIR%\bin\dmc -D_WIN32_WINNT -D_MT -DHAVE_PTW32_CONFIG_H -I.;c:\dm\include -o+all -WD pthread.c user32.lib+kernel32.lib+wsock32.lib -L/impl -L/NODEBUG -L/SU:WINDOWS
+%DMCDIR%\bin\dmc -D_MT -DHAVE_CONFIG_H -I.;c:\dm\include -o+all -WD pthread.c user32.lib+kernel32.lib+wsock32.lib -L/impl -L/NODEBUG -L/SU:WINDOWS
; DEBUG
-%DMCDIR%\bin\dmc -g -D_WIN32_WINNT -D_MT -DHAVE_PTW32_CONFIG_H -I.;c:\dm\include -o+all -WD pthread.c user32.lib+kernel32.lib+wsock32.lib -L/impl -L/SU:WINDOWS
+%DMCDIR%\bin\dmc -g -D_MT -DHAVE_CONFIG_H -I.;c:\dm\include -o+all -WD pthread.c user32.lib+kernel32.lib+wsock32.lib -L/impl -L/SU:WINDOWS
diff --git a/pthreads/cleanup.c b/pthreads/cleanup.c
index 381d1e87c..ae8ae4187 100644
--- a/pthreads/cleanup.c
+++ b/pthreads/cleanup.c
@@ -10,10 +10,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -36,6 +37,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/common.mk b/pthreads/common.mk
new file mode 100755
index 000000000..da26f719e
--- /dev/null
+++ b/pthreads/common.mk
@@ -0,0 +1,309 @@
+# Common makefile definitions
+
+RESOURCE_OBJS = \
+ version.$(RESEXT)
+
+# pthread.c aggregates all source into a single compilation unit for inlinability
+DLL_OBJS = \
+ pthread.$(OBJEXT)
+
+# Separate modules for minimising the size of statically linked images
+STATIC_OBJS = \
+ autostatic.$(OBJEXT) \
+ cleanup.$(OBJEXT) \
+ create.$(OBJEXT) \
+ dll.$(OBJEXT) \
+ errno.$(OBJEXT) \
+ global.$(OBJEXT) \
+ pthread_attr_destroy.$(OBJEXT) \
+ pthread_attr_getdetachstate.$(OBJEXT) \
+ pthread_attr_getinheritsched.$(OBJEXT) \
+ pthread_attr_getschedparam.$(OBJEXT) \
+ pthread_attr_getschedpolicy.$(OBJEXT) \
+ pthread_attr_getscope.$(OBJEXT) \
+ pthread_attr_getstackaddr.$(OBJEXT) \
+ pthread_attr_getstacksize.$(OBJEXT) \
+ pthread_attr_init.$(OBJEXT) \
+ pthread_attr_setdetachstate.$(OBJEXT) \
+ pthread_attr_setinheritsched.$(OBJEXT) \
+ pthread_attr_setschedparam.$(OBJEXT) \
+ pthread_attr_setschedpolicy.$(OBJEXT) \
+ pthread_attr_setscope.$(OBJEXT) \
+ pthread_attr_setstackaddr.$(OBJEXT) \
+ pthread_attr_setstacksize.$(OBJEXT) \
+ pthread_barrier_destroy.$(OBJEXT) \
+ pthread_barrier_init.$(OBJEXT) \
+ pthread_barrier_wait.$(OBJEXT) \
+ pthread_barrierattr_destroy.$(OBJEXT) \
+ pthread_barrierattr_getpshared.$(OBJEXT) \
+ pthread_barrierattr_init.$(OBJEXT) \
+ pthread_barrierattr_setpshared.$(OBJEXT) \
+ pthread_cancel.$(OBJEXT) \
+ pthread_cond_destroy.$(OBJEXT) \
+ pthread_cond_init.$(OBJEXT) \
+ pthread_cond_signal.$(OBJEXT) \
+ pthread_cond_wait.$(OBJEXT) \
+ pthread_condattr_destroy.$(OBJEXT) \
+ pthread_condattr_getpshared.$(OBJEXT) \
+ pthread_condattr_init.$(OBJEXT) \
+ pthread_condattr_setpshared.$(OBJEXT) \
+ pthread_delay_np.$(OBJEXT) \
+ pthread_detach.$(OBJEXT) \
+ pthread_equal.$(OBJEXT) \
+ pthread_exit.$(OBJEXT) \
+ pthread_getconcurrency.$(OBJEXT) \
+ pthread_getschedparam.$(OBJEXT) \
+ pthread_getspecific.$(OBJEXT) \
+ pthread_getunique_np.$(OBJEXT) \
+ pthread_getw32threadhandle_np.$(OBJEXT) \
+ pthread_join.$(OBJEXT) \
+ pthread_timedjoin_np.$(OBJEXT) \
+ pthread_tryjoin_np.$(OBJEXT) \
+ pthread_key_create.$(OBJEXT) \
+ pthread_key_delete.$(OBJEXT) \
+ pthread_kill.$(OBJEXT) \
+ pthread_mutex_consistent.$(OBJEXT) \
+ pthread_mutex_destroy.$(OBJEXT) \
+ pthread_mutex_init.$(OBJEXT) \
+ pthread_mutex_lock.$(OBJEXT) \
+ pthread_mutex_timedlock.$(OBJEXT) \
+ pthread_mutex_trylock.$(OBJEXT) \
+ pthread_mutex_unlock.$(OBJEXT) \
+ pthread_mutexattr_destroy.$(OBJEXT) \
+ pthread_mutexattr_getkind_np.$(OBJEXT) \
+ pthread_mutexattr_getpshared.$(OBJEXT) \
+ pthread_mutexattr_getrobust.$(OBJEXT) \
+ pthread_mutexattr_gettype.$(OBJEXT) \
+ pthread_mutexattr_init.$(OBJEXT) \
+ pthread_mutexattr_setkind_np.$(OBJEXT) \
+ pthread_mutexattr_setpshared.$(OBJEXT) \
+ pthread_mutexattr_setrobust.$(OBJEXT) \
+ pthread_mutexattr_settype.$(OBJEXT) \
+ pthread_num_processors_np.$(OBJEXT) \
+ pthread_once.$(OBJEXT) \
+ pthread_rwlock_destroy.$(OBJEXT) \
+ pthread_rwlock_init.$(OBJEXT) \
+ pthread_rwlock_rdlock.$(OBJEXT) \
+ pthread_rwlock_timedrdlock.$(OBJEXT) \
+ pthread_rwlock_timedwrlock.$(OBJEXT) \
+ pthread_rwlock_tryrdlock.$(OBJEXT) \
+ pthread_rwlock_trywrlock.$(OBJEXT) \
+ pthread_rwlock_unlock.$(OBJEXT) \
+ pthread_rwlock_wrlock.$(OBJEXT) \
+ pthread_rwlockattr_destroy.$(OBJEXT) \
+ pthread_rwlockattr_getpshared.$(OBJEXT) \
+ pthread_rwlockattr_init.$(OBJEXT) \
+ pthread_rwlockattr_setpshared.$(OBJEXT) \
+ pthread_self.$(OBJEXT) \
+ pthread_setaffinity.$(OBJEXT) \
+ pthread_setcancelstate.$(OBJEXT) \
+ pthread_setcanceltype.$(OBJEXT) \
+ pthread_setconcurrency.$(OBJEXT) \
+ pthread_setschedparam.$(OBJEXT) \
+ pthread_setspecific.$(OBJEXT) \
+ pthread_spin_destroy.$(OBJEXT) \
+ pthread_spin_init.$(OBJEXT) \
+ pthread_spin_lock.$(OBJEXT) \
+ pthread_spin_trylock.$(OBJEXT) \
+ pthread_spin_unlock.$(OBJEXT) \
+ pthread_testcancel.$(OBJEXT) \
+ pthread_timechange_handler_np.$(OBJEXT) \
+ pthread_win32_attach_detach_np.$(OBJEXT) \
+ ptw32_MCS_lock.$(OBJEXT) \
+ ptw32_callUserDestroyRoutines.$(OBJEXT) \
+ ptw32_calloc.$(OBJEXT) \
+ ptw32_cond_check_need_init.$(OBJEXT) \
+ ptw32_getprocessors.$(OBJEXT) \
+ ptw32_is_attr.$(OBJEXT) \
+ ptw32_mutex_check_need_init.$(OBJEXT) \
+ ptw32_new.$(OBJEXT) \
+ ptw32_processInitialize.$(OBJEXT) \
+ ptw32_processTerminate.$(OBJEXT) \
+ ptw32_relmillisecs.$(OBJEXT) \
+ ptw32_reuse.$(OBJEXT) \
+ ptw32_rwlock_cancelwrwait.$(OBJEXT) \
+ ptw32_rwlock_check_need_init.$(OBJEXT) \
+ ptw32_semwait.$(OBJEXT) \
+ ptw32_spinlock_check_need_init.$(OBJEXT) \
+ ptw32_threadDestroy.$(OBJEXT) \
+ ptw32_threadStart.$(OBJEXT) \
+ ptw32_throw.$(OBJEXT) \
+ ptw32_timespec.$(OBJEXT) \
+ ptw32_tkAssocCreate.$(OBJEXT) \
+ ptw32_tkAssocDestroy.$(OBJEXT) \
+ sched_get_priority_max.$(OBJEXT) \
+ sched_get_priority_min.$(OBJEXT) \
+ sched_getscheduler.$(OBJEXT) \
+ sched_setaffinity.$(OBJEXT) \
+ sched_setscheduler.$(OBJEXT) \
+ sched_yield.$(OBJEXT) \
+ sem_close.$(OBJEXT) \
+ sem_destroy.$(OBJEXT) \
+ sem_getvalue.$(OBJEXT) \
+ sem_init.$(OBJEXT) \
+ sem_open.$(OBJEXT) \
+ sem_post.$(OBJEXT) \
+ sem_post_multiple.$(OBJEXT) \
+ sem_timedwait.$(OBJEXT) \
+ sem_trywait.$(OBJEXT) \
+ sem_unlink.$(OBJEXT) \
+ sem_wait.$(OBJEXT) \
+ signal.$(OBJEXT) \
+ w32_CancelableWait.$(OBJEXT)
+
+PTHREAD_SRCS = \
+ ptw32_MCS_lock.c \
+ ptw32_is_attr.c \
+ ptw32_processInitialize.c \
+ ptw32_processTerminate.c \
+ ptw32_threadStart.c \
+ ptw32_threadDestroy.c \
+ ptw32_tkAssocCreate.c \
+ ptw32_tkAssocDestroy.c \
+ ptw32_callUserDestroyRoutines.c \
+ ptw32_semwait.c \
+ ptw32_timespec.c \
+ ptw32_throw.c \
+ ptw32_getprocessors.c \
+ ptw32_calloc.c \
+ ptw32_new.c \
+ ptw32_reuse.c \
+ ptw32_relmillisecs.c \
+ ptw32_cond_check_need_init.c \
+ ptw32_mutex_check_need_init.c \
+ ptw32_rwlock_check_need_init.c \
+ ptw32_rwlock_cancelwrwait.c \
+ ptw32_spinlock_check_need_init.c \
+ pthread_attr_init.c \
+ pthread_attr_destroy.c \
+ pthread_attr_getdetachstate.c \
+ pthread_attr_setdetachstate.c \
+ pthread_attr_getscope.c \
+ pthread_attr_setscope.c \
+ pthread_attr_getstackaddr.c \
+ pthread_attr_setstackaddr.c \
+ pthread_attr_getstacksize.c \
+ pthread_attr_setstacksize.c \
+ pthread_barrier_init.c \
+ pthread_barrier_destroy.c \
+ pthread_barrier_wait.c \
+ pthread_barrierattr_init.c \
+ pthread_barrierattr_destroy.c \
+ pthread_barrierattr_setpshared.c \
+ pthread_barrierattr_getpshared.c \
+ pthread_setcancelstate.c \
+ pthread_setcanceltype.c \
+ pthread_testcancel.c \
+ pthread_cancel.c \
+ pthread_condattr_destroy.c \
+ pthread_condattr_getpshared.c \
+ pthread_condattr_init.c \
+ pthread_condattr_setpshared.c \
+ pthread_cond_destroy.c \
+ pthread_cond_init.c \
+ pthread_cond_signal.c \
+ pthread_cond_wait.c \
+ create.c \
+ cleanup.c \
+ dll.c \
+ autostatic.c \
+ errno.c \
+ pthread_exit.c \
+ global.c \
+ pthread_equal.c \
+ pthread_getconcurrency.c \
+ pthread_kill.c \
+ pthread_once.c \
+ pthread_self.c \
+ pthread_setconcurrency.c \
+ w32_CancelableWait.c \
+ pthread_mutex_init.c \
+ pthread_mutex_destroy.c \
+ pthread_mutexattr_init.c \
+ pthread_mutexattr_destroy.c \
+ pthread_mutexattr_getpshared.c \
+ pthread_mutexattr_setpshared.c \
+ pthread_mutexattr_settype.c \
+ pthread_mutexattr_gettype.c \
+ pthread_mutexattr_setrobust.c \
+ pthread_mutexattr_getrobust.c \
+ pthread_mutex_lock.c \
+ pthread_mutex_timedlock.c \
+ pthread_mutex_unlock.c \
+ pthread_mutex_trylock.c \
+ pthread_mutex_consistent.c \
+ pthread_mutexattr_setkind_np.c \
+ pthread_mutexattr_getkind_np.c \
+ pthread_getw32threadhandle_np.c \
+ pthread_getunique_np.c \
+ pthread_setaffinity.c \
+ pthread_delay_np.c \
+ pthread_num_processors_np.c \
+ pthread_win32_attach_detach_np.c \
+ pthread_timechange_handler_np.c \
+ pthread_rwlock_init.c \
+ pthread_rwlock_destroy.c \
+ pthread_rwlockattr_init.c \
+ pthread_rwlockattr_destroy.c \
+ pthread_rwlockattr_getpshared.c \
+ pthread_rwlockattr_setpshared.c \
+ pthread_rwlock_rdlock.c \
+ pthread_rwlock_timedrdlock.c \
+ pthread_rwlock_wrlock.c \
+ pthread_rwlock_timedwrlock.c \
+ pthread_rwlock_unlock.c \
+ pthread_rwlock_tryrdlock.c \
+ pthread_rwlock_trywrlock.c \
+ pthread_attr_setschedpolicy.c \
+ pthread_attr_getschedpolicy.c \
+ pthread_attr_setschedparam.c \
+ pthread_attr_getschedparam.c \
+ pthread_attr_setinheritsched.c \
+ pthread_attr_getinheritsched.c \
+ pthread_setschedparam.c \
+ pthread_getschedparam.c \
+ sched_get_priority_max.c \
+ sched_get_priority_min.c \
+ sched_setscheduler.c \
+ sched_getscheduler.c \
+ sched_yield.c \
+ sched_setaffinity.c \
+ sem_init.c \
+ sem_destroy.c \
+ sem_trywait.c \
+ sem_timedwait.c \
+ sem_wait.c \
+ sem_post.c \
+ sem_post_multiple.c \
+ sem_getvalue.c \
+ sem_open.c \
+ sem_close.c \
+ sem_unlink.c \
+ pthread_spin_init.c \
+ pthread_spin_destroy.c \
+ pthread_spin_lock.c \
+ pthread_spin_unlock.c \
+ pthread_spin_trylock.c \
+ pthread_detach.c \
+ pthread_join.c \
+ pthread_timedjoin_np.c \
+ pthread_tryjoin_np.c \
+ pthread_key_create.c \
+ pthread_key_delete.c \
+ pthread_setspecific.c \
+ pthread_getspecific.c
+
+INCL = \
+ config.h \
+ implement.h \
+ need_errno.h \
+ pthread.h \
+ semaphore.h \
+ need_errno.h
+
+# Output useful info if no target given. I.e. the first target that "make" sees is used in this case.
+default_target: help
+
+pthread.$(OBJEXT): pthread.c $(PTHREAD_SRCS)
+
+# end common.mk
diff --git a/pthreads/condvar.c b/pthreads/condvar.c
index 704f4d793..01cc3d0a7 100644
--- a/pthreads/condvar.c
+++ b/pthreads/condvar.c
@@ -39,7 +39,6 @@
#include "pthread.h"
#include "implement.h"
-#include "ptw32_cond_check_need_init.c"
#include "pthread_condattr_init.c"
#include "pthread_condattr_destroy.c"
#include "pthread_condattr_getpshared.c"
diff --git a/pthreads/config.h b/pthreads/config.h
index e231724e3..ccdff48da 100644
--- a/pthreads/config.h
+++ b/pthreads/config.h
@@ -46,7 +46,7 @@
/* Do we know about type mode_t? */
#undef HAVE_MODE_T
-/*
+/*
* Define if GCC has atomic builtins, i.e. __sync_* intrinsics
* __sync_lock_* is implemented in mingw32 gcc 4.5.2 at least
* so this define does not turn those on or off. If you get an
@@ -148,6 +148,4 @@
#define HAVE_C_INLINE
#endif
-
-
-#endif
+#endif /* PTW32_CONFIG_H */
diff --git a/pthreads/context.h b/pthreads/context.h
index 3d4511f5b..b7140019c 100644
--- a/pthreads/context.h
+++ b/pthreads/context.h
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/create.c b/pthreads/create.c
index e15418588..f63ca0a92 100644
--- a/pthreads/create.c
+++ b/pthreads/create.c
@@ -9,32 +9,37 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
* http://sources.redhat.com/pthreads-win32/contributors.html
- *
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library in the file COPYING.LIB;
* if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
#if ! defined(_UWIN) && ! defined(WINCE)
@@ -44,7 +49,7 @@
int
pthread_create (pthread_t * tid,
const pthread_attr_t * attr,
- void *(*start) (void *), void *arg)
+ void *(PTW32_CDECL *start) (void *), void *arg)
/*
* ------------------------------------------------------
* DOCPUBLIC
@@ -85,6 +90,7 @@ pthread_create (pthread_t * tid,
{
pthread_t thread;
ptw32_thread_t * tp;
+ ptw32_thread_t * sp;
register pthread_attr_t a;
HANDLE threadH = 0;
int result = EAGAIN;
@@ -92,7 +98,6 @@ pthread_create (pthread_t * tid,
ThreadParms *parms = NULL;
unsigned int stackSize;
int priority;
- pthread_t self;
/*
* Before doing anything, check that tid can be stored through
@@ -102,6 +107,11 @@ pthread_create (pthread_t * tid,
*/
tid->x = 0;
+ if (NULL == (sp = (ptw32_thread_t *)pthread_self().p))
+ {
+ goto FAIL0;
+ }
+
if (attr != NULL)
{
a = *attr;
@@ -129,16 +139,13 @@ pthread_create (pthread_t * tid,
parms->start = start;
parms->arg = arg;
-#if defined(HAVE_SIGSET_T)
-
/*
- * Threads inherit their initial sigmask from their creator thread.
+ * Threads inherit their initial sigmask and CPU affinity from their creator thread.
*/
- self = pthread_self();
- tp->sigmask = ((ptw32_thread_t *)self.p)->sigmask;
-
-#endif /* HAVE_SIGSET_T */
-
+#if defined(HAVE_SIGSET_T)
+ tp->sigmask = sp->sigmask;
+#endif
+ tp->cpuset = sp->cpuset;
if (a != NULL)
{
@@ -164,17 +171,14 @@ pthread_create (pthread_t * tid,
* PTHREAD_EXPLICIT_SCHED and priority THREAD_PRIORITY_NORMAL.
*/
if (PTHREAD_INHERIT_SCHED == a->inheritsched)
- {
- /*
- * If the thread that called pthread_create() is a Win32 thread
- * then the inherited priority could be the result of a temporary
- * system adjustment. This is not the case for POSIX threads.
- */
-#if ! defined(HAVE_SIGSET_T)
- self = pthread_self ();
-#endif
- priority = ((ptw32_thread_t *) self.p)->sched_priority;
- }
+ {
+ /*
+ * If the thread that called pthread_create() is a Win32 thread
+ * then the inherited priority could be the result of a temporary
+ * system adjustment. This is not the case for POSIX threads.
+ */
+ priority = sp->sched_priority;
+ }
#endif
@@ -200,7 +204,7 @@ pthread_create (pthread_t * tid,
* finished with it here.
*/
-#if ! (defined (__MINGW64__) || defined(__MINGW32__)) || defined (__MSVCRT__) || defined (__DMC__)
+#if ! defined (PTW32_CONFIG_MINGW) || defined (__MSVCRT__) || defined (__DMC__)
tp->threadH =
threadH =
@@ -215,14 +219,16 @@ pthread_create (pthread_t * tid,
if (threadH != 0)
{
if (a != NULL)
- {
- (void) ptw32_setthreadpriority (thread, SCHED_OTHER, priority);
- }
+ {
+ (void) ptw32_setthreadpriority (thread, SCHED_OTHER, priority);
+ }
+
+ SetThreadAffinityMask(tp->threadH, tp->cpuset);
if (run)
- {
- ResumeThread (threadH);
- }
+ {
+ ResumeThread (threadH);
+ }
}
#else
@@ -251,19 +257,21 @@ pthread_create (pthread_t * tid,
else
{
if (!run)
- {
- /*
- * beginthread does not allow for create flags, so we do it now.
- * Note that beginthread itself creates the thread in SUSPENDED
- * mode, and then calls ResumeThread to start it.
- */
- SuspendThread (threadH);
- }
-
+ {
+ /*
+ * beginthread does not allow for create flags, so we do it now.
+ * Note that beginthread itself creates the thread in SUSPENDED
+ * mode, and then calls ResumeThread to start it.
+ */
+ SuspendThread (threadH);
+ }
+
if (a != NULL)
- {
- (void) ptw32_setthreadpriority (thread, SCHED_OTHER, priority);
- }
+ {
+ (void) ptw32_setthreadpriority (thread, SCHED_OTHER, priority);
+ }
+
+ SetThreadAffinityMask(tp->threadH, tp->cpuset);
}
ptw32_mcs_lock_release (&stateLock);
diff --git a/pthreads/dll.c b/pthreads/dll.c
index 05e01bee7..31c427a0a 100644
--- a/pthreads/dll.c
+++ b/pthreads/dll.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,11 +35,15 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
-#if !defined(PTW32_STATIC_LIB)
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
#include "pthread.h"
#include "implement.h"
+#if !defined(PTW32_STATIC_LIB)
+
#if defined(_MSC_VER)
/*
* lpvReserved yields an unreferenced formal parameter;
@@ -89,4 +94,12 @@ DllMain (HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpvReserved)
} /* DllMain */
-#endif /* PTW32_STATIC_LIB */
+#endif /* !PTW32_STATIC_LIB */
+
+#if ! defined(PTW32_BUILD_INLINED)
+/*
+ * Avoid "translation unit is empty" warnings
+ */
+typedef int foo;
+#endif
+
diff --git a/pthreads/errno.c b/pthreads/errno.c
index 2f8a317f0..fc61a889c 100644
--- a/pthreads/errno.c
+++ b/pthreads/errno.c
@@ -1,94 +1,106 @@
-/*
- * errno.c
- *
- * Description:
- * This translation unit implements routines associated with spawning a new
- * thread.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#if defined(NEED_ERRNO)
-
-#include "pthread.h"
-#include "implement.h"
-
-static int reallyBad = ENOMEM;
-
-/*
- * Re-entrant errno.
- *
- * Each thread has it's own errno variable in pthread_t.
- *
- * The benefit of using the pthread_t structure
- * instead of another TSD key is TSD keys are limited
- * on Win32 to 64 per process. Secondly, to implement
- * it properly without using pthread_t you'd need
- * to dynamically allocate an int on starting the thread
- * and store it manually into TLS and then ensure that you free
- * it on thread termination. We get all that for free
- * by simply storing the errno on the pthread_t structure.
- *
- * MSVC and Mingw32 already have their own thread-safe errno.
- *
- * #if defined( _REENTRANT ) || defined( _MT )
- * #define errno *_errno()
- *
- * int *_errno( void );
- * #else
- * extern int errno;
- * #endif
- *
- */
-
-int *
-_errno (void)
-{
- pthread_t self;
- int *result;
-
- if ((self = pthread_self ()).p == NULL)
- {
- /*
- * Yikes! unable to allocate a thread!
- * Throw an exception? return an error?
- */
- result = &reallyBad;
- }
- else
- {
- result = (int *)(&self.p->exitStatus);
- }
-
- return (result);
-
-} /* _errno */
-
-#endif /* (NEED_ERRNO) */
+/*
+ * errno.c
+ *
+ * Description:
+ * This translation unit implements routines associated with spawning a new
+ * thread.
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads-win32 - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * http://sources.redhat.com/pthreads-win32/contributors.html
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#if defined(NEED_ERRNO)
+
+#include "pthread.h"
+#include "implement.h"
+
+static int reallyBad = ENOMEM;
+
+/*
+ * Re-entrant errno.
+ *
+ * Each thread has it's own errno variable in pthread_t.
+ *
+ * The benefit of using the pthread_t structure
+ * instead of another TSD key is TSD keys are limited
+ * on Win32 to 64 per process. Secondly, to implement
+ * it properly without using pthread_t you'd need
+ * to dynamically allocate an int on starting the thread
+ * and store it manually into TLS and then ensure that you free
+ * it on thread termination. We get all that for free
+ * by simply storing the errno on the pthread_t structure.
+ *
+ * MSVC and Mingw32 already have their own thread-safe errno.
+ *
+ * #if defined( _REENTRANT ) || defined( _MT )
+ * #define errno *_errno()
+ *
+ * int *_errno( void );
+ * #else
+ * extern int errno;
+ * #endif
+ *
+ */
+
+int *
+_errno (void)
+{
+ pthread_t self;
+ int *result;
+
+ if ((self = pthread_self ()).p == NULL)
+ {
+ /*
+ * Yikes! unable to allocate a thread!
+ * Throw an exception? return an error?
+ */
+ result = &reallyBad;
+ }
+ else
+ {
+ result = (int *)(&self.p->exitStatus);
+ }
+
+ return (result);
+
+} /* _errno */
+
+#endif /* (NEED_ERRNO) */
+
+#if ! defined(PTW32_BUILD_INLINED)
+/*
+ * Avoid "translation unit is empty" warnings
+ */
+typedef int foo;
+#endif
diff --git a/pthreads/global.c b/pthreads/global.c
index f1e9b3f66..548455f01 100644
--- a/pthreads/global.c
+++ b/pthreads/global.c
@@ -9,32 +9,37 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
* http://sources.redhat.com/pthreads-win32/contributors.html
- *
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library in the file COPYING.LIB;
* if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
@@ -57,12 +62,12 @@ int ptw32_features = 0;
*/
unsigned __int64 ptw32_threadSeqNumber = 0;
-/*
+/*
* Function pointer to QueueUserAPCEx if it exists, otherwise
* it will be set at runtime to a substitute routine which cannot unblock
* blocked threads.
*/
-DWORD (*ptw32_register_cancelation) (PAPCFUNC, HANDLE, DWORD) = NULL;
+DWORD (*ptw32_register_cancellation) (PAPCFUNC, HANDLE, DWORD) = NULL;
/*
* Global lock for managing pthread_t struct reuse.
diff --git a/pthreads/implement.h b/pthreads/implement.h
index 6b9f42503..189c668e5 100644
--- a/pthreads/implement.h
+++ b/pthreads/implement.h
@@ -9,26 +9,26 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
* Contact Email: Ross.Johnson@homemail.com.au
- *
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
* http://sources.redhat.com/pthreads-win32/contributors.html
- *
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library in the file COPYING.LIB;
* if not, write to the Free Software Foundation, Inc.,
@@ -38,8 +38,12 @@
#if !defined(_IMPLEMENT_H)
#define _IMPLEMENT_H
+#if !defined(PTW32_CONFIG_H) && !defined(_PTHREAD_TEST_H_)
+# error "config.h was not #included"
+#endif
+
#if !defined(_WIN32_WINNT)
-#define _WIN32_WINNT 0x0400
+# define _WIN32_WINNT 0x0400
#endif
#include <windows.h>
@@ -52,6 +56,39 @@ typedef VOID (APIENTRY *PAPCFUNC)(DWORD dwParam);
#endif
/*
+ * Designed to allow error values to be set and retrieved in builds where
+ * MSCRT libraries are statically linked to DLLs.
+ */
+#if ( defined(PTW32_CONFIG_MINGW) && __MSVCRT_VERSION__ >= 0x0800 ) || \
+ ( defined(_MSC_VER) && _MSC_VER >= 1400 ) /* MSVC8+ */
+# if defined(PTW32_CONFIG_MINGW)
+__attribute__((unused))
+# endif
+static int ptw32_get_errno(void) { int err = 0; _get_errno(&err); return err; }
+# define PTW32_GET_ERRNO() ptw32_get_errno()
+# if defined(PTW32_USES_SEPARATE_CRT)
+# if defined(PTW32_CONFIG_MINGW)
+__attribute__((unused))
+# endif
+static void ptw32_set_errno(int err) { _set_errno(err); SetLastError(err); }
+# define PTW32_SET_ERRNO(err) ptw32_set_errno(err)
+# else
+# define PTW32_SET_ERRNO(err) _set_errno(err)
+# endif
+#else
+# define PTW32_GET_ERRNO() (errno)
+# if defined(PTW32_USES_SEPARATE_CRT)
+# if defined(PTW32_CONFIG_MINGW)
+__attribute__((unused))
+# endif
+static void ptw32_set_errno(int err) { errno = err; SetLastError(err); }
+# define PTW32_SET_ERRNO(err) ptw32_set_errno(err)
+# else
+# define PTW32_SET_ERRNO(err) (errno = (err))
+# endif
+#endif
+
+/*
* note: ETIMEDOUT is correctly defined in winsock.h
*/
#include <winsock.h>
@@ -60,11 +97,11 @@ typedef VOID (APIENTRY *PAPCFUNC)(DWORD dwParam);
* In case ETIMEDOUT hasn't been defined above somehow.
*/
#if !defined(ETIMEDOUT)
-# define ETIMEDOUT 10060 /* This is the value in winsock.h. */
+# define ETIMEDOUT 10060 /* This is the value in winsock.h. */
#endif
#if !defined(malloc)
-#include <malloc.h>
+# include <malloc.h>
#endif
#if defined(__CLEANUP_C)
@@ -72,45 +109,62 @@ typedef VOID (APIENTRY *PAPCFUNC)(DWORD dwParam);
#endif
#if !defined(INT_MAX)
-#include <limits.h>
+# include <limits.h>
#endif
/* use local include files during development */
#include "semaphore.h"
#include "sched.h"
-#if defined(HAVE_C_INLINE) || defined(__cplusplus)
-#define INLINE inline
-#else
+/* MSVC 7.1 doesn't like complex #if expressions */
#define INLINE
+#if defined(PTW32_BUILD_INLINED)
+# if defined(HAVE_C_INLINE) || defined(__cplusplus)
+# undef INLINE
+# define INLINE inline
+# endif
#endif
-#if defined(_MSC_VER) && _MSC_VER < 1300
-/*
- * MSVC 6 does not use the "volatile" qualifier
- */
-#define PTW32_INTERLOCKED_VOLATILE
+#if defined(PTW32_CONFIG_MSVC6)
+# define PTW32_INTERLOCKED_VOLATILE
#else
-#define PTW32_INTERLOCKED_VOLATILE volatile
+# define PTW32_INTERLOCKED_VOLATILE volatile
#endif
+
#define PTW32_INTERLOCKED_LONG long
-#define PTW32_INTERLOCKED_SIZE size_t
#define PTW32_INTERLOCKED_PVOID PVOID
#define PTW32_INTERLOCKED_LONGPTR PTW32_INTERLOCKED_VOLATILE long*
-#define PTW32_INTERLOCKED_SIZEPTR PTW32_INTERLOCKED_VOLATILE size_t*
#define PTW32_INTERLOCKED_PVOID_PTR PTW32_INTERLOCKED_VOLATILE PVOID*
+#if defined(_WIN64)
+# define PTW32_INTERLOCKED_SIZE LONGLONG
+# define PTW32_INTERLOCKED_SIZEPTR PTW32_INTERLOCKED_VOLATILE LONGLONG*
+#else
+# define PTW32_INTERLOCKED_SIZE long
+# define PTW32_INTERLOCKED_SIZEPTR PTW32_INTERLOCKED_VOLATILE long*
+#endif
-#if defined(__MINGW64__) || defined(__MINGW32__)
+#if defined(PTW32_CONFIG_MINGW)
# include <stdint.h>
#elif defined(__BORLANDC__)
# define int64_t ULONGLONG
#else
# define int64_t _int64
-# if defined(_MSC_VER) && _MSC_VER < 1300
+# if defined(PTW32_CONFIG_MSVC6)
typedef long intptr_t;
# endif
#endif
+/*
+ * Don't allow the linker to optimize away autostatic.obj in static builds.
+ */
+#if defined(PTW32_STATIC_LIB) && defined(PTW32_BUILD)
+ void ptw32_autostatic_anchor(void);
+# if defined(PTW32_CONFIG_MINGW)
+ __attribute__((unused, used))
+# endif
+ static void (*local_autostatic_anchor)(void) = ptw32_autostatic_anchor;
+#endif
+
typedef enum
{
/*
@@ -122,7 +176,7 @@ typedef enum
PThreadStateRunning, /* Thread alive & kicking */
PThreadStateSuspended, /* Thread alive but suspended */
PThreadStateCancelPending, /* Thread alive but */
- /* has cancelation pending. */
+ /* has cancellation pending. */
PThreadStateCanceling, /* Thread alive but is */
/* in the process of terminating */
/* due to a cancellation request */
@@ -139,7 +193,6 @@ typedef struct ptw32_mcs_node_t_* ptw32_mcs_lock_t;
typedef struct ptw32_robust_node_t_ ptw32_robust_node_t;
typedef struct ptw32_thread_t_ ptw32_thread_t;
-
struct ptw32_thread_t_
{
unsigned __int64 seqNumber; /* Process-unique thread sequence number */
@@ -170,7 +223,8 @@ struct ptw32_thread_t_
int cancelState;
int cancelType;
int implicit:1;
- DWORD thread; /* Win32 thread ID */
+ DWORD thread; /* Windows thread ID */
+ size_t cpuset; /* Thread CPU affinity set */
#if defined(_UWIN)
DWORD dummy[5];
#endif
@@ -178,7 +232,7 @@ struct ptw32_thread_t_
};
-/*
+/*
* Special value to mark attribute objects as valid.
*/
#define PTW32_ATTR_VALID ((unsigned long) 0xC4C0FFEE)
@@ -329,7 +383,7 @@ struct pthread_barrierattr_t_
struct pthread_key_t_
{
DWORD key;
- void (*destructor) (void *);
+ void (PTW32_CDECL *destructor) (void *);
ptw32_mcs_lock_t keyLock;
void *threads;
};
@@ -340,7 +394,7 @@ typedef struct ThreadParms ThreadParms;
struct ThreadParms
{
pthread_t tid;
- void *(*start) (void *);
+ void *(PTW32_CDECL *start) (void *);
void *arg;
};
@@ -386,6 +440,12 @@ struct pthread_rwlockattr_t_
int pshared;
};
+typedef union
+{
+ char cpuset[CPU_SETSIZE/8];
+ size_t _cpuset;
+} _sched_cpu_set_vector_;
+
typedef struct ThreadKeyAssoc ThreadKeyAssoc;
struct ThreadKeyAssoc
@@ -469,7 +529,7 @@ struct ThreadKeyAssoc
* The pthread_key_t->threads attribute is the head of
* a chain of associations that runs through the
* nextThreads link. This chain provides the 1 to many
- * relationship between a pthread_key_t and all the
+ * relationship between a pthread_key_t and all the
* PThreads that have called pthread_setspecific for
* this pthread_key_t.
*
@@ -557,7 +617,7 @@ struct ThreadKeyAssoc
/* Declared in pthread_cancel.c */
-extern DWORD (*ptw32_register_cancelation) (PAPCFUNC, HANDLE, DWORD);
+extern DWORD (*ptw32_register_cancellation) (PAPCFUNC, HANDLE, DWORD);
/* Thread Reuse stack bottom marker. Must not be NULL or any valid pointer to memory. */
#define PTW32_THREAD_REUSE_EMPTY ((ptw32_thread_t *)(size_t) 1)
@@ -607,13 +667,14 @@ extern "C"
int ptw32_cond_check_need_init (pthread_cond_t * cond);
int ptw32_mutex_check_need_init (pthread_mutex_t * mutex);
int ptw32_rwlock_check_need_init (pthread_rwlock_t * rwlock);
+ int ptw32_spinlock_check_need_init (pthread_spinlock_t * lock);
int ptw32_robust_mutex_inherit(pthread_mutex_t * mutex);
void ptw32_robust_mutex_add(pthread_mutex_t* mutex, pthread_t self);
void ptw32_robust_mutex_remove(pthread_mutex_t* mutex, ptw32_thread_t* otp);
DWORD
- ptw32_RegisterCancelation (PAPCFUNC callback,
+ ptw32_Registercancellation (PAPCFUNC callback,
HANDLE threadH, DWORD callback_arg);
int ptw32_processInitialize (void);
@@ -636,7 +697,7 @@ extern "C"
void ptw32_rwlock_cancelwrwait (void *arg);
-#if ! (defined (__MINGW64__) || defined(__MINGW32__)) || (defined(__MSVCRT__) && ! defined(__DMC__))
+#if ! defined (PTW32_CONFIG_MINGW) || (defined (__MSVCRT__) && ! defined (__DMC__))
unsigned __stdcall
#else
void
@@ -746,9 +807,15 @@ extern "C"
*
* The above aren't available in Mingw32 as of gcc 4.5.2 so define our own.
*/
+#if defined(__cplusplus)
+# define PTW32_TO_VLONG64PTR(ptr) reinterpret_cast<volatile LONG64 *>(ptr)
+#else
+# define PTW32_TO_VLONG64PTR(ptr) (ptr)
+#endif
+
#if defined(__GNUC__)
# if defined(_WIN64)
-# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_64(location, value, comparand) \
+# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_64(location, value, comparand) \
({ \
__typeof (value) _result; \
__asm__ __volatile__ \
@@ -785,7 +852,7 @@ extern "C"
})
# define PTW32_INTERLOCKED_INCREMENT_64(location) \
({ \
- PTW32_INTERLOCKED_LONG _temp = 1; \
+ PTW32_INTERLOCKED_LONG _temp = 1; \
__asm__ __volatile__ \
( \
"lock\n\t" \
@@ -797,7 +864,7 @@ extern "C"
})
# define PTW32_INTERLOCKED_DECREMENT_64(location) \
({ \
- PTW32_INTERLOCKED_LONG _temp = -1; \
+ PTW32_INTERLOCKED_LONG _temp = -1; \
__asm__ __volatile__ \
( \
"lock\n\t" \
@@ -808,7 +875,7 @@ extern "C"
--_temp; \
})
#endif
-# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG(location, value, comparand) \
+# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG(location, value, comparand) \
({ \
__typeof (value) _result; \
__asm__ __volatile__ \
@@ -845,7 +912,7 @@ extern "C"
})
# define PTW32_INTERLOCKED_INCREMENT_LONG(location) \
({ \
- PTW32_INTERLOCKED_LONG _temp = 1; \
+ PTW32_INTERLOCKED_LONG _temp = 1; \
__asm__ __volatile__ \
( \
"lock\n\t" \
@@ -857,7 +924,7 @@ extern "C"
})
# define PTW32_INTERLOCKED_DECREMENT_LONG(location) \
({ \
- PTW32_INTERLOCKED_LONG _temp = -1; \
+ PTW32_INTERLOCKED_LONG _temp = -1; \
__asm__ __volatile__ \
( \
"lock\n\t" \
@@ -876,48 +943,48 @@ extern "C"
(PTW32_INTERLOCKED_SIZE)value)
#else
# if defined(_WIN64)
-# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_64 InterlockedCompareExchange64
-# define PTW32_INTERLOCKED_EXCHANGE_64 InterlockedExchange64
-# define PTW32_INTERLOCKED_EXCHANGE_ADD_64 InterlockedExchangeAdd64
-# define PTW32_INTERLOCKED_INCREMENT_64 InterlockedIncrement64
-# define PTW32_INTERLOCKED_DECREMENT_64 InterlockedDecrement64
+# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_64(p,v,c) InterlockedCompareExchange64(PTW32_TO_VLONG64PTR(p),(v),(c))
+# define PTW32_INTERLOCKED_EXCHANGE_64(p,v) InterlockedExchange64(PTW32_TO_VLONG64PTR(p),(v))
+# define PTW32_INTERLOCKED_EXCHANGE_ADD_64(p,v) InterlockedExchangeAdd64(PTW32_TO_VLONG64PTR(p),(v))
+# define PTW32_INTERLOCKED_INCREMENT_64(p) InterlockedIncrement64(PTW32_TO_VLONG64PTR(p))
+# define PTW32_INTERLOCKED_DECREMENT_64(p) InterlockedDecrement64(PTW32_TO_VLONG64PTR(p))
# endif
-# if defined(_MSC_VER) && _MSC_VER < 1300 && !defined(_WIN64) /* MSVC 6 */
+# if defined(PTW32_CONFIG_MSVC6) && !defined(_WIN64)
# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG(location, value, comparand) \
((LONG)InterlockedCompareExchange((PVOID *)(location), (PVOID)(value), (PVOID)(comparand)))
# else
# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG InterlockedCompareExchange
# endif
-# define PTW32_INTERLOCKED_EXCHANGE_LONG InterlockedExchange
-# define PTW32_INTERLOCKED_EXCHANGE_ADD_LONG InterlockedExchangeAdd
-# define PTW32_INTERLOCKED_INCREMENT_LONG InterlockedIncrement
-# define PTW32_INTERLOCKED_DECREMENT_LONG InterlockedDecrement
-# if defined(_MSC_VER) && _MSC_VER < 1300 && !defined(_WIN64) /* MSVC 6 */
+# define PTW32_INTERLOCKED_EXCHANGE_LONG(p,v) InterlockedExchange((p),(v))
+# define PTW32_INTERLOCKED_EXCHANGE_ADD_LONG(p,v) InterlockedExchangeAdd((p),(v))
+# define PTW32_INTERLOCKED_INCREMENT_LONG(p) InterlockedIncrement((p))
+# define PTW32_INTERLOCKED_DECREMENT_LONG(p) InterlockedDecrement((p))
+# if defined(PTW32_CONFIG_MSVC6) && !defined(_WIN64)
# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR InterlockedCompareExchange
# define PTW32_INTERLOCKED_EXCHANGE_PTR(location, value) \
((PVOID)InterlockedExchange((LPLONG)(location), (LONG)(value)))
# else
-# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR InterlockedCompareExchangePointer
-# define PTW32_INTERLOCKED_EXCHANGE_PTR InterlockedExchangePointer
+# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR(p,v,c) InterlockedCompareExchangePointer((p),(v),(c))
+# define PTW32_INTERLOCKED_EXCHANGE_PTR(p,v) InterlockedExchangePointer((p),(v))
# endif
#endif
#if defined(_WIN64)
-# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE PTW32_INTERLOCKED_COMPARE_EXCHANGE_64
-# define PTW32_INTERLOCKED_EXCHANGE_SIZE PTW32_INTERLOCKED_EXCHANGE_64
-# define PTW32_INTERLOCKED_EXCHANGE_ADD_SIZE PTW32_INTERLOCKED_EXCHANGE_ADD_64
-# define PTW32_INTERLOCKED_INCREMENT_SIZE PTW32_INTERLOCKED_INCREMENT_64
-# define PTW32_INTERLOCKED_DECREMENT_SIZE PTW32_INTERLOCKED_DECREMENT_64
+# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE(p,v,c) PTW32_INTERLOCKED_COMPARE_EXCHANGE_64(PTW32_TO_VLONG64PTR(p),(v),(c))
+# define PTW32_INTERLOCKED_EXCHANGE_SIZE(p,v) PTW32_INTERLOCKED_EXCHANGE_64(PTW32_TO_VLONG64PTR(p),(v))
+# define PTW32_INTERLOCKED_EXCHANGE_ADD_SIZE(p,v) PTW32_INTERLOCKED_EXCHANGE_ADD_64(PTW32_TO_VLONG64PTR(p),(v))
+# define PTW32_INTERLOCKED_INCREMENT_SIZE(p) PTW32_INTERLOCKED_INCREMENT_64(PTW32_TO_VLONG64PTR(p))
+# define PTW32_INTERLOCKED_DECREMENT_SIZE(p) PTW32_INTERLOCKED_DECREMENT_64(PTW32_TO_VLONG64PTR(p))
#else
-# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG
-# define PTW32_INTERLOCKED_EXCHANGE_SIZE PTW32_INTERLOCKED_EXCHANGE_LONG
-# define PTW32_INTERLOCKED_EXCHANGE_ADD_SIZE PTW32_INTERLOCKED_EXCHANGE_ADD_LONG
-# define PTW32_INTERLOCKED_INCREMENT_SIZE PTW32_INTERLOCKED_INCREMENT_LONG
-# define PTW32_INTERLOCKED_DECREMENT_SIZE PTW32_INTERLOCKED_DECREMENT_LONG
+# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE(p,v,c) PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG((p),(v),(c))
+# define PTW32_INTERLOCKED_EXCHANGE_SIZE(p,v) PTW32_INTERLOCKED_EXCHANGE_LONG((p),(v))
+# define PTW32_INTERLOCKED_EXCHANGE_ADD_SIZE(p,v) PTW32_INTERLOCKED_EXCHANGE_ADD_LONG((p),(v))
+# define PTW32_INTERLOCKED_INCREMENT_SIZE(p) PTW32_INTERLOCKED_INCREMENT_LONG((p))
+# define PTW32_INTERLOCKED_DECREMENT_SIZE(p) PTW32_INTERLOCKED_DECREMENT_LONG((p))
#endif
#if defined(NEED_CREATETHREAD)
-/*
+/*
* Macro uses args so we can cast start_proc to LPTHREAD_START_ROUTINE
* in order to avoid warnings because of return type
*/
diff --git a/pthreads/manual/ChangeLog b/pthreads/manual/ChangeLog
index 071b847ef..6b72f075d 100644
--- a/pthreads/manual/ChangeLog
+++ b/pthreads/manual/ChangeLog
@@ -1,3 +1,20 @@
+2012-10-04 Ross Johnson <ross at homemail dot com dot au>
+
+ * pthread_join.html (pthread_tryjoin_np): Added description.
+ * index.html (pthread_tryjoin_np): Added link.
+
+2012-09-20 Ross Johnson <ross at homemail dot com dot au>
+
+ * cpu_set.html: New manual page.
+ * pthread_create.html: Updated.
+ * index.html: Updated.
+ * sched_setaffinity.html: Fixed corrupted formatting.
+
+2012-08-19 Ross Johnson <ross at homemail dot com dot au>
+
+ * pthread_join.html(pthread_timedjoin_np): Added.
+ * index.html(pthread_timedjoin_np): Added link.
+
2011-03-26 Ross Johnson <ross at homemail dot com dot au>
* pthread_nutex_init.html (robust mutexes): Added
diff --git a/pthreads/manual/cpu_set.html b/pthreads/manual/cpu_set.html
new file mode 100755
index 000000000..45c38ce4f
--- /dev/null
+++ b/pthreads/manual/cpu_set.html
@@ -0,0 +1,119 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<HTML>
+<HEAD>
+ <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=windows-1252">
+ <TITLE>PTHREAD_CREATE(3) manual page</TITLE>
+ <META NAME="GENERATOR" CONTENT="OpenOffice.org 3.4 (Win32)">
+ <META NAME="CREATED" CONTENT="20050504;19394700">
+ <META NAME="CHANGED" CONTENT="20120921;12103385">
+ <STYLE TYPE="text/css">
+ <!--
+ H4.cjk { font-family: "SimSun" }
+ H4.ctl { font-family: "Mangal" }
+ H2.cjk { font-family: "SimSun" }
+ H2.ctl { font-family: "Mangal" }
+ -->
+ </STYLE>
+</HEAD>
+<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR">
+<H4 CLASS="western"><FONT FACE="Times New Roman, serif"><FONT SIZE=3><SPAN STYLE="font-style: normal">POSIX
+Threads for Windows &ndash; REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></SPAN></FONT></FONT></H4>
+<P><A HREF="index.html">Reference Index</A></P>
+<P><A HREF="#toc">Table of Contents</A></P>
+<H2 CLASS="western"><A HREF="#toc0" NAME="sect0">Name</A></H2>
+<P>Operations on CPU affinity sets:</P>
+<P>CPU_EQUAL - test equality of two sets</P>
+<P>CPU_ZERO - clear all CPUs from set</P>
+<P>CPU_SET - set a specified CPU in a set</P>
+<P>CPU_CLR - unset a specified CPU in a set</P>
+<P>CPU_ISSET - test if a specified CPU in a set is set</P>
+<P>CPU_COUNT - return the number of CPUs currently set</P>
+<P>CPU_AND - obtain the intersection of two sets</P>
+<P>CPU_OR - obtain the union of two sets</P>
+<P>CPU_XOR - obtain the mutually excluded set</P>
+<H2 CLASS="western"><A HREF="#toc1" NAME="sect1">Synopsis</A></H2>
+<P><B>#include &lt;sched.h&gt; </B>
+</P>
+<P><B>int CPU_EQUAL(cpu_set_t * </B><I><SPAN STYLE="font-weight: normal">set1</SPAN></I><B>,
+cpu_set_t * </B><I><SPAN STYLE="font-weight: normal">set2</SPAN></I><B>);</B></P>
+<P><B>void CPU_ZERO(cpu_set_t * </B><I><SPAN STYLE="font-weight: normal">set</SPAN></I><B>);</B></P>
+<P><B>void CPU_SET(int </B><I><SPAN STYLE="font-weight: normal">cpu</SPAN></I><B>,
+cpu_set_t * </B><I><SPAN STYLE="font-weight: normal">set</SPAN></I><B>);</B></P>
+<P><B>void CPU_CLR(int </B><I><SPAN STYLE="font-weight: normal">cpu</SPAN></I><B>,
+cpu_set_t * </B><I><SPAN STYLE="font-weight: normal">set</SPAN></I><B>);</B></P>
+<P><B>int CPU_ISSET(int </B><I><SPAN STYLE="font-weight: normal">cpu</SPAN></I><B>,
+cpu_set_t * </B><I><SPAN STYLE="font-weight: normal">set</SPAN></I><B>);</B></P>
+<P><B>int CPU_COUNT(cpu_set_t * </B><I><SPAN STYLE="font-weight: normal">set</SPAN></I><B>);</B></P>
+<P><B>void CPU_AND(cpu_set_t * </B><I><SPAN STYLE="font-weight: normal">destset</SPAN></I><B>,
+cpu_set_t * </B><I><SPAN STYLE="font-weight: normal">srcset1</SPAN></I><B>,
+cpu_set_t * </B><I><SPAN STYLE="font-weight: normal">srcset2</SPAN></I><B>);</B></P>
+<P><B>void CPU_OR(cpu_set_t * </B><I><SPAN STYLE="font-weight: normal">destset</SPAN></I><B>,
+cpu_set_t * </B><I><SPAN STYLE="font-weight: normal">srcset1</SPAN></I><B>,
+cpu_set_t * </B><I><SPAN STYLE="font-weight: normal">srcset2</SPAN></I><B>);</B></P>
+<P><B>void CPU_XOR(cpu_set_t * </B><I><SPAN STYLE="font-weight: normal">destset</SPAN></I><B>,
+cpu_set_t * </B><I><SPAN STYLE="font-weight: normal">srcset1</SPAN></I><B>,
+cpu_set_t * </B><I><SPAN STYLE="font-weight: normal">srcset2</SPAN></I><B>);</B></P>
+<H2 CLASS="western"><A HREF="#toc2" NAME="sect2">Description</A></H2>
+<P>The cpu_set_t data structure represents a set of CPUs. CPU sets
+are used by <A HREF="sched_setaffinity.html"><B>sched_setaffinity</B>()</A>
+and <A HREF="pthread_setaffinity_np.html"><B>pthread_setaffinity_np</B>()</A>,
+etc.</P>
+<P>The cpu_set_t data type is implemented as a bitset. However, the
+data structure is considered opaque: all manipulation of CPU sets
+should be done via the macros described in this page.</P>
+<P>The following macros are provided to operate on the CPU set set:</P>
+<P><B>CPU_ZERO</B> Clears <I>set</I>, so that it contains no CPUs.</P>
+<P><B>CPU_SET</B> Add CPU cpu to <I>set</I>.</P>
+<P><B>CPU_CLR</B> Remove CPU cpu from <I>set</I>.</P>
+<P><B>CPU_ISSET</B> Test to see if CPU cpu is a member of <I>set</I>.</P>
+<P><B>CPU_COUNT</B> Return the number of CPUs in <I>set</I>.</P>
+<P>Where a <I>cpu</I> argument is specified, it should not produce
+side effects, since the above macros may evaluate the argument more
+than once.</P>
+<P>The first available CPU on the system corresponds to a cpu value
+of 0, the next CPU corresponds to a cpu value of 1, and so on.</P>
+<P>The following macros perform logical operations on CPU sets:</P>
+<P><B>CPU_AND</B> Store the intersection of the sets <I>srcset1</I>
+and <I>srcset2</I> in <I>destset</I> (which may be one of the source
+sets).</P>
+<P><B>CPU_OR</B> Store the union of the sets <I>srcset1</I> and
+<I>srcset2</I> in <I>destset</I> (which may be one of the source
+sets).</P>
+<P><B>CPU_XOR</B> Store the XOR of the sets <I>srcset1</I> and
+<I>srcset2</I> in <I>destset</I> (which may be one of the source
+sets). The XOR means the set of CPUs that are in either srcset1 or
+srcset2, but not both.</P>
+<P><B>CPU_EQUAL</B> Test whether two CPU set contain exactly the
+same CPUs.</P>
+<H2 CLASS="western"><A HREF="#toc3" NAME="sect3">Return Value</A></H2>
+<P>These macros either return a value consistent with the operation
+of nothing.</P>
+<H2 CLASS="western"><A HREF="#toc4" NAME="sect4">Errors</A></H2>
+<P>These macros do not return an error status.</P>
+<H2 CLASS="western"><A HREF="#toc6" NAME="sect6">See Also</A></H2>
+<P><A HREF="sched_setaffinity.html"><B>sched_getaffinity(3)</B></A> ,
+<A HREF="sched_setaffinity.html"><B>sched_setaffinity(3)</B></A><SPAN STYLE="font-weight: normal">
+, </SPAN><A HREF="pthread_setaffinity_np.html"><B>pthread_setaffininty_np</B>(3)</A>
+, <A HREF="pthread_setaffinity_np.html"><B>pthread_getaffinity_np</B>(3)</A>
+.</P>
+<HR>
+<P><A NAME="toc"></A><B>Table of Contents</B></P>
+<UL>
+ <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A>
+ </P>
+ <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A>
+ </P>
+ <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A>
+ </P>
+ <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Return
+ Value</A>
+ </P>
+ <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Errors</A>
+ </P>
+ <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">See
+ Also</A></P>
+</UL>
+<H4 CLASS="western"><BR><BR>
+</H4>
+</BODY>
+</HTML> \ No newline at end of file
diff --git a/pthreads/manual/index.html b/pthreads/manual/index.html
index f7b5bc919..34080b147 100644
--- a/pthreads/manual/index.html
+++ b/pthreads/manual/index.html
@@ -1,158 +1,162 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-<HTML>
-<HEAD>
- <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8">
- <TITLE></TITLE>
- <META NAME="GENERATOR" CONTENT="OpenOffice.org 3.2 (Linux)">
- <META NAME="CREATED" CONTENT="20050504;17350500">
- <META NAME="CHANGEDBY" CONTENT="Ross Johnson">
- <META NAME="CHANGED" CONTENT="20110326;18352700">
- <META NAME="CHANGEDBY" CONTENT="Ross Johnson">
- <STYLE TYPE="text/css">
- <!--
- H4.cjk { font-family: "AR PL UMing CN" }
- H4.ctl { font-family: "Lohit Devanagari" }
- H3.cjk { font-family: "AR PL UMing CN" }
- H3.ctl { font-family: "Lohit Devanagari" }
- H2.cjk { font-family: "AR PL UMing CN" }
- H2.ctl { font-family: "Lohit Devanagari" }
- -->
- </STYLE>
-</HEAD>
-<BODY LANG="en-GB" DIR="LTR">
-<H4 CLASS="western">POSIX Threads for Windows ā€“ REFERENCE -
-<A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4>
-<H3 CLASS="western">Table of Contents</H3>
-<P STYLE="margin-left: 0.79in"><A HREF="#sect1" NAME="toc1">POSIX
-threads API reference</A><BR><A HREF="#sect2" NAME="toc2">Miscellaneous
-POSIX thread safe routines provided by Pthreads-w32</A><BR><A HREF="#sect3" NAME="toc3">Non-portable
-Pthreads-w32 routines</A><BR><A HREF="#sect4" NAME="toc4">Other</A></P>
-<H2 CLASS="western"><A HREF="#toc1" NAME="sect1">POSIX threads API
-reference</A></H2>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_attr_init.html"><B>pthread_attr_destroy</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_attr_init.html"><B>pthread_attr_getdetachstate</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_attr_init.html"><B>pthread_attr_getinheritsched</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_attr_init.html"><B>pthread_attr_getschedparam</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_attr_init.html"><B>pthread_attr_getschedpolicy</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_attr_init.html"><B>pthread_attr_getscope</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_attr_setstackaddr.html"><B>pthread_attr_getstackaddr</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_attr_setstacksize.html"><B>pthread_attr_getstacksize</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_attr_init.html"><B>pthread_attr_init</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_attr_init.html"><B>pthread_attr_setdetachstate</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_attr_init.html"><B>pthread_attr_setinheritsched</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_attr_init.html"><B>pthread_attr_setschedparam</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_attr_init.html"><B>pthread_attr_setschedpolicy</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_attr_init.html"><B>pthread_attr_setscope</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_attr_setstackaddr.html"><B>pthread_attr_setstackaddr</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_attr_setstacksize.html"><B>pthread_attr_setstacksize</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_barrierattr_init.html"><B>pthread_barrierattr_destroy</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_barrierattr_setpshared.html"><B>pthread_barrierattr_getpshared</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_barrierattr_init.html"><B>pthread_barrierattr_init</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_barrierattr_setpshared.html"><B>pthread_barrierattr_setpshared</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_barrier_init.html"><B>pthread_barrier_destroy</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_barrier_init.html"><B>pthread_barrier_init</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_barrier_wait.html"><B>pthread_barrier_wait</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_cancel.html"><B>pthread_cancel</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_cleanup_push.html"><B>pthread_cleanup_pop</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_cleanup_push.html"><B>pthread_cleanup_push</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_condattr_init.html"><B>pthread_condattr_destroy</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_condattr_setpshared.html"><B>pthread_condattr_getpshared</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_condattr_init.html"><B>pthread_condattr_init</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_condattr_setpshared.html"><B>pthread_condattr_setpshared</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_cond_init.html"><B>pthread_cond_broadcast</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_cond_init.html"><B>pthread_cond_destroy</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_cond_init.html"><B>pthread_cond_init</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_cond_init.html"><B>pthread_cond_signal</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_cond_init.html"><B>pthread_cond_timedwait</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_cond_init.html"><B>pthread_cond_wait</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_create.html"><B>pthread_create</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_detach.html"><B>pthread_detach</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_equal.html"><B>pthread_equal</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_exit.html"><B>pthread_exit</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_setconcurrency.html"><B>pthread_getconcurrency</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_setschedparam.html"><B>pthread_getschedparam</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_getunique_np.html"><B>pthread_getunique_np</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_key_create.html"><B>pthread_getspecific</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_join.html"><B>pthread_join</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_key_create.html"><B>pthread_key_create</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_key_create.html"><B>pthread_key_delete</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_kill.html"><B>pthread_kill</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_mutexattr_init.html"><B>pthread_mutexattr_destroy</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_mutexattr_init.html"><B>pthread_mutexattr_getkind_np</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_mutexattr_setpshared.html"><B>pthread_mutexattr_getpshared</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_mutexattr_init.html"><B>pthread_mutexattr_getrobust</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_mutexattr_init.html"><B>pthread_mutexattr_gettype</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_mutexattr_init.html"><B>pthread_mutexattr_init</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_mutexattr_init.html"><B>pthread_mutexattr_setkind_np</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_mutexattr_setpshared.html"><B>pthread_mutexattr_setpshared</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_mutexattr_init.html"><B>pthread_mutexattr_setrobust</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_mutexattr_init.html"><B>pthread_mutexattr_settype</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_mutex_init.html"><B>pthread_mutex_consistent</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_mutex_init.html"><B>pthread_mutex_destroy</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_mutex_init.html"><B>pthread_mutex_init</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_mutex_init.html"><B>pthread_mutex_lock</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_mutex_init.html"><B>pthread_mutex_timedlock</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_mutex_init.html"><B>pthread_mutex_trylock</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_mutex_init.html"><B>pthread_mutex_unlock</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_once.html"><B>pthread_once</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_rwlockattr_init.html"><B>pthread_rwlockattr_destroy</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_rwlockattr_setpshared.html"><B>pthread_rwlockattr_getpshared</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_rwlockattr_init.html"><B>pthread_rwlockattr_init</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_rwlockattr_setpshared.html"><B>pthread_rwlockattr_setpshared</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_rwlock_init.html"><B>pthread_rwlock_destroy</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_rwlock_init.html"><B>pthread_rwlock_init</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_rwlock_rdlock.html"><B>pthread_rwlock_rdlock</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_rwlock_timedrdlock.html"><B>pthread_rwlock_timedrdlock</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_rwlock_timedwrlock.html"><B>pthread_rwlock_timedwrlock</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_rwlock_rdlock.html"><B>pthread_rwlock_tryrdlock</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_rwlock_wrlock.html"><B>pthread_rwlock_trywrlock</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_rwlock_unlock.html"><B>pthread_rwlock_unlock</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_rwlock_wrlock.html"><B>pthread_rwlock_wrlock</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_self.html"><B>pthread_self</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_cancel.html"><B>pthread_setcancelstate</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_cancel.html"><B>pthread_setcanceltype</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_setconcurrency.html"><B>pthread_setconcurrency</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_setschedparam.html"><B>pthread_setschedparam</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_key_create.html"><B>pthread_setspecific</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_kill.html"><B>pthread_sigmask</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_spin_init.html"><B>pthread_spin_destroy</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_spin_init.html"><B>pthread_spin_init</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_spin_lock.html"><B>pthread_spin_lock</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_spin_lock.html"><B>pthread_spin_trylock</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_spin_unlock.html"><B>pthread_spin_unlock</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_cancel.html"><B>pthread_testcancel</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="sched_get_priority_max.html"><B>sched_get_priority_max</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="sched_get_priority_max.html"><B>sched_get_priority_min</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="sched_getscheduler.html"><B>sched_getscheduler</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="sched_setscheduler.html"><B>sched_setscheduler</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="sched_yield.html"><B>sched_yield</B></A></P>
-<P STYLE="margin-left: 0.79in"><B>sem_close</B></P>
-<P STYLE="margin-left: 0.79in"><A HREF="sem_init.html"><B>sem_destroy</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="sem_init.html"><B>sem_getvalue</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="sem_init.html"><B>sem_init</B></A></P>
-<P STYLE="margin-left: 0.79in"><B>sem_open</B></P>
-<P STYLE="margin-left: 0.79in"><A HREF="sem_init.html"><B>sem_post</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="sem_init.html"><B>sem_post_multiple</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="sem_init.html"><B>sem_timedwait</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="sem_init.html"><B>sem_trywait</B></A></P>
-<P STYLE="margin-left: 0.79in"><B>sem_unlink</B></P>
-<P STYLE="margin-left: 0.79in"><A HREF="sem_init.html"><B>sem_wait</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_kill.html"><B>sigwait</B></A></P>
-<H2 CLASS="western"><A HREF="#toc3" NAME="sect3">Non-portable
-Pthreads-w32 routines</A></H2>
-<P STYLE="margin-left: 0.79in"><A HREF="pthreadCancelableWait.html"><B>pthreadCancelableTimedWait</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthreadCancelableWait.html"><B>pthreadCancelableWait</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_delay_np.html"><B>pthread_delay_np</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_getw32threadhandle_np.html"><B>pthread_getw32threadhandle_np</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_num_processors_np.html"><B>pthread_num_processors_np</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_win32_test_features_np.html"><B>pthread_win32_test_features_np</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_timechange_handler_np.html"><B>pthread_timechange_handler_np</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_win32_attach_detach_np.html"><B>pthread_win32_process_attach_np</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_win32_attach_detach_np.html"><B>pthread_win32_process_detach_np</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_win32_attach_detach_np.html"><B>pthread_win32_thread_attach_np</B></A></P>
-<P STYLE="margin-left: 0.79in"><A HREF="pthread_win32_attach_detach_np.html"><B>pthread_win32_thread_detach_np</B></A></P>
-<H2 CLASS="western"><A HREF="#toc4" NAME="sect4">Other</A></H2>
-<P STYLE="margin-left: 0.79in"><A HREF="PortabilityIssues.html"><B>Portability
-issues</B></A></P>
-</BODY>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<HTML>
+<HEAD>
+ <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=windows-1252">
+ <TITLE></TITLE>
+ <META NAME="GENERATOR" CONTENT="OpenOffice.org 3.4 (Win32)">
+ <META NAME="CREATED" CONTENT="20050504;17350500">
+ <META NAME="CHANGED" CONTENT="20121004;13410656">
+ <STYLE TYPE="text/css">
+ <!--
+ H4.cjk { font-family: "AR PL UMing CN" }
+ H4.ctl { font-family: "Lohit Devanagari" }
+ H3.cjk { font-family: "AR PL UMing CN" }
+ H3.ctl { font-family: "Lohit Devanagari" }
+ H2.cjk { font-family: "AR PL UMing CN" }
+ H2.ctl { font-family: "Lohit Devanagari" }
+ -->
+ </STYLE>
+</HEAD>
+<BODY LANG="en-GB" DIR="LTR">
+<H4 CLASS="western">POSIX Threads for Windows &ndash; REFERENCE -
+<A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4>
+<H3 CLASS="western">Table of Contents</H3>
+<P STYLE="margin-left: 2.01cm"><A HREF="#sect1" NAME="toc1">POSIX
+threads API reference</A><BR><A HREF="#sect2" NAME="toc2">Miscellaneous
+POSIX thread safe routines provided by Pthreads-w32</A><BR><A HREF="#sect3" NAME="toc3">Non-portable
+Pthreads-w32 routines</A><BR><A HREF="#sect4" NAME="toc4">Other</A></P>
+<H2 CLASS="western"><A HREF="#toc1" NAME="sect1">POSIX threads API
+reference</A></H2>
+<P STYLE="margin-left: 2.01cm"><A HREF="cpu_set.html"><B>cpu_set</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_attr_init.html"><B>pthread_attr_destroy</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_attr_init.html"><B>pthread_attr_getdetachstate</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_attr_init.html"><B>pthread_attr_getinheritsched</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_attr_init.html"><B>pthread_attr_getschedparam</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_attr_init.html"><B>pthread_attr_getschedpolicy</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_attr_init.html"><B>pthread_attr_getscope</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_attr_setstackaddr.html"><B>pthread_attr_getstackaddr</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_attr_setstacksize.html"><B>pthread_attr_getstacksize</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_attr_init.html"><B>pthread_attr_init</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_attr_init.html"><B>pthread_attr_setdetachstate</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_attr_init.html"><B>pthread_attr_setinheritsched</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_attr_init.html"><B>pthread_attr_setschedparam</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_attr_init.html"><B>pthread_attr_setschedpolicy</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_attr_init.html"><B>pthread_attr_setscope</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_attr_setstackaddr.html"><B>pthread_attr_setstackaddr</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_attr_setstacksize.html"><B>pthread_attr_setstacksize</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_barrierattr_init.html"><B>pthread_barrierattr_destroy</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_barrierattr_setpshared.html"><B>pthread_barrierattr_getpshared</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_barrierattr_init.html"><B>pthread_barrierattr_init</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_barrierattr_setpshared.html"><B>pthread_barrierattr_setpshared</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_barrier_init.html"><B>pthread_barrier_destroy</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_barrier_init.html"><B>pthread_barrier_init</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_barrier_wait.html"><B>pthread_barrier_wait</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_cancel.html"><B>pthread_cancel</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_cleanup_push.html"><B>pthread_cleanup_pop</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_cleanup_push.html"><B>pthread_cleanup_push</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_condattr_init.html"><B>pthread_condattr_destroy</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_condattr_setpshared.html"><B>pthread_condattr_getpshared</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_condattr_init.html"><B>pthread_condattr_init</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_condattr_setpshared.html"><B>pthread_condattr_setpshared</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_cond_init.html"><B>pthread_cond_broadcast</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_cond_init.html"><B>pthread_cond_destroy</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_cond_init.html"><B>pthread_cond_init</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_cond_init.html"><B>pthread_cond_signal</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_cond_init.html"><B>pthread_cond_timedwait</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_cond_init.html"><B>pthread_cond_wait</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_create.html"><B>pthread_create</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_detach.html"><B>pthread_detach</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_equal.html"><B>pthread_equal</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_exit.html"><B>pthread_exit</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_setconcurrency.html"><B>pthread_getconcurrency</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_setschedparam.html"><B>pthread_getschedparam</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_getunique_np.html"><B>pthread_getunique_np</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_key_create.html"><B>pthread_getspecific</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_join.html"><B>pthread_join</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_join.html"><B>pthread_timedjoin_np</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_join.html"><B>pthread_tryjoin_np</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_key_create.html"><B>pthread_key_create</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_key_create.html"><B>pthread_key_delete</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_kill.html"><B>pthread_kill</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_mutexattr_init.html"><B>pthread_mutexattr_destroy</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_mutexattr_init.html"><B>pthread_mutexattr_getkind_np</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_mutexattr_setpshared.html"><B>pthread_mutexattr_getpshared</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_mutexattr_init.html"><B>pthread_mutexattr_getrobust</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_mutexattr_init.html"><B>pthread_mutexattr_gettype</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_mutexattr_init.html"><B>pthread_mutexattr_init</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_mutexattr_init.html"><B>pthread_mutexattr_setkind_np</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_mutexattr_setpshared.html"><B>pthread_mutexattr_setpshared</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_mutexattr_init.html"><B>pthread_mutexattr_setrobust</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_mutexattr_init.html"><B>pthread_mutexattr_settype</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_mutex_init.html"><B>pthread_mutex_consistent</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_mutex_init.html"><B>pthread_mutex_destroy</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_mutex_init.html"><B>pthread_mutex_init</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_mutex_init.html"><B>pthread_mutex_lock</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_mutex_init.html"><B>pthread_mutex_timedlock</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_mutex_init.html"><B>pthread_mutex_trylock</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_mutex_init.html"><B>pthread_mutex_unlock</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_once.html"><B>pthread_once</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_rwlockattr_init.html"><B>pthread_rwlockattr_destroy</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_rwlockattr_setpshared.html"><B>pthread_rwlockattr_getpshared</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_rwlockattr_init.html"><B>pthread_rwlockattr_init</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_rwlockattr_setpshared.html"><B>pthread_rwlockattr_setpshared</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_rwlock_init.html"><B>pthread_rwlock_destroy</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_rwlock_init.html"><B>pthread_rwlock_init</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_rwlock_rdlock.html"><B>pthread_rwlock_rdlock</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_rwlock_timedrdlock.html"><B>pthread_rwlock_timedrdlock</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_rwlock_timedwrlock.html"><B>pthread_rwlock_timedwrlock</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_rwlock_rdlock.html"><B>pthread_rwlock_tryrdlock</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_rwlock_wrlock.html"><B>pthread_rwlock_trywrlock</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_rwlock_unlock.html"><B>pthread_rwlock_unlock</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_rwlock_wrlock.html"><B>pthread_rwlock_wrlock</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_self.html"><B>pthread_self</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_cancel.html"><B>pthread_setcancelstate</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_cancel.html"><B>pthread_setcanceltype</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_setconcurrency.html"><B>pthread_setconcurrency</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_setschedparam.html"><B>pthread_setschedparam</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_key_create.html"><B>pthread_setspecific</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_kill.html"><B>pthread_sigmask</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_spin_init.html"><B>pthread_spin_destroy</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_spin_init.html"><B>pthread_spin_init</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_spin_lock.html"><B>pthread_spin_lock</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_spin_lock.html"><B>pthread_spin_trylock</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_spin_unlock.html"><B>pthread_spin_unlock</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_cancel.html"><B>pthread_testcancel</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="sched_get_priority_max.html"><B>sched_get_priority_max</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="sched_get_priority_max.html"><B>sched_get_priority_min</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="sched_setaffinity.html"><B>sched_getaffinity</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="sched_getscheduler.html"><B>sched_getscheduler</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="sched_setaffinity.html"><B>sched_setaffinity</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="sched_setscheduler.html"><B>sched_setscheduler</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="sched_yield.html"><B>sched_yield</B></A></P>
+<P STYLE="margin-left: 2.01cm"><B>sem_close</B></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="sem_init.html"><B>sem_destroy</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="sem_init.html"><B>sem_getvalue</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="sem_init.html"><B>sem_init</B></A></P>
+<P STYLE="margin-left: 2.01cm"><B>sem_open</B></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="sem_init.html"><B>sem_post</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="sem_init.html"><B>sem_post_multiple</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="sem_init.html"><B>sem_timedwait</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="sem_init.html"><B>sem_trywait</B></A></P>
+<P STYLE="margin-left: 2.01cm"><B>sem_unlink</B></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="sem_init.html"><B>sem_wait</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_kill.html"><B>sigwait</B></A></P>
+<H2 CLASS="western"><A HREF="#toc3" NAME="sect3">Non-portable
+Pthreads-w32 routines</A></H2>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthreadCancelableWait.html"><B>pthreadCancelableTimedWait</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthreadCancelableWait.html"><B>pthreadCancelableWait</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_delay_np.html"><B>pthread_delay_np</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_getw32threadhandle_np.html"><B>pthread_getw32threadhandle_np</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_num_processors_np.html"><B>pthread_num_processors_np</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_win32_test_features_np.html"><B>pthread_win32_test_features_np</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_timechange_handler_np.html"><B>pthread_timechange_handler_np</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_join.html"><B>pthread_timedjoin_np</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_win32_attach_detach_np.html"><B>pthread_win32_process_attach_np</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_win32_attach_detach_np.html"><B>pthread_win32_process_detach_np</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_win32_attach_detach_np.html"><B>pthread_win32_thread_attach_np</B></A></P>
+<P STYLE="margin-left: 2.01cm"><A HREF="pthread_win32_attach_detach_np.html"><B>pthread_win32_thread_detach_np</B></A></P>
+<H2 CLASS="western"><A HREF="#toc4" NAME="sect4">Other</A></H2>
+<P STYLE="margin-left: 2.01cm"><A HREF="PortabilityIssues.html"><B>Portability
+issues</B></A></P>
+</BODY>
</HTML> \ No newline at end of file
diff --git a/pthreads/manual/pthread_create.html b/pthreads/manual/pthread_create.html
index d1ebbc3e1..5e75de49b 100644
--- a/pthreads/manual/pthread_create.html
+++ b/pthreads/manual/pthread_create.html
@@ -1,94 +1,112 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-<HTML>
-<HEAD>
- <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8">
- <TITLE>PTHREAD_CREATE(3) manual page</TITLE>
- <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)">
- <META NAME="CREATED" CONTENT="20050504;19394700">
- <META NAME="CHANGED" CONTENT="20050504;20140200">
- <!-- manual page source format generated by PolyglotMan v3.2, -->
- <!-- available at http://polyglotman.sourceforge.net/ -->
-</HEAD>
-<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR">
-<H4>POSIX Threads for Windows ā€“ REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4>
-<P><A HREF="index.html">Reference Index</A></P>
-<P><A HREF="#toc">Table of Contents</A></P>
-<H2><A HREF="#toc0" NAME="sect0">Name</A></H2>
-<P>pthread_create - create a new thread
-</P>
-<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2>
-<P><B>#include &lt;pthread.h&gt;</B>
-</P>
-<P><B>int pthread_create(pthread_t * </B><I>thread</I><B>,
-pthread_attr_t * </B><I>attr</I><B>, void * (*</B><I>start_routine</I><B>)(void
-*), void * </B><I>arg</I><B>);</B>
-</P>
-<H2><A HREF="#toc2" NAME="sect2">Description</A></H2>
-<P><B>pthread_create</B> creates a new thread of control that
-executes concurrently with the calling thread. The new thread applies
-the function <I>start_routine</I> passing it <I>arg</I> as first
-argument. The new thread terminates either explicitly, by calling
-<A HREF="pthread_exit.html"><B>pthread_exit</B>(3)</A> , or
-implicitly, by returning from the <I>start_routine</I> function. The
-latter case is equivalent to calling <A HREF="pthread_exit.html"><B>pthread_exit</B>(3)</A>
-with the result returned by <I>start_routine</I> as exit code.
-</P>
-<P>The initial signal state of the new thread is inherited from it's
-creating thread and there are no pending signals. <B>Pthreads-w32</B>
-does not yet implement signals.</P>
-<P>The <I>attr</I> argument specifies thread attributes to be applied
-to the new thread. See <A HREF="pthread_attr_init.html"><B>pthread_attr_init</B>(3)</A>
-for a complete list of thread attributes. The <I>attr</I> argument
-can also be <B>NULL</B>, in which case default attributes are used:
-the created thread is joinable (not detached) and has default (non
-real-time) scheduling policy.
-</P>
-<H2><A HREF="#toc3" NAME="sect3">Return Value</A></H2>
-<P>On success, the identifier of the newly created thread is stored
-in the location pointed by the <I>thread</I> argument, and a 0 is
-returned. On error, a non-zero error code is returned.
-</P>
-<H2><A HREF="#toc4" NAME="sect4">Errors</A></H2>
-<DL>
- <DT><B>EAGAIN</B>
- </DT><DL>
- <DL>
- <DT>
- Not enough system resources to create a process for the new
- thread, or<BR>more than <B>PTHREAD_THREADS_MAX</B> threads are
- already active.
- </DT></DL>
- </DL>
-</DL>
-<H2>
-<A HREF="#toc5" NAME="sect5">Author</A></H2>
-<P>Xavier Leroy &lt;Xavier.Leroy@inria.fr&gt;
-</P>
-<P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P>
-<H2><A HREF="#toc6" NAME="sect6">See Also</A></H2>
-<P><A HREF="pthread_exit.html"><B>pthread_exit</B>(3)</A> ,
-<A HREF="pthread_join.html"><B>pthread_join</B>(3)</A> ,
-<A HREF="pthread_detach.html"><B>pthread_detach</B>(3)</A> ,
-<A HREF="pthread_attr_init.html"><B>pthread_attr_init</B>(3)</A> .
-</P>
-<HR>
-<P><A NAME="toc"></A><B>Table of Contents</B></P>
-<UL>
- <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A>
- </P>
- <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A>
- </P>
- <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A>
- </P>
- <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Return
- Value</A>
- </P>
- <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Errors</A>
- </P>
- <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Author</A>
- </P>
- <LI><P><A HREF="#sect6" NAME="toc6">See Also</A>
- </P>
-</UL>
-</BODY>
-</HTML>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<HTML>
+<HEAD>
+ <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=windows-1252">
+ <TITLE>PTHREAD_CREATE(3) manual page</TITLE>
+ <META NAME="GENERATOR" CONTENT="OpenOffice.org 3.4 (Win32)">
+ <META NAME="CREATED" CONTENT="20050504;19394700">
+ <META NAME="CHANGED" CONTENT="20120921;10335710">
+ <STYLE TYPE="text/css">
+ <!--
+ H4.cjk { font-family: "SimSun" }
+ H4.ctl { font-family: "Mangal" }
+ H2.cjk { font-family: "SimSun" }
+ H2.ctl { font-family: "Mangal" }
+ -->
+ </STYLE>
+</HEAD>
+<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR">
+<H4 CLASS="western">POSIX Threads for Windows &ndash; REFERENCE -
+<A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4>
+<P><A HREF="index.html">Reference Index</A></P>
+<P><A HREF="#toc">Table of Contents</A></P>
+<H2 CLASS="western"><A HREF="#toc0" NAME="sect0">Name</A></H2>
+<P>pthread_create - create a new thread
+</P>
+<H2 CLASS="western"><A HREF="#toc1" NAME="sect1">Synopsis</A></H2>
+<P><B>#include &lt;pthread.h&gt;</B>
+</P>
+<P><B>int pthread_create(pthread_t * </B><I>thread</I><B>,
+pthread_attr_t * </B><I>attr</I><B>, void * (*</B><I>start_routine</I><B>)(void
+*), void * </B><I>arg</I><B>);</B>
+</P>
+<H2 CLASS="western"><A HREF="#toc2" NAME="sect2">Description</A></H2>
+<P><B>pthread_create</B> creates a new thread of control that
+executes concurrently with the calling thread. The new thread applies
+the function <I>start_routine</I> passing it <I>arg</I> as first
+argument. The new thread terminates either explicitly, by calling
+<A HREF="pthread_exit.html"><B>pthread_exit</B>(3)</A> , or
+implicitly, by returning from the <I>start_routine</I> function. The
+latter case is equivalent to calling <A HREF="pthread_exit.html"><B>pthread_exit</B>(3)</A>
+with the result returned by <I>start_routine</I> as exit code.
+</P>
+<P>The initial signal state of the new thread is inherited from it's
+creating thread and there are no pending signals. <B>Pthreads-w32</B>
+does not yet implement signals.</P>
+<P>The initial CPU affinity of the new thread is inherited from it's
+creating thread. A threads CPU affinity can be obtained through
+<A HREF="pthread_setaffinity_np.html"><B>pthread_getaffinity_np(3)</B></A>
+and may be changed through <A HREF="pthread_setaffinity_np.html"><B>pthread_setaffinity_np(3)</B></A>.
+Unless changed, all threads inherit the CPU affinity of the parent
+process. See <A HREF="sched_setaffinity.html"><B>sched_getaffinity(3)</B></A>
+and <A HREF="sched_setaffinity.html"><B>sched_setaffinity(3)</B></A>.</P>
+<P>The <I>attr</I> argument specifies thread attributes to be applied
+to the new thread. See <A HREF="pthread_attr_init.html"><B>pthread_attr_init</B>(3)</A>
+for a complete list of thread attributes. The <I>attr</I> argument
+can also be <B>NULL</B>, in which case default attributes are used:
+the created thread is joinable (not detached) and has default (non
+real-time) scheduling policy.
+</P>
+<H2 CLASS="western"><A HREF="#toc3" NAME="sect3">Return Value</A></H2>
+<P>On success, the identifier of the newly created thread is stored
+in the location pointed by the <I>thread</I> argument, and a 0 is
+returned. On error, a non-zero error code is returned.
+</P>
+<H2 CLASS="western"><A HREF="#toc4" NAME="sect4">Errors</A></H2>
+<DL>
+ <DT><B>EAGAIN</B>
+ </DT><DL>
+ <DL>
+ <DT STYLE="margin-bottom: 0.5cm">
+ Not enough system resources to create a process for the new
+ thread, or<BR>more than <B>PTHREAD_THREADS_MAX</B> threads are
+ already active.
+ </DT></DL>
+ </DL>
+</DL>
+<H2 CLASS="western">
+<A HREF="#toc5" NAME="sect5">Author</A></H2>
+<P>Xavier Leroy &lt;Xavier.Leroy@inria.fr&gt;
+</P>
+<P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P>
+<H2 CLASS="western"><A HREF="#toc6" NAME="sect6">See Also</A></H2>
+<P><A HREF="pthread_exit.html"><B>pthread_exit</B>(3)</A> ,
+<A HREF="pthread_join.html"><B>pthread_join</B>(3)</A> ,
+<A HREF="pthread_detach.html"><B>pthread_detach</B>(3)</A> ,
+<A HREF="pthread_attr_init.html"><B>pthread_attr_init</B>(3)</A> ,
+<A HREF="pthread_setaffinity_np.html"><B>pthread_getaffinity_np(3)</B></A>
+, <A HREF="pthread_setaffinity_np.html"><B>pthread_setaffinity_np(3)</B></A>
+, <A HREF="sched_setaffinity.html"><B>sched_getaffinity(3)</B></A> ,
+<A HREF="sched_setaffinity.html"><B>sched_setaffinity(3)</B></A> .
+</P>
+<HR>
+<P><A NAME="toc"></A><B>Table of Contents</B></P>
+<UL>
+ <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A>
+ </P>
+ <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A>
+ </P>
+ <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A>
+ </P>
+ <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Return
+ Value</A>
+ </P>
+ <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Errors</A>
+ </P>
+ <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Author</A>
+ </P>
+ <LI><P><A HREF="#sect6" NAME="toc6">See Also</A>
+ </P>
+</UL>
+</BODY>
+</HTML> \ No newline at end of file
diff --git a/pthreads/manual/pthread_join.html b/pthreads/manual/pthread_join.html
index 3e3f3b902..e1a8116d9 100644
--- a/pthreads/manual/pthread_join.html
+++ b/pthreads/manual/pthread_join.html
@@ -1,118 +1,153 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-<HTML>
-<HEAD>
- <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8">
- <TITLE>PTHREAD_JOIN(3) manual page</TITLE>
- <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)">
- <META NAME="CREATED" CONTENT="20050504;18232700">
- <META NAME="CHANGED" CONTENT="20050504;18421400">
- <!-- manual page source format generated by PolyglotMan v3.2, -->
- <!-- available at http://polyglotman.sourceforge.net/ -->
-</HEAD>
-<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR">
-<H4>POSIX Threads for Windows ā€“ REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4>
-<P><A HREF="index.html">Reference Index</A></P>
-<P><A HREF="#toc">Table of Contents</A></P>
-<H2><A HREF="#toc0" NAME="sect0">Name</A></H2>
-<P>pthread_join - wait for termination of another thread
-</P>
-<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2>
-<P><B>#include &lt;pthread.h&gt;</B>
-</P>
-<P><B>int pthread_join(pthread_t </B><I>th</I><B>, void
-**</B><I>thread_return</I><B>);</B>
-</P>
-<H2><A HREF="#toc2" NAME="sect2">Description</A></H2>
-<P><B>pthread_join</B> suspends the execution of the calling thread
-until the thread identified by <I>th</I> terminates, either by
-calling <A HREF="pthread_exit.html"><B>pthread_exit</B>(3)</A> or by
-being cancelled.
-</P>
-<P>If <I>thread_return</I> is not <B>NULL</B>, the return value of <I>th</I>
-is stored in the location pointed to by <I>thread_return</I>. The
-return value of <I>th</I> is either the argument it gave to
-<A HREF="pthread_exit.html"><B>pthread_exit</B>(3)</A> , or
-<B>PTHREAD_CANCELED</B> if <I>th</I> was cancelled.
-</P>
-<P>The joined thread <B>th</B> must be in the joinable state: it must
-not have been detached using <A HREF="pthread_detach.html"><B>pthread_detach</B>(3)</A>
-or the <B>PTHREAD_CREATE_DETACHED</B> attribute to <A HREF="pthread_create.html"><B>pthread_create</B>(3)</A>
-.
-</P>
-<P>When a joinable thread terminates, its memory resources (thread
-descriptor and stack) are not deallocated until another thread
-performs <B>pthread_join</B> on it. Therefore, <B>pthread_join</B>
-must be called once for each joinable thread created to avoid memory
-leaks.
-</P>
-<P>At most one thread can wait for the termination of a given thread.
-Calling <B>pthread_join</B> on a thread <I>th</I> on which another
-thread is already waiting for termination returns an error.
-</P>
-<H2><A HREF="#toc3" NAME="sect3">Cancellation</A></H2>
-<P><B>pthread_join</B> is a cancellation point. If a thread is
-cancelled while suspended in <B>pthread_join</B>, the thread
-execution resumes immediately and the cancellation is executed
-without waiting for the <I>th</I> thread to terminate. If
-cancellation occurs during <B>pthread_join</B>, the <I>th</I> thread
-remains not joined.
-</P>
-<H2><A HREF="#toc4" NAME="sect4">Return Value</A></H2>
-<P>On success, the return value of <I>th</I> is stored in the
-location pointed to by <I>thread_return</I>, and 0 is returned. On
-error, a non-zero error code is returned.
-</P>
-<H2><A HREF="#toc5" NAME="sect5">Errors</A></H2>
-<DL>
- <DT><B>ESRCH</B>
- </DT><DD>
- No thread could be found corresponding to that specified by <I>th</I>.
- </DD><DT>
- <B>EINVAL</B>
- </DT><DD>
- The <I>th</I> thread has been detached.
- </DD><DT>
- <B>EINVAL</B>
- </DT><DD>
- Another thread is already waiting on termination of <I>th</I>.
- </DD><DT>
- <B>EDEADLK</B>
- </DT><DD STYLE="margin-bottom: 0.5cm">
- The <I>th</I> argument refers to the calling thread.
- </DD></DL>
-<H2>
-<A HREF="#toc6" NAME="sect6">Author</A></H2>
-<P>Xavier Leroy &lt;Xavier.Leroy@inria.fr&gt;
-</P>
-<H2><A HREF="#toc7" NAME="sect7">See Also</A></H2>
-<P><A HREF="pthread_exit.html"><B>pthread_exit</B>(3)</A> ,
-<A HREF="pthread_detach.html"><B>pthread_detach</B>(3)</A> ,
-<A HREF="pthread_create.html"><B>pthread_create</B>(3)</A> ,
-<A HREF="pthread_attr_setdetachstate.html"><B>pthread_attr_setdetachstate</B>(3)</A>
-, <A HREF="pthread_cleanup_push.html"><B>pthread_cleanup_push</B>(3)</A>
-, <A HREF="pthread_key_create.html"><B>pthread_key_create</B>(3)</A>
-.
-</P>
-<HR>
-<P><A NAME="toc"></A><B>Table of Contents</B></P>
-<UL>
- <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A>
- </P>
- <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A>
- </P>
- <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A>
- </P>
- <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Cancellation</A>
- </P>
- <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Return
- Value</A>
- </P>
- <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Errors</A>
- </P>
- <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">Author</A>
- </P>
- <LI><P><A HREF="#sect7" NAME="toc7">See Also</A>
- </P>
-</UL>
-</BODY>
-</HTML>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<HTML>
+<HEAD>
+ <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=windows-1252">
+ <TITLE>PTHREAD_JOIN(3) manual page</TITLE>
+ <META NAME="GENERATOR" CONTENT="OpenOffice.org 3.4 (Win32)">
+ <META NAME="CREATED" CONTENT="20050504;18232700">
+ <META NAME="CHANGED" CONTENT="20121004;13330921">
+ <STYLE TYPE="text/css">
+ <!--
+ H4.cjk { font-family: "SimSun" }
+ H4.ctl { font-family: "Mangal" }
+ H2.cjk { font-family: "SimSun" }
+ H2.ctl { font-family: "Mangal" }
+ -->
+ </STYLE>
+</HEAD>
+<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR">
+<H4 CLASS="western">POSIX Threads for Windows &ndash; REFERENCE -
+<A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4>
+<P><A HREF="index.html">Reference Index</A></P>
+<P><A HREF="#toc">Table of Contents</A></P>
+<H2 CLASS="western"><A HREF="#toc0" NAME="sect0">Name</A></H2>
+<P>pthread_join - wait for termination of another thread</P>
+<P>pthread_timedjoin_np - wait for termination of another thread with
+a timeout
+</P>
+<P>pthread_tryjoin_np &ndash; join another thread without waiting</P>
+<H2 CLASS="western"><A HREF="#toc1" NAME="sect1">Synopsis</A></H2>
+<P><B>#include &lt;pthread.h&gt;</B>
+</P>
+<P><B>int pthread_join(pthread_t </B><I>th</I><B>, void
+**</B><I>thread_return</I><B>);</B>
+</P>
+<P><B>int pthread_timedjoin_np(pthread_t </B><I>th</I><B>, void
+**</B><I>thread_return, </I><SPAN STYLE="font-style: normal"><B>const
+struct timespec *</B></SPAN><I>abstime</I><B>);</B>
+</P>
+<P><B>int pthread_tryjoin_np(pthread_t </B><I>th</I><B>, void
+**</B><I>thread_return</I><B>);</B>
+</P>
+<H2 CLASS="western"><A HREF="#toc2" NAME="sect2">Description</A></H2>
+<P><B>pthread_join</B> suspends the execution of the calling thread
+until the thread identified by <I>th</I> terminates, either by
+calling <A HREF="pthread_exit.html"><B>pthread_exit</B>(3)</A> or by
+being cancelled.
+</P>
+<P>If <I>thread_return</I> is not <B>NULL</B>, the return value of <I>th</I>
+is stored in the location pointed to by <I>thread_return</I>. The
+return value of <I>th</I> is either the argument it gave to
+<A HREF="pthread_exit.html"><B>pthread_exit</B>(3)</A> , or
+<B>PTHREAD_CANCELED</B> if <I>th</I> was cancelled.
+</P>
+<P>The joined thread <I><SPAN STYLE="font-weight: normal">th</SPAN></I>
+must be in the joinable state: it must not have been detached using
+<A HREF="pthread_detach.html"><B>pthread_detach</B>(3)</A> or the
+<B>PTHREAD_CREATE_DETACHED</B> attribute to <A HREF="pthread_create.html"><B>pthread_create</B>(3)</A>
+.
+</P>
+<P>When a joinable thread terminates, its memory resources (thread
+descriptor and stack) are not deallocated until another thread
+performs <B>pthread_join</B> on it. Therefore, <B>pthread_join</B>
+must be called once for each joinable thread created to avoid memory
+leaks.</P>
+<P><B>pthread_timedjoin_np</B> is identical to pthread_join except
+that it will return the error ETIMEDOUT if the target thread <I>th</I>
+has not exited before <I>abstime</I> passes. If <I>abstime</I> is
+NULL the function will wait forever and it's behaviour will therefore
+be identical to pthread_join.</P>
+<P><B>pthread_tryjoin_np</B> is identical to pthread_join except that
+it will return immediately with the error EBUSY if the target thread
+<I>th</I> has not exited.</P>
+<P>At most one thread can wait for the termination of a given thread.
+Calling <B>pthread_join</B> on a thread <I>th</I> on which another
+thread is already waiting for termination returns an error.
+</P>
+<H2 CLASS="western"><A HREF="#toc3" NAME="sect3">Cancellation</A></H2>
+<P><B>pthread_join, pthread_tryjoin_np</B> <SPAN STYLE="font-weight: normal">and
+</SPAN><B>pthread_timedjoin_np</B> are cancellation points. If a
+thread is cancelled while suspended in <SPAN STYLE="font-weight: normal">either
+function</SPAN>, the thread execution resumes immediately and the
+cancellation is executed without waiting for the <I>th</I> thread to
+terminate. If cancellation occurs during either function, the <I>th</I>
+thread remains not joined.
+</P>
+<H2 CLASS="western"><A HREF="#toc4" NAME="sect4">Return Value</A></H2>
+<P>On success, the return value of <I>th</I> is stored in the
+location pointed to by <I>thread_return</I>, and 0 is returned. On
+error, a non-zero error code is returned.
+</P>
+<H2 CLASS="western"><A HREF="#toc5" NAME="sect5">Errors</A></H2>
+<DL>
+ <DT><B>ESRCH</B>
+ </DT><DD>
+ No thread could be found corresponding to that specified by <I>th</I>.
+ </DD><DT>
+ <B>EINVAL</B>
+ </DT><DD>
+ The <I>th</I> thread has been detached.
+ </DD><DT>
+ <B>EINVAL</B>
+ </DT><DD>
+ Another thread is already waiting on termination of <I>th</I>.
+ </DD><DT>
+ <B>ETIMEDOUT</B>
+ </DT><DD>
+ <SPAN STYLE="font-style: normal"><SPAN STYLE="font-weight: normal">(pthread_timedjoin_np
+ only):</SPAN></SPAN> <I>abstime</I> <SPAN STYLE="font-style: normal">passed
+ before </SPAN><I>th</I> <SPAN STYLE="font-style: normal">could be
+ joined</SPAN>.
+ </DD><DT>
+ <B>EDEADLK</B>
+ </DT><DD STYLE="margin-bottom: 0.5cm">
+ The <I>th</I> argument refers to the calling thread.
+ </DD></DL>
+<H2 CLASS="western">
+<A HREF="#toc6" NAME="sect6">Author</A></H2>
+<P>Xavier Leroy &lt;Xavier.Leroy@inria.fr&gt;
+</P>
+<P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.
+</P>
+<H2 CLASS="western"><A HREF="#toc7" NAME="sect7">See Also</A></H2>
+<P><A HREF="pthread_exit.html"><B>pthread_exit</B>(3)</A> ,
+<A HREF="pthread_detach.html"><B>pthread_detach</B>(3)</A> ,
+<A HREF="pthread_create.html"><B>pthread_create</B>(3)</A> ,
+<A HREF="pthread_attr_setdetachstate.html"><B>pthread_attr_setdetachstate</B>(3)</A>
+, <A HREF="pthread_cleanup_push.html"><B>pthread_cleanup_push</B>(3)</A>
+, <A HREF="pthread_key_create.html"><B>pthread_key_create</B>(3)</A>
+.
+</P>
+<HR>
+<P><A NAME="toc"></A><B>Table of Contents</B></P>
+<UL>
+ <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A>
+ </P>
+ <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A>
+ </P>
+ <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A>
+ </P>
+ <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Cancellation</A>
+ </P>
+ <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Return
+ Value</A>
+ </P>
+ <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Errors</A>
+ </P>
+ <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">Author</A>
+ </P>
+ <LI><P><A HREF="#sect7" NAME="toc7">See Also</A>
+ </P>
+</UL>
+</BODY>
+</HTML> \ No newline at end of file
diff --git a/pthreads/manual/sched_setaffinity.html b/pthreads/manual/sched_setaffinity.html
new file mode 100755
index 000000000..ec7ef7e0e
--- /dev/null
+++ b/pthreads/manual/sched_setaffinity.html
@@ -0,0 +1,143 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<HTML>
+<HEAD>
+ <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=windows-1252">
+ <TITLE>PTHREAD_CREATE(3) manual page</TITLE>
+ <META NAME="GENERATOR" CONTENT="OpenOffice.org 3.4 (Win32)">
+ <META NAME="CREATED" CONTENT="20050504;19394700">
+ <META NAME="CHANGED" CONTENT="20120921;10513422">
+ <STYLE TYPE="text/css">
+ <!--
+ H4.cjk { font-family: "SimSun" }
+ H4.ctl { font-family: "Mangal" }
+ H2.cjk { font-family: "SimSun" }
+ H2.ctl { font-family: "Mangal" }
+ -->
+ </STYLE>
+</HEAD>
+<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR">
+<H4 CLASS="western"><FONT FACE="Times New Roman, serif"><FONT SIZE=3><SPAN STYLE="font-style: normal">POSIX
+Threads for Windows &ndash; REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></SPAN></FONT></FONT></H4>
+<P><A HREF="index.html">Reference Index</A></P>
+<P><A HREF="#toc">Table of Contents</A></P>
+<H2 CLASS="western"><A HREF="#toc0" NAME="sect0">Name</A></H2>
+<P>sched_setaffinity - set process CPU affinity</P>
+<P>sched_getaffinity - get process CPU affinity</P>
+<H2 CLASS="western"><A HREF="#toc1" NAME="sect1">Synopsis</A></H2>
+<P><B>#include &lt;sched.h&gt; </B>
+</P>
+<P><B>int sched_setaffinity(pid_t </B><I><SPAN STYLE="font-weight: normal">pid</SPAN></I><B>,
+int </B><I><SPAN STYLE="font-weight: normal">cpusetsize</SPAN></I><B>,
+const cpu_set_t *</B><I><SPAN STYLE="font-weight: normal">mask</SPAN></I><B>);</B></P>
+<P><B>int sched_getaffinity(pid_t </B><I><SPAN STYLE="font-weight: normal">pid</SPAN></I><B>,
+int </B><I><SPAN STYLE="font-weight: normal">cpusetsize</SPAN></I><B>,
+cpu_set_t *</B><I><SPAN STYLE="font-weight: normal">mask</SPAN></I><B>);</B></P>
+<H2 CLASS="western"><A HREF="#toc2" NAME="sect2">Description</A></H2>
+<P><B>sched_setaffinity</B> sets the CPU affinity mask of the process
+whose ID is <I>pid</I> to the value specified by mask. If <I>pid</I>
+is zero, then the calling process is used. The argument <I>cpusetsize</I>
+is the length (in bytes) of the data pointed to by <I>mask</I>.
+Normally this argument would be specified as <I>sizeof(cpu_set_t)</I>.</P>
+<P>If the process specified by <I>pid</I> is not currently running on
+one of the CPUs specified in <I>mask</I>, then that process is
+migrated to one of the CPUs specified in <I>mask</I>.</P>
+<P>After a call to <B>sched_setaffinity</B>, the set of CPUs on which
+the process will actually run is the intersection of the set
+specified in the <I>mask</I> argument and the set of CPUs actually
+present on the system.</P>
+<P><B>sched_getaffinity</B> writes the affinity mask of the process
+whose ID is <I>pid</I> into the cpu_set_t structure pointed to by
+<I>mask</I>. The <I>cpusetsize</I> argument specifies the size (in
+bytes) of <I>mask</I>. If <I>pid</I> is zero, then the mask of the
+calling process is returned.</P>
+<P><B>Pthreads-w32</B> currently ignores the <I>cpusetsize</I>
+parameter for either function because cpu_set_t is a direct typeset
+to the Windows affinity vector type DWORD_PTR.</P>
+<P>Windows may require that the requesting process have permission to
+set its own CPU affinity or that of another process.</P>
+<H2 CLASS="western"><A HREF="#toc3" NAME="sect3">Return Value</A></H2>
+<P>On success, <B>sched_setaffinity</B> and <B>sched_getaffinity</B>
+return 0. On error, -1 is returned, and <I>errno</I> is set
+appropriately.</P>
+<H2 CLASS="western"><A HREF="#toc4" NAME="sect4">Errors</A></H2>
+<DL>
+ <DT><B>EFAULT</B></DT><DL>
+ <DL>
+ <DT STYLE="margin-left: 0.02cm">
+ A supplied memory address was invalid.</DT></DL>
+ </DL>
+ <DT>
+ <B>EINVAL</B></DT><DL>
+ <DL>
+ <DT STYLE="margin-left: 0.04cm">
+ The affinity bit mask mask contains no processors that are
+ currently physically on the system.</DT></DL>
+ </DL>
+ <DT>
+ <B>EAGAIN</B></DT><DL>
+ <DL>
+ <DT STYLE="margin-left: 0.02cm">
+ The function did not succeed in changing or obtaining the CPU
+ affinity for some undetermined reason. Try again.</DT></DL>
+ </DL>
+ <DT>
+ <B>EPERM</B></DT><DL>
+ <DL>
+ <DT STYLE="margin-left: 0.02cm">
+ The calling process does not have appropriate privileges.</DT></DL>
+ </DL>
+ <DT>
+ <B>ESRCH</B>
+ </DT><DL>
+ <DL>
+ <DT STYLE="margin-left: 0.02cm">
+ The process whose ID is pid could not be found.</DT></DL>
+ </DL>
+</DL>
+<H2 CLASS="western">
+<A HREF="#toc5" NAME="sect5">Application Usage</A></H2>
+<P>A process's CPU affinity mask determines the set of CPUs on which
+it is eligible to run. On a multiprocessor system, setting the CPU
+affinity mask can be used to obtain performance benefits. For
+example, by dedicating one CPU to a particular process (i.e., setting
+the affinity mask of that process to specify a single CPU, and
+setting the affinity mask of all other processes to exclude that
+CPU), it is possible to ensure maximum execution speed for that
+process. Restricting a process to run on a single CPU also avoids the
+performance cost caused by the cache invalidation that occurs when a
+process ceases to execute on one CPU and then recommences execution
+on a different CPU.</P>
+<P>A CPU affinity mask is represented by the cpu_set_t structure, a
+&quot;CPU set&quot;, pointed to by <I>mask</I>. A set of macros for
+manipulating CPU sets is described in <B>cpu_set</B>(3).</P>
+<H2 CLASS="western"><A HREF="#toc6" NAME="sect6">See Also</A></H2>
+<P><A HREF="cpu_set.html"><B>cpu_set</B>(3)</A>,
+<A HREF="pthread_setaffinity_np.html"><B>pthread_setaffininty_np</B>(3)</A>,
+<A HREF="pthread_setaffinity_np.html"><B>pthread_getaffinity_np</B>(3)</A></P>
+<H2 CLASS="western"><A HREF="#toc7" NAME="sect7">Copyright</A></H2>
+<P>Most of this is taken from the Linux manual page.</P>
+<P>Modified by Ross Johnson for use with <B>Pthreads-w32</B>.</P>
+<HR>
+<P><A NAME="toc"></A><B>Table of Contents</B></P>
+<UL>
+ <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A>
+ </P>
+ <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A>
+ </P>
+ <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A>
+ </P>
+ <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Return
+ Value</A>
+ </P>
+ <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Errors</A>
+ </P>
+ <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Application
+ Usage</A></P>
+ <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">See
+ Also</A></P>
+ <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect7" NAME="toc7">Copyright</A></P>
+</UL>
+<H4 CLASS="western"><BR><BR>
+</H4>
+</BODY>
+</HTML> \ No newline at end of file
diff --git a/pthreads/misc.c b/pthreads/misc.c
index 06d1d2137..2dff6bdd5 100644
--- a/pthreads/misc.c
+++ b/pthreads/misc.c
@@ -44,7 +44,4 @@
#include "pthread_equal.c"
#include "pthread_setconcurrency.c"
#include "pthread_getconcurrency.c"
-#include "ptw32_new.c"
-#include "ptw32_calloc.c"
-#include "ptw32_reuse.c"
#include "w32_CancelableWait.c"
diff --git a/pthreads/mutex.c b/pthreads/mutex.c
index c2b3607ca..0a930d88f 100644
--- a/pthreads/mutex.c
+++ b/pthreads/mutex.c
@@ -44,7 +44,6 @@
#include "implement.h"
-#include "ptw32_mutex_check_need_init.c"
#include "pthread_mutex_init.c"
#include "pthread_mutex_destroy.c"
#include "pthread_mutexattr_init.c"
diff --git a/pthreads/nonportable.c b/pthreads/nonportable.c
index 742cb969b..3ac8189e6 100644
--- a/pthreads/nonportable.c
+++ b/pthreads/nonportable.c
@@ -42,6 +42,7 @@
#include "pthread_getw32threadhandle_np.c"
#include "pthread_getunique_np.c"
#include "pthread_delay_np.c"
+#include "pthread_timedjoin_np.c"
#include "pthread_num_processors_np.c"
#include "pthread_win32_attach_detach_np.c"
#include "pthread_timechange_handler_np.c"
diff --git a/pthreads/private.c b/pthreads/private.c
index 1b1ccb7c5..86fac4ad0 100644
--- a/pthreads/private.c
+++ b/pthreads/private.c
@@ -52,3 +52,11 @@
#include "ptw32_relmillisecs.c"
#include "ptw32_throw.c"
#include "ptw32_getprocessors.c"
+#include "ptw32_new.c"
+#include "ptw32_calloc.c"
+#include "ptw32_reuse.c"
+#include "ptw32_cond_check_need_init.c"
+#include "ptw32_mutex_check_need_init.c"
+#include "ptw32_rwlock_check_need_init.c"
+#include "ptw32_rwlock_cancelwrwait.c"
+#include "ptw32_spinlock_check_need_init.c"
diff --git a/pthreads/pthread.c b/pthreads/pthread.c
index 0456aa6d3..9d882d0ab 100644
--- a/pthreads/pthread.c
+++ b/pthreads/pthread.c
@@ -1,66 +1,188 @@
-/*
- * pthread.c
- *
- * Description:
- * This translation unit agregates pthreads-win32 translation units.
- * It is used for inline optimisation of the library,
- * maximising for speed at the expense of size.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-/* The following are ordered for inlining */
-
-#include "private.c"
-#include "attr.c"
-#include "barrier.c"
-#include "cancel.c"
-#include "cleanup.c"
-#include "condvar.c"
-#include "create.c"
-#include "dll.c"
-#include "autostatic.c"
-#include "errno.c"
-#include "exit.c"
-#include "fork.c"
-#include "global.c"
-#include "misc.c"
-#include "mutex.c"
-#include "nonportable.c"
-#include "rwlock.c"
-#include "sched.c"
-#include "semaphore.c"
-#include "signal.c"
-#include "spin.c"
-#include "sync.c"
-#include "tsd.c"
+/*
+ * pthread.c
+ *
+ * Description:
+ * This translation unit agregates pthreads-win32 translation units.
+ * It is used for inline optimisation of the library,
+ * maximising for speed at the expense of size.
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads-win32 - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * http://sources.redhat.com/pthreads-win32/contributors.html
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "pthread.h"
+#include "implement.h"
+
+/* The following are ordered for inlining */
+
+#include "ptw32_MCS_lock.c"
+#include "ptw32_is_attr.c"
+#include "ptw32_processInitialize.c"
+#include "ptw32_processTerminate.c"
+#include "ptw32_threadStart.c"
+#include "ptw32_threadDestroy.c"
+#include "ptw32_tkAssocCreate.c"
+#include "ptw32_tkAssocDestroy.c"
+#include "ptw32_callUserDestroyRoutines.c"
+#include "ptw32_semwait.c"
+#include "ptw32_timespec.c"
+#include "ptw32_throw.c"
+#include "ptw32_getprocessors.c"
+#include "ptw32_calloc.c"
+#include "ptw32_new.c"
+#include "ptw32_reuse.c"
+#include "ptw32_relmillisecs.c"
+#include "ptw32_cond_check_need_init.c"
+#include "ptw32_mutex_check_need_init.c"
+#include "ptw32_rwlock_check_need_init.c"
+#include "ptw32_rwlock_cancelwrwait.c"
+#include "ptw32_spinlock_check_need_init.c"
+#include "pthread_attr_init.c"
+#include "pthread_attr_destroy.c"
+#include "pthread_attr_getdetachstate.c"
+#include "pthread_attr_setdetachstate.c"
+#include "pthread_attr_getscope.c"
+#include "pthread_attr_setscope.c"
+#include "pthread_attr_getstackaddr.c"
+#include "pthread_attr_setstackaddr.c"
+#include "pthread_attr_getstacksize.c"
+#include "pthread_attr_setstacksize.c"
+#include "pthread_barrier_init.c"
+#include "pthread_barrier_destroy.c"
+#include "pthread_barrier_wait.c"
+#include "pthread_barrierattr_init.c"
+#include "pthread_barrierattr_destroy.c"
+#include "pthread_barrierattr_setpshared.c"
+#include "pthread_barrierattr_getpshared.c"
+#include "pthread_setcancelstate.c"
+#include "pthread_setcanceltype.c"
+#include "pthread_testcancel.c"
+#include "pthread_cancel.c"
+#include "pthread_condattr_destroy.c"
+#include "pthread_condattr_getpshared.c"
+#include "pthread_condattr_init.c"
+#include "pthread_condattr_setpshared.c"
+#include "pthread_cond_destroy.c"
+#include "pthread_cond_init.c"
+#include "pthread_cond_signal.c"
+#include "pthread_cond_wait.c"
+#include "create.c"
+#include "cleanup.c"
+#include "dll.c"
+#include "autostatic.c"
+#include "errno.c"
+#include "pthread_exit.c"
+#include "global.c"
+#include "pthread_equal.c"
+#include "pthread_getconcurrency.c"
+#include "pthread_kill.c"
+#include "pthread_once.c"
+#include "pthread_self.c"
+#include "pthread_setconcurrency.c"
+#include "w32_CancelableWait.c"
+#include "pthread_mutex_init.c"
+#include "pthread_mutex_destroy.c"
+#include "pthread_mutexattr_init.c"
+#include "pthread_mutexattr_destroy.c"
+#include "pthread_mutexattr_getpshared.c"
+#include "pthread_mutexattr_setpshared.c"
+#include "pthread_mutexattr_settype.c"
+#include "pthread_mutexattr_gettype.c"
+#include "pthread_mutexattr_setrobust.c"
+#include "pthread_mutexattr_getrobust.c"
+#include "pthread_mutex_lock.c"
+#include "pthread_mutex_timedlock.c"
+#include "pthread_mutex_unlock.c"
+#include "pthread_mutex_trylock.c"
+#include "pthread_mutex_consistent.c"
+#include "pthread_mutexattr_setkind_np.c"
+#include "pthread_mutexattr_getkind_np.c"
+#include "pthread_getw32threadhandle_np.c"
+#include "pthread_getunique_np.c"
+#include "pthread_timedjoin_np.c"
+#include "pthread_tryjoin_np.c"
+#include "pthread_setaffinity.c"
+#include "pthread_delay_np.c"
+#include "pthread_num_processors_np.c"
+#include "pthread_win32_attach_detach_np.c"
+#include "pthread_timechange_handler_np.c"
+#include "pthread_rwlock_init.c"
+#include "pthread_rwlock_destroy.c"
+#include "pthread_rwlockattr_init.c"
+#include "pthread_rwlockattr_destroy.c"
+#include "pthread_rwlockattr_getpshared.c"
+#include "pthread_rwlockattr_setpshared.c"
+#include "pthread_rwlock_rdlock.c"
+#include "pthread_rwlock_timedrdlock.c"
+#include "pthread_rwlock_wrlock.c"
+#include "pthread_rwlock_timedwrlock.c"
+#include "pthread_rwlock_unlock.c"
+#include "pthread_rwlock_tryrdlock.c"
+#include "pthread_rwlock_trywrlock.c"
+#include "pthread_attr_setschedpolicy.c"
+#include "pthread_attr_getschedpolicy.c"
+#include "pthread_attr_setschedparam.c"
+#include "pthread_attr_getschedparam.c"
+#include "pthread_attr_setinheritsched.c"
+#include "pthread_attr_getinheritsched.c"
+#include "pthread_setschedparam.c"
+#include "pthread_getschedparam.c"
+#include "sched_get_priority_max.c"
+#include "sched_get_priority_min.c"
+#include "sched_setscheduler.c"
+#include "sched_getscheduler.c"
+#include "sched_yield.c"
+#include "sched_setaffinity.c"
+#include "sem_init.c"
+#include "sem_destroy.c"
+#include "sem_trywait.c"
+#include "sem_timedwait.c"
+#include "sem_wait.c"
+#include "sem_post.c"
+#include "sem_post_multiple.c"
+#include "sem_getvalue.c"
+#include "sem_open.c"
+#include "sem_close.c"
+#include "sem_unlink.c"
+#include "pthread_spin_init.c"
+#include "pthread_spin_destroy.c"
+#include "pthread_spin_lock.c"
+#include "pthread_spin_unlock.c"
+#include "pthread_spin_trylock.c"
+#include "pthread_detach.c"
+#include "pthread_join.c"
+#include "pthread_key_create.c"
+#include "pthread_key_delete.c"
+#include "pthread_setspecific.c"
+#include "pthread_getspecific.c"
diff --git a/pthreads/pthread.h b/pthreads/pthread.h
index 9a1978820..25bc773cd 100644
--- a/pthreads/pthread.h
+++ b/pthreads/pthread.h
@@ -4,26 +4,27 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
* http://sources.redhat.com/pthreads-win32/contributors.html
- *
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library in the file COPYING.LIB;
* if not, write to the Free Software Foundation, Inc.,
@@ -37,8 +38,8 @@
* See the README file for an explanation of the pthreads-win32 version
* numbering scheme and how the DLL is named etc.
*/
-#define PTW32_VERSION 2,9,0,0
-#define PTW32_VERSION_STRING "2, 9, 0, 0\0"
+#define PTW32_VERSION 2,10,0,0
+#define PTW32_VERSION_STRING "2, 10, 0, 0\0"
/* There are three implementations of cancel cleanup.
* Note that pthread.h is included in both application
@@ -65,7 +66,7 @@
* Define defaults for cleanup code.
* Note: Unless the build explicitly defines one of the following, then
* we default to standard C style cleanup. This style uses setjmp/longjmp
- * in the cancelation and thread exit implementations and therefore won't
+ * in the cancellation and thread exit implementations and therefore won't
* do stack unwinding if linked to applications that have it (e.g.
* C++ apps). This is currently consistent with most/all commercial Unix
* POSIX threads implementations.
@@ -86,34 +87,35 @@
#undef PTW32_LEVEL
#if defined(_POSIX_SOURCE)
-#define PTW32_LEVEL 0
-/* Early POSIX */
+#define PTW32_LEVEL 0 /* Early POSIX */
#endif
#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309
#undef PTW32_LEVEL
-#define PTW32_LEVEL 1
-/* Include 1b, 1c and 1d */
+#define PTW32_LEVEL 1 /* Include 1b, 1c and 1d */
#endif
#if defined(INCLUDE_NP)
#undef PTW32_LEVEL
-#define PTW32_LEVEL 2
-/* Include Non-Portable extensions */
+#define PTW32_LEVEL 2 /* Include Non-Portable extensions */
#endif
#define PTW32_LEVEL_MAX 3
#if ( defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112 ) || !defined(PTW32_LEVEL)
-#define PTW32_LEVEL PTW32_LEVEL_MAX
-/* Include everything */
+#define PTW32_LEVEL PTW32_LEVEL_MAX /* Include everything */
#endif
-#if defined(_UWIN)
-# define HAVE_STRUCT_TIMESPEC 1
-# define HAVE_SIGNAL_H 1
-# undef HAVE_PTW32_CONFIG_H
-# pragma comment(lib, "pthread")
+#if defined(__MINGW32__) || defined(__MINGW64__)
+# define PTW32_CONFIG_MINGW
+#endif
+#if defined(_MSC_VER)
+# if _MSC_VER < 1300
+# define PTW32_CONFIG_MSVC6
+# endif
+# if _MSC_VER < 1400
+# define PTW32_CONFIG_MSVC7
+# endif
#endif
/*
@@ -190,7 +192,7 @@
*/
/* Try to avoid including windows.h */
-#if (defined(__MINGW64__) || defined(__MINGW32__)) && defined(__cplusplus)
+#if defined(PTW32_CONFIG_MINGW) && defined(__cplusplus)
#define PTW32_INCLUDE_WINDOWS_H
#endif
@@ -198,35 +200,6 @@
#include <windows.h>
#endif
-#if defined(_MSC_VER) && _MSC_VER < 1300 || defined(__DMC__)
-/*
- * VC++6.0 or early compiler's header has no DWORD_PTR type.
- */
-typedef unsigned long DWORD_PTR;
-typedef unsigned long ULONG_PTR;
-#endif
-/*
- * -----------------
- * autoconf switches
- * -----------------
- */
-
-#if defined(HAVE_PTW32_CONFIG_H)
-#include "config.h"
-#endif /* HAVE_PTW32_CONFIG_H */
-
-#if !defined(NEED_FTIME)
-#include <time.h>
-#else /* NEED_FTIME */
-/* use native WIN32 time API */
-#endif /* NEED_FTIME */
-
-#if defined(HAVE_SIGNAL_H)
-#include <signal.h>
-#endif /* HAVE_SIGNAL_H */
-
-#include <limits.h>
-
/*
* Boolean values to make us independent of system includes.
*/
@@ -244,18 +217,29 @@ enum {
# if defined(WINCE)
# define NEED_ERRNO
# define NEED_SEM
-# endif
-# if defined(__MINGW64__)
+# elif defined(_UWIN)
+# define HAVE_MODE_T
+# define HAVE_STRUCT_TIMESPEC
+# define HAVE_SIGNAL_H
+# elif defined(__MINGW64__)
# define HAVE_STRUCT_TIMESPEC
# define HAVE_MODE_T
-# elif defined(_UWIN) || defined(__MINGW32__)
+# elif defined(__MINGW32__)
# define HAVE_MODE_T
# endif
#endif
-/*
- *
- */
+#if !defined(NEED_FTIME)
+#include <time.h>
+#else /* NEED_FTIME */
+/* use native WIN32 time API */
+#endif /* NEED_FTIME */
+
+#if defined(HAVE_SIGNAL_H)
+#include <signal.h>
+#endif
+
+#include <limits.h>
#if PTW32_LEVEL >= PTW32_LEVEL_MAX
#if defined(NEED_ERRNO)
@@ -265,6 +249,8 @@ enum {
#endif
#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */
+#include <sched.h>
+
/*
* Several systems don't define some error numbers.
*/
@@ -296,8 +282,6 @@ enum {
# define ENOTRECOVERABLE 44
#endif
-#include <sched.h>
-
/*
* To avoid including windows.h we define only those things that we
* actually need from it.
@@ -358,17 +342,17 @@ extern "C"
* either indicates that sysconf(), which is not implemented, may be used at
* runtime to check the status of the option.
*
- * _POSIX_THREADS (== 200112L)
- * If == 200112L, you can use threads
+ * _POSIX_THREADS (== 20080912L)
+ * If == 20080912L, you can use threads
*
- * _POSIX_THREAD_ATTR_STACKSIZE (== 200112L)
- * If == 200112L, you can control the size of a thread's
+ * _POSIX_THREAD_ATTR_STACKSIZE (== 200809L)
+ * If == 200809L, you can control the size of a thread's
* stack
* pthread_attr_getstacksize
* pthread_attr_setstacksize
*
* _POSIX_THREAD_ATTR_STACKADDR (== -1)
- * If == 200112L, you can allocate and control a thread's
+ * If == 200809L, you can allocate and control a thread's
* stack. If not supported, the following functions
* will return ENOSYS, indicating they are not
* supported:
@@ -383,13 +367,13 @@ extern "C"
* writers over readers when threads have equal priority.
*
* _POSIX_THREAD_PRIO_INHERIT (== -1)
- * If == 200112L, you can create priority inheritance
+ * If == 200809L, you can create priority inheritance
* mutexes.
* pthread_mutexattr_getprotocol +
* pthread_mutexattr_setprotocol +
*
* _POSIX_THREAD_PRIO_PROTECT (== -1)
- * If == 200112L, you can create priority ceiling mutexes
+ * If == 200809L, you can create priority ceiling mutexes
* Indicates the availability of:
* pthread_mutex_getprioceiling
* pthread_mutex_setprioceiling
@@ -408,22 +392,24 @@ extern "C"
* pthread_condattr_getpshared
* pthread_condattr_setpshared
*
- * _POSIX_THREAD_SAFE_FUNCTIONS (== 200112L)
- * If == 200112L you can use the special *_r library
+ * _POSIX_THREAD_SAFE_FUNCTIONS (== 200809L)
+ * If == 200809L you can use the special *_r library
* functions that provide thread-safe behaviour
*
- * _POSIX_READER_WRITER_LOCKS (== 200112L)
- * If == 200112L, you can use read/write locks
+ * _POSIX_READER_WRITER_LOCKS (== 200809L)
+ * If == 200809L, you can use read/write locks
*
- * _POSIX_SPIN_LOCKS (== 200112L)
- * If == 200112L, you can use spin locks
+ * _POSIX_SPIN_LOCKS (== 200809L)
+ * If == 200809L, you can use spin locks
*
- * _POSIX_BARRIERS (== 200112L)
- * If == 200112L, you can use barriers
+ * _POSIX_BARRIERS (== 200809L)
+ * If == 200809L, you can use barriers
*
- * + These functions provide both 'inherit' and/or
- * 'protect' protocol, based upon these macro
- * settings.
+ * _POSIX_ROBUST_MUTEXES (== 200809L)
+ * If == 200809L, you can use robust mutexes
+ * Officially this should also imply
+ * _POSIX_THREAD_PROCESS_SHARED != -1 however
+ * not here yet.
*
* -------------------------------------------------------------
*/
@@ -449,6 +435,9 @@ extern "C"
#undef _POSIX_THREAD_ATTR_STACKSIZE
#define _POSIX_THREAD_ATTR_STACKSIZE 200809L
+#undef _POSIX_ROBUST_MUTEXES
+#define _POSIX_ROBUST_MUTEXES 200809L
+
/*
* The following options are not supported
*/
@@ -557,18 +546,6 @@ extern "C"
# define PTW32_DLLPORT
#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 exposed function prototypes.
- *
- * We force all calls to cdecl even though this could slow Watcom code down
- * slightly. If you know that the Watcom compiler will be used to build both
- * the DLL and application, then you can probably define this as a null string.
- * Remember that pthread.h (this file) is used for both the DLL and application builds.
- */
-#define PTW32_CDECL __cdecl
-
#if defined(_UWIN) && PTW32_LEVEL >= PTW32_LEVEL_MAX
# include <sys/types.h>
#else
@@ -591,6 +568,7 @@ typedef struct pthread_mutexattr_t_ * pthread_mutexattr_t;
typedef struct pthread_cond_t_ * pthread_cond_t;
typedef struct pthread_condattr_t_ * pthread_condattr_t;
#endif
+
typedef struct pthread_rwlock_t_ * pthread_rwlock_t;
typedef struct pthread_rwlockattr_t_ * pthread_rwlockattr_t;
typedef struct pthread_spinlock_t_ * pthread_spinlock_t;
@@ -658,7 +636,7 @@ enum {
/*
* ====================
* ====================
- * Cancelation
+ * cancellation
* ====================
* ====================
*/
@@ -939,7 +917,7 @@ PTW32_DLLPORT int PTW32_CDECL pthread_attr_getscope (const pthread_attr_t *,
*/
PTW32_DLLPORT int PTW32_CDECL pthread_create (pthread_t * tid,
const pthread_attr_t * attr,
- void *(*start) (void *),
+ void *(PTW32_CDECL *start) (void *),
void *arg);
PTW32_DLLPORT int PTW32_CDECL pthread_detach (pthread_t tid);
@@ -965,13 +943,13 @@ PTW32_DLLPORT int PTW32_CDECL pthread_setcanceltype (int type,
PTW32_DLLPORT void PTW32_CDECL pthread_testcancel (void);
PTW32_DLLPORT int PTW32_CDECL pthread_once (pthread_once_t * once_control,
- void (*init_routine) (void));
+ void (PTW32_CDECL *init_routine) (void));
#if PTW32_LEVEL >= PTW32_LEVEL_MAX
PTW32_DLLPORT ptw32_cleanup_t * PTW32_CDECL ptw32_pop_cleanup (int execute);
PTW32_DLLPORT void PTW32_CDECL ptw32_push_cleanup (ptw32_cleanup_t * cleanup,
- void (*routine) (void *),
+ ptw32_cleanup_callback_t routine,
void *arg);
#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */
@@ -979,7 +957,7 @@ PTW32_DLLPORT void PTW32_CDECL ptw32_push_cleanup (ptw32_cleanup_t * cleanup,
* Thread Specific Data Functions
*/
PTW32_DLLPORT int PTW32_CDECL pthread_key_create (pthread_key_t * key,
- void (*destructor) (void *));
+ void (PTW32_CDECL *destructor) (void *));
PTW32_DLLPORT int PTW32_CDECL pthread_key_delete (pthread_key_t key);
@@ -1114,7 +1092,7 @@ PTW32_DLLPORT int PTW32_CDECL pthread_getschedparam (pthread_t thread,
struct sched_param *param);
PTW32_DLLPORT int PTW32_CDECL pthread_setconcurrency (int);
-
+
PTW32_DLLPORT int PTW32_CDECL pthread_getconcurrency (void);
/*
@@ -1170,6 +1148,17 @@ PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_setkind_np(pthread_mutexattr_t *
int kind);
PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_getkind_np(pthread_mutexattr_t * attr,
int *kind);
+PTW32_DLLPORT int PTW32_CDECL pthread_timedjoin_np(pthread_t thread,
+ void **value_ptr,
+ const struct timespec *abstime);
+PTW32_DLLPORT int PTW32_CDECL pthread_tryjoin_np(pthread_t thread,
+ void **value_ptr);
+PTW32_DLLPORT int PTW32_CDECL pthread_setaffinity_np(pthread_t thread,
+ size_t cpusetsize,
+ const cpu_set_t *cpuset);
+PTW32_DLLPORT int PTW32_CDECL pthread_getaffinity_np(pthread_t thread,
+ size_t cpusetsize,
+ cpu_set_t *cpuset);
/*
* Possibly supported by other POSIX threads implementations
@@ -1192,8 +1181,8 @@ PTW32_DLLPORT int PTW32_CDECL pthread_win32_thread_detach_np(void);
*/
PTW32_DLLPORT int PTW32_CDECL pthread_win32_test_features_np(int);
enum ptw32_features {
- PTW32_SYSTEM_INTERLOCKED_COMPARE_EXCHANGE = 0x0001, /* System provides it. */
- PTW32_ALERTABLE_ASYNC_CANCEL = 0x0002 /* Can cancel blocked threads. */
+ PTW32_SYSTEM_INTERLOCKED_COMPARE_EXCHANGE = 0x0001, /* System provides it. */
+ PTW32_ALERTABLE_ASYNC_CANCEL = 0x0002 /* Can cancel blocked threads. */
};
/*
@@ -1242,22 +1231,58 @@ PTW32_DLLPORT int PTW32_CDECL pthreadCancelableTimedWait (HANDLE waitHandle,
#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */
/*
- * Thread-Safe C Runtime Library Mappings.
+ * Declare a thread-safe errno for Open Watcom
+ * (note: this has not been tested in a long time)
*/
-#if !defined(_UWIN)
-# if defined(NEED_ERRNO)
- PTW32_DLLPORT int * PTW32_CDECL _errno( void );
-# else
-# if !defined(errno)
-# if (defined(_MT) || defined(_DLL))
- __declspec(dllimport) extern int * __cdecl _errno(void);
-# define errno (*_errno())
-# endif
-# endif
+#if defined(__WATCOMC__) && !defined(errno)
+# if defined(_MT) || defined(_DLL)
+ __declspec(dllimport) extern int * __cdecl _errno(void);
+# define errno (*_errno())
# endif
#endif
/*
+ * If pthreads-win32 is compiled as a DLL with MSVC, and
+ * both it and the application are linked against the static
+ * C runtime (i.e. with the /MT compiler flag), then the
+ * application will not see the same C runtime globals as
+ * the library. These include the errno variable, and the
+ * termination routine called by terminate(). For details,
+ * refer to the following links:
+ *
+ * http://support.microsoft.com/kb/94248
+ * (Section 4: Problems Encountered When Using Multiple CRT Libraries)
+ *
+ * http://social.msdn.microsoft.com/forums/en-US/vclanguage/thread/b4500c0d-1b69-40c7-9ef5-08da1025b5bf
+ *
+ * When pthreads-win32 is built with PTW32_USES_SEPARATE_CRT
+ * defined, the following features are enabled:
+ *
+ * (1) In addition to setting the errno variable when errors
+ * occur, the library will also call SetLastError() with the
+ * same value. The application can then use GetLastError()
+ * to obtain the value of errno. (This pair of routines are
+ * in kernel32.dll, and so are not affected by the use of
+ * multiple CRT libraries.)
+ *
+ * (2) When C++ or SEH cleanup is used, the library defines
+ * a function pthread_win32_set_terminate_np(), which can be
+ * used to set the termination routine that should be called
+ * when an unhandled exception occurs in a thread function
+ * (or otherwise inside the library).
+ *
+ * Note: "_DLL" implies the /MD compiler flag.
+ */
+#if defined(_MSC_VER) && !defined(_DLL) && !defined(PTW32_STATIC_LIB)
+# define PTW32_USES_SEPARATE_CRT
+#endif
+
+#if defined(PTW32_USES_SEPARATE_CRT) && (defined(__CLEANUP_CXX) || defined(__CLEANUP_SEH))
+typedef void (*ptw32_terminate_handler)();
+PTW32_DLLPORT ptw32_terminate_handler PTW32_CDECL pthread_win32_set_terminate_np(ptw32_terminate_handler termFunction);
+#endif
+
+/*
* Some compiler environments don't define some things.
*/
#if defined(__BORLANDC__)
@@ -1309,7 +1334,7 @@ PTW32_DLLPORT DWORD PTW32_CDECL ptw32_get_exception_services_code(void);
#if defined(_MSC_VER)
/*
* WARNING: Replace any 'catch( ... )' with 'PtW32CatchAll'
- * if you want Pthread-Win32 cancelation and pthread_exit to work.
+ * if you want Pthread-Win32 cancellation and pthread_exit to work.
*/
#if !defined(PtW32NoCatchWarn)
@@ -1319,7 +1344,7 @@ PTW32_DLLPORT DWORD PTW32_CDECL ptw32_get_exception_services_code(void);
#pragma message("When compiling applications with MSVC++ and C++ exception handling:")
#pragma message(" Replace any 'catch( ... )' in routines called from POSIX threads")
#pragma message(" with 'PtW32CatchAll' or 'CATCHALL' if you want POSIX thread")
-#pragma message(" cancelation and pthread_exit to work. For example:")
+#pragma message(" cancellation and pthread_exit to work. For example:")
#pragma message("")
#pragma message(" #if defined(PtW32CatchAll)")
#pragma message(" PtW32CatchAll")
diff --git a/pthreads/pthread_attr_destroy.c b/pthreads/pthread_attr_destroy.c
index 8b3e04c53..7bb0e320b 100644
--- a/pthreads/pthread_attr_destroy.c
+++ b/pthreads/pthread_attr_destroy.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_attr_getdetachstate.c b/pthreads/pthread_attr_getdetachstate.c
index ce56bab7f..93d613352 100644
--- a/pthreads/pthread_attr_getdetachstate.c
+++ b/pthreads/pthread_attr_getdetachstate.c
@@ -1,86 +1,91 @@
-/*
- * pthread_attr_getdetachstate.c
- *
- * Description:
- * This translation unit implements operations on thread attribute objects.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-
-int
-pthread_attr_getdetachstate (const pthread_attr_t * attr, int *detachstate)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * This function determines whether threads created with
- * 'attr' will run detached.
- *
- * PARAMETERS
- * attr
- * pointer to an instance of pthread_attr_t
- *
- * detachstate
- * pointer to an integer into which is returned one
- * of:
- *
- * PTHREAD_CREATE_JOINABLE
- * Thread ID is valid, must be joined
- *
- * PTHREAD_CREATE_DETACHED
- * Thread ID is invalid, cannot be joined,
- * canceled, or modified
- *
- *
- * DESCRIPTION
- * This function determines whether threads created with
- * 'attr' will run detached.
- *
- * NOTES:
- * 1) You cannot join or cancel detached threads.
- *
- * RESULTS
- * 0 successfully retrieved detach state,
- * EINVAL 'attr' is invalid
- *
- * ------------------------------------------------------
- */
-{
- if (ptw32_is_attr (attr) != 0 || detachstate == NULL)
- {
- return EINVAL;
- }
-
- *detachstate = (*attr)->detachstate;
- return 0;
-}
+/*
+ * pthread_attr_getdetachstate.c
+ *
+ * Description:
+ * This translation unit implements operations on thread attribute objects.
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads-win32 - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * http://sources.redhat.com/pthreads-win32/contributors.html
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "pthread.h"
+#include "implement.h"
+
+
+int
+pthread_attr_getdetachstate (const pthread_attr_t * attr, int *detachstate)
+ /*
+ * ------------------------------------------------------
+ * DOCPUBLIC
+ * This function determines whether threads created with
+ * 'attr' will run detached.
+ *
+ * PARAMETERS
+ * attr
+ * pointer to an instance of pthread_attr_t
+ *
+ * detachstate
+ * pointer to an integer into which is returned one
+ * of:
+ *
+ * PTHREAD_CREATE_JOINABLE
+ * Thread ID is valid, must be joined
+ *
+ * PTHREAD_CREATE_DETACHED
+ * Thread ID is invalid, cannot be joined,
+ * canceled, or modified
+ *
+ *
+ * DESCRIPTION
+ * This function determines whether threads created with
+ * 'attr' will run detached.
+ *
+ * NOTES:
+ * 1) You cannot join or cancel detached threads.
+ *
+ * RESULTS
+ * 0 successfully retrieved detach state,
+ * EINVAL 'attr' is invalid
+ *
+ * ------------------------------------------------------
+ */
+{
+ if (ptw32_is_attr (attr) != 0 || detachstate == NULL)
+ {
+ return EINVAL;
+ }
+
+ *detachstate = (*attr)->detachstate;
+ return 0;
+}
diff --git a/pthreads/pthread_attr_getinheritsched.c b/pthreads/pthread_attr_getinheritsched.c
index 81a55b605..657624cca 100644
--- a/pthreads/pthread_attr_getinheritsched.c
+++ b/pthreads/pthread_attr_getinheritsched.c
@@ -1,51 +1,56 @@
-/*
- * pthread_attr_getinheritsched.c
- *
- * Description:
- * POSIX thread functions that deal with thread scheduling.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-#include "sched.h"
-
-int
-pthread_attr_getinheritsched (const pthread_attr_t * attr, int *inheritsched)
-{
- if (ptw32_is_attr (attr) != 0 || inheritsched == NULL)
- {
- return EINVAL;
- }
-
- *inheritsched = (*attr)->inheritsched;
- return 0;
-}
+/*
+ * pthread_attr_getinheritsched.c
+ *
+ * Description:
+ * POSIX thread functions that deal with thread scheduling.
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads-win32 - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * http://sources.redhat.com/pthreads-win32/contributors.html
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "pthread.h"
+#include "implement.h"
+#include "sched.h"
+
+int
+pthread_attr_getinheritsched (const pthread_attr_t * attr, int *inheritsched)
+{
+ if (ptw32_is_attr (attr) != 0 || inheritsched == NULL)
+ {
+ return EINVAL;
+ }
+
+ *inheritsched = (*attr)->inheritsched;
+ return 0;
+}
diff --git a/pthreads/pthread_attr_getschedparam.c b/pthreads/pthread_attr_getschedparam.c
index ab89b2241..b7be1cbab 100644
--- a/pthreads/pthread_attr_getschedparam.c
+++ b/pthreads/pthread_attr_getschedparam.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
#include "sched.h"
diff --git a/pthreads/pthread_attr_getschedpolicy.c b/pthreads/pthread_attr_getschedpolicy.c
index e743f15ec..f27f5ee38 100644
--- a/pthreads/pthread_attr_getschedpolicy.c
+++ b/pthreads/pthread_attr_getschedpolicy.c
@@ -1,61 +1,57 @@
-/*
- * pthread_attr_getschedpolicy.c
- *
- * Description:
- * POSIX thread functions that deal with thread scheduling.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-#include "sched.h"
-
-int
-pthread_attr_getschedpolicy (const pthread_attr_t * attr, int *policy)
-{
- if (ptw32_is_attr (attr) != 0 || policy == NULL)
- {
- return EINVAL;
- }
-
- /*
- * Validate the policy arg.
- * Check that a policy constant wasn't passed rather than &policy.
- */
- if (policy <= (int *) SCHED_MAX)
- {
- return EINVAL;
- }
-
- *policy = SCHED_OTHER;
-
- return 0;
-}
+/*
+ * pthread_attr_getschedpolicy.c
+ *
+ * Description:
+ * POSIX thread functions that deal with thread scheduling.
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads-win32 - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * http://sources.redhat.com/pthreads-win32/contributors.html
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "pthread.h"
+#include "implement.h"
+#include "sched.h"
+
+int
+pthread_attr_getschedpolicy (const pthread_attr_t * attr, int *policy)
+{
+ if (ptw32_is_attr (attr) != 0 || policy == NULL)
+ {
+ return EINVAL;
+ }
+
+ *policy = SCHED_OTHER;
+
+ return 0;
+}
diff --git a/pthreads/pthread_attr_getscope.c b/pthreads/pthread_attr_getscope.c
index 2efdb2fe6..c5c5f0644 100644
--- a/pthreads/pthread_attr_getscope.c
+++ b/pthreads/pthread_attr_getscope.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_attr_getstackaddr.c b/pthreads/pthread_attr_getstackaddr.c
index 1a2da01c7..17a7147f7 100644
--- a/pthreads/pthread_attr_getstackaddr.c
+++ b/pthreads/pthread_attr_getstackaddr.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_attr_getstacksize.c b/pthreads/pthread_attr_getstacksize.c
index dff9230f2..f606afc44 100644
--- a/pthreads/pthread_attr_getstacksize.c
+++ b/pthreads/pthread_attr_getstacksize.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_attr_init.c b/pthreads/pthread_attr_init.c
index ae9d3eb5f..49626dd0d 100644
--- a/pthreads/pthread_attr_init.c
+++ b/pthreads/pthread_attr_init.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_attr_setdetachstate.c b/pthreads/pthread_attr_setdetachstate.c
index 784642a80..02dd88bf1 100644
--- a/pthreads/pthread_attr_setdetachstate.c
+++ b/pthreads/pthread_attr_setdetachstate.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_attr_setinheritsched.c b/pthreads/pthread_attr_setinheritsched.c
index e0a407a3b..d551190c8 100644
--- a/pthreads/pthread_attr_setinheritsched.c
+++ b/pthreads/pthread_attr_setinheritsched.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
#include "sched.h"
diff --git a/pthreads/pthread_attr_setschedparam.c b/pthreads/pthread_attr_setschedparam.c
index f246bfae7..3505c9a5f 100644
--- a/pthreads/pthread_attr_setschedparam.c
+++ b/pthreads/pthread_attr_setschedparam.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
#include "sched.h"
diff --git a/pthreads/pthread_attr_setschedpolicy.c b/pthreads/pthread_attr_setschedpolicy.c
index 45ff16597..5fe0c0c78 100644
--- a/pthreads/pthread_attr_setschedpolicy.c
+++ b/pthreads/pthread_attr_setschedpolicy.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
#include "sched.h"
diff --git a/pthreads/pthread_attr_setscope.c b/pthreads/pthread_attr_setscope.c
index 39a51df88..96bc49415 100644
--- a/pthreads/pthread_attr_setscope.c
+++ b/pthreads/pthread_attr_setscope.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_attr_setstackaddr.c b/pthreads/pthread_attr_setstackaddr.c
index 1316c0659..e527ec3d3 100644
--- a/pthreads/pthread_attr_setstackaddr.c
+++ b/pthreads/pthread_attr_setstackaddr.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_attr_setstacksize.c b/pthreads/pthread_attr_setstacksize.c
index eb13589a0..5acec7e2b 100644
--- a/pthreads/pthread_attr_setstacksize.c
+++ b/pthreads/pthread_attr_setstacksize.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_barrier_destroy.c b/pthreads/pthread_barrier_destroy.c
index 55163cc85..61cd0cda6 100644
--- a/pthreads/pthread_barrier_destroy.c
+++ b/pthreads/pthread_barrier_destroy.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_barrier_init.c b/pthreads/pthread_barrier_init.c
index 59a30f4a4..bc76fcd78 100644
--- a/pthreads/pthread_barrier_init.c
+++ b/pthreads/pthread_barrier_init.c
@@ -1,69 +1,74 @@
-/*
- * pthread_barrier_init.c
- *
- * Description:
- * This translation unit implements barrier primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-
-int
-pthread_barrier_init (pthread_barrier_t * barrier,
- const pthread_barrierattr_t * attr, unsigned int count)
-{
- pthread_barrier_t b;
-
- if (barrier == NULL || count == 0)
- {
- return EINVAL;
- }
-
- if (NULL != (b = (pthread_barrier_t) calloc (1, sizeof (*b))))
- {
- b->pshared = (attr != NULL && *attr != NULL
- ? (*attr)->pshared : PTHREAD_PROCESS_PRIVATE);
-
- b->nCurrentBarrierHeight = b->nInitialBarrierHeight = count;
- b->lock = 0;
-
- if (0 == sem_init (&(b->semBarrierBreeched), b->pshared, 0))
- {
- *barrier = b;
- return 0;
- }
- (void) free (b);
- }
-
- return ENOMEM;
-}
+/*
+ * pthread_barrier_init.c
+ *
+ * Description:
+ * This translation unit implements barrier primitives.
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads-win32 - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * http://sources.redhat.com/pthreads-win32/contributors.html
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "pthread.h"
+#include "implement.h"
+
+
+int
+pthread_barrier_init (pthread_barrier_t * barrier,
+ const pthread_barrierattr_t * attr, unsigned int count)
+{
+ pthread_barrier_t b;
+
+ if (barrier == NULL || count == 0)
+ {
+ return EINVAL;
+ }
+
+ if (NULL != (b = (pthread_barrier_t) calloc (1, sizeof (*b))))
+ {
+ b->pshared = (attr != NULL && *attr != NULL
+ ? (*attr)->pshared : PTHREAD_PROCESS_PRIVATE);
+
+ b->nCurrentBarrierHeight = b->nInitialBarrierHeight = count;
+ b->lock = 0;
+
+ if (0 == sem_init (&(b->semBarrierBreeched), b->pshared, 0))
+ {
+ *barrier = b;
+ return 0;
+ }
+ (void) free (b);
+ }
+
+ return ENOMEM;
+}
diff --git a/pthreads/pthread_barrier_wait.c b/pthreads/pthread_barrier_wait.c
index e0e97e6c7..9d573afee 100644
--- a/pthreads/pthread_barrier_wait.c
+++ b/pthreads/pthread_barrier_wait.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_barrierattr_destroy.c b/pthreads/pthread_barrierattr_destroy.c
index 5ab662e3f..d8953a9b7 100644
--- a/pthreads/pthread_barrierattr_destroy.c
+++ b/pthreads/pthread_barrierattr_destroy.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_barrierattr_getpshared.c b/pthreads/pthread_barrierattr_getpshared.c
index 44c467e2b..7d9736c09 100644
--- a/pthreads/pthread_barrierattr_getpshared.c
+++ b/pthreads/pthread_barrierattr_getpshared.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_barrierattr_init.c b/pthreads/pthread_barrierattr_init.c
index 342f8b0c6..aef72b4f7 100644
--- a/pthreads/pthread_barrierattr_init.c
+++ b/pthreads/pthread_barrierattr_init.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_barrierattr_setpshared.c b/pthreads/pthread_barrierattr_setpshared.c
index 08c6fde30..7f5dc549d 100644
--- a/pthreads/pthread_barrierattr_setpshared.c
+++ b/pthreads/pthread_barrierattr_setpshared.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_cancel.c b/pthreads/pthread_cancel.c
index ae60b7293..bda3ab01d 100644
--- a/pthreads/pthread_cancel.c
+++ b/pthreads/pthread_cancel.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
#include "context.h"
@@ -55,12 +60,12 @@ ptw32_cancel_callback (ULONG_PTR unused)
}
/*
- * ptw32_RegisterCancelation() -
+ * ptw32_Registercancellation() -
* Must have args of same type as QueueUserAPCEx because this function
* is a substitute for QueueUserAPCEx if it's not available.
*/
DWORD
-ptw32_RegisterCancelation (PAPCFUNC unused1, HANDLE threadH, DWORD unused2)
+ptw32_Registercancellation (PAPCFUNC unused1, HANDLE threadH, DWORD unused2)
{
CONTEXT context;
@@ -155,10 +160,10 @@ pthread_cancel (pthread_t thread)
/*
* If alertdrv and QueueUserAPCEx is available then the following
* will result in a call to QueueUserAPCEx with the args given, otherwise
- * this will result in a call to ptw32_RegisterCancelation and only
+ * this will result in a call to ptw32_Registercancellation and only
* the threadH arg will be used.
*/
- ptw32_register_cancelation ((PAPCFUNC)ptw32_cancel_callback, threadH, 0);
+ ptw32_register_cancellation ((PAPCFUNC)ptw32_cancel_callback, threadH, 0);
ptw32_mcs_lock_release (&stateLock);
ResumeThread (threadH);
}
diff --git a/pthreads/pthread_cond_destroy.c b/pthreads/pthread_cond_destroy.c
index 40d4a0896..12e76330d 100644
--- a/pthreads/pthread_cond_destroy.c
+++ b/pthreads/pthread_cond_destroy.c
@@ -9,10 +9,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -35,6 +36,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
@@ -138,7 +143,7 @@ pthread_cond_destroy (pthread_cond_t * cond)
*/
if (ptw32_semwait (&(cv->semBlockLock)) != 0) /* Non-cancelable */
{
- result = errno;
+ result = PTW32_GET_ERRNO();
}
else
{
@@ -166,7 +171,7 @@ pthread_cond_destroy (pthread_cond_t * cond)
{
if (sem_post (&(cv->semBlockLock)) != 0)
{
- result = errno;
+ result = PTW32_GET_ERRNO();
}
result1 = pthread_mutex_unlock (&(cv->mtxUnblockLock));
result2 = EBUSY;
@@ -180,11 +185,11 @@ pthread_cond_destroy (pthread_cond_t * cond)
if (sem_destroy (&(cv->semBlockLock)) != 0)
{
- result = errno;
+ result = PTW32_GET_ERRNO();
}
if (sem_destroy (&(cv->semBlockQueue)) != 0)
{
- result1 = errno;
+ result1 = PTW32_GET_ERRNO();
}
if ((result2 = pthread_mutex_unlock (&(cv->mtxUnblockLock))) == 0)
{
diff --git a/pthreads/pthread_cond_init.c b/pthreads/pthread_cond_init.c
index f28fd67b4..b9379a373 100644
--- a/pthreads/pthread_cond_init.c
+++ b/pthreads/pthread_cond_init.c
@@ -9,10 +9,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -35,6 +36,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
@@ -101,13 +106,13 @@ pthread_cond_init (pthread_cond_t * cond, const pthread_condattr_t * attr)
if (sem_init (&(cv->semBlockLock), 0, 1) != 0)
{
- result = errno;
+ result = PTW32_GET_ERRNO();
goto FAIL0;
}
if (sem_init (&(cv->semBlockQueue), 0, 0) != 0)
{
- result = errno;
+ result = PTW32_GET_ERRNO();
goto FAIL1;
}
diff --git a/pthreads/pthread_cond_signal.c b/pthreads/pthread_cond_signal.c
index 2b4f6d4d4..6c9a1c1c5 100644
--- a/pthreads/pthread_cond_signal.c
+++ b/pthreads/pthread_cond_signal.c
@@ -9,10 +9,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -39,6 +40,10 @@
* See the comments at the top of pthread_cond_wait.c.
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
@@ -112,7 +117,7 @@ ptw32_cond_unblock (pthread_cond_t * cond, int unblockAll)
/* Use the non-cancellable version of sem_wait() */
if (ptw32_semwait (&(cv->semBlockLock)) != 0)
{
- result = errno;
+ result = PTW32_GET_ERRNO();
(void) pthread_mutex_unlock (&(cv->mtxUnblockLock));
return result;
}
@@ -141,7 +146,7 @@ ptw32_cond_unblock (pthread_cond_t * cond, int unblockAll)
{
if (sem_post_multiple (&(cv->semBlockQueue), nSignalsToIssue) != 0)
{
- result = errno;
+ result = PTW32_GET_ERRNO();
}
}
diff --git a/pthreads/pthread_cond_wait.c b/pthreads/pthread_cond_wait.c
index 359219ae9..0dd695cbb 100644
--- a/pthreads/pthread_cond_wait.c
+++ b/pthreads/pthread_cond_wait.c
@@ -9,10 +9,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -255,9 +256,12 @@
* return result;
* }
* -------------------------------------------------------------
- *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
@@ -303,7 +307,7 @@ ptw32_cond_wait_cleanup (void *args)
/* Use the non-cancellable version of sem_wait() */
if (ptw32_semwait (&(cv->semBlockLock)) != 0)
{
- *resultPtr = errno;
+ *resultPtr = PTW32_GET_ERRNO();
/*
* This is a fatal error for this CV,
* so we deliberately don't unlock
@@ -314,7 +318,7 @@ ptw32_cond_wait_cleanup (void *args)
cv->nWaitersBlocked -= cv->nWaitersGone;
if (sem_post (&(cv->semBlockLock)) != 0)
{
- *resultPtr = errno;
+ *resultPtr = PTW32_GET_ERRNO();
/*
* This is a fatal error for this CV,
* so we deliberately don't unlock
@@ -335,7 +339,7 @@ ptw32_cond_wait_cleanup (void *args)
{
if (sem_post (&(cv->semBlockLock)) != 0)
{
- *resultPtr = errno;
+ *resultPtr = PTW32_GET_ERRNO();
return;
}
}
@@ -384,14 +388,14 @@ ptw32_cond_timedwait (pthread_cond_t * cond,
/* Thread can be cancelled in sem_wait() but this is OK */
if (sem_wait (&(cv->semBlockLock)) != 0)
{
- return errno;
+ return PTW32_GET_ERRNO();
}
++(cv->nWaitersBlocked);
if (sem_post (&(cv->semBlockLock)) != 0)
{
- return errno;
+ return PTW32_GET_ERRNO();
}
/*
@@ -401,7 +405,7 @@ ptw32_cond_timedwait (pthread_cond_t * cond,
cleanup_args.cv = cv;
cleanup_args.resultPtr = &result;
-#if defined(_MSC_VER) && _MSC_VER < 1400
+#if defined(PTW32_CONFIG_MSVC7)
#pragma inline_depth(0)
#endif
pthread_cleanup_push (ptw32_cond_wait_cleanup, (void *) &cleanup_args);
@@ -430,7 +434,7 @@ ptw32_cond_timedwait (pthread_cond_t * cond,
*/
if (sem_timedwait (&(cv->semBlockQueue), abstime) != 0)
{
- result = errno;
+ result = PTW32_GET_ERRNO();
}
}
@@ -438,7 +442,7 @@ ptw32_cond_timedwait (pthread_cond_t * cond,
* Always cleanup
*/
pthread_cleanup_pop (1);
-#if defined(_MSC_VER) && _MSC_VER < 1400
+#if defined(PTW32_CONFIG_MSVC7)
#pragma inline_depth()
#endif
diff --git a/pthreads/pthread_condattr_destroy.c b/pthreads/pthread_condattr_destroy.c
index 58a14828f..696065efd 100644
--- a/pthreads/pthread_condattr_destroy.c
+++ b/pthreads/pthread_condattr_destroy.c
@@ -9,10 +9,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -35,6 +36,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_condattr_getpshared.c b/pthreads/pthread_condattr_getpshared.c
index a0ac6d882..dc161a9d1 100644
--- a/pthreads/pthread_condattr_getpshared.c
+++ b/pthreads/pthread_condattr_getpshared.c
@@ -9,10 +9,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -35,6 +36,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_condattr_init.c b/pthreads/pthread_condattr_init.c
index 5987878e0..aa32cc6d9 100644
--- a/pthreads/pthread_condattr_init.c
+++ b/pthreads/pthread_condattr_init.c
@@ -9,10 +9,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -35,6 +36,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_condattr_setpshared.c b/pthreads/pthread_condattr_setpshared.c
index 954fb3829..977b5a5c0 100644
--- a/pthreads/pthread_condattr_setpshared.c
+++ b/pthreads/pthread_condattr_setpshared.c
@@ -9,10 +9,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -35,6 +36,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_delay_np.c b/pthreads/pthread_delay_np.c
index e6c96d807..76a54b654 100644
--- a/pthreads/pthread_delay_np.c
+++ b/pthreads/pthread_delay_np.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
@@ -50,7 +55,7 @@
*
* Specifying an interval of zero (0) seconds and zero (0) nanoseconds is
* allowed and can be used to force the thread to give up the processor or to
- * deliver a pending cancelation request.
+ * deliver a pending cancellation request.
*
* The timespec structure contains the following two fields:
*
@@ -135,8 +140,8 @@ pthread_delay_np (struct timespec *interval)
if (sp->cancelState == PTHREAD_CANCEL_ENABLE)
{
/*
- * Async cancelation won't catch us until wait_time is up.
- * Deferred cancelation will cancel us immediately.
+ * Async cancellation won't catch us until wait_time is up.
+ * Deferred cancellation will cancel us immediately.
*/
if (WAIT_OBJECT_0 ==
(status = WaitForSingleObject (sp->cancelEvent, wait_time)))
diff --git a/pthreads/pthread_detach.c b/pthreads/pthread_detach.c
index 9ff6587f3..412fd92a3 100644
--- a/pthreads/pthread_detach.c
+++ b/pthreads/pthread_detach.c
@@ -9,10 +9,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -35,6 +36,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
@@ -77,9 +82,9 @@ pthread_detach (pthread_t thread)
int result;
BOOL destroyIt = PTW32_FALSE;
ptw32_thread_t * tp = (ptw32_thread_t *) thread.p;
- ptw32_mcs_local_node_t node;
+ ptw32_mcs_local_node_t reuseLock;
- ptw32_mcs_lock_acquire(&ptw32_thread_reuse_lock, &node);
+ ptw32_mcs_lock_acquire(&ptw32_thread_reuse_lock, &reuseLock);
if (NULL == tp
|| thread.x != tp->ptHandle.x)
@@ -115,7 +120,7 @@ pthread_detach (pthread_t thread)
ptw32_mcs_lock_release (&stateLock);
}
- ptw32_mcs_lock_release(&node);
+ ptw32_mcs_lock_release(&reuseLock);
if (result == 0)
{
diff --git a/pthreads/pthread_equal.c b/pthreads/pthread_equal.c
index 5ddd82acb..48da7e203 100644
--- a/pthreads/pthread_equal.c
+++ b/pthreads/pthread_equal.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_exit.c b/pthreads/pthread_exit.c
index 37b3c0990..6b3bc19c6 100644
--- a/pthreads/pthread_exit.c
+++ b/pthreads/pthread_exit.c
@@ -9,10 +9,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -35,6 +36,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
#if !defined(_UWIN)
@@ -88,7 +93,7 @@ pthread_exit (void *value_ptr)
* Implicit POSIX handles are cleaned up in ptw32_throw() now.
*/
-#if ! (defined (__MINGW64__) || defined(__MINGW32__)) || defined (__MSVCRT__) || defined (__DMC__)
+#if ! defined (PTW32_CONFIG_MINGW) || defined (__MSVCRT__) || defined (__DMC__)
_endthreadex ((unsigned) (size_t) value_ptr);
#else
_endthread ();
diff --git a/pthreads/pthread_getconcurrency.c b/pthreads/pthread_getconcurrency.c
index cf9e9c85c..de46fe7cb 100644
--- a/pthreads/pthread_getconcurrency.c
+++ b/pthreads/pthread_getconcurrency.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_getschedparam.c b/pthreads/pthread_getschedparam.c
index 0afcfb74a..044581188 100644
--- a/pthreads/pthread_getschedparam.c
+++ b/pthreads/pthread_getschedparam.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
#include "sched.h"
@@ -51,11 +56,7 @@ pthread_getschedparam (pthread_t thread, int *policy,
return result;
}
- /*
- * Validate the policy and param args.
- * Check that a policy constant wasn't passed rather than &policy.
- */
- if (policy <= (int *) SCHED_MAX || param == NULL)
+ if (policy == NULL)
{
return EINVAL;
}
diff --git a/pthreads/pthread_getspecific.c b/pthreads/pthread_getspecific.c
index 51a15ba13..77caa6b18 100644
--- a/pthreads/pthread_getspecific.c
+++ b/pthreads/pthread_getspecific.c
@@ -1,87 +1,92 @@
-/*
- * pthread_getspecific.c
- *
- * Description:
- * POSIX thread functions which implement thread-specific data (TSD).
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-
-void *
-pthread_getspecific (pthread_key_t key)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * This function returns the current value of key in the
- * calling thread. If no value has been set for 'key' in
- * the thread, NULL is returned.
- *
- * PARAMETERS
- * key
- * an instance of pthread_key_t
- *
- *
- * DESCRIPTION
- * This function returns the current value of key in the
- * calling thread. If no value has been set for 'key' in
- * the thread, NULL is returned.
- *
- * RESULTS
- * key value or NULL on failure
- *
- * ------------------------------------------------------
- */
-{
- void * ptr;
-
- if (key == NULL)
- {
- ptr = NULL;
- }
- else
- {
- int lasterror = GetLastError ();
-#if defined(RETAIN_WSALASTERROR)
- int lastWSAerror = WSAGetLastError ();
-#endif
- ptr = TlsGetValue (key->key);
-
- SetLastError (lasterror);
-#if defined(RETAIN_WSALASTERROR)
- WSASetLastError (lastWSAerror);
-#endif
- }
-
- return ptr;
-}
+/*
+ * pthread_getspecific.c
+ *
+ * Description:
+ * POSIX thread functions which implement thread-specific data (TSD).
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads-win32 - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * http://sources.redhat.com/pthreads-win32/contributors.html
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "pthread.h"
+#include "implement.h"
+
+
+void *
+pthread_getspecific (pthread_key_t key)
+ /*
+ * ------------------------------------------------------
+ * DOCPUBLIC
+ * This function returns the current value of key in the
+ * calling thread. If no value has been set for 'key' in
+ * the thread, NULL is returned.
+ *
+ * PARAMETERS
+ * key
+ * an instance of pthread_key_t
+ *
+ *
+ * DESCRIPTION
+ * This function returns the current value of key in the
+ * calling thread. If no value has been set for 'key' in
+ * the thread, NULL is returned.
+ *
+ * RESULTS
+ * key value or NULL on failure
+ *
+ * ------------------------------------------------------
+ */
+{
+ void * ptr;
+
+ if (key == NULL)
+ {
+ ptr = NULL;
+ }
+ else
+ {
+ int lasterror = GetLastError ();
+#if defined(RETAIN_WSALASTERROR)
+ int lastWSAerror = WSAGetLastError ();
+#endif
+ ptr = TlsGetValue (key->key);
+
+ SetLastError (lasterror);
+#if defined(RETAIN_WSALASTERROR)
+ WSASetLastError (lastWSAerror);
+#endif
+ }
+
+ return ptr;
+}
diff --git a/pthreads/pthread_getunique_np.c b/pthreads/pthread_getunique_np.c
index 4496c68bf..55031f046 100644
--- a/pthreads/pthread_getunique_np.c
+++ b/pthreads/pthread_getunique_np.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_getw32threadhandle_np.c b/pthreads/pthread_getw32threadhandle_np.c
index cdca10141..b6ab544dd 100644
--- a/pthreads/pthread_getw32threadhandle_np.c
+++ b/pthreads/pthread_getw32threadhandle_np.c
@@ -1,65 +1,70 @@
-/*
- * pthread_getw32threadhandle_np.c
- *
- * Description:
- * This translation unit implements non-portable thread functions.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-/*
- * pthread_getw32threadhandle_np()
- *
- * Returns the win32 thread handle that the POSIX
- * thread "thread" is running as.
- *
- * Applications can use the win32 handle to set
- * win32 specific attributes of the thread.
- */
-HANDLE
-pthread_getw32threadhandle_np (pthread_t thread)
-{
- return ((ptw32_thread_t *)thread.p)->threadH;
-}
-
-/*
- * pthread_getw32threadid_np()
- *
- * Returns the win32 thread id that the POSIX
- * thread "thread" is running as.
- */
-DWORD
-pthread_getw32threadid_np (pthread_t thread)
-{
- return ((ptw32_thread_t *)thread.p)->thread;
-}
+/*
+ * pthread_getw32threadhandle_np.c
+ *
+ * Description:
+ * This translation unit implements non-portable thread functions.
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads-win32 - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * http://sources.redhat.com/pthreads-win32/contributors.html
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "pthread.h"
+#include "implement.h"
+
+/*
+ * pthread_getw32threadhandle_np()
+ *
+ * Returns the win32 thread handle that the POSIX
+ * thread "thread" is running as.
+ *
+ * Applications can use the win32 handle to set
+ * win32 specific attributes of the thread.
+ */
+HANDLE
+pthread_getw32threadhandle_np (pthread_t thread)
+{
+ return ((ptw32_thread_t *)thread.p)->threadH;
+}
+
+/*
+ * pthread_getw32threadid_np()
+ *
+ * Returns the win32 thread id that the POSIX
+ * thread "thread" is running as.
+ */
+DWORD
+pthread_getw32threadid_np (pthread_t thread)
+{
+ return ((ptw32_thread_t *)thread.p)->thread;
+}
diff --git a/pthreads/pthread_join.c b/pthreads/pthread_join.c
index c2b7c1e75..963725516 100644
--- a/pthreads/pthread_join.c
+++ b/pthreads/pthread_join.c
@@ -9,10 +9,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -35,6 +36,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
@@ -123,9 +128,9 @@ pthread_join (pthread_t thread, void **value_ptr)
else
{
/*
- * Pthread_join is a cancelation point.
+ * Pthread_join is a cancellation point.
* If we are canceled then our target thread must not be
- * detached (destroyed). This is guarranteed because
+ * detached (destroyed). This is guaranteed because
* pthreadCancelableWait will not return if we
* are canceled.
*/
diff --git a/pthreads/pthread_key_create.c b/pthreads/pthread_key_create.c
index bdeee09b3..6839d88bd 100644
--- a/pthreads/pthread_key_create.c
+++ b/pthreads/pthread_key_create.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
@@ -44,7 +49,7 @@
#endif
int
-pthread_key_create (pthread_key_t * key, void (*destructor) (void *))
+pthread_key_create (pthread_key_t * key, void (PTW32_CDECL *destructor) (void *))
/*
* ------------------------------------------------------
* DOCPUBLIC
diff --git a/pthreads/pthread_key_delete.c b/pthreads/pthread_key_delete.c
index 09d70c63f..ac9f99179 100644
--- a/pthreads/pthread_key_delete.c
+++ b/pthreads/pthread_key_delete.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_kill.c b/pthreads/pthread_kill.c
index 5473b43cd..9bfa9fa9f 100644
--- a/pthreads/pthread_kill.c
+++ b/pthreads/pthread_kill.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_mutex_consistent.c b/pthreads/pthread_mutex_consistent.c
index b7805e7b1..053a5a6ce 100644
--- a/pthreads/pthread_mutex_consistent.c
+++ b/pthreads/pthread_mutex_consistent.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
/*
* From the Sun Multi-threaded Programming Guide
*
@@ -41,29 +46,29 @@
* mutex, usually because its process terminated abnormally. The value of robustness that is
* defined in pthread.h is PTHREAD_MUTEX_ROBUST or PTHREAD_MUTEX_STALLED. The
* default value is PTHREAD_MUTEX_STALLED .
- * ā–  PTHREAD_MUTEX_STALLED
+ * [] PTHREAD_MUTEX_STALLED
* When the owner of the mutex terminates without unlocking the mutex, all subsequent calls
* to pthread_mutex_lock() are blocked from progress in an unspecified manner.
- * ā–  PTHREAD_MUTEX_ROBUST
+ * [] PTHREAD_MUTEX_ROBUST
* When the owner of the mutex terminates without unlocking the mutex, the mutex is
* unlocked. The next owner of this mutex acquires the mutex with an error return of
* EOWNERDEAD.
- * Note ā€“ Your application must always check the return code from pthread_mutex_lock() for
+ * Note - Your application must always check the return code from pthread_mutex_lock() for
* a mutex initialized with the PTHREAD_MUTEX_ROBUST attribute.
- * ā–  The new owner of this mutex should make the state protected by the mutex consistent.
+ * [] The new owner of this mutex should make the state protected by the mutex consistent.
* This state might have been left inconsistent when the previous owner terminated.
- * ā–  If the new owner is able to make the state consistent, call
+ * [] If the new owner is able to make the state consistent, call
* pthread_mutex_consistent() for the mutex before unlocking the mutex. This
* marks the mutex as consistent and subsequent calls to pthread_mutex_lock() and
* pthread_mutex_unlock() will behave in the normal manner.
- * ā–  If the new owner is not able to make the state consistent, do not call
+ * [] If the new owner is not able to make the state consistent, do not call
* pthread_mutex_consistent() for the mutex, but unlock the mutex.
* All waiters are woken up and all subsequent calls to pthread_mutex_lock() fail to
* acquire the mutex. The return code is ENOTRECOVERABLE. The mutex can be made
* consistent by calling pthread_mutex_destroy() to uninitialize the mutex, and calling
* pthread_mutex_int() to reinitialize the mutex.However, the state that was protected
* by the mutex remains inconsistent and some form of application recovery is required.
- * ā–  If the thread that acquires the lock with EOWNERDEAD terminates without unlocking the
+ * [] If the thread that acquires the lock with EOWNERDEAD terminates without unlocking the
* mutex, the next owner acquires the lock with an EOWNERDEAD return code.
*/
#if !defined(_UWIN)
@@ -100,9 +105,9 @@ ptw32_robust_mutex_inherit(pthread_mutex_t * mutex)
}
/*
- * The next two internal support functions depend on only being
- * called by the thread that owns the robust mutex. This enables
- * us to avoid additional locks.
+ * The next two internal support functions depend on being
+ * called only by the thread that owns the robust mutex. This
+ * enables us to avoid additional locks.
* Any mutex currently in the thread's robust mutex list is held
* by the thread, again eliminating the need for locks.
* The forward/backward links allow the thread to unlock mutexes
diff --git a/pthreads/pthread_mutex_destroy.c b/pthreads/pthread_mutex_destroy.c
index 7b8c9cd65..545d08394 100644
--- a/pthreads/pthread_mutex_destroy.c
+++ b/pthreads/pthread_mutex_destroy.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_mutex_init.c b/pthreads/pthread_mutex_init.c
index daf805e5b..3366d2030 100644
--- a/pthreads/pthread_mutex_init.c
+++ b/pthreads/pthread_mutex_init.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_mutex_lock.c b/pthreads/pthread_mutex_lock.c
index eee9abe8c..5a7cb3bae 100644
--- a/pthreads/pthread_mutex_lock.c
+++ b/pthreads/pthread_mutex_lock.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#if !defined(_UWIN)
/*# include <process.h> */
#endif
diff --git a/pthreads/pthread_mutex_timedlock.c b/pthreads/pthread_mutex_timedlock.c
index 174531679..d1091e98f 100644
--- a/pthreads/pthread_mutex_timedlock.c
+++ b/pthreads/pthread_mutex_timedlock.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
@@ -52,7 +57,7 @@ ptw32_timed_eventwait (HANDLE event, const struct timespec *abstime)
* block until it can successfully decrease the value or
* until interrupted by a signal.
*
- * This routine is not a cancelation point.
+ * This routine is not a cancellation point.
*
* RESULTS
* 0 successfully signaled,
@@ -86,18 +91,17 @@ ptw32_timed_eventwait (HANDLE event, const struct timespec *abstime)
status = WaitForSingleObject (event, milliseconds);
- if (status == WAIT_OBJECT_0)
- {
- return 0;
- }
- else if (status == WAIT_TIMEOUT)
- {
- return ETIMEDOUT;
- }
- else
- {
- return EINVAL;
- }
+ if (status != WAIT_OBJECT_0)
+ {
+ if (status == WAIT_TIMEOUT)
+ {
+ return ETIMEDOUT;
+ }
+ else
+ {
+ return EINVAL;
+ }
+ }
}
return 0;
diff --git a/pthreads/pthread_mutex_trylock.c b/pthreads/pthread_mutex_trylock.c
index d6b68724d..840ec4214 100644
--- a/pthreads/pthread_mutex_trylock.c
+++ b/pthreads/pthread_mutex_trylock.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_mutex_unlock.c b/pthreads/pthread_mutex_unlock.c
index 3d65d1a95..aa5850a1b 100644
--- a/pthreads/pthread_mutex_unlock.c
+++ b/pthreads/pthread_mutex_unlock.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_mutexattr_destroy.c b/pthreads/pthread_mutexattr_destroy.c
index 9d424bfa2..ae8428ccb 100644
--- a/pthreads/pthread_mutexattr_destroy.c
+++ b/pthreads/pthread_mutexattr_destroy.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_mutexattr_getkind_np.c b/pthreads/pthread_mutexattr_getkind_np.c
index 2d82ec6bc..13903b873 100644
--- a/pthreads/pthread_mutexattr_getkind_np.c
+++ b/pthreads/pthread_mutexattr_getkind_np.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_mutexattr_getpshared.c b/pthreads/pthread_mutexattr_getpshared.c
index 42f9589c5..b285d2d27 100644
--- a/pthreads/pthread_mutexattr_getpshared.c
+++ b/pthreads/pthread_mutexattr_getpshared.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_mutexattr_getrobust.c b/pthreads/pthread_mutexattr_getrobust.c
index be004837b..28c286579 100644
--- a/pthreads/pthread_mutexattr_getrobust.c
+++ b/pthreads/pthread_mutexattr_getrobust.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_mutexattr_gettype.c b/pthreads/pthread_mutexattr_gettype.c
index 6f805e503..a6e4cdb81 100644
--- a/pthreads/pthread_mutexattr_gettype.c
+++ b/pthreads/pthread_mutexattr_gettype.c
@@ -1,56 +1,61 @@
-/*
- * pthread_mutexattr_gettype.c
- *
- * Description:
- * This translation unit implements mutual exclusion (mutex) primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-
-int
-pthread_mutexattr_gettype (const pthread_mutexattr_t * attr, int *kind)
-{
- int result = 0;
-
- if (attr != NULL && *attr != NULL && kind != NULL)
- {
- *kind = (*attr)->kind;
- }
- else
- {
- result = EINVAL;
- }
-
- return (result);
-}
+/*
+ * pthread_mutexattr_gettype.c
+ *
+ * Description:
+ * This translation unit implements mutual exclusion (mutex) primitives.
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads-win32 - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * http://sources.redhat.com/pthreads-win32/contributors.html
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "pthread.h"
+#include "implement.h"
+
+
+int
+pthread_mutexattr_gettype (const pthread_mutexattr_t * attr, int *kind)
+{
+ int result = 0;
+
+ if (attr != NULL && *attr != NULL && kind != NULL)
+ {
+ *kind = (*attr)->kind;
+ }
+ else
+ {
+ result = EINVAL;
+ }
+
+ return (result);
+}
diff --git a/pthreads/pthread_mutexattr_init.c b/pthreads/pthread_mutexattr_init.c
index d2797ff24..037b88b3d 100644
--- a/pthreads/pthread_mutexattr_init.c
+++ b/pthreads/pthread_mutexattr_init.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
@@ -78,6 +83,7 @@ pthread_mutexattr_init (pthread_mutexattr_t * attr)
{
ma->pshared = PTHREAD_PROCESS_PRIVATE;
ma->kind = PTHREAD_MUTEX_DEFAULT;
+ ma->robustness = PTHREAD_MUTEX_STALLED;
}
*attr = ma;
diff --git a/pthreads/pthread_mutexattr_setkind_np.c b/pthreads/pthread_mutexattr_setkind_np.c
index faa936658..3d55d8210 100644
--- a/pthreads/pthread_mutexattr_setkind_np.c
+++ b/pthreads/pthread_mutexattr_setkind_np.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_mutexattr_setpshared.c b/pthreads/pthread_mutexattr_setpshared.c
index cfa6f7199..997f469ab 100644
--- a/pthreads/pthread_mutexattr_setpshared.c
+++ b/pthreads/pthread_mutexattr_setpshared.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_mutexattr_setrobust.c b/pthreads/pthread_mutexattr_setrobust.c
index b1acef757..4f18b4890 100644
--- a/pthreads/pthread_mutexattr_setrobust.c
+++ b/pthreads/pthread_mutexattr_setrobust.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_mutexattr_settype.c b/pthreads/pthread_mutexattr_settype.c
index 8365daf65..bb650eb42 100644
--- a/pthreads/pthread_mutexattr_settype.c
+++ b/pthreads/pthread_mutexattr_settype.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_num_processors_np.c b/pthreads/pthread_num_processors_np.c
index 3067d117d..f94b074d7 100644
--- a/pthreads/pthread_num_processors_np.c
+++ b/pthreads/pthread_num_processors_np.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_once.c b/pthreads/pthread_once.c
index ef2c1f168..c80983726 100644
--- a/pthreads/pthread_once.c
+++ b/pthreads/pthread_once.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,11 +35,15 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
int
-pthread_once (pthread_once_t * once_control, void (*init_routine) (void))
+pthread_once (pthread_once_t * once_control, void (PTW32_CDECL *init_routine) (void))
{
if (once_control == NULL || init_routine == NULL)
{
@@ -56,7 +61,7 @@ pthread_once (pthread_once_t * once_control, void (*init_routine) (void))
if (!once_control->done)
{
-#if defined(_MSC_VER) && _MSC_VER < 1400
+#if defined(PTW32_CONFIG_MSVC7)
#pragma inline_depth(0)
#endif
@@ -64,14 +69,14 @@ pthread_once (pthread_once_t * once_control, void (*init_routine) (void))
(*init_routine)();
pthread_cleanup_pop(0);
-#if defined(_MSC_VER) && _MSC_VER < 1400
+#if defined(PTW32_CONFIG_MSVC7)
#pragma inline_depth()
#endif
once_control->done = PTW32_TRUE;
}
- ptw32_mcs_lock_release(&node);
+ ptw32_mcs_lock_release(&node);
}
return 0;
diff --git a/pthreads/pthread_rwlock_destroy.c b/pthreads/pthread_rwlock_destroy.c
index 245a89241..edb6338b9 100644
--- a/pthreads/pthread_rwlock_destroy.c
+++ b/pthreads/pthread_rwlock_destroy.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include <limits.h>
#include "pthread.h"
diff --git a/pthreads/pthread_rwlock_init.c b/pthreads/pthread_rwlock_init.c
index c1d703d4d..90a669469 100644
--- a/pthreads/pthread_rwlock_init.c
+++ b/pthreads/pthread_rwlock_init.c
@@ -1,109 +1,114 @@
-/*
- * pthread_rwlock_init.c
- *
- * Description:
- * This translation unit implements read/write lock primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include <limits.h>
-
-#include "pthread.h"
-#include "implement.h"
-
-int
-pthread_rwlock_init (pthread_rwlock_t * rwlock,
- const pthread_rwlockattr_t * attr)
-{
- int result;
- pthread_rwlock_t rwl = 0;
-
- if (rwlock == NULL)
- {
- return EINVAL;
- }
-
- if (attr != NULL && *attr != NULL)
- {
- result = EINVAL; /* Not supported */
- goto DONE;
- }
-
- rwl = (pthread_rwlock_t) calloc (1, sizeof (*rwl));
-
- if (rwl == NULL)
- {
- result = ENOMEM;
- goto DONE;
- }
-
- rwl->nSharedAccessCount = 0;
- rwl->nExclusiveAccessCount = 0;
- rwl->nCompletedSharedAccessCount = 0;
-
- result = pthread_mutex_init (&rwl->mtxExclusiveAccess, NULL);
- if (result != 0)
- {
- goto FAIL0;
- }
-
- result = pthread_mutex_init (&rwl->mtxSharedAccessCompleted, NULL);
- if (result != 0)
- {
- goto FAIL1;
- }
-
- result = pthread_cond_init (&rwl->cndSharedAccessCompleted, NULL);
- if (result != 0)
- {
- goto FAIL2;
- }
-
- rwl->nMagic = PTW32_RWLOCK_MAGIC;
-
- result = 0;
- goto DONE;
-
-FAIL2:
- (void) pthread_mutex_destroy (&(rwl->mtxSharedAccessCompleted));
-
-FAIL1:
- (void) pthread_mutex_destroy (&(rwl->mtxExclusiveAccess));
-
-FAIL0:
- (void) free (rwl);
- rwl = NULL;
-
-DONE:
- *rwlock = rwl;
-
- return result;
-}
+/*
+ * pthread_rwlock_init.c
+ *
+ * Description:
+ * This translation unit implements read/write lock primitives.
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads-win32 - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * http://sources.redhat.com/pthreads-win32/contributors.html
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <limits.h>
+
+#include "pthread.h"
+#include "implement.h"
+
+int
+pthread_rwlock_init (pthread_rwlock_t * rwlock,
+ const pthread_rwlockattr_t * attr)
+{
+ int result;
+ pthread_rwlock_t rwl = 0;
+
+ if (rwlock == NULL)
+ {
+ return EINVAL;
+ }
+
+ if (attr != NULL && *attr != NULL)
+ {
+ result = EINVAL; /* Not supported */
+ goto DONE;
+ }
+
+ rwl = (pthread_rwlock_t) calloc (1, sizeof (*rwl));
+
+ if (rwl == NULL)
+ {
+ result = ENOMEM;
+ goto DONE;
+ }
+
+ rwl->nSharedAccessCount = 0;
+ rwl->nExclusiveAccessCount = 0;
+ rwl->nCompletedSharedAccessCount = 0;
+
+ result = pthread_mutex_init (&rwl->mtxExclusiveAccess, NULL);
+ if (result != 0)
+ {
+ goto FAIL0;
+ }
+
+ result = pthread_mutex_init (&rwl->mtxSharedAccessCompleted, NULL);
+ if (result != 0)
+ {
+ goto FAIL1;
+ }
+
+ result = pthread_cond_init (&rwl->cndSharedAccessCompleted, NULL);
+ if (result != 0)
+ {
+ goto FAIL2;
+ }
+
+ rwl->nMagic = PTW32_RWLOCK_MAGIC;
+
+ result = 0;
+ goto DONE;
+
+FAIL2:
+ (void) pthread_mutex_destroy (&(rwl->mtxSharedAccessCompleted));
+
+FAIL1:
+ (void) pthread_mutex_destroy (&(rwl->mtxExclusiveAccess));
+
+FAIL0:
+ (void) free (rwl);
+ rwl = NULL;
+
+DONE:
+ *rwlock = rwl;
+
+ return result;
+}
diff --git a/pthreads/pthread_rwlock_rdlock.c b/pthreads/pthread_rwlock_rdlock.c
index 542217642..4d0d393c5 100644
--- a/pthreads/pthread_rwlock_rdlock.c
+++ b/pthreads/pthread_rwlock_rdlock.c
@@ -1,102 +1,107 @@
-/*
- * pthread_rwlock_rdlock.c
- *
- * Description:
- * This translation unit implements read/write lock primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include <limits.h>
-
-#include "pthread.h"
-#include "implement.h"
-
-int
-pthread_rwlock_rdlock (pthread_rwlock_t * rwlock)
-{
- int result;
- pthread_rwlock_t rwl;
-
- if (rwlock == NULL || *rwlock == NULL)
- {
- return EINVAL;
- }
-
- /*
- * We do a quick check to see if we need to do more work
- * to initialise a static rwlock. We check
- * again inside the guarded section of ptw32_rwlock_check_need_init()
- * to avoid race conditions.
- */
- if (*rwlock == PTHREAD_RWLOCK_INITIALIZER)
- {
- result = ptw32_rwlock_check_need_init (rwlock);
-
- if (result != 0 && result != EBUSY)
- {
- return result;
- }
- }
-
- rwl = *rwlock;
-
- if (rwl->nMagic != PTW32_RWLOCK_MAGIC)
- {
- return EINVAL;
- }
-
- if ((result = pthread_mutex_lock (&(rwl->mtxExclusiveAccess))) != 0)
- {
- return result;
- }
-
- if (++rwl->nSharedAccessCount == INT_MAX)
- {
- if ((result =
- pthread_mutex_lock (&(rwl->mtxSharedAccessCompleted))) != 0)
- {
- (void) pthread_mutex_unlock (&(rwl->mtxExclusiveAccess));
- return result;
- }
-
- rwl->nSharedAccessCount -= rwl->nCompletedSharedAccessCount;
- rwl->nCompletedSharedAccessCount = 0;
-
- if ((result =
- pthread_mutex_unlock (&(rwl->mtxSharedAccessCompleted))) != 0)
- {
- (void) pthread_mutex_unlock (&(rwl->mtxExclusiveAccess));
- return result;
- }
- }
-
- return (pthread_mutex_unlock (&(rwl->mtxExclusiveAccess)));
-}
+/*
+ * pthread_rwlock_rdlock.c
+ *
+ * Description:
+ * This translation unit implements read/write lock primitives.
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads-win32 - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * http://sources.redhat.com/pthreads-win32/contributors.html
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <limits.h>
+
+#include "pthread.h"
+#include "implement.h"
+
+int
+pthread_rwlock_rdlock (pthread_rwlock_t * rwlock)
+{
+ int result;
+ pthread_rwlock_t rwl;
+
+ if (rwlock == NULL || *rwlock == NULL)
+ {
+ return EINVAL;
+ }
+
+ /*
+ * We do a quick check to see if we need to do more work
+ * to initialise a static rwlock. We check
+ * again inside the guarded section of ptw32_rwlock_check_need_init()
+ * to avoid race conditions.
+ */
+ if (*rwlock == PTHREAD_RWLOCK_INITIALIZER)
+ {
+ result = ptw32_rwlock_check_need_init (rwlock);
+
+ if (result != 0 && result != EBUSY)
+ {
+ return result;
+ }
+ }
+
+ rwl = *rwlock;
+
+ if (rwl->nMagic != PTW32_RWLOCK_MAGIC)
+ {
+ return EINVAL;
+ }
+
+ if ((result = pthread_mutex_lock (&(rwl->mtxExclusiveAccess))) != 0)
+ {
+ return result;
+ }
+
+ if (++rwl->nSharedAccessCount == INT_MAX)
+ {
+ if ((result =
+ pthread_mutex_lock (&(rwl->mtxSharedAccessCompleted))) != 0)
+ {
+ (void) pthread_mutex_unlock (&(rwl->mtxExclusiveAccess));
+ return result;
+ }
+
+ rwl->nSharedAccessCount -= rwl->nCompletedSharedAccessCount;
+ rwl->nCompletedSharedAccessCount = 0;
+
+ if ((result =
+ pthread_mutex_unlock (&(rwl->mtxSharedAccessCompleted))) != 0)
+ {
+ (void) pthread_mutex_unlock (&(rwl->mtxExclusiveAccess));
+ return result;
+ }
+ }
+
+ return (pthread_mutex_unlock (&(rwl->mtxExclusiveAccess)));
+}
diff --git a/pthreads/pthread_rwlock_timedrdlock.c b/pthreads/pthread_rwlock_timedrdlock.c
index d46998628..ed281f3d2 100644
--- a/pthreads/pthread_rwlock_timedrdlock.c
+++ b/pthreads/pthread_rwlock_timedrdlock.c
@@ -1,109 +1,114 @@
-/*
- * pthread_rwlock_timedrdlock.c
- *
- * Description:
- * This translation unit implements read/write lock primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include <limits.h>
-
-#include "pthread.h"
-#include "implement.h"
-
-int
-pthread_rwlock_timedrdlock (pthread_rwlock_t * rwlock,
- const struct timespec *abstime)
-{
- int result;
- pthread_rwlock_t rwl;
-
- if (rwlock == NULL || *rwlock == NULL)
- {
- return EINVAL;
- }
-
- /*
- * We do a quick check to see if we need to do more work
- * to initialise a static rwlock. We check
- * again inside the guarded section of ptw32_rwlock_check_need_init()
- * to avoid race conditions.
- */
- if (*rwlock == PTHREAD_RWLOCK_INITIALIZER)
- {
- result = ptw32_rwlock_check_need_init (rwlock);
-
- if (result != 0 && result != EBUSY)
- {
- return result;
- }
- }
-
- rwl = *rwlock;
-
- if (rwl->nMagic != PTW32_RWLOCK_MAGIC)
- {
- return EINVAL;
- }
-
- if ((result =
- pthread_mutex_timedlock (&(rwl->mtxExclusiveAccess), abstime)) != 0)
- {
- return result;
- }
-
- if (++rwl->nSharedAccessCount == INT_MAX)
- {
- if ((result =
- pthread_mutex_timedlock (&(rwl->mtxSharedAccessCompleted),
- abstime)) != 0)
- {
- if (result == ETIMEDOUT)
- {
- ++rwl->nCompletedSharedAccessCount;
- }
- (void) pthread_mutex_unlock (&(rwl->mtxExclusiveAccess));
- return result;
- }
-
- rwl->nSharedAccessCount -= rwl->nCompletedSharedAccessCount;
- rwl->nCompletedSharedAccessCount = 0;
-
- if ((result =
- pthread_mutex_unlock (&(rwl->mtxSharedAccessCompleted))) != 0)
- {
- (void) pthread_mutex_unlock (&(rwl->mtxExclusiveAccess));
- return result;
- }
- }
-
- return (pthread_mutex_unlock (&(rwl->mtxExclusiveAccess)));
-}
+/*
+ * pthread_rwlock_timedrdlock.c
+ *
+ * Description:
+ * This translation unit implements read/write lock primitives.
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads-win32 - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * http://sources.redhat.com/pthreads-win32/contributors.html
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <limits.h>
+
+#include "pthread.h"
+#include "implement.h"
+
+int
+pthread_rwlock_timedrdlock (pthread_rwlock_t * rwlock,
+ const struct timespec *abstime)
+{
+ int result;
+ pthread_rwlock_t rwl;
+
+ if (rwlock == NULL || *rwlock == NULL)
+ {
+ return EINVAL;
+ }
+
+ /*
+ * We do a quick check to see if we need to do more work
+ * to initialise a static rwlock. We check
+ * again inside the guarded section of ptw32_rwlock_check_need_init()
+ * to avoid race conditions.
+ */
+ if (*rwlock == PTHREAD_RWLOCK_INITIALIZER)
+ {
+ result = ptw32_rwlock_check_need_init (rwlock);
+
+ if (result != 0 && result != EBUSY)
+ {
+ return result;
+ }
+ }
+
+ rwl = *rwlock;
+
+ if (rwl->nMagic != PTW32_RWLOCK_MAGIC)
+ {
+ return EINVAL;
+ }
+
+ if ((result =
+ pthread_mutex_timedlock (&(rwl->mtxExclusiveAccess), abstime)) != 0)
+ {
+ return result;
+ }
+
+ if (++rwl->nSharedAccessCount == INT_MAX)
+ {
+ if ((result =
+ pthread_mutex_timedlock (&(rwl->mtxSharedAccessCompleted),
+ abstime)) != 0)
+ {
+ if (result == ETIMEDOUT)
+ {
+ ++rwl->nCompletedSharedAccessCount;
+ }
+ (void) pthread_mutex_unlock (&(rwl->mtxExclusiveAccess));
+ return result;
+ }
+
+ rwl->nSharedAccessCount -= rwl->nCompletedSharedAccessCount;
+ rwl->nCompletedSharedAccessCount = 0;
+
+ if ((result =
+ pthread_mutex_unlock (&(rwl->mtxSharedAccessCompleted))) != 0)
+ {
+ (void) pthread_mutex_unlock (&(rwl->mtxExclusiveAccess));
+ return result;
+ }
+ }
+
+ return (pthread_mutex_unlock (&(rwl->mtxExclusiveAccess)));
+}
diff --git a/pthreads/pthread_rwlock_timedwrlock.c b/pthreads/pthread_rwlock_timedwrlock.c
index 8c111bbb1..7622d97f8 100644
--- a/pthreads/pthread_rwlock_timedwrlock.c
+++ b/pthreads/pthread_rwlock_timedwrlock.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include <limits.h>
#include "pthread.h"
@@ -101,10 +106,10 @@ pthread_rwlock_timedwrlock (pthread_rwlock_t * rwlock,
rwl->nCompletedSharedAccessCount = -rwl->nSharedAccessCount;
/*
- * This routine may be a cancelation point
+ * This routine may be a cancellation point
* according to POSIX 1003.1j section 18.1.2.
*/
-#if defined(_MSC_VER) && _MSC_VER < 1400
+#if defined(PTW32_CONFIG_MSVC7)
#pragma inline_depth(0)
#endif
pthread_cleanup_push (ptw32_rwlock_cancelwrwait, (void *) rwl);
@@ -119,7 +124,7 @@ pthread_rwlock_timedwrlock (pthread_rwlock_t * rwlock,
while (result == 0 && rwl->nCompletedSharedAccessCount < 0);
pthread_cleanup_pop ((result != 0) ? 1 : 0);
-#if defined(_MSC_VER) && _MSC_VER < 1400
+#if defined(PTW32_CONFIG_MSVC7)
#pragma inline_depth()
#endif
diff --git a/pthreads/pthread_rwlock_tryrdlock.c b/pthreads/pthread_rwlock_tryrdlock.c
index 95dcca507..5660b5ad5 100644
--- a/pthreads/pthread_rwlock_tryrdlock.c
+++ b/pthreads/pthread_rwlock_tryrdlock.c
@@ -1,102 +1,107 @@
-/*
- * pthread_rwlock_tryrdlock.c
- *
- * Description:
- * This translation unit implements read/write lock primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include <limits.h>
-
-#include "pthread.h"
-#include "implement.h"
-
-int
-pthread_rwlock_tryrdlock (pthread_rwlock_t * rwlock)
-{
- int result;
- pthread_rwlock_t rwl;
-
- if (rwlock == NULL || *rwlock == NULL)
- {
- return EINVAL;
- }
-
- /*
- * We do a quick check to see if we need to do more work
- * to initialise a static rwlock. We check
- * again inside the guarded section of ptw32_rwlock_check_need_init()
- * to avoid race conditions.
- */
- if (*rwlock == PTHREAD_RWLOCK_INITIALIZER)
- {
- result = ptw32_rwlock_check_need_init (rwlock);
-
- if (result != 0 && result != EBUSY)
- {
- return result;
- }
- }
-
- rwl = *rwlock;
-
- if (rwl->nMagic != PTW32_RWLOCK_MAGIC)
- {
- return EINVAL;
- }
-
- if ((result = pthread_mutex_trylock (&(rwl->mtxExclusiveAccess))) != 0)
- {
- return result;
- }
-
- if (++rwl->nSharedAccessCount == INT_MAX)
- {
- if ((result =
- pthread_mutex_lock (&(rwl->mtxSharedAccessCompleted))) != 0)
- {
- (void) pthread_mutex_unlock (&(rwl->mtxExclusiveAccess));
- return result;
- }
-
- rwl->nSharedAccessCount -= rwl->nCompletedSharedAccessCount;
- rwl->nCompletedSharedAccessCount = 0;
-
- if ((result =
- pthread_mutex_unlock (&(rwl->mtxSharedAccessCompleted))) != 0)
- {
- (void) pthread_mutex_unlock (&(rwl->mtxExclusiveAccess));
- return result;
- }
- }
-
- return (pthread_mutex_unlock (&rwl->mtxExclusiveAccess));
-}
+/*
+ * pthread_rwlock_tryrdlock.c
+ *
+ * Description:
+ * This translation unit implements read/write lock primitives.
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads-win32 - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * http://sources.redhat.com/pthreads-win32/contributors.html
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <limits.h>
+
+#include "pthread.h"
+#include "implement.h"
+
+int
+pthread_rwlock_tryrdlock (pthread_rwlock_t * rwlock)
+{
+ int result;
+ pthread_rwlock_t rwl;
+
+ if (rwlock == NULL || *rwlock == NULL)
+ {
+ return EINVAL;
+ }
+
+ /*
+ * We do a quick check to see if we need to do more work
+ * to initialise a static rwlock. We check
+ * again inside the guarded section of ptw32_rwlock_check_need_init()
+ * to avoid race conditions.
+ */
+ if (*rwlock == PTHREAD_RWLOCK_INITIALIZER)
+ {
+ result = ptw32_rwlock_check_need_init (rwlock);
+
+ if (result != 0 && result != EBUSY)
+ {
+ return result;
+ }
+ }
+
+ rwl = *rwlock;
+
+ if (rwl->nMagic != PTW32_RWLOCK_MAGIC)
+ {
+ return EINVAL;
+ }
+
+ if ((result = pthread_mutex_trylock (&(rwl->mtxExclusiveAccess))) != 0)
+ {
+ return result;
+ }
+
+ if (++rwl->nSharedAccessCount == INT_MAX)
+ {
+ if ((result =
+ pthread_mutex_lock (&(rwl->mtxSharedAccessCompleted))) != 0)
+ {
+ (void) pthread_mutex_unlock (&(rwl->mtxExclusiveAccess));
+ return result;
+ }
+
+ rwl->nSharedAccessCount -= rwl->nCompletedSharedAccessCount;
+ rwl->nCompletedSharedAccessCount = 0;
+
+ if ((result =
+ pthread_mutex_unlock (&(rwl->mtxSharedAccessCompleted))) != 0)
+ {
+ (void) pthread_mutex_unlock (&(rwl->mtxExclusiveAccess));
+ return result;
+ }
+ }
+
+ return (pthread_mutex_unlock (&rwl->mtxExclusiveAccess));
+}
diff --git a/pthreads/pthread_rwlock_trywrlock.c b/pthreads/pthread_rwlock_trywrlock.c
index 3c6fccaa1..f12df055f 100644
--- a/pthreads/pthread_rwlock_trywrlock.c
+++ b/pthreads/pthread_rwlock_trywrlock.c
@@ -1,122 +1,127 @@
-/*
- * pthread_rwlock_trywrlock.c
- *
- * Description:
- * This translation unit implements read/write lock primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include <limits.h>
-
-#include "pthread.h"
-#include "implement.h"
-
-int
-pthread_rwlock_trywrlock (pthread_rwlock_t * rwlock)
-{
- int result, result1;
- pthread_rwlock_t rwl;
-
- if (rwlock == NULL || *rwlock == NULL)
- {
- return EINVAL;
- }
-
- /*
- * We do a quick check to see if we need to do more work
- * to initialise a static rwlock. We check
- * again inside the guarded section of ptw32_rwlock_check_need_init()
- * to avoid race conditions.
- */
- if (*rwlock == PTHREAD_RWLOCK_INITIALIZER)
- {
- result = ptw32_rwlock_check_need_init (rwlock);
-
- if (result != 0 && result != EBUSY)
- {
- return result;
- }
- }
-
- rwl = *rwlock;
-
- if (rwl->nMagic != PTW32_RWLOCK_MAGIC)
- {
- return EINVAL;
- }
-
- if ((result = pthread_mutex_trylock (&(rwl->mtxExclusiveAccess))) != 0)
- {
- return result;
- }
-
- if ((result =
- pthread_mutex_trylock (&(rwl->mtxSharedAccessCompleted))) != 0)
- {
- result1 = pthread_mutex_unlock (&(rwl->mtxExclusiveAccess));
- return ((result1 != 0) ? result1 : result);
- }
-
- if (rwl->nExclusiveAccessCount == 0)
- {
- if (rwl->nCompletedSharedAccessCount > 0)
- {
- rwl->nSharedAccessCount -= rwl->nCompletedSharedAccessCount;
- rwl->nCompletedSharedAccessCount = 0;
- }
-
- if (rwl->nSharedAccessCount > 0)
- {
- if ((result =
- pthread_mutex_unlock (&(rwl->mtxSharedAccessCompleted))) != 0)
- {
- (void) pthread_mutex_unlock (&(rwl->mtxExclusiveAccess));
- return result;
- }
-
- if ((result =
- pthread_mutex_unlock (&(rwl->mtxExclusiveAccess))) == 0)
- {
- result = EBUSY;
- }
- }
- else
- {
- rwl->nExclusiveAccessCount = 1;
- }
- }
- else
- {
- result = EBUSY;
- }
-
- return result;
-}
+/*
+ * pthread_rwlock_trywrlock.c
+ *
+ * Description:
+ * This translation unit implements read/write lock primitives.
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads-win32 - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * http://sources.redhat.com/pthreads-win32/contributors.html
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <limits.h>
+
+#include "pthread.h"
+#include "implement.h"
+
+int
+pthread_rwlock_trywrlock (pthread_rwlock_t * rwlock)
+{
+ int result, result1;
+ pthread_rwlock_t rwl;
+
+ if (rwlock == NULL || *rwlock == NULL)
+ {
+ return EINVAL;
+ }
+
+ /*
+ * We do a quick check to see if we need to do more work
+ * to initialise a static rwlock. We check
+ * again inside the guarded section of ptw32_rwlock_check_need_init()
+ * to avoid race conditions.
+ */
+ if (*rwlock == PTHREAD_RWLOCK_INITIALIZER)
+ {
+ result = ptw32_rwlock_check_need_init (rwlock);
+
+ if (result != 0 && result != EBUSY)
+ {
+ return result;
+ }
+ }
+
+ rwl = *rwlock;
+
+ if (rwl->nMagic != PTW32_RWLOCK_MAGIC)
+ {
+ return EINVAL;
+ }
+
+ if ((result = pthread_mutex_trylock (&(rwl->mtxExclusiveAccess))) != 0)
+ {
+ return result;
+ }
+
+ if ((result =
+ pthread_mutex_trylock (&(rwl->mtxSharedAccessCompleted))) != 0)
+ {
+ result1 = pthread_mutex_unlock (&(rwl->mtxExclusiveAccess));
+ return ((result1 != 0) ? result1 : result);
+ }
+
+ if (rwl->nExclusiveAccessCount == 0)
+ {
+ if (rwl->nCompletedSharedAccessCount > 0)
+ {
+ rwl->nSharedAccessCount -= rwl->nCompletedSharedAccessCount;
+ rwl->nCompletedSharedAccessCount = 0;
+ }
+
+ if (rwl->nSharedAccessCount > 0)
+ {
+ if ((result =
+ pthread_mutex_unlock (&(rwl->mtxSharedAccessCompleted))) != 0)
+ {
+ (void) pthread_mutex_unlock (&(rwl->mtxExclusiveAccess));
+ return result;
+ }
+
+ if ((result =
+ pthread_mutex_unlock (&(rwl->mtxExclusiveAccess))) == 0)
+ {
+ result = EBUSY;
+ }
+ }
+ else
+ {
+ rwl->nExclusiveAccessCount = 1;
+ }
+ }
+ else
+ {
+ result = EBUSY;
+ }
+
+ return result;
+}
diff --git a/pthreads/pthread_rwlock_unlock.c b/pthreads/pthread_rwlock_unlock.c
index 4a9db569f..63feac3ea 100644
--- a/pthreads/pthread_rwlock_unlock.c
+++ b/pthreads/pthread_rwlock_unlock.c
@@ -1,93 +1,98 @@
-/*
- * pthread_rwlock_unlock.c
- *
- * Description:
- * This translation unit implements read/write lock primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include <limits.h>
-
-#include "pthread.h"
-#include "implement.h"
-
-int
-pthread_rwlock_unlock (pthread_rwlock_t * rwlock)
-{
- int result, result1;
- pthread_rwlock_t rwl;
-
- if (rwlock == NULL || *rwlock == NULL)
- {
- return (EINVAL);
- }
-
- if (*rwlock == PTHREAD_RWLOCK_INITIALIZER)
- {
- /*
- * Assume any race condition here is harmless.
- */
- return 0;
- }
-
- rwl = *rwlock;
-
- if (rwl->nMagic != PTW32_RWLOCK_MAGIC)
- {
- return EINVAL;
- }
-
- if (rwl->nExclusiveAccessCount == 0)
- {
- if ((result =
- pthread_mutex_lock (&(rwl->mtxSharedAccessCompleted))) != 0)
- {
- return result;
- }
-
- if (++rwl->nCompletedSharedAccessCount == 0)
- {
- result = pthread_cond_signal (&(rwl->cndSharedAccessCompleted));
- }
-
- result1 = pthread_mutex_unlock (&(rwl->mtxSharedAccessCompleted));
- }
- else
- {
- rwl->nExclusiveAccessCount--;
-
- result = pthread_mutex_unlock (&(rwl->mtxSharedAccessCompleted));
- result1 = pthread_mutex_unlock (&(rwl->mtxExclusiveAccess));
-
- }
-
- return ((result != 0) ? result : result1);
-}
+/*
+ * pthread_rwlock_unlock.c
+ *
+ * Description:
+ * This translation unit implements read/write lock primitives.
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads-win32 - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * http://sources.redhat.com/pthreads-win32/contributors.html
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <limits.h>
+
+#include "pthread.h"
+#include "implement.h"
+
+int
+pthread_rwlock_unlock (pthread_rwlock_t * rwlock)
+{
+ int result, result1;
+ pthread_rwlock_t rwl;
+
+ if (rwlock == NULL || *rwlock == NULL)
+ {
+ return (EINVAL);
+ }
+
+ if (*rwlock == PTHREAD_RWLOCK_INITIALIZER)
+ {
+ /*
+ * Assume any race condition here is harmless.
+ */
+ return 0;
+ }
+
+ rwl = *rwlock;
+
+ if (rwl->nMagic != PTW32_RWLOCK_MAGIC)
+ {
+ return EINVAL;
+ }
+
+ if (rwl->nExclusiveAccessCount == 0)
+ {
+ if ((result =
+ pthread_mutex_lock (&(rwl->mtxSharedAccessCompleted))) != 0)
+ {
+ return result;
+ }
+
+ if (++rwl->nCompletedSharedAccessCount == 0)
+ {
+ result = pthread_cond_signal (&(rwl->cndSharedAccessCompleted));
+ }
+
+ result1 = pthread_mutex_unlock (&(rwl->mtxSharedAccessCompleted));
+ }
+ else
+ {
+ rwl->nExclusiveAccessCount--;
+
+ result = pthread_mutex_unlock (&(rwl->mtxSharedAccessCompleted));
+ result1 = pthread_mutex_unlock (&(rwl->mtxExclusiveAccess));
+
+ }
+
+ return ((result != 0) ? result : result1);
+}
diff --git a/pthreads/pthread_rwlock_wrlock.c b/pthreads/pthread_rwlock_wrlock.c
index e8b4fbb30..722a673f7 100644
--- a/pthreads/pthread_rwlock_wrlock.c
+++ b/pthreads/pthread_rwlock_wrlock.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include <limits.h>
#include "pthread.h"
@@ -97,10 +102,10 @@ pthread_rwlock_wrlock (pthread_rwlock_t * rwlock)
rwl->nCompletedSharedAccessCount = -rwl->nSharedAccessCount;
/*
- * This routine may be a cancelation point
+ * This routine may be a cancellation point
* according to POSIX 1003.1j section 18.1.2.
*/
-#if defined(_MSC_VER) && _MSC_VER < 1400
+#if defined(PTW32_CONFIG_MSVC7)
#pragma inline_depth(0)
#endif
pthread_cleanup_push (ptw32_rwlock_cancelwrwait, (void *) rwl);
@@ -113,7 +118,7 @@ pthread_rwlock_wrlock (pthread_rwlock_t * rwlock)
while (result == 0 && rwl->nCompletedSharedAccessCount < 0);
pthread_cleanup_pop ((result != 0) ? 1 : 0);
-#if defined(_MSC_VER) && _MSC_VER < 1400
+#if defined(PTW32_CONFIG_MSVC7)
#pragma inline_depth()
#endif
diff --git a/pthreads/pthread_rwlockattr_destroy.c b/pthreads/pthread_rwlockattr_destroy.c
index 1e0aa2fdc..e9e3407b7 100644
--- a/pthreads/pthread_rwlockattr_destroy.c
+++ b/pthreads/pthread_rwlockattr_destroy.c
@@ -1,84 +1,89 @@
-/*
- * pthread_rwlockattr_destroy.c
- *
- * Description:
- * This translation unit implements read/write lock primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include <limits.h>
-
-#include "pthread.h"
-#include "implement.h"
-
-int
-pthread_rwlockattr_destroy (pthread_rwlockattr_t * attr)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * Destroys a rwlock attributes object. The object can
- * no longer be used.
- *
- * PARAMETERS
- * attr
- * pointer to an instance of pthread_rwlockattr_t
- *
- *
- * DESCRIPTION
- * Destroys a rwlock attributes object. The object can
- * no longer be used.
- *
- * NOTES:
- * 1) Does not affect rwlockss created using 'attr'
- *
- * RESULTS
- * 0 successfully released attr,
- * EINVAL 'attr' is invalid.
- *
- * ------------------------------------------------------
- */
-{
- int result = 0;
-
- if (attr == NULL || *attr == NULL)
- {
- result = EINVAL;
- }
- else
- {
- pthread_rwlockattr_t rwa = *attr;
-
- *attr = NULL;
- free (rwa);
- }
-
- return (result);
-} /* pthread_rwlockattr_destroy */
+/*
+ * pthread_rwlockattr_destroy.c
+ *
+ * Description:
+ * This translation unit implements read/write lock primitives.
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads-win32 - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * http://sources.redhat.com/pthreads-win32/contributors.html
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <limits.h>
+
+#include "pthread.h"
+#include "implement.h"
+
+int
+pthread_rwlockattr_destroy (pthread_rwlockattr_t * attr)
+ /*
+ * ------------------------------------------------------
+ * DOCPUBLIC
+ * Destroys a rwlock attributes object. The object can
+ * no longer be used.
+ *
+ * PARAMETERS
+ * attr
+ * pointer to an instance of pthread_rwlockattr_t
+ *
+ *
+ * DESCRIPTION
+ * Destroys a rwlock attributes object. The object can
+ * no longer be used.
+ *
+ * NOTES:
+ * 1) Does not affect rwlockss created using 'attr'
+ *
+ * RESULTS
+ * 0 successfully released attr,
+ * EINVAL 'attr' is invalid.
+ *
+ * ------------------------------------------------------
+ */
+{
+ int result = 0;
+
+ if (attr == NULL || *attr == NULL)
+ {
+ result = EINVAL;
+ }
+ else
+ {
+ pthread_rwlockattr_t rwa = *attr;
+
+ *attr = NULL;
+ free (rwa);
+ }
+
+ return (result);
+} /* pthread_rwlockattr_destroy */
diff --git a/pthreads/pthread_rwlockattr_getpshared.c b/pthreads/pthread_rwlockattr_getpshared.c
index 1198e4808..4de7d30ea 100644
--- a/pthreads/pthread_rwlockattr_getpshared.c
+++ b/pthreads/pthread_rwlockattr_getpshared.c
@@ -1,97 +1,102 @@
-/*
- * pthread_rwlockattr_getpshared.c
- *
- * Description:
- * This translation unit implements read/write lock primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include <limits.h>
-
-#include "pthread.h"
-#include "implement.h"
-
-int
-pthread_rwlockattr_getpshared (const pthread_rwlockattr_t * attr,
- int *pshared)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * Determine whether rwlocks created with 'attr' can be
- * shared between processes.
- *
- * PARAMETERS
- * attr
- * pointer to an instance of pthread_rwlockattr_t
- *
- * pshared
- * will be set to one of:
- *
- * PTHREAD_PROCESS_SHARED
- * May be shared if in shared memory
- *
- * PTHREAD_PROCESS_PRIVATE
- * Cannot be shared.
- *
- *
- * DESCRIPTION
- * Rwlocks creatd with 'attr' can be shared between
- * processes if pthread_rwlock_t variable is allocated
- * in memory shared by these processes.
- * NOTES:
- * 1) pshared rwlocks MUST be allocated in shared
- * memory.
- * 2) The following macro is defined if shared rwlocks
- * are supported:
- * _POSIX_THREAD_PROCESS_SHARED
- *
- * RESULTS
- * 0 successfully retrieved attribute,
- * EINVAL 'attr' is invalid,
- *
- * ------------------------------------------------------
- */
-{
- int result;
-
- if ((attr != NULL && *attr != NULL) && (pshared != NULL))
- {
- *pshared = (*attr)->pshared;
- result = 0;
- }
- else
- {
- result = EINVAL;
- }
-
- return (result);
-
-} /* pthread_rwlockattr_getpshared */
+/*
+ * pthread_rwlockattr_getpshared.c
+ *
+ * Description:
+ * This translation unit implements read/write lock primitives.
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads-win32 - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * http://sources.redhat.com/pthreads-win32/contributors.html
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <limits.h>
+
+#include "pthread.h"
+#include "implement.h"
+
+int
+pthread_rwlockattr_getpshared (const pthread_rwlockattr_t * attr,
+ int *pshared)
+ /*
+ * ------------------------------------------------------
+ * DOCPUBLIC
+ * Determine whether rwlocks created with 'attr' can be
+ * shared between processes.
+ *
+ * PARAMETERS
+ * attr
+ * pointer to an instance of pthread_rwlockattr_t
+ *
+ * pshared
+ * will be set to one of:
+ *
+ * PTHREAD_PROCESS_SHARED
+ * May be shared if in shared memory
+ *
+ * PTHREAD_PROCESS_PRIVATE
+ * Cannot be shared.
+ *
+ *
+ * DESCRIPTION
+ * Rwlocks creatd with 'attr' can be shared between
+ * processes if pthread_rwlock_t variable is allocated
+ * in memory shared by these processes.
+ * NOTES:
+ * 1) pshared rwlocks MUST be allocated in shared
+ * memory.
+ * 2) The following macro is defined if shared rwlocks
+ * are supported:
+ * _POSIX_THREAD_PROCESS_SHARED
+ *
+ * RESULTS
+ * 0 successfully retrieved attribute,
+ * EINVAL 'attr' is invalid,
+ *
+ * ------------------------------------------------------
+ */
+{
+ int result;
+
+ if ((attr != NULL && *attr != NULL) && (pshared != NULL))
+ {
+ *pshared = (*attr)->pshared;
+ result = 0;
+ }
+ else
+ {
+ result = EINVAL;
+ }
+
+ return (result);
+
+} /* pthread_rwlockattr_getpshared */
diff --git a/pthreads/pthread_rwlockattr_init.c b/pthreads/pthread_rwlockattr_init.c
index 6edbbb6a7..994b7ec04 100644
--- a/pthreads/pthread_rwlockattr_init.c
+++ b/pthreads/pthread_rwlockattr_init.c
@@ -1,83 +1,88 @@
-/*
- * pthread_rwlockattr_init.c
- *
- * Description:
- * This translation unit implements read/write lock primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include <limits.h>
-
-#include "pthread.h"
-#include "implement.h"
-
-int
-pthread_rwlockattr_init (pthread_rwlockattr_t * attr)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * Initializes a rwlock attributes object with default
- * attributes.
- *
- * PARAMETERS
- * attr
- * pointer to an instance of pthread_rwlockattr_t
- *
- *
- * DESCRIPTION
- * Initializes a rwlock attributes object with default
- * attributes.
- *
- * RESULTS
- * 0 successfully initialized attr,
- * ENOMEM insufficient memory for attr.
- *
- * ------------------------------------------------------
- */
-{
- int result = 0;
- pthread_rwlockattr_t rwa;
-
- rwa = (pthread_rwlockattr_t) calloc (1, sizeof (*rwa));
-
- if (rwa == NULL)
- {
- result = ENOMEM;
- }
- else
- {
- rwa->pshared = PTHREAD_PROCESS_PRIVATE;
- }
-
- *attr = rwa;
-
- return (result);
-} /* pthread_rwlockattr_init */
+/*
+ * pthread_rwlockattr_init.c
+ *
+ * Description:
+ * This translation unit implements read/write lock primitives.
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads-win32 - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * http://sources.redhat.com/pthreads-win32/contributors.html
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <limits.h>
+
+#include "pthread.h"
+#include "implement.h"
+
+int
+pthread_rwlockattr_init (pthread_rwlockattr_t * attr)
+ /*
+ * ------------------------------------------------------
+ * DOCPUBLIC
+ * Initializes a rwlock attributes object with default
+ * attributes.
+ *
+ * PARAMETERS
+ * attr
+ * pointer to an instance of pthread_rwlockattr_t
+ *
+ *
+ * DESCRIPTION
+ * Initializes a rwlock attributes object with default
+ * attributes.
+ *
+ * RESULTS
+ * 0 successfully initialized attr,
+ * ENOMEM insufficient memory for attr.
+ *
+ * ------------------------------------------------------
+ */
+{
+ int result = 0;
+ pthread_rwlockattr_t rwa;
+
+ rwa = (pthread_rwlockattr_t) calloc (1, sizeof (*rwa));
+
+ if (rwa == NULL)
+ {
+ result = ENOMEM;
+ }
+ else
+ {
+ rwa->pshared = PTHREAD_PROCESS_PRIVATE;
+ }
+
+ *attr = rwa;
+
+ return (result);
+} /* pthread_rwlockattr_init */
diff --git a/pthreads/pthread_rwlockattr_setpshared.c b/pthreads/pthread_rwlockattr_setpshared.c
index 76d71fabe..0263c11f9 100644
--- a/pthreads/pthread_rwlockattr_setpshared.c
+++ b/pthreads/pthread_rwlockattr_setpshared.c
@@ -1,120 +1,125 @@
-/*
- * pthread_rwlockattr_setpshared.c
- *
- * Description:
- * This translation unit implements read/write lock primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include <limits.h>
-
-#include "pthread.h"
-#include "implement.h"
-
-int
-pthread_rwlockattr_setpshared (pthread_rwlockattr_t * attr, int pshared)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * Rwlocks created with 'attr' can be shared between
- * processes if pthread_rwlock_t variable is allocated
- * in memory shared by these processes.
- *
- * PARAMETERS
- * attr
- * pointer to an instance of pthread_rwlockattr_t
- *
- * pshared
- * must be one of:
- *
- * PTHREAD_PROCESS_SHARED
- * May be shared if in shared memory
- *
- * PTHREAD_PROCESS_PRIVATE
- * Cannot be shared.
- *
- * DESCRIPTION
- * Rwlocks creatd with 'attr' can be shared between
- * processes if pthread_rwlock_t variable is allocated
- * in memory shared by these processes.
- *
- * NOTES:
- * 1) pshared rwlocks MUST be allocated in shared
- * memory.
- *
- * 2) The following macro is defined if shared rwlocks
- * are supported:
- * _POSIX_THREAD_PROCESS_SHARED
- *
- * RESULTS
- * 0 successfully set attribute,
- * EINVAL 'attr' or pshared is invalid,
- * ENOSYS PTHREAD_PROCESS_SHARED not supported,
- *
- * ------------------------------------------------------
- */
-{
- int result;
-
- if ((attr != NULL && *attr != NULL) &&
- ((pshared == PTHREAD_PROCESS_SHARED) ||
- (pshared == PTHREAD_PROCESS_PRIVATE)))
- {
- if (pshared == PTHREAD_PROCESS_SHARED)
- {
-
-#if !defined( _POSIX_THREAD_PROCESS_SHARED )
-
- result = ENOSYS;
- pshared = PTHREAD_PROCESS_PRIVATE;
-
-#else
-
- result = 0;
-
-#endif /* _POSIX_THREAD_PROCESS_SHARED */
-
- }
- else
- {
- result = 0;
- }
-
- (*attr)->pshared = pshared;
- }
- else
- {
- result = EINVAL;
- }
-
- return (result);
-
-} /* pthread_rwlockattr_setpshared */
+/*
+ * pthread_rwlockattr_setpshared.c
+ *
+ * Description:
+ * This translation unit implements read/write lock primitives.
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads-win32 - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * http://sources.redhat.com/pthreads-win32/contributors.html
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <limits.h>
+
+#include "pthread.h"
+#include "implement.h"
+
+int
+pthread_rwlockattr_setpshared (pthread_rwlockattr_t * attr, int pshared)
+ /*
+ * ------------------------------------------------------
+ * DOCPUBLIC
+ * Rwlocks created with 'attr' can be shared between
+ * processes if pthread_rwlock_t variable is allocated
+ * in memory shared by these processes.
+ *
+ * PARAMETERS
+ * attr
+ * pointer to an instance of pthread_rwlockattr_t
+ *
+ * pshared
+ * must be one of:
+ *
+ * PTHREAD_PROCESS_SHARED
+ * May be shared if in shared memory
+ *
+ * PTHREAD_PROCESS_PRIVATE
+ * Cannot be shared.
+ *
+ * DESCRIPTION
+ * Rwlocks creatd with 'attr' can be shared between
+ * processes if pthread_rwlock_t variable is allocated
+ * in memory shared by these processes.
+ *
+ * NOTES:
+ * 1) pshared rwlocks MUST be allocated in shared
+ * memory.
+ *
+ * 2) The following macro is defined if shared rwlocks
+ * are supported:
+ * _POSIX_THREAD_PROCESS_SHARED
+ *
+ * RESULTS
+ * 0 successfully set attribute,
+ * EINVAL 'attr' or pshared is invalid,
+ * ENOSYS PTHREAD_PROCESS_SHARED not supported,
+ *
+ * ------------------------------------------------------
+ */
+{
+ int result;
+
+ if ((attr != NULL && *attr != NULL) &&
+ ((pshared == PTHREAD_PROCESS_SHARED) ||
+ (pshared == PTHREAD_PROCESS_PRIVATE)))
+ {
+ if (pshared == PTHREAD_PROCESS_SHARED)
+ {
+
+#if !defined( _POSIX_THREAD_PROCESS_SHARED )
+
+ result = ENOSYS;
+ pshared = PTHREAD_PROCESS_PRIVATE;
+
+#else
+
+ result = 0;
+
+#endif /* _POSIX_THREAD_PROCESS_SHARED */
+
+ }
+ else
+ {
+ result = 0;
+ }
+
+ (*attr)->pshared = pshared;
+ }
+ else
+ {
+ result = EINVAL;
+ }
+
+ return (result);
+
+} /* pthread_rwlockattr_setpshared */
diff --git a/pthreads/pthread_self.c b/pthreads/pthread_self.c
index 9a1765f82..ad4e989db 100644
--- a/pthreads/pthread_self.c
+++ b/pthreads/pthread_self.c
@@ -8,32 +8,37 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
* http://sources.redhat.com/pthreads-win32/contributors.html
- *
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library in the file COPYING.LIB;
* if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
@@ -60,6 +65,7 @@ pthread_self (void)
*/
{
pthread_t self;
+ DWORD_PTR vThreadMask, vProcessMask, vSystemMask;
pthread_t nil = {NULL, 0};
ptw32_thread_t * sp;
@@ -76,6 +82,7 @@ pthread_self (void)
}
else
{
+ int fail = PTW32_FALSE;
/*
* Need to create an implicit 'self' for the currently
* executing thread.
@@ -84,58 +91,83 @@ pthread_self (void)
sp = (ptw32_thread_t *) self.p;
if (sp != NULL)
- {
- /*
- * This is a non-POSIX thread which has chosen to call
- * a POSIX threads function for some reason. We assume that
- * it isn't joinable, but we do assume that it's
- * (deferred) cancelable.
- */
- sp->implicit = 1;
- sp->detachState = PTHREAD_CREATE_DETACHED;
- sp->thread = GetCurrentThreadId ();
+ {
+ /*
+ * This is a non-POSIX thread which has chosen to call
+ * a POSIX threads function for some reason. We assume that
+ * it isn't joinable, but we do assume that it's
+ * (deferred) cancelable.
+ */
+ sp->implicit = 1;
+ sp->detachState = PTHREAD_CREATE_DETACHED;
+ sp->thread = GetCurrentThreadId ();
#if defined(NEED_DUPLICATEHANDLE)
- /*
- * DuplicateHandle does not exist on WinCE.
- *
- * NOTE:
- * GetCurrentThread only returns a pseudo-handle
- * which is only valid in the current thread context.
- * Therefore, you should not pass the handle to
- * other threads for whatever purpose.
- */
- sp->threadH = GetCurrentThread ();
+ /*
+ * DuplicateHandle does not exist on WinCE.
+ *
+ * NOTE:
+ * GetCurrentThread only returns a pseudo-handle
+ * which is only valid in the current thread context.
+ * Therefore, you should not pass the handle to
+ * other threads for whatever purpose.
+ */
+ sp->threadH = GetCurrentThread ();
#else
- if (!DuplicateHandle (GetCurrentProcess (),
+ if (!DuplicateHandle (GetCurrentProcess (),
GetCurrentThread (),
GetCurrentProcess (),
&sp->threadH,
0, FALSE, DUPLICATE_SAME_ACCESS))
- {
- /*
- * Should not do this, but we have no alternative if
- * we can't get a Win32 thread handle.
- * Thread structs are never freed.
- */
- ptw32_threadReusePush (self);
- /*
- * As this is a win32 thread calling us and we have failed,
- * return a value that makes sense to win32.
- */
- return nil;
- }
+ {
+ fail = PTW32_TRUE;
+ }
#endif
+ /*
+ * Get this threads CPU affinity by temporarily setting the threads
+ * affinity to that of the process to get the old thread affinity,
+ * then reset to the old affinity.
+ */
+ if (!fail)
+ {
+ if (GetProcessAffinityMask(GetCurrentProcess(), &vProcessMask, &vSystemMask))
+ {
+ vThreadMask = SetThreadAffinityMask(sp->threadH, vProcessMask);
+ if (vThreadMask)
+ {
+ if (SetThreadAffinityMask(sp->threadH, vThreadMask))
+ {
+ sp->cpuset = (size_t) vThreadMask;
+ }
+ else fail = PTW32_TRUE;
+ }
+ else fail = PTW32_TRUE;
+ }
+ else fail = PTW32_TRUE;
- /*
- * No need to explicitly serialise access to sched_priority
- * because the new handle is not yet public.
- */
- sp->sched_priority = GetThreadPriority (sp->threadH);
- pthread_setspecific (ptw32_selfThreadKey, (void *) sp);
- }
+ /*
+ * No need to explicitly serialise access to sched_priority
+ * because the new handle is not yet public.
+ */
+ sp->sched_priority = GetThreadPriority (sp->threadH);
+ pthread_setspecific (ptw32_selfThreadKey, (void *) sp);
+ }
+ }
+
+ if (fail)
+ {
+ /*
+ * Thread structs are never freed but are reused so if this
+ * continues to fail at least we don't leak memory.
+ */
+ ptw32_threadReusePush (self);
+ /*
+ * As this is a win32 thread calling us and we have failed,
+ * return a value that makes sense to win32.
+ */
+ return nil;
+ }
}
return (self);
-
-} /* pthread_self */
+}
diff --git a/pthreads/pthread_setaffinity.c b/pthreads/pthread_setaffinity.c
new file mode 100755
index 000000000..62fc4945a
--- /dev/null
+++ b/pthreads/pthread_setaffinity.c
@@ -0,0 +1,225 @@
+/*
+ * pthread_setaffinity.c
+ *
+ * Description:
+ * This translation unit implements thread cpu affinity setting.
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads-win32 - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * http://sources.redhat.com/pthreads-win32/contributors.html
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "pthread.h"
+#include "implement.h"
+
+int
+pthread_setaffinity_np (pthread_t thread, size_t cpusetsize,
+ const cpu_set_t *cpuset)
+ /*
+ * ------------------------------------------------------
+ * DOCPUBLIC
+ * The pthread_setaffinity_np() function sets the CPU affinity mask
+ * of the thread thread to the CPU set pointed to by cpuset. If the
+ * call is successful, and the thread is not currently running on one
+ * of the CPUs in cpuset, then it is migrated to one of those CPUs.
+ *
+ * PARAMETERS
+ * thread
+ * The target thread
+ *
+ * cpusetsize
+ * Ignored in pthreads4w.
+ * Usually set to sizeof(cpu_set_t)
+ *
+ * cpuset
+ * The new cpu set mask.
+ *
+ * The set of CPUs on which the thread will actually run
+ * is the intersection of the set specified in the cpuset
+ * argument and the set of CPUs actually present for
+ * the process.
+ *
+ * DESCRIPTION
+ * The pthread_setaffinity_np() function sets the CPU affinity mask
+ * of the thread thread to the CPU set pointed to by cpuset. If the
+ * call is successful, and the thread is not currently running on one
+ * of the CPUs in cpuset, then it is migrated to one of those CPUs.
+ *
+ * RESULTS
+ * 0 Success
+ * ESRCH Thread does not exist
+ * EFAULT pcuset is NULL
+ * EAGAIN The thread affinity could not be set
+ *
+ * ------------------------------------------------------
+ */
+{
+ int result = 0;
+ ptw32_thread_t * tp;
+ ptw32_mcs_local_node_t node;
+ cpu_set_t processCpuset;
+
+ ptw32_mcs_lock_acquire (&ptw32_thread_reuse_lock, &node);
+
+ tp = (ptw32_thread_t *) thread.p;
+
+ if (NULL == tp || thread.x != tp->ptHandle.x || NULL == tp->threadH)
+ {
+ result = ESRCH;
+ }
+ else
+ {
+ if (cpuset)
+ {
+ if (sched_getaffinity(0, sizeof(cpu_set_t), &processCpuset))
+ {
+ result = PTW32_GET_ERRNO();
+ }
+ else
+ {
+ /*
+ * Result is the intersection of available CPUs and the mask.
+ */
+ cpu_set_t newMask;
+
+ CPU_AND(&newMask, &processCpuset, cpuset);
+
+ if (((_sched_cpu_set_vector_*)&newMask)->_cpuset)
+ {
+ if (SetThreadAffinityMask (tp->threadH, ((_sched_cpu_set_vector_*)&newMask)->_cpuset))
+ {
+ /*
+ * We record the intersection of the process affinity
+ * and the thread affinity cpusets so that
+ * pthread_getaffinity_np() returns the actual thread
+ * CPU set.
+ */
+ tp->cpuset = ((_sched_cpu_set_vector_*)&newMask)->_cpuset;
+ }
+ else
+ {
+ result = EAGAIN;
+ }
+ }
+ else
+ {
+ result = EINVAL;
+ }
+ }
+ }
+ else
+ {
+ result = EFAULT;
+ }
+ }
+
+ ptw32_mcs_lock_release (&node);
+
+ return result;
+}
+
+int
+pthread_getaffinity_np (pthread_t thread, size_t cpusetsize, cpu_set_t *cpuset)
+ /*
+ * ------------------------------------------------------
+ * DOCPUBLIC
+ * The pthread_getaffinity_np() function returns the CPU affinity mask
+ * of the thread thread in the CPU set pointed to by cpuset.
+ *
+ * PARAMETERS
+ * thread
+ * The target thread
+ *
+ * cpusetsize
+ * Ignored in pthreads4w.
+ * Usually set to sizeof(cpu_set_t)
+ *
+ * cpuset
+ * The location where the current cpu set
+ * will be returned.
+ *
+ *
+ * DESCRIPTION
+ * The pthread_getaffinity_np() function returns the CPU affinity mask
+ * of the thread thread in the CPU set pointed to by cpuset.
+ *
+ * RESULTS
+ * 0 Success
+ * ESRCH thread does not exist
+ * EFAULT cpuset is NULL
+ *
+ * ------------------------------------------------------
+ */
+{
+ int result = 0;
+ ptw32_thread_t * tp;
+ ptw32_mcs_local_node_t node;
+
+ ptw32_mcs_lock_acquire(&ptw32_thread_reuse_lock, &node);
+
+ tp = (ptw32_thread_t *) thread.p;
+
+ if (NULL == tp || thread.x != tp->ptHandle.x || NULL == tp->threadH)
+ {
+ result = ESRCH;
+ }
+ else
+ {
+ if (cpuset)
+ {
+ if (tp->cpuset)
+ {
+ /*
+ * The application may have set thread affinity independently
+ * via SetThreadAffinityMask(). If so, we adjust our record of the threads
+ * affinity and try to do so in a reasonable way.
+ */
+ DWORD_PTR vThreadMask = SetThreadAffinityMask(tp->threadH, tp->cpuset);
+ if (vThreadMask && vThreadMask != tp->cpuset)
+ {
+ (void) SetThreadAffinityMask(tp->threadH, vThreadMask);
+ tp->cpuset = vThreadMask;
+ }
+ }
+ ((_sched_cpu_set_vector_*)cpuset)->_cpuset = tp->cpuset;
+ }
+ else
+ {
+ result = EFAULT;
+ }
+ }
+
+ ptw32_mcs_lock_release(&node);
+
+ return result;
+}
diff --git a/pthreads/pthread_setcancelstate.c b/pthreads/pthread_setcancelstate.c
index bbcd624af..152682577 100644
--- a/pthreads/pthread_setcancelstate.c
+++ b/pthreads/pthread_setcancelstate.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_setcanceltype.c b/pthreads/pthread_setcanceltype.c
index 72b0af5bb..41ecfe0db 100644
--- a/pthreads/pthread_setcanceltype.c
+++ b/pthreads/pthread_setcanceltype.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
@@ -52,7 +57,7 @@ pthread_setcanceltype (int type, int *oldtype)
* type,
* oldtype
* PTHREAD_CANCEL_DEFERRED
- * only deferred cancelation is allowed,
+ * only deferred cancellation is allowed,
*
* PTHREAD_CANCEL_ASYNCHRONOUS
* Asynchronous cancellation is allowed
diff --git a/pthreads/pthread_setconcurrency.c b/pthreads/pthread_setconcurrency.c
index f62346f8e..1861f96e7 100644
--- a/pthreads/pthread_setconcurrency.c
+++ b/pthreads/pthread_setconcurrency.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_setschedparam.c b/pthreads/pthread_setschedparam.c
index b762753cd..f0576d4f2 100644
--- a/pthreads/pthread_setschedparam.c
+++ b/pthreads/pthread_setschedparam.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
#include "sched.h"
diff --git a/pthreads/pthread_setspecific.c b/pthreads/pthread_setspecific.c
index 0f29e704a..044308b8b 100644
--- a/pthreads/pthread_setspecific.c
+++ b/pthreads/pthread_setspecific.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_spin_destroy.c b/pthreads/pthread_spin_destroy.c
index 786c4e34c..8309a0901 100644
--- a/pthreads/pthread_spin_destroy.c
+++ b/pthreads/pthread_spin_destroy.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_spin_init.c b/pthreads/pthread_spin_init.c
index 553af7eac..ae3406f66 100644
--- a/pthreads/pthread_spin_init.c
+++ b/pthreads/pthread_spin_init.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_spin_lock.c b/pthreads/pthread_spin_lock.c
index b560e1489..300ce97cd 100644
--- a/pthreads/pthread_spin_lock.c
+++ b/pthreads/pthread_spin_lock.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_spin_trylock.c b/pthreads/pthread_spin_trylock.c
index a6c65aff6..51fc879e6 100644
--- a/pthreads/pthread_spin_trylock.c
+++ b/pthreads/pthread_spin_trylock.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_spin_unlock.c b/pthreads/pthread_spin_unlock.c
index 3a6932aef..762584ce1 100644
--- a/pthreads/pthread_spin_unlock.c
+++ b/pthreads/pthread_spin_unlock.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_testcancel.c b/pthreads/pthread_testcancel.c
index 665865000..f69585630 100644
--- a/pthreads/pthread_testcancel.c
+++ b/pthreads/pthread_testcancel.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_timechange_handler_np.c b/pthreads/pthread_timechange_handler_np.c
index 0f97e74f1..98934e3c1 100644
--- a/pthreads/pthread_timechange_handler_np.c
+++ b/pthreads/pthread_timechange_handler_np.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/pthread_timedjoin_np.c b/pthreads/pthread_timedjoin_np.c
new file mode 100755
index 000000000..827b6f675
--- /dev/null
+++ b/pthreads/pthread_timedjoin_np.c
@@ -0,0 +1,188 @@
+/*
+ * pthread_timedjoin_np.c
+ *
+ * Description:
+ * This translation unit implements functions related to thread
+ * synchronisation.
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads-win32 - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * http://sources.redhat.com/pthreads-win32/contributors.html
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "pthread.h"
+#include "implement.h"
+
+/*
+ * Not needed yet, but defining it should indicate clashes with build target
+ * environment that should be fixed.
+ */
+#if !defined(WINCE)
+# include <signal.h>
+#endif
+
+
+int
+pthread_timedjoin_np (pthread_t thread, void **value_ptr, const struct timespec *abstime)
+ /*
+ * ------------------------------------------------------
+ * DOCPUBLIC
+ * This function waits for 'thread' to terminate and
+ * returns the thread's exit value if 'value_ptr' is not
+ * NULL or until 'abstime' passes and returns an
+ * error. If 'abstime' is NULL then the function waits
+ * forever, i.e. reverts to pthread_join behaviour.
+ * This function detaches the thread on successful
+ * completion.
+ *
+ * PARAMETERS
+ * thread
+ * an instance of pthread_t
+ *
+ * value_ptr
+ * pointer to an instance of pointer to void
+ *
+ * abstime
+ * pointer to an instance of struct timespec
+ * representing an absolute time value
+ *
+ *
+ * DESCRIPTION
+ * This function waits for 'thread' to terminate and
+ * returns the thread's exit value if 'value_ptr' is not
+ * NULL or until 'abstime' passes and returns an
+ * error. If 'abstime' is NULL then the function waits
+ * forever, i.e. reverts to pthread_join behaviour.
+ * This function detaches the thread on successful
+ * completion.
+ * NOTE: Detached threads cannot be joined or canceled.
+ * In this implementation 'abstime' will be
+ * resolved to the nearest millisecond.
+ *
+ * RESULTS
+ * 0 'thread' has completed
+ * ETIMEDOUT abstime passed
+ * EINVAL thread is not a joinable thread,
+ * ESRCH no thread could be found with ID 'thread',
+ * ENOENT thread couldn't find it's own valid handle,
+ * EDEADLK attempt to join thread with self
+ *
+ * ------------------------------------------------------
+ */
+{
+ int result;
+ pthread_t self;
+ DWORD milliseconds;
+ ptw32_thread_t * tp = (ptw32_thread_t *) thread.p;
+ ptw32_mcs_local_node_t node;
+
+ if (abstime == NULL)
+ {
+ milliseconds = INFINITE;
+ }
+ else
+ {
+ /*
+ * Calculate timeout as milliseconds from current system time.
+ */
+ milliseconds = ptw32_relmillisecs (abstime);
+ }
+
+ ptw32_mcs_lock_acquire(&ptw32_thread_reuse_lock, &node);
+
+ if (NULL == tp
+ || thread.x != tp->ptHandle.x)
+ {
+ result = ESRCH;
+ }
+ else if (PTHREAD_CREATE_DETACHED == tp->detachState)
+ {
+ result = EINVAL;
+ }
+ else
+ {
+ result = 0;
+ }
+
+ ptw32_mcs_lock_release(&node);
+
+ if (result == 0)
+ {
+ /*
+ * The target thread is joinable and can't be reused before we join it.
+ */
+ self = pthread_self();
+
+ if (NULL == self.p)
+ {
+ result = ENOENT;
+ }
+ else if (pthread_equal (self, thread))
+ {
+ result = EDEADLK;
+ }
+ else
+ {
+ /*
+ * Pthread_join is a cancellation point.
+ * If we are canceled then our target thread must not be
+ * detached (destroyed). This is guaranteed because
+ * pthreadCancelableTimedWait will not return if we
+ * are canceled.
+ */
+ result = pthreadCancelableTimedWait (tp->threadH, milliseconds);
+
+ if (0 == result)
+ {
+ if (value_ptr != NULL)
+ {
+ *value_ptr = tp->exitStatus;
+ }
+
+ /*
+ * The result of making multiple simultaneous calls to
+ * pthread_join() or pthread_timedjoin_np() or pthread_detach()
+ * specifying the same target is undefined.
+ */
+ result = pthread_detach (thread);
+ }
+ else if (ETIMEDOUT != result)
+ {
+ result = ESRCH;
+ }
+ }
+ }
+
+ return (result);
+
+}
diff --git a/pthreads/pthread_tryjoin_np.c b/pthreads/pthread_tryjoin_np.c
new file mode 100755
index 000000000..e9fe1dae6
--- /dev/null
+++ b/pthreads/pthread_tryjoin_np.c
@@ -0,0 +1,173 @@
+/*
+ * pthread_tryjoin_np.c
+ *
+ * Description:
+ * This translation unit implements functions related to thread
+ * synchronisation.
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads-win32 - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * http://sources.redhat.com/pthreads-win32/contributors.html
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "pthread.h"
+#include "implement.h"
+
+/*
+ * Not needed yet, but defining it should indicate clashes with build target
+ * environment that should be fixed.
+ */
+#if !defined(WINCE)
+# include <signal.h>
+#endif
+
+
+int
+pthread_tryjoin_np (pthread_t thread, void **value_ptr)
+ /*
+ * ------------------------------------------------------
+ * DOCPUBLIC
+ * This function checks if 'thread' has terminated and
+ * returns the thread's exit value if 'value_ptr' is not
+ * NULL or until 'abstime' passes and returns an
+ * error. If the thread has not exited the function returns
+ * immediately. This function detaches the thread on successful
+ * completion.
+ *
+ * PARAMETERS
+ * thread
+ * an instance of pthread_t
+ *
+ * value_ptr
+ * pointer to an instance of pointer to void
+ *
+ *
+ * DESCRIPTION
+ * This function checks if 'thread' has terminated and
+ * returns the thread's exit value if 'value_ptr' is not
+ * NULL or until 'abstime' passes and returns an
+ * error. If the thread has not exited the function returns
+ * immediately. This function detaches the thread on successful
+ * completion.
+ * NOTE: Detached threads cannot be joined or canceled.
+ * In this implementation 'abstime' will be
+ * resolved to the nearest millisecond.
+ *
+ * RESULTS
+ * 0 'thread' has completed
+ * EBUSY 'thread' is still live
+ * EINVAL thread is not a joinable thread,
+ * ESRCH no thread could be found with ID 'thread',
+ * ENOENT thread couldn't find it's own valid handle,
+ * EDEADLK attempt to join thread with self
+ *
+ * ------------------------------------------------------
+ */
+{
+ int result;
+ pthread_t self;
+ ptw32_thread_t * tp = (ptw32_thread_t *) thread.p;
+ ptw32_mcs_local_node_t node;
+
+ ptw32_mcs_lock_acquire(&ptw32_thread_reuse_lock, &node);
+
+ if (NULL == tp
+ || thread.x != tp->ptHandle.x)
+ {
+ result = ESRCH;
+ }
+ else if (PTHREAD_CREATE_DETACHED == tp->detachState)
+ {
+ result = EINVAL;
+ }
+ else
+ {
+ result = 0;
+ }
+
+ ptw32_mcs_lock_release(&node);
+
+ if (result == 0)
+ {
+ /*
+ * The target thread is joinable and can't be reused before we join it.
+ */
+ self = pthread_self();
+
+ if (NULL == self.p)
+ {
+ result = ENOENT;
+ }
+ else if (pthread_equal (self, thread))
+ {
+ result = EDEADLK;
+ }
+ else
+ {
+ /*
+ * Pthread_join is a cancellation point.
+ * If we are canceled then our target thread must not be
+ * detached (destroyed). This is guaranteed because
+ * pthreadCancelableTimedWait will not return if we
+ * are canceled.
+ */
+ result = pthreadCancelableTimedWait (tp->threadH, 0);
+
+ if (0 == result)
+ {
+ if (value_ptr != NULL)
+ {
+ *value_ptr = tp->exitStatus;
+ }
+
+ /*
+ * The result of making multiple simultaneous calls to
+ * pthread_join(), pthread_timedjoin_np(), pthread_tryjoin_np()
+ * or pthread_detach() specifying the same target is undefined.
+ */
+ result = pthread_detach (thread);
+ }
+ else if (ETIMEDOUT == result)
+ {
+ result = EBUSY;
+ }
+ else
+ {
+ result = ESRCH;
+ }
+ }
+ }
+
+ return (result);
+
+}
diff --git a/pthreads/pthread_win32_attach_detach_np.c b/pthreads/pthread_win32_attach_detach_np.c
index bfad45065..c1da33554 100644
--- a/pthreads/pthread_win32_attach_detach_np.c
+++ b/pthreads/pthread_win32_attach_detach_np.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
@@ -70,7 +75,7 @@ pthread_win32_process_attach_np ()
*
* This should take care of any security issues.
*/
-#if defined(__GNUC__) || _MSC_VER < 1400
+#if defined(__GNUC__) || defined(PTW32_CONFIG_MSVC7)
if(GetSystemDirectory(QuserExDLLPathBuf, sizeof(QuserExDLLPathBuf)))
{
(void) strncat(QuserExDLLPathBuf,
@@ -89,7 +94,7 @@ pthread_win32_process_attach_np ()
if (ptw32_h_quserex != NULL)
{
- ptw32_register_cancelation = (DWORD (*)(PAPCFUNC, HANDLE, DWORD))
+ ptw32_register_cancellation = (DWORD (*)(PAPCFUNC, HANDLE, DWORD))
#if defined(NEED_UNICODE_CONSTS)
GetProcAddress (ptw32_h_quserex,
(const TCHAR *) TEXT ("QueueUserAPCEx"));
@@ -98,9 +103,9 @@ pthread_win32_process_attach_np ()
#endif
}
- if (NULL == ptw32_register_cancelation)
+ if (NULL == ptw32_register_cancellation)
{
- ptw32_register_cancelation = ptw32_RegisterCancelation;
+ ptw32_register_cancellation = ptw32_Registercancellation;
if (ptw32_h_quserex != NULL)
{
@@ -123,7 +128,7 @@ pthread_win32_process_attach_np ()
if (queue_user_apc_ex_init == NULL || !queue_user_apc_ex_init ())
{
- ptw32_register_cancelation = ptw32_RegisterCancelation;
+ ptw32_register_cancellation = ptw32_Registercancellation;
(void) FreeLibrary (ptw32_h_quserex);
ptw32_h_quserex = 0;
@@ -155,7 +160,10 @@ pthread_win32_process_detach_np ()
if (sp->detachState == PTHREAD_CREATE_DETACHED)
{
ptw32_threadDestroy (sp->ptHandle);
- TlsSetValue (ptw32_selfThreadKey->key, NULL);
+ if (ptw32_selfThreadKey)
+ {
+ TlsSetValue (ptw32_selfThreadKey->key, NULL);
+ }
}
}
@@ -230,7 +238,7 @@ pthread_win32_thread_detach_np ()
(PTW32_INTERLOCKED_LONG)-1);
/*
* If there are no waiters then the next thread to block will
- * sleep, wakeup immediately and then go back to sleep.
+ * sleep, wake up immediately and then go back to sleep.
* See pthread_mutex_lock.c.
*/
SetEvent(mx->event);
@@ -241,7 +249,10 @@ pthread_win32_thread_detach_np ()
{
ptw32_threadDestroy (sp->ptHandle);
- TlsSetValue (ptw32_selfThreadKey->key, NULL);
+ if (ptw32_selfThreadKey)
+ {
+ TlsSetValue (ptw32_selfThreadKey->key, NULL);
+ }
}
}
}
diff --git a/pthreads/ptw32_MCS_lock.c b/pthreads/ptw32_MCS_lock.c
index d69cf80eb..434e9b85e 100644
--- a/pthreads/ptw32_MCS_lock.c
+++ b/pthreads/ptw32_MCS_lock.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -89,6 +90,10 @@
* }
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "sched.h"
#include "implement.h"
@@ -114,7 +119,7 @@ ptw32_mcs_flag_set (HANDLE * flag)
}
/*
- * ptw32_mcs_flag_set -- wait for notification from another.
+ * ptw32_mcs_flag_wait -- wait for notification from another.
*
* Store an event handle in the flag and wait on it if the flag has not been
* set, and proceed without creating an event otherwise.
@@ -122,7 +127,7 @@ ptw32_mcs_flag_set (HANDLE * flag)
INLINE void
ptw32_mcs_flag_wait (HANDLE * flag)
{
- if ((PTW32_INTERLOCKED_LONG)0 ==
+ if ((PTW32_INTERLOCKED_SIZE)0 ==
PTW32_INTERLOCKED_EXCHANGE_ADD_SIZE((PTW32_INTERLOCKED_SIZEPTR)flag,
(PTW32_INTERLOCKED_SIZE)0)) /* MBR fence */
{
diff --git a/pthreads/ptw32_callUserDestroyRoutines.c b/pthreads/ptw32_callUserDestroyRoutines.c
index f290f7ba5..88325dc93 100644
--- a/pthreads/ptw32_callUserDestroyRoutines.c
+++ b/pthreads/ptw32_callUserDestroyRoutines.c
@@ -9,10 +9,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -35,6 +36,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/ptw32_calloc.c b/pthreads/ptw32_calloc.c
index e7b9e64fe..b01c335e5 100644
--- a/pthreads/ptw32_calloc.c
+++ b/pthreads/ptw32_calloc.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/ptw32_cond_check_need_init.c b/pthreads/ptw32_cond_check_need_init.c
index ec3e8bbd6..251678cc0 100644
--- a/pthreads/ptw32_cond_check_need_init.c
+++ b/pthreads/ptw32_cond_check_need_init.c
@@ -9,10 +9,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -35,6 +36,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/ptw32_getprocessors.c b/pthreads/ptw32_getprocessors.c
index e60c3143f..4ac3cce9e 100644
--- a/pthreads/ptw32_getprocessors.c
+++ b/pthreads/ptw32_getprocessors.c
@@ -9,10 +9,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -35,6 +36,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/ptw32_is_attr.c b/pthreads/ptw32_is_attr.c
index 36395f81f..80917cfbb 100644
--- a/pthreads/ptw32_is_attr.c
+++ b/pthreads/ptw32_is_attr.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/ptw32_mutex_check_need_init.c b/pthreads/ptw32_mutex_check_need_init.c
index 897db3c68..846a4b7c4 100644
--- a/pthreads/ptw32_mutex_check_need_init.c
+++ b/pthreads/ptw32_mutex_check_need_init.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,13 +35,17 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
static struct pthread_mutexattr_t_ ptw32_recursive_mutexattr_s =
- {PTHREAD_PROCESS_PRIVATE, PTHREAD_MUTEX_RECURSIVE};
+ {PTHREAD_PROCESS_PRIVATE, PTHREAD_MUTEX_RECURSIVE, PTHREAD_MUTEX_STALLED};
static struct pthread_mutexattr_t_ ptw32_errorcheck_mutexattr_s =
- {PTHREAD_PROCESS_PRIVATE, PTHREAD_MUTEX_ERRORCHECK};
+ {PTHREAD_PROCESS_PRIVATE, PTHREAD_MUTEX_ERRORCHECK, PTHREAD_MUTEX_STALLED};
static pthread_mutexattr_t ptw32_recursive_mutexattr = &ptw32_recursive_mutexattr_s;
static pthread_mutexattr_t ptw32_errorcheck_mutexattr = &ptw32_errorcheck_mutexattr_s;
diff --git a/pthreads/ptw32_new.c b/pthreads/ptw32_new.c
index ac836ead3..4f9456a22 100644
--- a/pthreads/ptw32_new.c
+++ b/pthreads/ptw32_new.c
@@ -8,32 +8,37 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
* http://sources.redhat.com/pthreads-win32/contributors.html
- *
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library in the file COPYING.LIB;
* if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
@@ -79,6 +84,7 @@ ptw32_new (void)
tp->threadLock = 0;
tp->robustMxListLock = 0;
tp->robustMxList = NULL;
+ CPU_ZERO((cpu_set_t*)&tp->cpuset);
tp->cancelEvent = CreateEvent (0, (int) PTW32_TRUE, /* manualReset */
(int) PTW32_FALSE, /* setSignaled */
NULL);
diff --git a/pthreads/ptw32_processInitialize.c b/pthreads/ptw32_processInitialize.c
index 8da3e41fa..b84a642ae 100644
--- a/pthreads/ptw32_processInitialize.c
+++ b/pthreads/ptw32_processInitialize.c
@@ -9,10 +9,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -35,6 +36,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/ptw32_processTerminate.c b/pthreads/ptw32_processTerminate.c
index 83f0f23ca..035bac6d2 100644
--- a/pthreads/ptw32_processTerminate.c
+++ b/pthreads/ptw32_processTerminate.c
@@ -9,10 +9,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -35,6 +36,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/ptw32_relmillisecs.c b/pthreads/ptw32_relmillisecs.c
index 894d5c9d4..34a855c10 100644
--- a/pthreads/ptw32_relmillisecs.c
+++ b/pthreads/ptw32_relmillisecs.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
#if !defined(NEED_FTIME)
@@ -57,8 +62,8 @@ ptw32_relmillisecs (const struct timespec * abstime)
FILETIME ft;
SYSTEMTIME st;
#else /* ! NEED_FTIME */
-#if ( defined(_MSC_VER) && _MSC_VER >= 1300 ) || \
- ( (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 )
+#if ( defined(_MSC_VER) && _MSC_VER >= 1300 ) /* MSVC7+ */ || \
+ ( defined(PTW32_CONFIG_MINGW) && __MSVCRT_VERSION__ >= 0x0601 )
struct __timeb64 currSysTime;
#else
struct _timeb currSysTime;
@@ -99,10 +104,10 @@ ptw32_relmillisecs (const struct timespec * abstime)
#else /* ! NEED_FTIME */
-#if defined(_MSC_VER) && _MSC_VER >= 1400
+#if defined(_MSC_VER) && _MSC_VER >= 1400 /* MSVC8+ */
_ftime64_s(&currSysTime);
-#elif ( defined(_MSC_VER) && _MSC_VER >= 1300 ) || \
- ( (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 )
+#elif ( defined(_MSC_VER) && _MSC_VER >= 1300 ) /* MSVC7+ */ || \
+ ( defined(PTW32_CONFIG_MINGW) && __MSVCRT_VERSION__ >= 0x0601 )
_ftime64(&currSysTime);
#else
_ftime(&currSysTime);
diff --git a/pthreads/ptw32_reuse.c b/pthreads/ptw32_reuse.c
index 7325857ba..8e7b85bf5 100644
--- a/pthreads/ptw32_reuse.c
+++ b/pthreads/ptw32_reuse.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/ptw32_rwlock_cancelwrwait.c b/pthreads/ptw32_rwlock_cancelwrwait.c
index a057bd1d7..9d5630c3f 100644
--- a/pthreads/ptw32_rwlock_cancelwrwait.c
+++ b/pthreads/ptw32_rwlock_cancelwrwait.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/ptw32_rwlock_check_need_init.c b/pthreads/ptw32_rwlock_check_need_init.c
index 858ee271c..8e24da88a 100644
--- a/pthreads/ptw32_rwlock_check_need_init.c
+++ b/pthreads/ptw32_rwlock_check_need_init.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/ptw32_semwait.c b/pthreads/ptw32_semwait.c
index c3c4fd0e5..f01d8bc79 100644
--- a/pthreads/ptw32_semwait.c
+++ b/pthreads/ptw32_semwait.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#if !defined(_UWIN)
/*# include <process.h> */
#endif
@@ -84,7 +89,7 @@ ptw32_semwait (sem_t * sem)
if (*sem == NULL)
{
(void) pthread_mutex_unlock (&s->lock);
- errno = EINVAL;
+ PTW32_SET_ERRNO(EINVAL);
return -1;
}
@@ -102,7 +107,7 @@ ptw32_semwait (sem_t * sem)
if (*sem == NULL)
{
(void) pthread_mutex_unlock (&s->lock);
- errno = EINVAL;
+ PTW32_SET_ERRNO(EINVAL);
return -1;
}
@@ -126,7 +131,7 @@ ptw32_semwait (sem_t * sem)
if (result != 0)
{
- errno = result;
+ PTW32_SET_ERRNO(result);
return -1;
}
diff --git a/pthreads/ptw32_spinlock_check_need_init.c b/pthreads/ptw32_spinlock_check_need_init.c
index 8808454ee..1cd0ff3fa 100644
--- a/pthreads/ptw32_spinlock_check_need_init.c
+++ b/pthreads/ptw32_spinlock_check_need_init.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/ptw32_threadDestroy.c b/pthreads/ptw32_threadDestroy.c
index 41499b11b..701a44060 100644
--- a/pthreads/ptw32_threadDestroy.c
+++ b/pthreads/ptw32_threadDestroy.c
@@ -9,10 +9,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -35,6 +36,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
@@ -64,7 +69,7 @@ ptw32_threadDestroy (pthread_t thread)
CloseHandle (threadCopy.cancelEvent);
}
-#if ! (defined(__MINGW64__) || defined(__MINGW32__)) || defined (__MSVCRT__) || defined (__DMC__)
+#if ! defined(PTW32_CONFIG_MINGW) || defined (__MSVCRT__) || defined (__DMC__)
/*
* See documentation for endthread vs endthreadex.
*/
diff --git a/pthreads/ptw32_threadStart.c b/pthreads/ptw32_threadStart.c
index cb08403b1..ffa0eb602 100644
--- a/pthreads/ptw32_threadStart.c
+++ b/pthreads/ptw32_threadStart.c
@@ -9,10 +9,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -35,6 +36,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
#include <stdio.h>
@@ -59,7 +64,7 @@ ExceptionFilter (EXCEPTION_POINTERS * ep, DWORD * ei)
for (param = 0; param < numParams; param++)
{
- ei[param] = ep->ExceptionRecord->ExceptionInformation[param];
+ ei[param] = (DWORD) ep->ExceptionRecord->ExceptionInformation[param];
}
return EXCEPTION_EXECUTE_HANDLER;
@@ -89,38 +94,32 @@ ExceptionFilter (EXCEPTION_POINTERS * ep, DWORD * ei)
#elif defined(__WATCOMC__)
# include <eh.h>
# include <exceptio.h>
-typedef terminate_handler
- terminate_function;
#else
# if defined(__GNUC__) && __GNUC__ < 3
# include <new.h>
# else
# include <new>
using
- std::terminate_handler;
-using
std::terminate;
using
std::set_terminate;
# endif
-typedef terminate_handler
- terminate_function;
#endif
-static terminate_function
- ptw32_oldTerminate;
-
-void
-ptw32_terminate ()
-{
- set_terminate (ptw32_oldTerminate);
- (void) pthread_win32_thread_detach_np ();
- terminate ();
-}
+#endif /* __CLEANUP_CXX */
+/*
+ * MSVC6 does not optimize ptw32_threadStart() safely
+ * (i.e. tests/context1.c fails with "abnormal program
+ * termination" in some configurations), and there's no
+ * point to optimizing this routine anyway
+ */
+#ifdef _MSC_VER
+# pragma optimize("g", off)
+# pragma warning( disable : 4748 )
#endif
-#if ! (defined(__MINGW64__) || defined(__MINGW32__)) || (defined (__MSVCRT__) && ! defined (__DMC__))
+#if ! defined (PTW32_CONFIG_MINGW) || (defined (__MSVCRT__) && ! defined (__DMC__))
unsigned
__stdcall
#else
@@ -131,7 +130,7 @@ ptw32_threadStart (void *vthreadParms)
ThreadParms * threadParms = (ThreadParms *) vthreadParms;
pthread_t self;
ptw32_thread_t * sp;
- void *(*start) (void *);
+ void * (PTW32_CDECL *start) (void *);
void * arg;
#if defined(__CLEANUP_SEH)
@@ -153,7 +152,7 @@ ptw32_threadStart (void *vthreadParms)
free (threadParms);
-#if (defined(__MINGW64__) || defined(__MINGW32__)) && ! defined (__MSVCRT__)
+#if defined (PTW32_CONFIG_MINGW) && ! defined (__MSVCRT__)
/*
* beginthread does not return the thread id and is running
* before it returns us the thread handle, and so we do it here.
@@ -194,19 +193,19 @@ ptw32_threadStart (void *vthreadParms)
{
switch (ei[0])
{
- case PTW32_EPS_CANCEL:
- status = sp->exitStatus = PTHREAD_CANCELED;
+ case PTW32_EPS_CANCEL:
+ status = sp->exitStatus = PTHREAD_CANCELED;
#if defined(_UWIN)
- if (--pthread_count <= 0)
- exit (0);
+ if (--pthread_count <= 0)
+ exit (0);
#endif
- break;
- case PTW32_EPS_EXIT:
- status = sp->exitStatus;
- break;
- default:
- status = sp->exitStatus = PTHREAD_CANCELED;
- break;
+ break;
+ case PTW32_EPS_EXIT:
+ status = sp->exitStatus;
+ break;
+ default:
+ status = sp->exitStatus = PTHREAD_CANCELED;
+ break;
}
}
@@ -218,7 +217,6 @@ ptw32_threadStart (void *vthreadParms)
if (0 == setjmp_rc)
{
-
/*
* Run the caller's routine;
*/
@@ -228,64 +226,27 @@ ptw32_threadStart (void *vthreadParms)
else
{
switch (setjmp_rc)
- {
- case PTW32_EPS_CANCEL:
- status = sp->exitStatus = PTHREAD_CANCELED;
- break;
- case PTW32_EPS_EXIT:
- status = sp->exitStatus;
- break;
- default:
- status = sp->exitStatus = PTHREAD_CANCELED;
- break;
- }
+ {
+ case PTW32_EPS_CANCEL:
+ status = sp->exitStatus = PTHREAD_CANCELED;
+ break;
+ case PTW32_EPS_EXIT:
+ status = sp->exitStatus;
+ break;
+ default:
+ status = sp->exitStatus = PTHREAD_CANCELED;
+ break;
+ }
}
#else /* __CLEANUP_C */
#if defined(__CLEANUP_CXX)
- ptw32_oldTerminate = set_terminate (&ptw32_terminate);
-
try
{
- /*
- * Run the caller's routine in a nested try block so that we
- * can run the user's terminate function, which may call
- * pthread_exit() or be canceled.
- */
- try
- {
- status = sp->exitStatus = (*start) (arg);
- sp->state = PThreadStateExiting;
- }
- catch (ptw32_exception &)
- {
- /*
- * Pass these through to the outer block.
- */
- throw;
- }
- catch (...)
- {
- /*
- * We want to run the user's terminate function if supplied.
- * That function may call pthread_exit() or be canceled, which will
- * be handled by the outer try block.
- *
- * ptw32_terminate() will be called if there is no user
- * supplied function.
- */
- terminate_function
- term_func = set_terminate (0);
- set_terminate (term_func);
-
- if (term_func != 0)
- {
- term_func ();
- }
- throw;
- }
+ status = sp->exitStatus = (*start) (arg);
+ sp->state = PThreadStateExiting;
}
catch (ptw32_exception_cancel &)
{
@@ -304,16 +265,13 @@ ptw32_threadStart (void *vthreadParms)
catch (...)
{
/*
- * A system unexpected exception has occurred running the user's
- * terminate routine. We get control back within this block
- * and exit with a substitute status. If the thread was not
- * cancelled then this indicates the unhandled exception.
+ * Some other exception occurred. Clean up while we have
+ * the opportunity, and call the terminate handler.
*/
- status = sp->exitStatus = PTHREAD_CANCELED;
+ (void) pthread_win32_thread_detach_np ();
+ terminate ();
}
- (void) set_terminate (ptw32_oldTerminate);
-
#else
#error ERROR [__FILE__, line __LINE__]: Cleanup type undefined.
@@ -326,7 +284,7 @@ ptw32_threadStart (void *vthreadParms)
/*
* We need to cleanup the pthread now if we have
* been statically linked, in which case the cleanup
- * in dllMain won't get done. Joinable threads will
+ * in DllMain won't get done. Joinable threads will
* only be partially cleaned up and must be fully cleaned
* up by pthread_join() or pthread_detach().
*
@@ -334,13 +292,13 @@ ptw32_threadStart (void *vthreadParms)
* implicitly created pthreads (those created
* for Win32 threads which have called pthreads routines)
* must be cleaned up explicitly by the application
- * (by calling pthread_win32_thread_detach_np()).
- * For the dll, dllMain will do the cleanup automatically.
+ * by calling pthread_exit().
+ * For the dll, DllMain will do the cleanup automatically.
*/
(void) pthread_win32_thread_detach_np ();
#endif
-#if ! (defined(__MINGW64__) || defined(__MINGW32__)) || defined (__MSVCRT__) || defined (__DMC__)
+#if ! defined (PTW32_CONFIG_MINGW) || defined (__MSVCRT__) || defined (__DMC__)
_endthreadex ((unsigned)(size_t) status);
#else
_endthread ();
@@ -350,8 +308,23 @@ ptw32_threadStart (void *vthreadParms)
* Never reached.
*/
-#if ! (defined(__MINGW64__) || defined(__MINGW32__)) || defined (__MSVCRT__) || defined (__DMC__)
+#if ! defined (PTW32_CONFIG_MINGW) || defined (__MSVCRT__) || defined (__DMC__)
return (unsigned)(size_t) status;
#endif
} /* ptw32_threadStart */
+
+/*
+ * Reset optimization
+ */
+#ifdef _MSC_VER
+# pragma optimize("", on)
+#endif
+
+#if defined (PTW32_USES_SEPARATE_CRT) && defined (__cplusplus)
+ptw32_terminate_handler
+pthread_win32_set_terminate_np(ptw32_terminate_handler termFunction)
+{
+ return set_terminate(termFunction);
+}
+#endif
diff --git a/pthreads/ptw32_throw.c b/pthreads/ptw32_throw.c
index 1404e940f..f96ffd487 100644
--- a/pthreads/ptw32_throw.c
+++ b/pthreads/ptw32_throw.c
@@ -9,10 +9,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -35,6 +36,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
@@ -90,21 +95,21 @@ ptw32_throw (DWORD exception)
* explicit thread exit here after cleaning up POSIX
* residue (i.e. cleanup handlers, POSIX thread handle etc).
*/
-#if ! (defined(__MINGW64__) || defined(__MINGW32__)) || defined (__MSVCRT__) || defined (__DMC__)
+#if ! defined (PTW32_CONFIG_MINGW) || defined (__MSVCRT__) || defined (__DMC__)
unsigned exitCode = 0;
switch (exception)
- {
- case PTW32_EPS_CANCEL:
- exitCode = (unsigned)(size_t) PTHREAD_CANCELED;
- break;
- case PTW32_EPS_EXIT:
- if (NULL != sp)
- {
- exitCode = (unsigned)(size_t) sp->exitStatus;
- }
- break;
- }
+ {
+ case PTW32_EPS_CANCEL:
+ exitCode = (unsigned)(size_t) PTHREAD_CANCELED;
+ break;
+ case PTW32_EPS_EXIT:
+ if (NULL != sp)
+ {
+ exitCode = (unsigned)(size_t) sp->exitStatus;
+ }
+ break;
+ }
#endif
#if defined(PTW32_STATIC_LIB)
@@ -113,7 +118,7 @@ ptw32_throw (DWORD exception)
#endif
-#if ! (defined(__MINGW64__) || defined(__MINGW32__)) || defined (__MSVCRT__) || defined (__DMC__)
+#if ! defined (PTW32_CONFIG_MINGW) || defined (__MSVCRT__) || defined (__DMC__)
_endthreadex (exitCode);
#else
_endthread ();
@@ -128,7 +133,7 @@ ptw32_throw (DWORD exception)
exceptionInformation[1] = (DWORD) (0);
exceptionInformation[2] = (DWORD) (0);
- RaiseException (EXCEPTION_PTW32_SERVICES, 0, 3, exceptionInformation);
+ RaiseException (EXCEPTION_PTW32_SERVICES, 0, 3, (ULONG_PTR *) exceptionInformation);
#else /* __CLEANUP_SEH */
diff --git a/pthreads/ptw32_timespec.c b/pthreads/ptw32_timespec.c
index 6318957a8..5d4e38caa 100644
--- a/pthreads/ptw32_timespec.c
+++ b/pthreads/ptw32_timespec.c
@@ -9,10 +9,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -35,6 +36,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/ptw32_tkAssocCreate.c b/pthreads/ptw32_tkAssocCreate.c
index 50d6c500c..85569be31 100644
--- a/pthreads/ptw32_tkAssocCreate.c
+++ b/pthreads/ptw32_tkAssocCreate.c
@@ -9,10 +9,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -35,6 +36,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/ptw32_tkAssocDestroy.c b/pthreads/ptw32_tkAssocDestroy.c
index fedebf593..87f78abe3 100644
--- a/pthreads/ptw32_tkAssocDestroy.c
+++ b/pthreads/ptw32_tkAssocDestroy.c
@@ -9,10 +9,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -35,6 +36,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/rwlock.c b/pthreads/rwlock.c
index 4a3cd2594..17d9452e1 100644
--- a/pthreads/rwlock.c
+++ b/pthreads/rwlock.c
@@ -34,8 +34,6 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
-#include "ptw32_rwlock_check_need_init.c"
-#include "ptw32_rwlock_cancelwrwait.c"
#include "pthread_rwlock_init.c"
#include "pthread_rwlock_destroy.c"
#include "pthread_rwlockattr_init.c"
diff --git a/pthreads/sched.h b/pthreads/sched.h
index f36a97a66..0a3282878 100644
--- a/pthreads/sched.h
+++ b/pthreads/sched.h
@@ -3,7 +3,7 @@
*
* Purpose:
* Provides an implementation of POSIX realtime extensions
- * as defined in
+ * as defined in
*
* POSIX 1003.1b-1993 (POSIX.1b)
*
@@ -11,26 +11,27 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
* http://sources.redhat.com/pthreads-win32/contributors.html
- *
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library in the file COPYING.LIB;
* if not, write to the Free Software Foundation, Inc.,
@@ -39,6 +40,15 @@
#if !defined(_SCHED_H)
#define _SCHED_H
+#if defined(_MSC_VER)
+# if _MSC_VER < 1300
+# define PTW32_CONFIG_MSVC6
+# endif
+# if _MSC_VER < 1400
+# define PTW32_CONFIG_MSVC7
+# endif
+#endif
+
#undef PTW32_SCHED_LEVEL
#if defined(_POSIX_SOURCE)
@@ -87,6 +97,20 @@
#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 exposed function prototypes.
+ *
+ * We force all calls to cdecl even though this could slow Watcom code down
+ * slightly. If you know that the Watcom compiler will be used to build both
+ * the DLL and application, then you can probably define this as a null string.
+ * Remember that sched.h (this file) is used for both the DLL and application builds.
+ */
+#if !defined(PTW32_CDECL)
+# define PTW32_CDECL __cdecl
+#endif
+
+/*
* This is a duplicate of what is in the autoconf config.h,
* which is only used when building the pthread-win32 libraries.
*/
@@ -108,6 +132,8 @@
*
*/
+#include <stdlib.h>
+
#if PTW32_SCHED_LEVEL >= PTW32_SCHED_LEVEL_MAX
#if defined(NEED_ERRNO)
#include "need_errno.h"
@@ -129,6 +155,14 @@
typedef int pid_t;
#endif
+/*
+ * Microsoft VC++6.0 lacks these *_PTR types
+ */
+#if defined(_MSC_VER) && _MSC_VER < 1300 && !defined(PTW32_HAVE_DWORD_PTR)
+typedef unsigned long ULONG_PTR;
+typedef ULONG_PTR DWORD_PTR;
+#endif
+
/* Thread scheduling policies */
enum {
@@ -143,20 +177,83 @@ struct sched_param {
int sched_priority;
};
+/*
+ * CPU affinity
+ *
+ * cpu_set_t:
+ * Considered opaque but cannot be an opaque pointer
+ * due to the need for compatibility with GNU systems
+ * and sched_setaffinity() et.al. which include the
+ * cpusetsize parameter "normally set to sizeof(cpu_set_t)".
+ */
+
+#define CPU_SETSIZE (sizeof(size_t)*8)
+
+#define CPU_COUNT(setptr) (_sched_affinitycpucount(setptr))
+
+#define CPU_ZERO(setptr) (_sched_affinitycpuzero(setptr))
+
+#define CPU_SET(cpu, setptr) (_sched_affinitycpuset((cpu),(setptr)))
+
+#define CPU_CLR(cpu, setptr) (_sched_affinitycpuclr((cpu),(setptr)))
+
+#define CPU_ISSET(cpu, setptr) (_sched_affinitycpuisset((cpu),(setptr)))
+
+#define CPU_AND(destsetptr, srcset1ptr, srcset2ptr) (_sched_affinitycpuand((destsetptr),(srcset1ptr),(srcset2ptr)))
+
+#define CPU_OR(destsetptr, srcset1ptr, srcset2ptr) (_sched_affinitycpuor((destsetptr),(srcset1ptr),(srcset2ptr)))
+
+#define CPU_XOR(destsetptr, srcset1ptr, srcset2ptr) (_sched_affinitycpuxor((destsetptr),(srcset1ptr),(srcset2ptr)))
+
+#define CPU_EQUAL(set1ptr, set2ptr) (_sched_affinitycpuequal((set1ptr),(set2ptr)))
+
+typedef union
+{
+ char cpuset[CPU_SETSIZE/8];
+ size_t _align;
+} cpu_set_t;
+
#if defined(__cplusplus)
extern "C"
{
#endif /* __cplusplus */
-PTW32_DLLPORT int __cdecl sched_yield (void);
+PTW32_DLLPORT int PTW32_CDECL sched_yield (void);
+
+PTW32_DLLPORT int PTW32_CDECL sched_get_priority_min (int policy);
+
+PTW32_DLLPORT int PTW32_CDECL sched_get_priority_max (int policy);
+
+PTW32_DLLPORT int PTW32_CDECL sched_setscheduler (pid_t pid, int policy);
+
+PTW32_DLLPORT int PTW32_CDECL sched_getscheduler (pid_t pid);
+
+/* Compatibility with Linux - not standard */
+
+PTW32_DLLPORT int PTW32_CDECL sched_setaffinity (pid_t pid, size_t cpusetsize, cpu_set_t *mask);
+
+PTW32_DLLPORT int PTW32_CDECL sched_getaffinity (pid_t pid, size_t cpusetsize, cpu_set_t *mask);
+
+/*
+ * Support routines and macros for cpu_set_t
+ */
+PTW32_DLLPORT int PTW32_CDECL _sched_affinitycpucount (const cpu_set_t *set);
+
+PTW32_DLLPORT void PTW32_CDECL _sched_affinitycpuzero (cpu_set_t *pset);
+
+PTW32_DLLPORT void PTW32_CDECL _sched_affinitycpuset (int cpu, cpu_set_t *pset);
+
+PTW32_DLLPORT void PTW32_CDECL _sched_affinitycpuclr (int cpu, cpu_set_t *pset);
+
+PTW32_DLLPORT int PTW32_CDECL _sched_affinitycpuisset (int cpu, const cpu_set_t *pset);
-PTW32_DLLPORT int __cdecl sched_get_priority_min (int policy);
+PTW32_DLLPORT void PTW32_CDECL _sched_affinitycpuand(cpu_set_t *pdestset, const cpu_set_t *psrcset1, const cpu_set_t *psrcset2);
-PTW32_DLLPORT int __cdecl sched_get_priority_max (int policy);
+PTW32_DLLPORT void PTW32_CDECL _sched_affinitycpuor(cpu_set_t *pdestset, const cpu_set_t *psrcset1, const cpu_set_t *psrcset2);
-PTW32_DLLPORT int __cdecl sched_setscheduler (pid_t pid, int policy);
+PTW32_DLLPORT void PTW32_CDECL _sched_affinitycpuxor(cpu_set_t *pdestset, const cpu_set_t *psrcset1, const cpu_set_t *psrcset2);
-PTW32_DLLPORT int __cdecl sched_getscheduler (pid_t pid);
+PTW32_DLLPORT int PTW32_CDECL _sched_affinitycpuequal (const cpu_set_t *pset1, const cpu_set_t *pset2);
/*
* Note that this macro returns ENOTSUP rather than
diff --git a/pthreads/sched_get_priority_max.c b/pthreads/sched_get_priority_max.c
index cabf2320a..e05867b75 100644
--- a/pthreads/sched_get_priority_max.c
+++ b/pthreads/sched_get_priority_max.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
#include "sched.h"
@@ -120,7 +125,7 @@ sched_get_priority_max (int policy)
{
if (policy < SCHED_MIN || policy > SCHED_MAX)
{
- errno = EINVAL;
+ PTW32_SET_ERRNO(EINVAL);
return -1;
}
diff --git a/pthreads/sched_get_priority_min.c b/pthreads/sched_get_priority_min.c
index 9c4f8591e..2c8a6560a 100644
--- a/pthreads/sched_get_priority_min.c
+++ b/pthreads/sched_get_priority_min.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
#include "sched.h"
@@ -121,7 +126,7 @@ sched_get_priority_min (int policy)
{
if (policy < SCHED_MIN || policy > SCHED_MAX)
{
- errno = EINVAL;
+ PTW32_SET_ERRNO(EINVAL);
return -1;
}
diff --git a/pthreads/sched_getscheduler.c b/pthreads/sched_getscheduler.c
index 8769c15e5..cac3f77e7 100644
--- a/pthreads/sched_getscheduler.c
+++ b/pthreads/sched_getscheduler.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
#include "sched.h"
@@ -57,9 +62,7 @@ sched_getscheduler (pid_t pid)
if (NULL == h)
{
- errno =
- (GetLastError () ==
- (0xFF & ERROR_ACCESS_DENIED)) ? EPERM : ESRCH;
+ PTW32_SET_ERRNO(((0xFF & ERROR_ACCESS_DENIED) == GetLastError()) ? EPERM : ESRCH);
return -1;
}
else
diff --git a/pthreads/sched_setaffinity.c b/pthreads/sched_setaffinity.c
new file mode 100755
index 000000000..07b0fb4f4
--- /dev/null
+++ b/pthreads/sched_setaffinity.c
@@ -0,0 +1,352 @@
+/*
+ * sched_setaffinity.c
+ *
+ * Description:
+ * POSIX scheduling functions that deal with CPU affinity.
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads-win32 - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * http://sources.redhat.com/pthreads-win32/contributors.html
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "pthread.h"
+#include "implement.h"
+#include "sched.h"
+
+int
+sched_setaffinity (pid_t pid, size_t cpusetsize, cpu_set_t *set)
+ /*
+ * ------------------------------------------------------
+ * DOCPUBLIC
+ * Sets the CPU affinity mask of the process whose ID is pid
+ * to the value specified by mask. If pid is zero, then the
+ * calling process is used. The argument cpusetsize is the
+ * length (in bytes) of the data pointed to by mask. Normally
+ * this argument would be specified as sizeof(cpu_set_t).
+ *
+ * If the process specified by pid is not currently running on
+ * one of the CPUs specified in mask, then that process is
+ * migrated to one of the CPUs specified in mask.
+ *
+ * PARAMETERS
+ * pid
+ * Process ID
+ *
+ * cpusetsize
+ * Currently ignored in pthreads4w.
+ * Usually set to sizeof(cpu_set_t)
+ *
+ * mask
+ * Pointer to the CPU mask to set (cpu_set_t).
+ *
+ * DESCRIPTION
+ * Sets the CPU affinity mask of the process whose ID is pid
+ * to the value specified by mask. If pid is zero, then the
+ * calling process is used. The argument cpusetsize is the
+ * length (in bytes) of the data pointed to by mask. Normally
+ * this argument would be specified as sizeof(cpu_set_t).
+ *
+ * If the process specified by pid is not currently running on
+ * one of the CPUs specified in mask, then that process is
+ * migrated to one of the CPUs specified in mask.
+ *
+ * RESULTS
+ * 0 successfully created semaphore,
+ * EFAULT 'mask' is a NULL pointer.
+ * EINVAL '*mask' contains no CPUs in the set
+ * of available CPUs.
+ * EAGAIN The system available CPUs could not
+ * be obtained.
+ * EPERM The process referred to by 'pid' is
+ * not modifiable by us.
+ * ESRCH The process referred to by 'pid' was
+ * not found.
+ * ENOSYS Function not supported.
+ *
+ * ------------------------------------------------------
+ */
+{
+#if ! defined(NEED_PROCESS_AFFINITY_MASK)
+
+ DWORD_PTR vProcessMask;
+ DWORD_PTR vSystemMask;
+ HANDLE h;
+ int targetPid = (int)(size_t) pid;
+ int result = 0;
+
+ if (NULL == set)
+ {
+ result = EFAULT;
+ }
+ else
+ {
+ if (0 == targetPid)
+ {
+ targetPid = (int) GetCurrentProcessId ();
+ }
+
+ h = OpenProcess (PROCESS_QUERY_INFORMATION|PROCESS_SET_INFORMATION, PTW32_FALSE, (DWORD) targetPid);
+
+ if (NULL == h)
+ {
+ result = (((0xFF & ERROR_ACCESS_DENIED) == GetLastError()) ? EPERM : ESRCH);
+ }
+ else
+ {
+ if (GetProcessAffinityMask (h, &vProcessMask, &vSystemMask))
+ {
+ /*
+ * Result is the intersection of available CPUs and the mask.
+ */
+ DWORD_PTR newMask = vSystemMask & ((_sched_cpu_set_vector_*)set)->_cpuset;
+
+ if (newMask)
+ {
+ if (SetProcessAffinityMask(h, newMask) == 0)
+ {
+ switch (GetLastError())
+ {
+ case (0xFF & ERROR_ACCESS_DENIED):
+ result = EPERM;
+ break;
+ case (0xFF & ERROR_INVALID_PARAMETER):
+ result = EINVAL;
+ break;
+ default:
+ result = EAGAIN;
+ break;
+ }
+ }
+ }
+ else
+ {
+ /*
+ * Mask does not contain any CPUs currently available on the system.
+ */
+ result = EINVAL;
+ }
+ }
+ else
+ {
+ result = EAGAIN;
+ }
+ }
+ CloseHandle(h);
+ }
+
+ if (result != 0)
+ {
+ PTW32_SET_ERRNO(result);
+ return -1;
+ }
+ else
+ {
+ return 0;
+ }
+
+#else
+
+ PTW32_SET_ERRNO(ENOSYS);
+ return -1;
+
+#endif
+}
+
+
+int
+sched_getaffinity (pid_t pid, size_t cpusetsize, cpu_set_t *set)
+ /*
+ * ------------------------------------------------------
+ * DOCPUBLIC
+ * Gets the CPU affinity mask of the process whose ID is pid
+ * to the value specified by mask. If pid is zero, then the
+ * calling process is used. The argument cpusetsize is the
+ * length (in bytes) of the data pointed to by mask. Normally
+ * this argument would be specified as sizeof(cpu_set_t).
+ *
+ * PARAMETERS
+ * pid
+ * Process ID
+ *
+ * cpusetsize
+ * Currently ignored in pthreads4w.
+ * Usually set to sizeof(cpu_set_t)
+ *
+ * mask
+ * Pointer to the CPU mask to set (cpu_set_t).
+ *
+ * DESCRIPTION
+ * Sets the CPU affinity mask of the process whose ID is pid
+ * to the value specified by mask. If pid is zero, then the
+ * calling process is used. The argument cpusetsize is the
+ * length (in bytes) of the data pointed to by mask. Normally
+ * this argument would be specified as sizeof(cpu_set_t).
+ *
+ * RESULTS
+ * 0 successfully created semaphore,
+ * EFAULT 'mask' is a NULL pointer.
+ * EAGAIN The system available CPUs could not
+ * be obtained.
+ * EPERM The process referred to by 'pid' is
+ * not modifiable by us.
+ * ESRCH The process referred to by 'pid' was
+ * not found.
+ *
+ * ------------------------------------------------------
+ */
+{
+ DWORD_PTR vProcessMask;
+ DWORD_PTR vSystemMask;
+ HANDLE h;
+ int targetPid = (int)(size_t) pid;
+ int result = 0;
+
+ if (NULL == set)
+ {
+ result = EFAULT;
+ }
+ else
+ {
+
+#if ! defined(NEED_PROCESS_AFFINITY_MASK)
+
+ if (0 == targetPid)
+ {
+ targetPid = (int) GetCurrentProcessId ();
+ }
+
+ h = OpenProcess (PROCESS_QUERY_INFORMATION, PTW32_FALSE, (DWORD) targetPid);
+
+ if (NULL == h)
+ {
+ result = (((0xFF & ERROR_ACCESS_DENIED) == GetLastError()) ? EPERM : ESRCH);
+ }
+ else
+ {
+ if (GetProcessAffinityMask (h, &vProcessMask, &vSystemMask))
+ {
+ ((_sched_cpu_set_vector_*)set)->_cpuset = vProcessMask;
+ }
+ else
+ {
+ result = EAGAIN;
+ }
+ }
+ CloseHandle(h);
+
+#else
+ ((_sched_cpu_set_vector_*)set)->_cpuset = (size_t)0x1;
+#endif
+
+ }
+
+ if (result != 0)
+ {
+ PTW32_SET_ERRNO(result);
+ return -1;
+ }
+ else
+ {
+ return 0;
+ }
+}
+
+/*
+ * Support routines for cpu_set_t
+ */
+int _sched_affinitycpucount (const cpu_set_t *set)
+{
+ size_t tset;
+ int count;
+
+ /*
+ * Relies on tset being unsigned, otherwise the right-shift will
+ * be arithmetic rather than logical and the 'for' will loop forever.
+ */
+ for (count = 0, tset = ((_sched_cpu_set_vector_*)set)->_cpuset; tset; tset >>= 1)
+ {
+ if (tset & (size_t)1)
+ {
+ count++;
+ }
+ }
+ return count;
+}
+
+void _sched_affinitycpuzero (cpu_set_t *pset)
+{
+ ((_sched_cpu_set_vector_*)pset)->_cpuset = (size_t)0;
+}
+
+void _sched_affinitycpuset (int cpu, cpu_set_t *pset)
+{
+ ((_sched_cpu_set_vector_*)pset)->_cpuset |= ((size_t)1 << cpu);
+}
+
+void _sched_affinitycpuclr (int cpu, cpu_set_t *pset)
+{
+ ((_sched_cpu_set_vector_*)pset)->_cpuset &= ~((size_t)1 << cpu);
+}
+
+int _sched_affinitycpuisset (int cpu, const cpu_set_t *pset)
+{
+ return ((((_sched_cpu_set_vector_*)pset)->_cpuset &
+ ((size_t)1 << cpu)) != (size_t)0);
+}
+
+void _sched_affinitycpuand(cpu_set_t *pdestset, const cpu_set_t *psrcset1, const cpu_set_t *psrcset2)
+{
+ ((_sched_cpu_set_vector_*)pdestset)->_cpuset =
+ (((_sched_cpu_set_vector_*)psrcset1)->_cpuset &
+ ((_sched_cpu_set_vector_*)psrcset2)->_cpuset);
+}
+
+void _sched_affinitycpuor(cpu_set_t *pdestset, const cpu_set_t *psrcset1, const cpu_set_t *psrcset2)
+{
+ ((_sched_cpu_set_vector_*)pdestset)->_cpuset =
+ (((_sched_cpu_set_vector_*)psrcset1)->_cpuset |
+ ((_sched_cpu_set_vector_*)psrcset2)->_cpuset);
+}
+
+void _sched_affinitycpuxor(cpu_set_t *pdestset, const cpu_set_t *psrcset1, const cpu_set_t *psrcset2)
+{
+ ((_sched_cpu_set_vector_*)pdestset)->_cpuset =
+ (((_sched_cpu_set_vector_*)psrcset1)->_cpuset ^
+ ((_sched_cpu_set_vector_*)psrcset2)->_cpuset);
+}
+
+int _sched_affinitycpuequal (const cpu_set_t *pset1, const cpu_set_t *pset2)
+{
+ return (((_sched_cpu_set_vector_*)pset1)->_cpuset ==
+ ((_sched_cpu_set_vector_*)pset2)->_cpuset);
+}
diff --git a/pthreads/sched_setscheduler.c b/pthreads/sched_setscheduler.c
index 869131637..3a3df912e 100644
--- a/pthreads/sched_setscheduler.c
+++ b/pthreads/sched_setscheduler.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
#include "sched.h"
@@ -59,9 +64,7 @@ sched_setscheduler (pid_t pid, int policy)
if (NULL == h)
{
- errno =
- (GetLastError () ==
- (0xFF & ERROR_ACCESS_DENIED)) ? EPERM : ESRCH;
+ PTW32_SET_ERRNO((GetLastError () == (0xFF & ERROR_ACCESS_DENIED)) ? EPERM : ESRCH);
return -1;
}
else
@@ -71,7 +74,7 @@ sched_setscheduler (pid_t pid, int policy)
if (SCHED_OTHER != policy)
{
- errno = ENOSYS;
+ PTW32_SET_ERRNO(ENOSYS);
return -1;
}
diff --git a/pthreads/sched_yield.c b/pthreads/sched_yield.c
index 6ac5ed926..30de449bc 100644
--- a/pthreads/sched_yield.c
+++ b/pthreads/sched_yield.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
#include "sched.h"
diff --git a/pthreads/sem_close.c b/pthreads/sem_close.c
index 6d7280f29..5e86ae82d 100644
--- a/pthreads/sem_close.c
+++ b/pthreads/sem_close.c
@@ -15,10 +15,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -41,6 +42,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "semaphore.h"
#include "implement.h"
@@ -53,6 +58,6 @@
int
sem_close (sem_t * sem)
{
- errno = ENOSYS;
+ PTW32_SET_ERRNO(ENOSYS);
return -1;
} /* sem_close */
diff --git a/pthreads/sem_destroy.c b/pthreads/sem_destroy.c
index 6c98e80b9..243ba8d38 100644
--- a/pthreads/sem_destroy.c
+++ b/pthreads/sem_destroy.c
@@ -15,10 +15,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -41,6 +42,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "semaphore.h"
#include "implement.h"
@@ -133,7 +138,7 @@ sem_destroy (sem_t * sem)
if (result != 0)
{
- errno = result;
+ PTW32_SET_ERRNO(result);
return -1;
}
diff --git a/pthreads/sem_getvalue.c b/pthreads/sem_getvalue.c
index baafb02cf..704af1260 100644
--- a/pthreads/sem_getvalue.c
+++ b/pthreads/sem_getvalue.c
@@ -15,10 +15,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -41,6 +42,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "semaphore.h"
#include "implement.h"
@@ -77,34 +82,38 @@ sem_getvalue (sem_t * sem, int *sval)
* pointed to by sem in the int pointed to by sval.
*/
{
- if (sem == NULL || *sem == NULL || sval == NULL)
+ int result = 0;
+
+ if (NULL == sem || NULL == *sem || NULL == sval)
{
- errno = EINVAL;
- return -1;
+ result = EINVAL;
}
else
{
- long value;
register sem_t s = *sem;
- int result = 0;
if ((result = pthread_mutex_lock(&s->lock)) == 0)
{
- /* See sem_destroy.c
- */
- if (*sem == NULL)
- {
- (void) pthread_mutex_unlock (&s->lock);
- errno = EINVAL;
- return -1;
- }
-
- value = s->value;
- (void) pthread_mutex_unlock(&s->lock);
- *sval = value;
+ /*
+ * See sem_destroy.c
+ */
+ if (*sem == NULL /* don't test 's' here */)
+ {
+ result = EINVAL;
+ }
+ else
+ {
+ *sval = s->value;
+ }
+ (void) pthread_mutex_unlock (&s->lock);
}
+ }
- return result;
+ if (result != 0)
+ {
+ PTW32_SET_ERRNO(result);
+ return -1;
}
+ return 0;
} /* sem_getvalue */
diff --git a/pthreads/sem_init.c b/pthreads/sem_init.c
index f682f4b20..c161d239f 100644
--- a/pthreads/sem_init.c
+++ b/pthreads/sem_init.c
@@ -13,10 +13,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -39,6 +40,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "semaphore.h"
#include "implement.h"
@@ -158,7 +163,7 @@ sem_init (sem_t * sem, int pshared, unsigned int value)
if (result != 0)
{
- errno = result;
+ PTW32_SET_ERRNO(result);
return -1;
}
diff --git a/pthreads/sem_open.c b/pthreads/sem_open.c
index fb1cc541f..60316e665 100644
--- a/pthreads/sem_open.c
+++ b/pthreads/sem_open.c
@@ -15,10 +15,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -41,6 +42,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "semaphore.h"
#include "implement.h"
@@ -53,6 +58,6 @@
int
sem_open (const char *name, int oflag, mode_t mode, unsigned int value)
{
- errno = ENOSYS;
+ PTW32_SET_ERRNO(ENOSYS);
return -1;
} /* sem_open */
diff --git a/pthreads/sem_post.c b/pthreads/sem_post.c
index 34832527b..b495420bf 100644
--- a/pthreads/sem_post.c
+++ b/pthreads/sem_post.c
@@ -15,10 +15,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -41,6 +42,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "semaphore.h"
#include "implement.h"
@@ -74,55 +79,58 @@ sem_post (sem_t * sem)
*/
{
int result = 0;
- sem_t s = *sem;
- if (s == NULL)
+ if (NULL == sem || NULL == *sem)
{
result = EINVAL;
}
- else if ((result = pthread_mutex_lock (&s->lock)) == 0)
- {
- /* See sem_destroy.c
- */
- if (*sem == NULL)
- {
- (void) pthread_mutex_unlock (&s->lock);
- result = EINVAL;
- return -1;
- }
-
- if (s->value < SEM_VALUE_MAX)
+ else
{
-#if defined(NEED_SEM)
- if (++s->value <= 0
- && !SetEvent(s->sem))
+ sem_t s = *sem;
+
+ if ((result = pthread_mutex_lock (&s->lock)) == 0)
{
- s->value--;
- result = EINVAL;
- }
+ /*
+ * See sem_destroy.c
+ */
+ if (NULL == *sem /* don't test 's' here */)
+ {
+ result = EINVAL;
+ }
+ else
+ {
+ if (s->value < SEM_VALUE_MAX)
+ {
+#if defined(NEED_SEM)
+ if (++s->value <= 0
+ && !SetEvent(s->sem))
+ {
+ s->value--;
+ result = EINVAL;
+ }
#else
- if (++s->value <= 0
- && !ReleaseSemaphore (s->sem, 1, NULL))
- {
- s->value--;
- result = EINVAL;
- }
+ if (++s->value <= 0
+ && !ReleaseSemaphore (s->sem, 1, NULL))
+ {
+ s->value--;
+ result = EINVAL;
+ }
#endif /* NEED_SEM */
+ }
+ else
+ {
+ result = ERANGE;
+ }
+ }
+ (void) pthread_mutex_unlock (&s->lock);
+ }
}
- else
- {
- result = ERANGE;
- }
-
- (void) pthread_mutex_unlock (&s->lock);
- }
if (result != 0)
{
- errno = result;
+ PTW32_SET_ERRNO(result);
return -1;
}
return 0;
-
-} /* sem_post */
+}
diff --git a/pthreads/sem_post_multiple.c b/pthreads/sem_post_multiple.c
index 44c168c6c..01d8bb541 100644
--- a/pthreads/sem_post_multiple.c
+++ b/pthreads/sem_post_multiple.c
@@ -15,10 +15,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -41,6 +42,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "semaphore.h"
#include "implement.h"
@@ -133,7 +138,7 @@ sem_post_multiple (sem_t * sem, int count)
if (result != 0)
{
- errno = result;
+ PTW32_SET_ERRNO(result);
return -1;
}
diff --git a/pthreads/sem_timedwait.c b/pthreads/sem_timedwait.c
index 638431cf1..36dedf575 100644
--- a/pthreads/sem_timedwait.c
+++ b/pthreads/sem_timedwait.c
@@ -15,10 +15,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -41,6 +42,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "semaphore.h"
#include "implement.h"
@@ -168,7 +173,7 @@ sem_timedwait (sem_t * sem, const struct timespec *abstime)
if (*sem == NULL)
{
(void) pthread_mutex_unlock (&s->lock);
- errno = EINVAL;
+ PTW32_SET_ERRNO(EINVAL);
return -1;
}
@@ -185,7 +190,7 @@ sem_timedwait (sem_t * sem, const struct timespec *abstime)
cleanup_args.sem = s;
cleanup_args.resultPtr = &result;
-#if defined(_MSC_VER) && _MSC_VER < 1400
+#if defined(PTW32_CONFIG_MSVC7)
#pragma inline_depth(0)
#endif
/* Must wait */
@@ -195,7 +200,7 @@ sem_timedwait (sem_t * sem, const struct timespec *abstime)
#endif
result = pthreadCancelableTimedWait (s->sem, milliseconds);
pthread_cleanup_pop(result);
-#if defined(_MSC_VER) && _MSC_VER < 1400
+#if defined(PTW32_CONFIG_MSVC7)
#pragma inline_depth()
#endif
@@ -206,7 +211,7 @@ sem_timedwait (sem_t * sem, const struct timespec *abstime)
if (*sem == NULL)
{
(void) pthread_mutex_unlock (&s->lock);
- errno = EINVAL;
+ PTW32_SET_ERRNO(EINVAL);
return -1;
}
@@ -228,7 +233,7 @@ sem_timedwait (sem_t * sem, const struct timespec *abstime)
if (result != 0)
{
- errno = result;
+ PTW32_SET_ERRNO(result);
return -1;
}
diff --git a/pthreads/sem_trywait.c b/pthreads/sem_trywait.c
index 63614ba2b..3147ff3e1 100644
--- a/pthreads/sem_trywait.c
+++ b/pthreads/sem_trywait.c
@@ -15,10 +15,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -41,6 +42,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "semaphore.h"
#include "implement.h"
@@ -90,7 +95,7 @@ sem_trywait (sem_t * sem)
if (*sem == NULL)
{
(void) pthread_mutex_unlock (&s->lock);
- errno = EINVAL;
+ PTW32_SET_ERRNO(EINVAL);
return -1;
}
@@ -108,7 +113,7 @@ sem_trywait (sem_t * sem)
if (result != 0)
{
- errno = result;
+ PTW32_SET_ERRNO(result);
return -1;
}
diff --git a/pthreads/sem_unlink.c b/pthreads/sem_unlink.c
index fb80569a0..26bc442c7 100644
--- a/pthreads/sem_unlink.c
+++ b/pthreads/sem_unlink.c
@@ -15,10 +15,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -41,6 +42,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "semaphore.h"
#include "implement.h"
@@ -53,6 +58,6 @@
int
sem_unlink (const char *name)
{
- errno = ENOSYS;
+ PTW32_SET_ERRNO(ENOSYS);
return -1;
} /* sem_unlink */
diff --git a/pthreads/sem_wait.c b/pthreads/sem_wait.c
index 50c11d808..97b50e9cd 100644
--- a/pthreads/sem_wait.c
+++ b/pthreads/sem_wait.c
@@ -15,10 +15,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -41,6 +42,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "semaphore.h"
#include "implement.h"
@@ -130,7 +135,7 @@ sem_wait (sem_t * sem)
if (*sem == NULL)
{
(void) pthread_mutex_unlock (&s->lock);
- errno = EINVAL;
+ PTW32_SET_ERRNO(EINVAL);
return -1;
}
@@ -139,7 +144,7 @@ sem_wait (sem_t * sem)
if (v < 0)
{
-#if defined(_MSC_VER) && _MSC_VER < 1400
+#if defined(PTW32_CONFIG_MSVC7)
#pragma inline_depth(0)
#endif
/* Must wait */
@@ -147,7 +152,7 @@ sem_wait (sem_t * sem)
result = pthreadCancelableWait (s->sem);
/* Cleanup if we're canceled or on any other error */
pthread_cleanup_pop(result);
-#if defined(_MSC_VER) && _MSC_VER < 1400
+#if defined(PTW32_CONFIG_MSVC7)
#pragma inline_depth()
#endif
}
@@ -158,7 +163,7 @@ sem_wait (sem_t * sem)
if (*sem == NULL)
{
(void) pthread_mutex_unlock (&s->lock);
- errno = EINVAL;
+ PTW32_SET_ERRNO(EINVAL);
return -1;
}
@@ -178,7 +183,7 @@ sem_wait (sem_t * sem)
if (result != 0)
{
- errno = result;
+ PTW32_SET_ERRNO(result);
return -1;
}
diff --git a/pthreads/semaphore.h b/pthreads/semaphore.h
index c6e9407e2..835677b40 100644
--- a/pthreads/semaphore.h
+++ b/pthreads/semaphore.h
@@ -11,10 +11,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -85,6 +86,10 @@
# define PTW32_DLLPORT
#endif
+#if !defined(PTW32_CDECL)
+# define PTW32_CDECL __cdecl
+#endif
+
/*
* This is a duplicate of what is in the autoconf config.h,
* which is only used when building the pthread-win32 libraries.
@@ -129,35 +134,35 @@ typedef unsigned int mode_t;
typedef struct sem_t_ * sem_t;
-PTW32_DLLPORT int __cdecl sem_init (sem_t * sem,
- int pshared,
- unsigned int value);
+PTW32_DLLPORT int PTW32_CDECL sem_init (sem_t * sem,
+ int pshared,
+ unsigned int value);
-PTW32_DLLPORT int __cdecl sem_destroy (sem_t * sem);
+PTW32_DLLPORT int PTW32_CDECL sem_destroy (sem_t * sem);
-PTW32_DLLPORT int __cdecl sem_trywait (sem_t * sem);
+PTW32_DLLPORT int PTW32_CDECL sem_trywait (sem_t * sem);
-PTW32_DLLPORT int __cdecl sem_wait (sem_t * sem);
+PTW32_DLLPORT int PTW32_CDECL sem_wait (sem_t * sem);
-PTW32_DLLPORT int __cdecl sem_timedwait (sem_t * sem,
- const struct timespec * abstime);
+PTW32_DLLPORT int PTW32_CDECL sem_timedwait (sem_t * sem,
+ const struct timespec * abstime);
-PTW32_DLLPORT int __cdecl sem_post (sem_t * sem);
+PTW32_DLLPORT int PTW32_CDECL sem_post (sem_t * sem);
-PTW32_DLLPORT int __cdecl sem_post_multiple (sem_t * sem,
- int count);
+PTW32_DLLPORT int PTW32_CDECL sem_post_multiple (sem_t * sem,
+ int count);
-PTW32_DLLPORT int __cdecl sem_open (const char * name,
- int oflag,
- mode_t mode,
- unsigned int value);
+PTW32_DLLPORT int PTW32_CDECL sem_open (const char * name,
+ int oflag,
+ mode_t mode,
+ unsigned int value);
-PTW32_DLLPORT int __cdecl sem_close (sem_t * sem);
+PTW32_DLLPORT int PTW32_CDECL sem_close (sem_t * sem);
-PTW32_DLLPORT int __cdecl sem_unlink (const char * name);
+PTW32_DLLPORT int PTW32_CDECL sem_unlink (const char * name);
-PTW32_DLLPORT int __cdecl sem_getvalue (sem_t * sem,
- int * sval);
+PTW32_DLLPORT int PTW32_CDECL sem_getvalue (sem_t * sem,
+ int * sval);
#if defined(__cplusplus)
} /* End of extern "C" */
diff --git a/pthreads/signal.c b/pthreads/signal.c
index eef466962..845019d3d 100644
--- a/pthreads/signal.c
+++ b/pthreads/signal.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -44,7 +45,7 @@
* signal (interrupt) to a specified thread in the same
* process.
* Signals are always asynchronous (no deferred signals).
- * Pthread-win32 has an async cancelation mechanism.
+ * Pthread-win32 has an async cancellation mechanism.
* A similar system can be written to deliver signals
* within the same process (on ix86 processors at least).
*
@@ -81,6 +82,10 @@
* pthread_t structure.
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/pthreads/spin.c b/pthreads/spin.c
index 41b5aa525..ebd88e15b 100644
--- a/pthreads/spin.c
+++ b/pthreads/spin.c
@@ -38,7 +38,6 @@
#include "implement.h"
-#include "ptw32_spinlock_check_need_init.c"
#include "pthread_spin_init.c"
#include "pthread_spin_destroy.c"
#include "pthread_spin_lock.c"
diff --git a/pthreads/tests/Bmakefile b/pthreads/tests/Bmakefile
index df2ac1b1b..f4bdd9cc5 100644
--- a/pthreads/tests/Bmakefile
+++ b/pthreads/tests/Bmakefile
@@ -5,7 +5,7 @@
#
# Pthreads-win32 - POSIX Threads Library for Win32
# Copyright(C) 1998 John E. Bossom
-# Copyright(C) 1999,2005 Pthreads-win32 contributors
+# Copyright(C) 1999,2012 Pthreads-win32 contributors
#
# Contact Email: rpj@callisto.canberra.edu.au
#
@@ -64,7 +64,7 @@ BCXFLAGS = -D__CLEANUP_C
CPLIB = $(BCLIB)
CPDLL = $(BCDLL)
-CFLAGS= -q $(OPTIM) /D_WIN32_WINNT=0x400 -w -tWC -tWM -4 -w-aus -w-asc -w-par
+CFLAGS= -q $(OPTIM) -w -tWC -tWM -4 -w-aus -w-asc -w-par
LFLAGS=
INCLUDES=-I.
BUILD_DIR=..
@@ -76,7 +76,7 @@ EHFLAGS =
# If a test case returns a non-zero exit code to the shell, make will
# stop.
-PASSES= loadfree.pass \
+PASSES= \
errno1.pass \
self1.pass mutex5.pass \
mutex1.pass mutex1n.pass mutex1e.pass mutex1r.pass \
@@ -87,7 +87,7 @@ PASSES= loadfree.pass \
exit1.pass create1.pass create2.pass reuse1.pass reuse2.pass equal1.pass \
sequence1.pass kill1.pass valid1.pass valid2.pass \
exit2.pass exit3.pass exit4.pass exit5.pass \
- join0.pass join1.pass detach1.pass join2.pass join3.pass \
+ join0.pass join1.pass detach1.pass join2.pass join3.pass join4.pass \
mutex4.pass mutex6.pass mutex6n.pass mutex6e.pass mutex6r.pass \
mutex6s.pass mutex6es.pass mutex6rs.pass \
mutex7.pass mutex7n.pass mutex7e.pass mutex7r.pass \
@@ -112,8 +112,10 @@ PASSES= loadfree.pass \
cleanup0.pass cleanup1.pass cleanup2.pass cleanup3.pass \
priority1.pass priority2.pass inherit1.pass \
spin1.pass spin2.pass spin3.pass spin4.pass \
- exception1.pass exception2.pass exception3.pass \
- cancel9.pass stress1.pass
+ exception1.pass exception2.pass exception3_0.pass exception3.pass \
+ cancel9.pass \
+ affinity1.pass affinity2.pass affinity3.pass affinity4.pass affinity5.pass \
+ stress1.pass
BENCHRESULTS = \
benchtest1.bench benchtest2.bench benchtest3.bench benchtest4.bench benchtest5.bench
@@ -214,6 +216,7 @@ clean:
- $(RM) *.o
- $(RM) *.asm
- $(RM) *.exe
+ - $(RM) *.manifest
- $(RM) *.pass
- $(RM) *.bench
- $(RM) *.log
@@ -223,6 +226,12 @@ benchtest2.bench:
benchtest3.bench:
benchtest4.bench:
benchtest5.bench:
+
+affinity1.pass:
+affinity2.pass: affinity1.pass
+affinity3.pass: affinity2.pass
+affinity4.pass: affinity3.pass
+affinity5.pass: affinity4.pass
barrier1.pass: semaphore4.pass
barrier2.pass: barrier1.pass
barrier3.pass: barrier2.pass
@@ -269,7 +278,8 @@ equal1.pass: create1.pass
errno1.pass: mutex3.pass
exception1.pass: cancel4.pass
exception2.pass: exception1.pass
-exception3.pass: exception2.pass
+exception3_0.pass: exception2.pass
+exception3.pass: exception3_0.pass
exit1.pass:
exit2.pass: create1.pass
exit3.pass: create1.pass
@@ -281,8 +291,8 @@ join0.pass: create1.pass
join1.pass: create1.pass
join2.pass: create1.pass
join3.pass: join2.pass
+join4.pass: join3.pass
kill1.pass:
-loadfree.pass: pthread.dll
mutex1.pass: self1.pass
mutex1n.pass: mutex1.pass
mutex1e.pass: mutex1.pass
diff --git a/pthreads/tests/ChangeLog b/pthreads/tests/ChangeLog
index dfb4f4555..5cb92fefa 100644
--- a/pthreads/tests/ChangeLog
+++ b/pthreads/tests/ChangeLog
@@ -1,3 +1,192 @@
+2012-10-16 Ross Johnson <ross dot johnson at homemail dot com dot au>
+
+ * GNUmakefile (EXTRAVERSION): Naming option for libraries to be
+ consistent with MSVS Makefile; no longer automatically based on
+ ARCH setting.
+
+2012-10-10 Ross Johnson <ross dot johnson at homemail dot com dot au>
+
+ * cancel1.c: Fix comment typo.
+ * Makefile: Adding functionality to support rapid turnaround of
+ individual or small sets of tests; removed loadfree test.
+ * GNUmakefile: Likewise.
+ * Bmakefile: Removed loadfree test.
+ * Wmakefile: Likewise.
+ * common.mk: New makefile include file; split out common macros.
+ * runorder.mk: New makefile include file; split out run order rules
+ to allow selective inclusion.
+ * loadfree.c: Removed from suite; not required; unnecessarily
+ complicates the makefiles.
+
+2012-10-04 Ross Johnson <ross dot johnson at homemail dot com dot au>
+
+ * join4.c: Modified for pthread_tryjoin_np tests.
+
+2012-09-29 Ross Johnson <ross dot johnson at homemail dot com dot au>
+
+ * Makefile: Align target names with build makefile target names
+ following changes there; remove the separate static tests list.
+ * GNUmakefile: Likewise; consolidate rules.
+
+2012-09-25 Ross Johnson <ross dot johnson at homemail dot com dot au>
+
+ * context1.c (anotherEnding): Should exit the thread, not return.
+
+2012-09-23 Ross Johnson <ross dot johnson at homemail dot com dot au>
+
+ * Makefile: Add secondary target names to existing test targets so
+ we can output how the library was built, e.g. "Running VC-inlined test".
+ This is useful when making "all-tests" from the library build Makefile.
+ * GNUmakefile: Similarly.
+
+2012-09-22 Ross Johnson <ross dot johnson at homemail dot com dot au>
+
+ * GNUmakefile: Do what Makefile does and print the make target
+ when running each test.
+
+2012-09-22 Daniel Richard. G <danielg at teragram dot com>
+
+ * Makefile: This reverts an earlier change of mine. In some
+ versions of nmake, $(MAKE) is a full path, which utterly futzes
+ up the "make help" output; regularized the test targets, so we
+ have e.g. VSE-static now; regularized the parentheticals;
+ removed a spurious use of $(DLL_VER); new test targets: VCX-debug
+ {VSE,VCX}-static{,-debug}; fixed the {VC,VCE}-static-debug targets.
+ * exception3.c: Narrowly exclude this test from the known-bad VS2005
+ configuration (By the way: I downloaded and tested with what is
+ presumably the most up-to-date MSVCR80.DLL. Same deal.); use
+ pthread_win32_set_terminate_np() when appropriate, and verify that
+ it has an effect different from calling set_terminate(); no need for
+ that assert(); it's overly pedantic.
+ * exception3_0.c: Same VS2005 exclusion.
+ * once3.c: Put in a note so that users know what to do if the test
+ hangs or exits abnormally (I figured this is better than narrowly
+ disabling pthread_cancel() on MSVC6, since cancellation does seem to
+ work correctly with /EHa, and we don't have any way of telling at
+ compile time whether /EHs or /EHa is in use).
+ * once4.c: Likewise.
+ * semaphore1.c: s/PTW32_BROKEN_ERRNO/PTW32_USES_SEPARATE_CRT/
+
+2012-09-22 Ross Johnson <ross dot johnson at homemail dot com dot au>
+
+ * pthread_win32_attach_detach_np.c (pthread_win32_detach_thread_np):
+ Check for NULL ptw32_selfThreadKey before call to TlsSetKey(). Need
+ to find where this is being set to NULL before this point. Was
+ consistently failing tests/seamphore3.c in all GC static builds and
+ never seen in GC DLL builds. May also be responsible for
+ inconsistent VCE fails on that test, although the fail mode was
+ different - the latter hangs the test while the former segfaults.
+
+2012-09-22 Ross Johnson <ross dot johnson at homemail dot com dot au>
+
+ * GNUmakefile (GC-static-debug): New make target.
+
+2012-09-21 Ross Johnson <ross dot johnson at homemail dot com dot au>
+
+ * affinity1.c: New test for new process CPU affinity routines.
+ * affinity2.c: New test for new process CPU affinity routines.
+ * affinity3.c: New test for new process and thread CPU affinity routines.
+ * affinity4.c: New test for new process and thread CPU affinity routines.
+ * affinity5.c: New test for new process and thread CPU affinity routines.
+ * Makefile: Add new tests.
+ * GNUmakfile: Likewise.
+ * Bmakfile: Likewise.
+ * Wmakfile: Likewise.
+
+2012-09-09 Ross Johnson <ross dot johnson at homemail dot com dot au>
+
+ * exception3.c: Rewrite to fix strategy.
+ * exception3_0.c: New test.
+ * exception2.c: Reduce sleep time to speed up test.
+ * Makefile (exception3_0.*): Add new test.
+ * GNUmakefile (exception3_0.*): Add new test.
+ * Bmakefile (exception3_0.*): Add new test.
+ * Wmakefile (exception3_0.*): Add new test.
+
+2012-09-05 Daniel Richard. G <danielg at teragram dot com>
+
+ * exception2.c: Fix result codes to avoid false negative failures.
+ * cancel9.c: cosmetic change.
+ * GNUmakefile (clean): delete manifest files.
+ * Bmakefile: Likewise.
+ * Wmakefile: Likewise.
+ * Makefile: Likewise.
+
+2012-09-04 Ross Johnson <ross dot johnson at homemail dot com dot au>
+
+ * Makefile (VCEFLAGS): Changed from /EHsc to /EHs which was causing
+ tests/once3.c to hang, suspect exceptions not being thrown from
+ extern C routines.
+ * cancel2.c: Rewrite to use a barrier for thread control; remove
+ asyncronous cancel type which was a massive bug in the test strategy
+ and cusing SEGFAULTs (access violations).
+ * eyal1.c: Remove unused variable 'i' to clear compiler warning.
+ * context1.c: Remove call to pthread_exit() in alternate ending to
+ quell error in GCE tests see when running x86 build on x64.
+
+2012-09-03 Ross Johnson <ross dot johnson at homemail dot com dot au>
+
+ * Makefile (VCE-static): Add VC++ static build target
+ (VCE-static-debug): Likewise.
+
+2012-08-29 Daniel Richard. G <danielg at teragram dot com>
+
+ * mutex6.c: Removed pointless exit(0) and never-reached comment.
+ * mutex6r.c: Likewise.
+ * mutex6rs.c: Likewise.
+ * mutex6s.c: Likewise.
+ * mutex6e.c: Likewise.
+ * mutex6es.c: Likewise.
+ * mutex7.c: Likewise.
+ * mutex7e.c: Likewise.
+ * mutex7n.c: Likewise.
+ * mutex7r.c: Likewise.
+ * mutex6n.c: Likewise; ensure operator precedence.
+ * once2.c (sharedInt_t): replace static initialization of struct with memset.
+ * once3.c: Likewise.
+ * once4.c: Likewise.
+ * cleanup0.c: Likewise.
+ * cleanup1.c: Likewise.
+ * cleanup2.c: Likewise.
+ * cleanup3.c: Likewise.
+ * openmp1.c: Fix casts.
+ * exit1.c: Remove assert statement that is never reached and return 1.
+ * exception2.c: Prevent displaying modal error dialog.
+
+2012-08-19 Ross Johnson <ross dot johnson at homemail dot com dot au>
+
+ * join4.c: Test for new pthread_timedjoin_np routine
+ * Makefile (join4): Added.
+ * GNUmakefile (join4): Added.
+ * Bmakefile (join4): Added.
+ * Wmakefile (join4): Added.
+ * test.h (sys/timeb.h): Add #include.
+ * mutex8.c (sys/timeb.h): Remove #include.
+ * mutex8e.c (sys/timeb.h): Remove #include.
+ * mutex8n.c (sys/timeb.h): Remove #include.
+ * mutex8r.c (sys/timeb.h): Remove #include.
+ * benchtest1.c (sys/timeb.h): Remove #include.
+ * benchtest2.c (sys/timeb.h): Remove #include.
+ * benchtest3.c (sys/timeb.h): Remove #include.
+ * benchtest4.c (sys/timeb.h): Remove #include.
+ * benchtest5.c (sys/timeb.h): Remove #include.
+
+2012-08-11 Daniel Richard. G <danielg at teragram dot com>
+
+ * Makefile: Various improvements.
+ * GNUmakefile: Likewise.
+
+2011-07-20 Ross Johnson <ross dot johnson at homemail dot com dot au>
+
+ * cancel2.c (PTHREAD_CANCELED): Fix cast warning when compiling with g++.
+ * cleanup0.c (PTHREAD_CANCELED): Likewise.
+ * cleanup1.c (PTHREAD_CANCELED): Likewise.
+
+2012-07-19 Daniel Richard. G <danielg at teragram dot com>
+
+ * Makefile: Various fixes.
+ * GNUmakefile: Likewise.
+
2011-07-03 Ross Johnson <ross dot johnson at homemail dot com dot au>
* create3.c: Removed; testing a condition that is not in the library's
@@ -96,7 +285,7 @@
* GNUMakefile: Update for new tests.
* Makefile: Ditto.
* BMakefile: Ditto.
- * once3.c: Improve cancelation testing.
+ * once3.c: Improve cancellation testing.
* stress1.c: Fix comment.
2007-01-04 Ross Johnson <Ross dot Johnson at homemail dot com dot au>
@@ -742,13 +931,13 @@
2000-01-04 Ross Johnson <rpj@special.ise.canberra.edu.au>
- * cancel4.c: New; Test cancelation does not occur in deferred
- cancelation threads with no cancelation points.
+ * cancel4.c: New; Test cancellation does not occur in deferred
+ cancellation threads with no cancellation points.
- * cancel3.c: New; Test asynchronous cancelation.
+ * cancel3.c: New; Test asynchronous cancellation.
* context1.c: New; Test context switching method for async
- cancelation.
+ cancellation.
1999-11-23 Ross Johnson <rpj@special.ise.canberra.edu.au>
@@ -772,7 +961,7 @@ Oct 14 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au>
* condvar7.c: New. Test broadcast after waiting thread is canceled.
* condvar8.c: New. Test multiple broadcasts.
* condvar9.c: New. Test multiple broadcasts with thread
- cancelation.
+ cancellation.
Sep 16 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au>
diff --git a/pthreads/tests/GNUmakefile b/pthreads/tests/GNUmakefile
index 355c27e8c..7cbdf7446 100644
--- a/pthreads/tests/GNUmakefile
+++ b/pthreads/tests/GNUmakefile
@@ -5,9 +5,7 @@
#
# Pthreads-win32 - POSIX Threads Library for Win32
# Copyright(C) 1998 John E. Bossom
-# Copyright(C) 1999,2005 Pthreads-win32 contributors
-#
-# Contact Email: rpj@callisto.canberra.edu.au
+# Copyright(C) 1999,2012 Pthreads-win32 contributors
#
# The current list of contributors is contained
# in the file CONTRIBUTORS included with the source
@@ -31,21 +29,27 @@
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
-DLL_VER = 2
+DLL_VER = 2$(EXTRAVERSION)
-CP = cp -f
-MV = mv -f
-RM = rm -f
-CAT = cat
-MKDIR = mkdir
-TOUCH = echo Passed >
-ECHO = @echo
-MAKE = make -k
+CP = cp -f
+MV = mv -f
+RM = rm -f
+CAT = cat
+MKDIR = mkdir
+ECHO = echo
+TOUCH = $(ECHO) Passed >
+TESTFILE = test -f
+TESTDIR = test -d
+AND = &&
# For cross compiling use e.g.
# # make CROSS=i386-mingw32msvc- clean GC
CROSS =
+# For cross testing use e.g.
+# # make RUN=wine CROSS=i386-mingw32msvc- clean GC
+RUN =
+
AR = $(CROSS)ar
DLLTOOL = $(CROSS)dlltool
CC = $(CROSS)gcc
@@ -53,25 +57,35 @@ CXX = $(CROSS)g++
RANLIB = $(CROSS)ranlib
#
-# Mingw32
+# Mingw
#
+XLIBS =
XXCFLAGS =
-XXLIBS = -lws2_32 -lgomp
+XXLIBS =
OPT = -O3
DOPT = -g -O0
-#CFLAGS = -O3 -UNDEBUG -Wall $(XXCFLAGS)
-CFLAGS = ${OPT} -UNDEBUG -Wall $(XXCFLAGS)
+CFLAGS = ${OPT} $(ARCH) -UNDEBUG -Wall $(XXCFLAGS)
+LFLAGS = $(ARCH) $(XXLFLAGS)
+#
+# Uncomment this next to link the GCC/C++ runtime libraries statically
+# (Be sure to read about these options and their associated caveats
+# at http://gcc.gnu.org/onlinedocs/gcc/Link-Options.html)
+#
+# NOTE 1: Doing this appears to break GCE:pthread_cleanup_*(), which
+# relies on C++ class destructors being called when leaving scope.
+#
+# NOTE 2: If you do this DO NOT distribute your pthreads DLLs with
+# the official filenaming, i.e. pthreadVC2.dll, etc. Instead, change DLL_VER
+# above to "2slgcc" for example, to build "pthreadGC2slgcc.dll", etc.
+#
+#LFLAGS += -static-libgcc -static-libstdc++
BUILD_DIR = ..
INCLUDES = -I.
-.INTERMEDIATE: %.exe %.pass
-.SECONDARY: %.exe %.pass
-.PRECIOUS: %.exe %.pass
-
TEST = GC
# Default lib version
-GCX = $(TEST)$(DLL_VER)
+GCX = GC$(DLL_VER)
# Files we need to run the tests
# - paths are relative to pthreads build dir.
@@ -81,345 +95,134 @@ DLL = pthread$(GCX).dll
# The next path is relative to $BUILD_DIR
QAPC = # ../QueueUserAPCEx/User/quserex.dll
-COPYFILES = $(HDR) $(LIB) $(DLL) $(QAPC)
-
-# If a test case returns a non-zero exit code to the shell, make will
-# stop.
-
-TESTS = \
- sizes loadfree \
- self1 mutex5 mutex1 mutex1e mutex1n mutex1r \
- semaphore1 semaphore2 semaphore3 \
- condvar1 condvar1_1 condvar1_2 condvar2 condvar2_1 exit1 \
- create1 create2 reuse1 reuse2 equal1 \
- sequence1 kill1 valid1 valid2 \
- exit2 exit3 exit4 exit5 \
- join0 join1 detach1 join2 join3 \
- mutex2 mutex2r mutex2e mutex3 mutex3r mutex3e \
- mutex4 mutex6 mutex6n mutex6e mutex6r \
- mutex6s mutex6es mutex6rs \
- mutex7 mutex7n mutex7e mutex7r mutex8 mutex8n mutex8e mutex8r \
- robust1 robust2 robust3 robust4 robust5 \
- count1 \
- once1 once2 once3 once4 self2 \
- cancel1 cancel2 \
- semaphore4 semaphore4t semaphore5 \
- barrier1 barrier2 barrier3 barrier4 barrier5 barrier6 \
- tsd1 tsd2 openmp1 delay1 delay2 eyal1 \
- condvar3 condvar3_1 condvar3_2 condvar3_3 \
- condvar4 condvar5 condvar6 condvar7 condvar8 condvar9 \
- errno1 \
- rwlock1 rwlock2 rwlock3 rwlock4 rwlock5 rwlock6 rwlock7 rwlock8 \
- rwlock2_t rwlock3_t rwlock4_t rwlock5_t rwlock6_t rwlock6_t2 \
- context1 cancel3 cancel4 cancel5 cancel6a cancel6d \
- cancel7 cancel8 \
- cleanup0 cleanup1 cleanup2 cleanup3 \
- priority1 priority2 inherit1 \
- spin1 spin2 spin3 spin4 \
- exception1 exception2 exception3 \
- cancel9 stress1
-
-STRESSTESTS = \
- stress1
-
-BENCHTESTS = \
- benchtest1 benchtest2 benchtest3 benchtest4 benchtest5
-
-STATICTESTS = \
- sizes \
- self1 mutex5 mutex1 mutex1e mutex1n mutex1r \
- semaphore1 semaphore2 semaphore3 \
- condvar1 condvar1_1 condvar1_2 condvar2 condvar2_1 exit1 \
- create1 create2 reuse1 reuse2 equal1 \
- sequence1 kill1 valid1 valid2 \
- exit2 exit3 exit4 exit5 \
- join0 join1 detach1 join2 join3 \
- mutex2 mutex2r mutex2e mutex3 mutex3r mutex3e \
- mutex4 mutex6 mutex6n mutex6e mutex6r \
- mutex6s mutex6es mutex6rs \
- mutex7 mutex7n mutex7e mutex7r mutex8 mutex8n mutex8e mutex8r \
- robust1 robust2 robust3 robust4 robust5 \
- count1 \
- once1 once2 once3 once4 self2 \
- cancel1 cancel2 \
- semaphore4 semaphore4t semaphore5 \
- barrier1 barrier2 barrier3 barrier4 barrier5 barrier6 \
- tsd1 tsd2 delay1 delay2 eyal1 \
- condvar3 condvar3_1 condvar3_2 condvar3_3 \
- condvar4 condvar5 condvar6 condvar7 condvar8 condvar9 \
- errno1 \
- rwlock1 rwlock2 rwlock3 rwlock4 rwlock5 rwlock6 rwlock7 rwlock8 \
- rwlock2_t rwlock3_t rwlock4_t rwlock5_t rwlock6_t rwlock6_t2 \
- context1 cancel3 cancel4 cancel5 cancel6a cancel6d \
- cancel7 cancel8 \
- cleanup0 cleanup1 cleanup2 cleanup3 \
- priority1 priority2 inherit1 \
- spin1 spin2 spin3 spin4 \
- exception1 exception2 exception3 \
- cancel9 stress1
-
-ALLTESTS = $(TESTS) $(BENCHTESTS)
-
-ASM = $(ALLTESTS:%=%.s)
-PASSES = $(TESTS:%=%.pass)
+include common.mk
+
+.INTERMEDIATE: $(ALL_KNOWN_TESTS:%=%.exe) $(BENCHTESTS:%=%.exe)
+.SECONDARY: $(ALL_KNOWN_TESTS:%=%.exe) $(ALL_KNOWN_TESTS:%=%.pass) $(BENCHTESTS:%=%.exe) $(BENCHTESTS:%=%.bench)
+.PRECIOUS: $(ALL_KNOWN_TESTS:%=%.exe) $(ALL_KNOWN_TESTS:%=%.pass) $(BENCHTESTS:%=%.exe) $(BENCHTESTS:%=%.bench)
+
+ASM = $(ALL_KNOWN_TESTS:%=%.s)
+TESTS = $(ALL_KNOWN_TESTS)
BENCHRESULTS = $(BENCHTESTS:%=%.bench)
-STRESSRESULTS = $(STRESSTESTS:%=%.pass)
-STATICRESULTS = $(STATICTESTS:%=%.pass)
+
+#
+# To build and run "foo.exe" and "bar.exe" only use, e.g.:
+# make clean GC NO_DEPS=1 TESTS="foo bar"
+#
+# To build and run "foo.exe" and "bar.exe" and run all prerequisite tests
+# use, e.g.:
+# make clean GC TESTS="foo bar"
+#
+# Set TESTS to one or more tests.
+#
+ifndef NO_DEPS
+include runorder.mk
+endif
help:
@ $(ECHO) "Run one of the following command lines:"
- @ $(ECHO) "make clean GC (to test using GC dll with C (no EH) applications)"
- @ $(ECHO) "make clean GCX (to test using GC dll with C++ (EH) applications)"
- @ $(ECHO) "make clean GCE (to test using GCE dll with C++ (EH) applications)"
- @ $(ECHO) "make clean GC-bench (to benchtest using GNU C dll with C cleanup code)"
- @ $(ECHO) "make clean GCE-bench (to benchtest using GNU C dll with C++ exception handling)"
- @ $(ECHO) "make clean GC-stress (to stresstest using GNU C dll with C cleanup code)"
- @ $(ECHO) "make clean GCE-stress (to stresstest using GNU C dll with C++ exception handling)"
- @ $(ECHO) "make clean GC-static (to test using GC static lib with C (no EH) applications)"
- @ $(ECHO) "make clean GC-debug (to test using GC dll with C (no EH) applications)"
-
-all:
- @ $(MAKE) clean GC
- @ $(MAKE) clean GCX
- @ $(MAKE) clean GCE
+ @ $(ECHO) "$(MAKE) clean GC (to test using GC dll with C (no EH) applications)"
+ @ $(ECHO) "$(MAKE) clean GCX (to test using GC dll with C++ (EH) applications)"
+ @ $(ECHO) "$(MAKE) clean GCE (to test using GCE dll with C++ (EH) applications)"
+ @ $(ECHO) "$(MAKE) clean GC-bench (to benchtest using GNU C dll with C cleanup code)"
+ @ $(ECHO) "$(MAKE) clean GC-debug (to test using GC dll with C (no EH) applications)"
+ @ $(ECHO) "$(MAKE) clean GC-static (to test using GC static lib with C (no EH) applications)"
+ @ $(ECHO) "$(MAKE) clean GC-static-debug (to test using GC static lib with C (no EH) applications)"
+ @ $(ECHO) "$(MAKE) clean GCE-static (to test using GC static lib with C (no EH) applications)"
+ @ $(ECHO) "$(MAKE) clean GCE-static-debug (to test using GC static lib with C (no EH) applications)"
+ @ $(ECHO) "$(MAKE) clean GCE-debug (to test using GCE dll with C++ (EH) applications)"
+ @ $(ECHO) "$(MAKE) clean GCX-static (to test using GC static lib with C++ applications)"
+ @ $(ECHO) "$(MAKE) clean GCX-static-debug (to test using GC static lib with C++ applications)"
+ @ $(ECHO) "$(MAKE) clean GCX-debug (to test using GCE dll with C++ (EH) applications)"
+ @ $(ECHO) "$(MAKE) clean GC-foo (to build individual test \"foo.c\" with C and run using GC dll)"
+ @ $(ECHO) "$(MAKE) clean GCE-foo (to build individual tests \"foo.c\" with C++ and run using GCE dll)"
+ @ $(ECHO) "$(MAKE) clean GCX-foo (to build individual tests \"foo.c\" with C++ and run using GC dll)"
GC:
- $(MAKE) TEST=GC CC=$(CC) XXCFLAGS="-fopenmp -D__CLEANUP_C" all-pass
+ @ $(MAKE) --no-builtin-rules TEST=$@ GCX="GC$(DLL_VER)" CC=$(CC) XXCFLAGS="-D__CLEANUP_C" allpassed
GC-asm:
- $(MAKE) TEST=GC CC=$(CC) XXCFLAGS="-fopenmp -D__CLEANUP_C" all-asm
-
-GCE:
- $(MAKE) TEST=GCE CC=$(CXX) XXCFLAGS="-fopenmp -mthreads -D__CLEANUP_CXX" all-pass
-
-GCX:
- $(MAKE) TEST=GC CC=$(CXX) XXCFLAGS="-fopenmp -mthreads -D__CLEANUP_C" all-pass
+ @ $(MAKE) --no-builtin-rules TEST=$@ GCX="GC$(DLL_VER)" CC=$(CC) XXCFLAGS="-D__CLEANUP_C" all-asm
GC-bench:
- $(MAKE) TEST=GC CC=$(CC) XXCFLAGS="-D__CLEANUP_C" XXLIBS="benchlib.o" all-bench
+ @ $(MAKE) --no-builtin-rules TEST=$@ GCX="GC$(DLL_VER)" CC=$(CC) XXCFLAGS="-D__CLEANUP_C" XXLIBS="benchlib.o" all-bench
-GCE-bench:
- $(MAKE) TEST=GCE CC=$(CXX) XXCFLAGS="-mthreads -D__CLEANUP_CXX" XXLIBS="benchlib." all-bench
+GC-bench-debug:
+ @ $(MAKE) --no-builtin-rules TEST=$@ GCX="GC$(DLL_VER)d" CC=$(CC) XXCFLAGS="-D__CLEANUP_C" XXLIBS="benchlib.o" OPT="${DOPT}" all-bench
GC-debug:
- $(MAKE) TEST=GC CC=$(CC) XXCFLAGS="-fopenmp -D__CLEANUP_C" OPT="${DOPT}" DLL_VER="$(DLL_VER)d" all-pass
+ @ $(MAKE) --no-builtin-rules TEST=$@ GCX="GC$(DLL_VER)d" CC=$(CC) XXCFLAGS="-D__CLEANUP_C" OPT="${DOPT}" allpassed
+
+GC-static GC-small-static:
+ @ $(MAKE) --no-builtin-rules TEST=$@ GCX="GC$(DLL_VER)" CC=$(CC) XXCFLAGS="-D__CLEANUP_C -DPTW32_STATIC_LIB" DLL="" allpassed
+
+GC-static-debug GC-small-static-debug:
+ @ $(MAKE) --no-builtin-rules TEST=$@ GCX="GC$(DLL_VER)d" CC=$(CC) XXCFLAGS="-D__CLEANUP_C -DPTW32_STATIC_LIB" OPT="$(DOPT)" DLL="" allpassed
+
+GCE:
+ @ $(MAKE) --no-builtin-rules TEST=$@ GCX="GCE$(DLL_VER)" CC=$(CXX) XXCFLAGS="-mthreads -D__CLEANUP_CXX" allpassed
GCE-debug:
- $(MAKE) TEST=GCE CC=$(CXX) XXCFLAGS="-fopenmp -D__CLEANUP_CXX" OPT="${DOPT}" DLL_VER="$(DLL_VER)d" all-pass
+ @ $(MAKE) --no-builtin-rules TEST=$@ GCX="GCE$(DLL_VER)d" CC=$(CXX) XXCFLAGS="-D__CLEANUP_CXX" OPT="${DOPT}" allpassed
-GC-bench-debug:
- $(MAKE) TEST=GC CC=$(CC) XXCFLAGS="-D__CLEANUP_C" XXLIBS="benchlib.o" OPT="${OPT}" DLL_VER="$(DLL_VER)d" all-bench
+GCE-static GCE-small-static:
+ @ $(MAKE) --no-builtin-rules TEST=$@ GCX="GCE$(DLL_VER)" CC=$(CXX) XXCFLAGS="-D__CLEANUP_CXX -DPTW32_STATIC_LIB" DLL="" allpassed
-GC-static:
- $(MAKE) TEST=GC CC=$(CC) XXCFLAGS="-D__CLEANUP_C -DPTW32_STATIC_LIB" XXLIBS="-lws2_32" DLL="" all-static
+GCE-static-debug GCE-small-static-debug:
+ @ $(MAKE) --no-builtin-rules TEST=$@ GCX="GCE$(DLL_VER)d" CC=$(CXX) XXCFLAGS="-D__CLEANUP_CXX -DPTW32_STATIC_LIB" OPT="$(DOPT)" DLL="" allpassed
+
+GCX:
+ @ $(MAKE) --no-builtin-rules TEST=$@ GCX="GC$(DLL_VER)" CC=$(CXX) XXCFLAGS="-mthreads -D__CLEANUP_C" allpassed
-GC-stress:
- $(ECHO) Stress tests can take a long time since they are trying to
- $(ECHO) expose weaknesses that may be intermittant or statistically rare.
- $(ECHO) A pass does not prove correctness, but may give greater confidence.
- $(MAKE) TEST=GC CC=$(CC) XXCFLAGS="-D__CLEANUP_C" XXLIBS="" all-stress
+GCX-debug:
+ @ $(MAKE) --no-builtin-rules TEST=$@ GCX="GC$(DLL_VER)d" CC=$(CXX) XXCFLAGS="-D__CLEANUP_C" OPT="${DOPT}" allpassed
-GCE-stress:
- $(MAKE) TEST=GCE CC=$(CXX) XXCFLAGS="-mthreads -D__CLEANUP_CXX" XXLIBS="" all-stress
+GCX-static GCX-small-static:
+ @ $(MAKE) --no-builtin-rules TEST=$@ GCX="GC$(DLL_VER)" CC=$(CXX) XXCFLAGS="-D__CLEANUP_C -DPTW32_STATIC_LIB" DLL="" allpassed
+
+GCX-static-debug GCX-small-static-debug:
+ @ $(MAKE) --no-builtin-rules TEST=$@ GCX="GC$(DLL_VER)d" CC=$(CXX) XXCFLAGS="-D__CLEANUP_C -DPTW32_STATIC_LIB" OPT="$(DOPT)" DLL="" allpassed
all-asm: $(ASM)
- @ $(ECHO) ALL TESTS PASSED! Congratulations!
-
-all-pass: $(PASSES)
- @ $(ECHO) ALL TESTS PASSED! Congratulations!
-
-all-bench: $(BENCHRESULTS)
- @ $(ECHO) BENCH TESTS COMPLETED.
-
-all-stress: $(STRESSRESULTS)
- @ $(ECHO) STRESS TESTS COMPLETED.
-
-all-static: $(STATICRESULTS)
- @ $(ECHO) ALL STATIC TESTS PASSED! Congratulations!
-
-benchtest1.bench:
-benchtest2.bench:
-benchtest3.bench:
-benchtest4.bench:
-benchtest5.bench:
-
-barrier1.pass: semaphore4.pass
-barrier2.pass: barrier1.pass
-barrier3.pass: barrier2.pass
-barrier4.pass: barrier3.pass
-barrier5.pass: barrier4.pass
-barrier6.pass: barrier5.pass
-cancel1.pass: create1.pass
-cancel2.pass: cancel1.pass
-cancel3.pass: context1.pass
-cancel4.pass: cancel3.pass
-cancel5.pass: cancel3.pass
-cancel6a.pass: cancel3.pass
-cancel6d.pass: cancel3.pass
-cancel7.pass: kill1.pass
-cancel8.pass: cancel7.pass
-cancel9.pass: cancel8.pass
-cleanup0.pass: cancel5.pass
-cleanup1.pass: cleanup0.pass
-cleanup2.pass: cleanup1.pass
-cleanup3.pass: cleanup2.pass
-condvar1.pass:
-condvar1_1.pass: condvar1.pass
-condvar1_2.pass: join2.pass
-condvar2.pass: condvar1.pass
-condvar2_1.pass: condvar2.pass join2.pass
-condvar3.pass: create1.pass condvar2.pass
-condvar3_1.pass: condvar3.pass join2.pass
-condvar3_2.pass: condvar3_1.pass
-condvar3_3.pass: condvar3_2.pass
-condvar4.pass: create1.pass
-condvar5.pass: condvar4.pass
-condvar6.pass: condvar5.pass
-condvar7.pass: condvar6.pass cleanup1.pass
-condvar8.pass: condvar7.pass
-condvar9.pass: condvar8.pass
-context1.pass: cancel1.pass
-count1.pass: join1.pass
-create1.pass: mutex2.pass
-create2.pass: create1.pass
-delay1.pass:
-delay2.pass: delay1.pass
-detach1.pass: join0.pass
-equal1.pass: create1.pass
-errno1.pass: mutex3.pass
-exception1.pass: cancel4.pass
-exception2.pass: exception1.pass
-exception3.pass: exception2.pass
-exit1.pass:
-exit2.pass: create1.pass
-exit3.pass: create1.pass
-exit4.pass:
-exit5.pass: exit4.pass kill1.pass
-eyal1.pass: tsd1.pass
-inherit1.pass: join1.pass priority1.pass
-join0.pass: create1.pass
-join1.pass: create1.pass
-join2.pass: create1.pass
-join3.pass: join2.pass
-kill1.pass:
-loadfree.pass: pthread.dll
-mutex1.pass: self1.pass
-mutex1n.pass: mutex1.pass
-mutex1e.pass: mutex1.pass
-mutex1r.pass: mutex1.pass
-mutex2.pass: mutex1.pass
-mutex2r.pass: mutex2.pass
-mutex2e.pass: mutex2.pass
-mutex3.pass: create1.pass
-mutex3r.pass: mutex3.pass
-mutex3e.pass: mutex3.pass
-mutex4.pass: mutex3.pass
-mutex5.pass:
-mutex6.pass: mutex4.pass
-mutex6n.pass: mutex4.pass
-mutex6e.pass: mutex4.pass
-mutex6r.pass: mutex4.pass
-mutex6s.pass: mutex6.pass
-mutex6rs.pass: mutex6r.pass
-mutex6es.pass: mutex6e.pass
-mutex7.pass: mutex6.pass
-mutex7n.pass: mutex6n.pass
-mutex7e.pass: mutex6e.pass
-mutex7r.pass: mutex6r.pass
-mutex8.pass: mutex7.pass
-mutex8n.pass: mutex7n.pass
-mutex8e.pass: mutex7e.pass
-mutex8r.pass: mutex7r.pass
-once1.pass: create1.pass
-once2.pass: once1.pass
-once3.pass: once2.pass
-once4.pass: once3.pass
-openmp1.pass: tsd2.pass
-priority1.pass: join1.pass
-priority2.pass: priority1.pass barrier3.pass
-reuse1.pass: create2.pass
-reuse2.pass: reuse1.pass
-robust1.pass: mutex8r.pass
-robust2.pass: mutex8r.pass
-robust3.pass: robust2.pass
-robust4.pass: robust3.pass
-robust5.pass: robust4.pass
-rwlock1.pass: condvar6.pass
-rwlock2.pass: rwlock1.pass
-rwlock3.pass: rwlock2.pass join2.pass
-rwlock4.pass: rwlock3.pass
-rwlock5.pass: rwlock4.pass
-rwlock6.pass: rwlock5.pass
-rwlock7.pass: rwlock6.pass
-rwlock8.pass: rwlock7.pass
-rwlock2_t.pass: rwlock2.pass
-rwlock3_t.pass: rwlock2_t.pass
-rwlock4_t.pass: rwlock3_t.pass
-rwlock5_t.pass: rwlock4_t.pass
-rwlock6_t.pass: rwlock5_t.pass
-rwlock6_t2.pass: rwlock6_t.pass
-self1.pass:
-self2.pass: create1.pass
-semaphore1.pass:
-semaphore2.pass:
-semaphore3.pass: semaphore2.pass
-semaphore4.pass: semaphore3.pass cancel1.pass
-semaphore4t.pass: semaphore4.pass
-semaphore5.pass: semaphore4.pass
-sequence1.pass: reuse2.pass
-sizes.pass:
-spin1.pass:
-spin2.pass: spin1.pass
-spin3.pass: spin2.pass
-spin4.pass: spin3.pass
-stress1.pass:
-tsd1.pass: barrier5.pass join1.pass
-tsd2.pass: tsd1.pass
-valid1.pass: join1.pass
-valid2.pass: valid1.pass
-
-sizes.pass: sizes.exe
- @ $(ECHO) Running $*
- ./$< > SIZES.$(TEST)
- @ $(CAT) SIZES.$(TEST)
- @ $(ECHO) Passed
- @ $(TOUCH) $@
+ @ $(ECHO) "ALL TESTS PASSED! Congratulations!"
+
+allpassed: $(HDR) $(LIB) $(DLL) $(QAPC) $(TESTS:%=%.pass)
+ @ $(ECHO) "ALL TESTS PASSED! Congratulations!"
+
+all-bench: $(HDR) $(LIB) $(DLL) $(QAPC) $(XXLIBS) $(BENCHRESULTS)
+ @ $(ECHO) "ALL BENCH TESTS COMPLETED."
+
+cancel9.exe: XLIBS = -lws2_32
%.pass: %.exe
- @ $(ECHO) Running $*
- ./$*
+ @ $(ECHO) Running $(TEST) test \"$*\"
+ @ $(RUN) ./$*
@ $(ECHO) Passed
@ $(TOUCH) $@
-%.bench: $(LIB) $(DLL) $(HDR) $(QAPC) $(XXLIBS) %.exe
- @ $(ECHO) Running $*
- ./$*
+%.bench: %.exe
+ @ $(ECHO) Running $(TEST) test \"$*\"
+ @ $(RUN) ./$*
@ $(ECHO) Done
@ $(TOUCH) $@
-%.exe: %.c $(LIB) $(DLL) $(HDR) $(QAPC)
- @ $(ECHO) Compiling $@
- @ $(ECHO) $(CC) $(CFLAGS) -o $@ $< $(INCLUDES) -L. -lpthread$(GCX) -lsupc++ $(XXLIBS)
- @ $(CC) $(CFLAGS) -o $@ $< $(INCLUDES) -L. -lpthread$(GCX) -lsupc++ $(XXLIBS)
+%.exe: %.c
+ $(CC) $(CFLAGS) $(LFLAGS) -o $@ $< $(INCLUDES) -L. -lpthread$(GCX) $(XLIBS) $(XXLIBS)
%.pre: %.c $(HDR)
- @ $(CC) -E $(CFLAGS) -o $@ $< $(INCLUDES)
+ $(CC) -E $(CFLAGS) -o $@ $< $(INCLUDES)
%.s: %.c $(HDR)
@ $(ECHO) Compiling $@
- @ $(CC) -S $(CFLAGS) -o $@ $< $(INCLUDES)
+ $(CC) -S $(CFLAGS) -o $@ $< $(INCLUDES)
-$(COPYFILES):
+$(HDR) $(LIB) $(DLL) $(QAPC):
@ $(ECHO) Copying $(BUILD_DIR)/$@
- @ $(CP) $(BUILD_DIR)/$@ .
+ @ $(TESTFILE) $(BUILD_DIR)/$@ $(AND) $(CP) $(BUILD_DIR)/$@ .
benchlib.o: benchlib.c
@ $(ECHO) Compiling $@
- @ $(ECHO) $(CC) -c $(CFLAGS) $< $(INCLUDES)
- @ $(CC) -c $(CFLAGS) $< $(INCLUDES)
-
-pthread.dll: $(DLL)
- @ $(CP) $(DLL) $@
+ $(CC) -c $(CFLAGS) $< $(INCLUDES)
clean:
- $(RM) *.dll
@@ -436,7 +239,8 @@ clean:
- $(RM) *.obj
- $(RM) *.pdb
- $(RM) *.exe
+ - $(RM) *.manifest
- $(RM) *.pass
- $(RM) *.bench
- - $(RM) *.static
- $(RM) *.log
+ \ No newline at end of file
diff --git a/pthreads/tests/Makefile b/pthreads/tests/Makefile
index 9b0ca3094..15f98686f 100644
--- a/pthreads/tests/Makefile
+++ b/pthreads/tests/Makefile
@@ -5,9 +5,7 @@
#
# Pthreads-win32 - POSIX Threads Library for Win32
# Copyright(C) 1998 John E. Bossom
-# Copyright(C) 1999,2005 Pthreads-win32 contributors
-#
-# Contact Email: rpj@callisto.canberra.edu.au
+# Copyright(C) 1999,2012 Pthreads-win32 contributors
#
# The current list of contributors is contained
# in the file CONTRIBUTORS included with the source
@@ -31,14 +29,15 @@
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
-DLL_VER = 2
+DLL_VER = 2$(EXTRAVERSION)
CP = copy
RM = erase
+RMDIR = rmdir /s /q
CAT = type
MKDIR = mkdir
-TOUCH = echo Passed >
ECHO = echo
+TOUCH = $(ECHO) touched >
# The next path is relative to $BUILD_DIR
QAPC = # ..\QueueUserAPCEx\User\quserex.dll
@@ -50,19 +49,25 @@ OPTIM = /O2 /Ob0
XXLIBS = ws2_32.lib
# C++ Exceptions
-VCEFLAGS = /EHsc /TP /DPtW32NoCatchWarn /D__CLEANUP_CXX
+VCEFLAGS = /EHs /TP /DPtW32NoCatchWarn /D__CLEANUP_CXX
VCELIB = pthreadVCE$(DLL_VER).lib
VCEDLL = pthreadVCE$(DLL_VER).dll
+VCELIBD = pthreadVCE$(DLL_VER)d.lib
+VCEDLLD = pthreadVCE$(DLL_VER)d.dll
# Structured Exceptions
VSEFLAGS = /D__CLEANUP_SEH
VSELIB = pthreadVSE$(DLL_VER).lib
VSEDLL = pthreadVSE$(DLL_VER).dll
+VSELIBD = pthreadVSE$(DLL_VER)d.lib
+VSEDLLD = pthreadVSE$(DLL_VER)d.dll
# C cleanup code
VCFLAGS = /D__CLEANUP_C
VCLIB = pthreadVC$(DLL_VER).lib
VCDLL = pthreadVC$(DLL_VER).dll
+VCLIBD = pthreadVC$(DLL_VER)d.lib
+VCDLLD = pthreadVC$(DLL_VER)d.dll
# C++ Exceptions in application - using VC version of pthreads dll
-VCXFLAGS = /EHsc /TP /D__CLEANUP_C
+VCXFLAGS = /EHs /TP /D__CLEANUP_C
# Defaults
CPLIB = $(VCLIB)
@@ -73,377 +78,168 @@ LFLAGS= /INCREMENTAL:NO
INCLUDES=-I.
BUILD_DIR=..
-COPYFILES = $(CPHDR) $(CPLIB) $(CPDLL) $(QAPC)
-
-TEST =
-EHFLAGS =
+EHFLAGS =
# If a test case returns a non-zero exit code to the shell, make will
# stop.
-PASSES = sizes.pass $(REGULAR_PASSES)
-
-REGULAR_PASSES = loadfree.pass \
- self1.pass mutex5.pass \
- mutex1.pass mutex1n.pass mutex1e.pass mutex1r.pass \
- semaphore1.pass semaphore2.pass semaphore3.pass \
- mutex2.pass mutex3.pass \
- mutex2r.pass mutex2e.pass mutex3r.pass mutex3e.pass \
- condvar1.pass condvar1_1.pass condvar1_2.pass condvar2.pass condvar2_1.pass \
- exit1.pass create1.pass create2.pass reuse1.pass reuse2.pass equal1.pass \
- sequence1.pass kill1.pass valid1.pass valid2.pass \
- exit2.pass exit3.pass exit4.pass exit5.pass \
- join0.pass join1.pass detach1.pass join2.pass join3.pass \
- mutex4.pass mutex6.pass mutex6n.pass mutex6e.pass mutex6r.pass \
- mutex6s.pass mutex6es.pass mutex6rs.pass \
- mutex7.pass mutex7n.pass mutex7e.pass mutex7r.pass \
- mutex8.pass mutex8n.pass mutex8e.pass mutex8r.pass \
- robust1.pass robust2.pass robust3.pass robust4.pass robust5.pass \
- count1.pass \
- once1.pass once2.pass once3.pass once4.pass \
- self2.pass \
- cancel1.pass cancel2.pass \
- semaphore4.pass semaphore4t.pass semaphore5.pass \
- barrier1.pass barrier2.pass barrier3.pass barrier4.pass barrier5.pass barrier6.pass \
- tsd1.pass tsd2.pass delay1.pass delay2.pass eyal1.pass \
- condvar3.pass condvar3_1.pass condvar3_2.pass condvar3_3.pass \
- condvar4.pass condvar5.pass condvar6.pass \
- condvar7.pass condvar8.pass condvar9.pass \
- errno1.pass \
- rwlock1.pass rwlock2.pass rwlock3.pass rwlock4.pass \
- rwlock5.pass rwlock6.pass rwlock7.pass rwlock8.pass \
- rwlock2_t.pass rwlock3_t.pass rwlock4_t.pass rwlock5_t.pass rwlock6_t.pass rwlock6_t2.pass \
- context1.pass \
- cancel3.pass cancel4.pass cancel5.pass cancel6a.pass cancel6d.pass \
- cancel7.pass cancel8.pass \
- cleanup0.pass cleanup1.pass cleanup2.pass cleanup3.pass \
- priority1.pass priority2.pass inherit1.pass \
- spin1.pass spin2.pass spin3.pass spin4.pass \
- exception1.pass exception2.pass exception3.pass \
- cancel9.pass stress1.pass
-
-BENCHRESULTS = \
- benchtest1.bench benchtest2.bench benchtest3.bench benchtest4.bench benchtest5.bench
-
-STRESSRESULTS = \
- stress1.stress
-
-STATICRESULTS = \
- sizes.pass \
- self1.pass mutex5.pass \
- mutex1.pass mutex1n.pass mutex1e.pass mutex1r.pass \
- semaphore1.pass semaphore2.pass semaphore3.pass \
- mutex2.pass mutex3.pass \
- mutex2r.pass mutex2e.pass mutex3r.pass mutex3e.pass \
- condvar1.pass condvar1_1.pass condvar1_2.pass condvar2.pass condvar2_1.pass \
- exit1.pass create1.pass create2.pass reuse1.pass reuse2.pass equal1.pass \
- sequence1.pass kill1.pass valid1.pass valid2.pass \
- exit2.pass exit3.pass exit4.pass exit5.pass \
- join0.pass join1.pass detach1.pass join2.pass join3.pass \
- mutex4.pass mutex6.pass mutex6n.pass mutex6e.pass mutex6r.pass \
- mutex6s.pass mutex6es.pass mutex6rs.pass \
- mutex7.pass mutex7n.pass mutex7e.pass mutex7r.pass \
- mutex8.pass mutex8n.pass mutex8e.pass mutex8r.pass \
- robust1.pass robust2.pass robust3.pass robust4.pass robust5.pass \
- count1.pass \
- once1.pass once2.pass once3.pass once4.pass \
- self2.pass \
- cancel1.pass cancel2.pass \
- semaphore4.pass semaphore4t.pass semaphore5.pass \
- barrier1.pass barrier2.pass barrier3.pass barrier4.pass barrier5.pass barrier6.pass \
- tsd1.pass tsd2.pass delay1.pass delay2.pass eyal1.pass \
- condvar3.pass condvar3_1.pass condvar3_2.pass condvar3_3.pass \
- condvar4.pass condvar5.pass condvar6.pass \
- condvar7.pass condvar8.pass condvar9.pass \
- errno1.pass \
- rwlock1.pass rwlock2.pass rwlock3.pass rwlock4.pass \
- rwlock5.pass rwlock6.pass rwlock7.pass rwlock8.pass \
- rwlock2_t.pass rwlock3_t.pass rwlock4_t.pass rwlock5_t.pass rwlock6_t.pass rwlock6_t2.pass \
- context1.pass \
- cancel3.pass cancel4.pass cancel5.pass cancel6a.pass cancel6d.pass \
- cancel7.pass cancel8.pass \
- cleanup0.pass cleanup1.pass cleanup2.pass cleanup3.pass \
- priority1.pass priority2.pass inherit1.pass \
- spin1.pass spin2.pass spin3.pass spin4.pass \
- exception1.pass exception2.pass exception3.pass \
- cancel9.pass stress1.pass
+include common.mk
+
+#
+# To build and run "foo.exe" and "bar.exe" only use, e.g.:
+# nmake clean VC NO_DEPS=1 TESTS="foo bar"
+#
+# To build and run "foo.exe" and "bar.exe" and run all prerequisite tests
+# use, e.g.:
+# nmake clean VC TESTS="foo bar"
+#
+# Set TESTS to one or more tests.
+#
+!IFNDEF NO_DEPS
+include runorder.mk
+!ENDIF
help:
@ $(ECHO) Run one of the following command lines:
- @ $(ECHO) nmake clean VC (to test using VC dll with VC (no EH) apps)
- @ $(ECHO) nmake clean VC-bench (to benchtest using VC dll with C bench apps)
- @ $(ECHO) nmake clean VC-stress (to stresstest using VC dll with C stress apps)
- @ $(ECHO) nmake clean VC-static (to test using VC static lib with VC (no EH) apps)
- @ $(ECHO) nmake clean VCX (to test using VC dll with VC++ (EH) applications)
- @ $(ECHO) nmake clean VCX-bench (to benchtest using VC dll with C++ bench apps)
- @ $(ECHO) nmake clean VCX-stress (to stresstest using VC dll with C++ stress apps)
- @ $(ECHO) nmake clean VCE (to test using the VCE dll with VC++ EH applications)
- @ $(ECHO) nmake clean VCE-bench (to benchtest using VCE dll with C++ bench apps)
- @ $(ECHO) nmake clean VCE-stress (to stresstest using VCE dll with C++ stress apps)
- @ $(ECHO) nmake clean VSE (to test using VSE dll with VC (SEH) apps)
- @ $(ECHO) nmake clean VSE-bench (to benchtest using VSE dll with SEH bench apps)
- @ $(ECHO) nmake clean VSE-stress (to stresstest using VSE dll with SEH stress apps)
-
-all:
- @ $(MAKE) /E clean VC
- @ $(MAKE) /E clean VCX
- @ $(MAKE) /E clean VCE
- @ $(MAKE) /E clean VSE
- @ $(MAKE) /E clean VC-bench
- @ $(MAKE) /E clean VC-stress
-
-# This allows an individual test application to be made using the default lib.
-# e.g. nmake clean test cancel3.exe
-test: $(CPLIB) $(CPDLL) $(CPHDR) $(QAPC)
-
-tests: $(CPLIB) $(CPDLL) $(CPHDR) $(QAPC) $(PASSES)
- @ $(ECHO) ALL TESTS PASSED! Congratulations!
-
-benchtests: $(CPLIB) $(CPDLL) $(CPHDR) $(XXLIBS) $(BENCHRESULTS)
- @ $(ECHO) ALL BENCH TESTS DONE.
-
-stresstests: $(CPLIB) $(CPDLL) $(CPHDR) $(STRESSRESULTS)
- @ $(ECHO) ALL STRESS TESTS DONE.
-
-statictests: $(CPLIB) $(CPDLL) $(CPHDR) $(STATICRESULTS)
- @ $(ECHO) ALL STATIC TESTS DONE.
-
-sizes.pass: sizes.exe
- @ $(ECHO) ... Running $(TEST)$(DLL_VER) test: $*.exe
- @ .\$*.exe > SIZES.$(TEST)
- @ $(CAT) SIZES.$(TEST)
- @ $(ECHO) ...... Passed
- @ $(TOUCH) $*.pass
-
-$(REGULAR_PASSES): $*.exe
- @ $(ECHO) ... Running $(TEST) test: $*.exe
- @ .\$*.exe
- @ $(ECHO) ...... Passed
- @ $(TOUCH) $*.pass
-
-$(BENCHRESULTS): $*.exe
- @ $(ECHO) ... Running $(TEST) benchtest: $*.exe
- @ .\$*.exe
- @ $(ECHO) ...... Done
- @ $(TOUCH) $*.bench
-
-$(STRESSRESULTS): $*.exe
- @ $(ECHO) ... Running $(TEST) stresstest: $*.exe
- @ .\$*.exe
- @ $(ECHO) ...... Done
- @ $(TOUCH) $*.pass
+ @ $(ECHO) nmake clean VC
+ @ $(ECHO) nmake clean VC-bench
+ @ $(ECHO) nmake clean VC-static
+ @ $(ECHO) nmake clean VC-static-bench
+ @ $(ECHO) nmake clean VC-debug
+ @ $(ECHO) nmake clean VC-static-debug
+ @ $(ECHO) nmake clean VC-small-static-debug
+ @ $(ECHO) nmake clean VCX
+ @ $(ECHO) nmake clean VCX-bench
+ @ $(ECHO) nmake clean VCX-static
+ @ $(ECHO) nmake clean VCX-static-bench
+ @ $(ECHO) nmake clean VCX-debug
+ @ $(ECHO) nmake clean VCX-static-debug
+ @ $(ECHO) nmake clean VCX-small-static-debug
+ @ $(ECHO) nmake clean VCE
+ @ $(ECHO) nmake clean VCE-bench
+ @ $(ECHO) nmake clean VCE-static
+ @ $(ECHO) nmake clean VCE-static-bench
+ @ $(ECHO) nmake clean VCE-debug
+ @ $(ECHO) nmake clean VCE-static-debug
+ @ $(ECHO) nmake clean VCE-small-static-debug
+ @ $(ECHO) nmake clean VSE
+ @ $(ECHO) nmake clean VSE-bench
+ @ $(ECHO) nmake clean VSE-static
+ @ $(ECHO) nmake clean VSE-static-bench
+ @ $(ECHO) nmake clean VSE-debug
+ @ $(ECHO) nmake clean VSE-static-debug
+ @ $(ECHO) nmake clean VSE-small-static-debug
VC:
- @ $(MAKE) /E TEST="$@" CPLIB="$(VCLIB)" CPDLL="$(VCDLL)" EHFLAGS="$(VCFLAGS)" tests
+ @ $(MAKE) /E /nologo TEST="$@" CPLIB="$(VCLIB)" CPDLL="$(VCDLL)" EHFLAGS="$(VCFLAGS)" allpassed
VCE:
- @ $(MAKE) /E TEST="$@" CPLIB="$(VCELIB)" CPDLL="$(VCEDLL)" EHFLAGS="$(VCEFLAGS)" tests
+ @ $(MAKE) /E /nologo TEST="$@" CPLIB="$(VCELIB)" CPDLL="$(VCEDLL)" EHFLAGS="$(VCEFLAGS)" allpassed
VSE:
- @ $(MAKE) /E TEST="$@" CPLIB="$(VSELIB)" CPDLL="$(VSEDLL)" EHFLAGS="$(VSEFLAGS)" tests
+ @ $(MAKE) /E /nologo TEST="$@" CPLIB="$(VSELIB)" CPDLL="$(VSEDLL)" EHFLAGS="$(VSEFLAGS)" allpassed
VCX:
- @ $(MAKE) /E TEST="$@" CPLIB="$(VCLIB)" CPDLL="$(VCDLL)" EHFLAGS="$(VCXFLAGS)" tests
+ @ $(MAKE) /E /nologo TEST="$@" CPLIB="$(VCLIB)" CPDLL="$(VCDLL)" EHFLAGS="$(VCXFLAGS)" allpassed
VC-bench:
- @ $(MAKE) /E TEST="$@" CPLIB="$(VCLIB)" CPDLL="$(VCDLL)" EHFLAGS="$(VCFLAGS)" XXLIBS="benchlib.o" benchtests
+ @ $(MAKE) /E /nologo TEST="$@" CPLIB="$(VCLIB)" CPDLL="$(VCDLL)" EHFLAGS="$(VCFLAGS)" $(BENCHTESTS)
VCE-bench:
- @ $(MAKE) /E TEST="$@" CPLIB="$(VCELIB)" CPDLL="$(VCEDLL)" EHFLAGS="$(VCEFLAGS)" XXLIBS="benchlib.o" benchtests
+ @ $(MAKE) /E /nologo TEST="$@" CPLIB="$(VCELIB)" CPDLL="$(VCEDLL)" EHFLAGS="$(VCEFLAGS)" $(BENCHTESTS)
VSE-bench:
- @ $(MAKE) /E TEST="$@" CPLIB="$(VSELIB)" CPDLL="$(VSEDLL)" EHFLAGS="$(VSEFLAGS)" XXLIBS="benchlib.o" benchtests
+ @ $(MAKE) /E /nologo TEST="$@" CPLIB="$(VSELIB)" CPDLL="$(VSEDLL)" EHFLAGS="$(VSEFLAGS)" $(BENCHTESTS)
VCX-bench:
- @ $(MAKE) /E TEST="$@" CPLIB="$(VCLIB)" CPDLL="$(VCDLL)" EHFLAGS="$(VCXFLAGS)" XXLIBS="benchlib.o" benchtests
+ @ $(MAKE) /E /nologo TEST="$@" CPLIB="$(VCLIB)" CPDLL="$(VCDLL)" EHFLAGS="$(VCXFLAGS)" $(BENCHTESTS)
-VC-stress:
- @ $(MAKE) /E TEST="$@" CPLIB="$(VCLIB)" CPDLL="$(VCDLL)" EHFLAGS="$(VCFLAGS)" stresstests
+VC-static VC-small-static:
+ @ $(MAKE) /E /nologo TEST="$@" CPLIB="$(VCLIB)" CPDLL="" EHFLAGS="$(VCFLAGS) /DPTW32_STATIC_LIB" allpassed
-VCE-stress:
- @ $(MAKE) /E TEST="$@" CPLIB="$(VCELIB)" CPDLL="$(VCEDLL)" EHFLAGS="$(VCEFLAGS)" stresstests
+VCE-static VCE-small-static:
+ @ $(MAKE) /E /nologo TEST="$@" CPLIB="$(VCELIB)" CPDLL="" EHFLAGS="$(VCEFLAGS) /DPTW32_STATIC_LIB" allpassed
-VSE-stress:
- @ $(MAKE) /E TEST="$@" CPLIB="$(VSELIB)" CPDLL="$(VSEDLL)" EHFLAGS="$(VSEFLAGS)" stresstests
+VSE-static VSE-small-static:
+ @ $(MAKE) /E /nologo TEST="$@" CPLIB="$(VSELIB)" CPDLL="" EHFLAGS="$(VSEFLAGS) /DPTW32_STATIC_LIB" allpassed
-VCX-stress:
- @ $(MAKE) /E TEST="$@" CPLIB="$(VCLIB)" CPDLL="$(VCDLL)" EHFLAGS="$(VCXFLAGS)" stresstests
+VCX-static VCX-small-static:
+ @ $(MAKE) /E /nologo TEST="$@" CPLIB="$(VCLIB)" CPDLL="" EHFLAGS="$(VCXFLAGS) /DPTW32_STATIC_LIB" allpassed
-VC-static:
- @ $(MAKE) /E TEST="$@" CPLIB="$(VCLIB)" CPDLL="" EHFLAGS="$(VCFLAGS) /DPTW32_STATIC_LIB" statictests
+VC-static-bench:
+ @ $(MAKE) /E /nologo TEST="$@" CPLIB="$(VCLIB)" CPDLL="" EHFLAGS="$(VCFLAGS) /DPTW32_STATIC_LIB" $(BENCHTESTS)
-.c.exe:
- @ $(ECHO) $(CC) $(EHFLAGS) $(CFLAGS) $(INCLUDES) $< /Fe$@ /link $(LFLAGS) $(CPLIB) $(XXLIBS)
- @ $(CC) $(EHFLAGS) $(CFLAGS) $(INCLUDES) $< /Fe$@ /link $(LFLAGS) $(CPLIB) $(XXLIBS)
+VCE-static-bench:
+ @ $(MAKE) /E /nologo TEST="$@" CPLIB="$(VCELIB)" CPDLL="" EHFLAGS="$(VCEFLAGS) /DPTW32_STATIC_LIB" $(BENCHTESTS)
-.c.o:
- @ $(ECHO) $(CC) $(EHFLAGS) /c $(CFLAGS) $(INCLUDES) $< /Fo$@
- @ $(CC) $(EHFLAGS) $(CFLAGS) /c $(INCLUDES) $< /Fo$@
+VSE-static-bench:
+ @ $(MAKE) /E /nologo TEST="$@" CPLIB="$(VSELIB)" CPDLL="" EHFLAGS="$(VSEFLAGS) /DPTW32_STATIC_LIB" $(BENCHTESTS)
-.c.i:
- @ $(CC) /P $(EHFLAGS) $(CFLAGS) $(INCLUDES) $<
+VCX-static-bench:
+ @ $(MAKE) /E /nologo TEST="$@" CPLIB="$(VCLIB)" CPDLL="" EHFLAGS="$(VCXFLAGS) /DPTW32_STATIC_LIB" $(BENCHTESTS)
+
+VC-debug:
+ @ $(MAKE) /E /nologo TEST="$@" CPLIB="$(VCLIBD)" CPDLL="$(VCDLLD)" EHFLAGS="$(VCFLAGS)" allpassed
+
+VC-static-debug VC-small-static-debug:
+ @ $(MAKE) /E /nologo TEST="$@" CPLIB="$(VCLIBD)" CPDLL="" EHFLAGS="$(VCFLAGS) /DPTW32_STATIC_LIB" allpassed
-$(COPYFILES):
- @ $(ECHO) Copying $(BUILD_DIR)\$@
- @ $(CP) $(BUILD_DIR)\$@ .
+VCE-debug:
+ @ $(MAKE) /E /nologo TEST="$@" CPLIB="$(VCELIBD)" CPDLL="$(VCEDLLD)" EHFLAGS="$(VCEFLAGS)" allpassed
-pthread.dll: $(CPDLL)
- @ $(CP) $(CPDLL) pthread.dll
- @ $(CP) $(CPLIB) pthread.lib
+VCE-static-debug VCE-small-static-debug:
+ @ $(MAKE) /E /nologo TEST="$@" CPLIB="$(VCELIBD)" CPDLL="" EHFLAGS="$(VCEFLAGS) /DPTW32_STATIC_LIB" allpassed
+
+VSE-debug:
+ @ $(MAKE) /E /nologo TEST="$@" CPLIB="$(VSELIBD)" CPDLL="$(VSEDLLD)" EHFLAGS="$(VSEFLAGS)" allpassed
+
+VSE-static-debug VSE-small-static-debug:
+ @ $(MAKE) /E /nologo TEST="$@" CPLIB="$(VSELIBD)" CPDLL="" EHFLAGS="$(VSEFLAGS) /DPTW32_STATIC_LIB" allpassed
+
+VCX-debug:
+ @ $(MAKE) /E /nologo TEST="$@" CPLIB="$(VCLIBD)" CPDLL="$(VCDLLD)" EHFLAGS="$(VCXFLAGS)" allpassed
+
+VCX-static-debug VCX-small-static-debug:
+ @ $(MAKE) /E /nologo TEST="$@" CPLIB="$(VCLIBD)" CPDLL="" EHFLAGS="$(VCXFLAGS) /DPTW32_STATIC_LIB" allpassed
clean:
- - $(RM) *.dll
- - $(RM) *.lib
- - $(RM) pthread.h
- - $(RM) semaphore.h
- - $(RM) sched.h
- - $(RM) *.e
- - $(RM) *.i
- - $(RM) *.obj
- - $(RM) *.pdb
- - $(RM) *.o
- - $(RM) *.asm
- - $(RM) *.exe
- - $(RM) *.pass
- - $(RM) *.bench
- - $(RM) *.log
-
-benchtest1.bench:
-benchtest2.bench:
-benchtest3.bench:
-benchtest4.bench:
-benchtest5.bench:
-
-barrier1.pass: semaphore4.pass
-barrier2.pass: barrier1.pass
-barrier3.pass: barrier2.pass
-barrier4.pass: barrier3.pass
-barrier5.pass: barrier4.pass
-barrier6.pass: barrier5.pass
-cancel1.pass: create1.pass
-cancel2.pass: cancel1.pass
-cancel3.pass: context1.pass
-cancel4.pass: cancel3.pass
-cancel5.pass: cancel3.pass
-cancel6a.pass: cancel3.pass
-cancel6d.pass: cancel3.pass
-cancel7.pass: kill1.pass
-cancel8.pass: cancel7.pass
-cancel9.pass: cancel8.pass
-cleanup0.pass: cancel5.pass
-cleanup1.pass: cleanup0.pass
-cleanup2.pass: cleanup1.pass
-cleanup3.pass: cleanup2.pass
-condvar1.pass:
-condvar1_1.pass: condvar1.pass
-condvar1_2.pass: join2.pass
-condvar2.pass: condvar1.pass
-condvar2_1.pass: condvar2.pass join2.pass
-condvar3.pass: create1.pass condvar2.pass
-condvar3_1.pass: condvar3.pass join2.pass
-condvar3_2.pass: condvar3_1.pass
-condvar3_3.pass: condvar3_2.pass
-condvar4.pass: create1.pass
-condvar5.pass: condvar4.pass
-condvar6.pass: condvar5.pass
-condvar7.pass: condvar6.pass cleanup1.pass
-condvar8.pass: condvar7.pass
-condvar9.pass: condvar8.pass
-context1.pass: cancel1.pass
-count1.pass: join1.pass
-create1.pass: mutex2.pass
-create2.pass: create1.pass
-delay1.pass:
-delay2.pass: delay1.pass
-detach1.pass: join0.pass
-equal1.pass: create1.pass
-errno1.pass: mutex3.pass
-exception1.pass: cancel4.pass
-exception2.pass: exception1.pass
-exception3.pass: exception2.pass
-exit1.pass:
-exit2.pass: create1.pass
-exit3.pass: create1.pass
-exit4.pass:
-exit5.pass: kill1.pass
-eyal1.pass: tsd1.pass
-inherit1.pass: join1.pass priority1.pass
-join0.pass: create1.pass
-join1.pass: create1.pass
-join2.pass: create1.pass
-join3.pass: join2.pass
-kill1.pass:
-loadfree.pass: pthread.dll
-mutex1.pass: self1.pass
-mutex1n.pass: mutex1.pass
-mutex1e.pass: mutex1.pass
-mutex1r.pass: mutex1.pass
-mutex2.pass: mutex1.pass
-mutex2r.pass: mutex2.pass
-mutex2e.pass: mutex2.pass
-mutex3.pass: create1.pass
-mutex3r.pass: mutex3.pass
-mutex3e.pass: mutex3.pass
-mutex4.pass: mutex3.pass
-mutex5.pass:
-mutex6.pass: mutex4.pass
-mutex6n.pass: mutex4.pass
-mutex6e.pass: mutex4.pass
-mutex6r.pass: mutex4.pass
-mutex6s.pass: mutex6.pass
-mutex6rs.pass: mutex6r.pass
-mutex6es.pass: mutex6e.pass
-mutex7.pass: mutex6.pass
-mutex7n.pass: mutex6n.pass
-mutex7e.pass: mutex6e.pass
-mutex7r.pass: mutex6r.pass
-mutex8.pass: mutex7.pass
-mutex8n.pass: mutex7n.pass
-mutex8e.pass: mutex7e.pass
-mutex8r.pass: mutex7r.pass
-once1.pass: create1.pass
-once2.pass: once1.pass
-once3.pass: once2.pass
-once4.pass: once3.pass
-priority1.pass: join1.pass
-priority2.pass: priority1.pass barrier3.pass
-reuse1.pass: create2.pass
-reuse2.pass: reuse1.pass
-robust1.pass: mutex8r.pass
-robust2.pass: mutex8r.pass
-robust3.pass: robust2.pass
-robust4.pass: robust3.pass
-robust5.pass: robust4.pass
-rwlock1.pass: condvar6.pass
-rwlock2.pass: rwlock1.pass
-rwlock3.pass: rwlock2.pass join2.pass
-rwlock4.pass: rwlock3.pass
-rwlock5.pass: rwlock4.pass
-rwlock6.pass: rwlock5.pass
-rwlock7.pass: rwlock6.pass
-rwlock8.pass: rwlock7.pass
-rwlock2_t.pass: rwlock2.pass
-rwlock3_t.pass: rwlock2_t.pass
-rwlock4_t.pass: rwlock3_t.pass
-rwlock5_t.pass: rwlock4_t.pass
-rwlock6_t.pass: rwlock5_t.pass
-rwlock6_t2.pass: rwlock6_t.pass
-self1.pass:
-self2.pass: create1.pass
-semaphore1.pass:
-semaphore2.pass:
-semaphore3.pass: semaphore2.pass
-semaphore4.pass: semaphore3.pass cancel1.pass
-semaphore4t.pass: semaphore4.pass
-semaphore5.pass: semaphore4.pass
-sequence1.pass: reuse2.pass
-sizes.pass:
-spin1.pass:
-spin2.pass: spin1.pass
-spin3.pass: spin2.pass
-spin4.pass: spin3.pass
-stress1.pass: condvar9.pass barrier5.pass
-tsd1.pass: barrier5.pass join1.pass
-tsd2.pass: tsd1.pass
-valid1.pass: join1.pass
-valid2.pass: valid1.pass
+ if exist *.dll $(RM) *.dll
+ if exist *.lib $(RM) *.lib
+ if exist pthread.h $(RM) pthread.h
+ if exist semaphore.h $(RM) semaphore.h
+ if exist sched.h $(RM) sched.h
+ if exist *.e $(RM) *.e
+ if exist *.i $(RM) *.i
+ if exist *.obj $(RM) *.obj
+ if exist *.pdb $(RM) *.pdb
+ if exist *.o $(RM) *.o
+ if exist *.asm $(RM) *.asm
+ if exist *.exe $(RM) *.exe
+ if exist *.manifest $(RM) *.manifest
+ if exist *.pass $(RM) *.pass
+ if exist *.bench $(RM) *.bench
+ if exist *.log $(RM) *.log
+
+.c.pass:
+ $(CC) $(EHFLAGS) $(CFLAGS) $(INCLUDES) $*.c /Fe$*.exe /link $(LFLAGS) $(CPLIB) $(XXLIBS)
+ @ $(ECHO) ... Running $(TEST) test: $*.exe
+ @ .\$*.exe
+ @ $(ECHO) ...... Passed
+ @ $(TOUCH) $*.pass
+
+$(ALL_KNOWN_TESTS): $(CPHDR) $(CPLIB) $(CPDLL) $(QAPC) $@.pass
+
+allpassed: $(TESTS)
+ @ $(ECHO) ALL TESTS PASSED! Congratulations!
+
+$(BENCHTESTS): $(CPHDR) $(CPLIB) $(CPDLL) $(QAPC)
+ $(CC) $(EHFLAGS) $(CFLAGS) $(INCLUDES) benchlib.c $*.c /Fe$*.exe /link $(LFLAGS) $(CPLIB) $(XXLIBS)
+ @ $(ECHO) ... Running $(TEST) benchmark: $*.exe
+ @ .\$*.exe
+ @ $(ECHO) ...... Done
+
+.c.i:
+ $(CC) /P $(EHFLAGS) $(CFLAGS) $(INCLUDES) $<
+
+$(CPHDR) $(CPLIB) $(CPDLL) $(QAPC):
+ @ if exist $(BUILD_DIR)\$@ $(ECHO) Copying $(BUILD_DIR)\$@ && $(CP) $(BUILD_DIR)\$@ .
diff --git a/pthreads/tests/SIZES.GC b/pthreads/tests/SIZES.GC
deleted file mode 100644
index d5ddf363f..000000000
--- a/pthreads/tests/SIZES.GC
+++ /dev/null
@@ -1,21 +0,0 @@
-Sizes of pthreads-win32 structs
--------------------------------
- pthread_t 8
- ptw32_thread_t 160
- pthread_attr_t_ 28
- sem_t_ 12
- pthread_mutex_t_ 28
- pthread_mutexattr_t_ 12
- pthread_spinlock_t_ 8
- pthread_barrier_t_ 36
- pthread_barrierattr_t_ 4
- pthread_key_t_ 16
- pthread_cond_t_ 32
- pthread_condattr_t_ 4
- pthread_rwlock_t_ 28
- pthread_rwlockattr_t_ 4
- pthread_once_t_ 16
- ptw32_cleanup_t 12
- ptw32_mcs_node_t_ 16
- sched_param 4
--------------------------------
diff --git a/pthreads/tests/SIZES.GCE b/pthreads/tests/SIZES.GCE
deleted file mode 100644
index 709114d52..000000000
--- a/pthreads/tests/SIZES.GCE
+++ /dev/null
@@ -1,21 +0,0 @@
-Sizes of pthreads-win32 structs
--------------------------------
- pthread_t 8
- ptw32_thread_t 96
- pthread_attr_t_ 28
- sem_t_ 12
- pthread_mutex_t_ 28
- pthread_mutexattr_t_ 12
- pthread_spinlock_t_ 8
- pthread_barrier_t_ 36
- pthread_barrierattr_t_ 4
- pthread_key_t_ 16
- pthread_cond_t_ 32
- pthread_condattr_t_ 4
- pthread_rwlock_t_ 28
- pthread_rwlockattr_t_ 4
- pthread_once_t_ 16
- ptw32_cleanup_t 12
- ptw32_mcs_node_t_ 16
- sched_param 4
--------------------------------
diff --git a/pthreads/tests/SIZES.VC b/pthreads/tests/SIZES.VC
deleted file mode 100644
index d5ddf363f..000000000
--- a/pthreads/tests/SIZES.VC
+++ /dev/null
@@ -1,21 +0,0 @@
-Sizes of pthreads-win32 structs
--------------------------------
- pthread_t 8
- ptw32_thread_t 160
- pthread_attr_t_ 28
- sem_t_ 12
- pthread_mutex_t_ 28
- pthread_mutexattr_t_ 12
- pthread_spinlock_t_ 8
- pthread_barrier_t_ 36
- pthread_barrierattr_t_ 4
- pthread_key_t_ 16
- pthread_cond_t_ 32
- pthread_condattr_t_ 4
- pthread_rwlock_t_ 28
- pthread_rwlockattr_t_ 4
- pthread_once_t_ 16
- ptw32_cleanup_t 12
- ptw32_mcs_node_t_ 16
- sched_param 4
--------------------------------
diff --git a/pthreads/tests/SIZES.VCE b/pthreads/tests/SIZES.VCE
deleted file mode 100644
index 709114d52..000000000
--- a/pthreads/tests/SIZES.VCE
+++ /dev/null
@@ -1,21 +0,0 @@
-Sizes of pthreads-win32 structs
--------------------------------
- pthread_t 8
- ptw32_thread_t 96
- pthread_attr_t_ 28
- sem_t_ 12
- pthread_mutex_t_ 28
- pthread_mutexattr_t_ 12
- pthread_spinlock_t_ 8
- pthread_barrier_t_ 36
- pthread_barrierattr_t_ 4
- pthread_key_t_ 16
- pthread_cond_t_ 32
- pthread_condattr_t_ 4
- pthread_rwlock_t_ 28
- pthread_rwlockattr_t_ 4
- pthread_once_t_ 16
- ptw32_cleanup_t 12
- ptw32_mcs_node_t_ 16
- sched_param 4
--------------------------------
diff --git a/pthreads/tests/SIZES.VSE b/pthreads/tests/SIZES.VSE
deleted file mode 100644
index 709114d52..000000000
--- a/pthreads/tests/SIZES.VSE
+++ /dev/null
@@ -1,21 +0,0 @@
-Sizes of pthreads-win32 structs
--------------------------------
- pthread_t 8
- ptw32_thread_t 96
- pthread_attr_t_ 28
- sem_t_ 12
- pthread_mutex_t_ 28
- pthread_mutexattr_t_ 12
- pthread_spinlock_t_ 8
- pthread_barrier_t_ 36
- pthread_barrierattr_t_ 4
- pthread_key_t_ 16
- pthread_cond_t_ 32
- pthread_condattr_t_ 4
- pthread_rwlock_t_ 28
- pthread_rwlockattr_t_ 4
- pthread_once_t_ 16
- ptw32_cleanup_t 12
- ptw32_mcs_node_t_ 16
- sched_param 4
--------------------------------
diff --git a/pthreads/tests/Wmakefile b/pthreads/tests/Wmakefile
index 2b37c4691..284f326cd 100644
--- a/pthreads/tests/Wmakefile
+++ b/pthreads/tests/Wmakefile
@@ -5,7 +5,7 @@
#
# Pthreads-win32 - POSIX Threads Library for Win32
# Copyright(C) 1998 John E. Bossom
-# Copyright(C) 1999,2005 Pthreads-win32 contributors
+# Copyright(C) 1999,2012 Pthreads-win32 contributors
#
# Contact Email: rpj@callisto.canberra.edu.au
#
@@ -62,7 +62,7 @@ WCDLL = pthreadWC$(DLL_VER).dll
# C++ Exceptions in application - using WC version of pthreads dll
WCXFLAGS = -xs -d__CLEANUP_C
-CFLAGS= -w4 -e25 -d_WIN32_WINNT=0x400 -d_REENTRANT -zq -bm $(OPTIM) -5r -bt=nt -mf -d2
+CFLAGS= -w4 -e25 -d_REENTRANT -zq -bm $(OPTIM) -5r -bt=nt -mf -d2
LFLAGS=
INCLUDES= -i=.
@@ -79,7 +79,7 @@ EHFLAGS =
# If a test case returns a non-zero exit code to the shell, make will
# stop.
-PASSES = sizes.pass loadfree.pass &
+PASSES = sizes.pass &
self1.pass mutex5.pass &
mutex1.pass mutex1n.pass mutex1e.pass mutex1r.pass &
semaphore1.pass semaphore2.pass semaphore3.pass &
@@ -89,7 +89,7 @@ PASSES = sizes.pass loadfree.pass &
exit1.pass create1.pass create2.pass reuse1.pass reuse2.pass equal1.pass &
sequence1.pass kill1.pass valid1.pass valid2.pass &
exit2.pass exit3.pass exit4 exit5 &
- join0.pass join1.pass detach1.pass join2.pass join3.pass &
+ join0.pass join1.pass detach1.pass join2.pass join3.pass join4.pass &
mutex4.pass mutex6.pass mutex6n.pass mutex6e.pass mutex6r.pass &
mutex6s.pass mutex6es.pass mutex6rs.pass &
mutex7.pass mutex7n.pass mutex7e.pass mutex7r.pass &
@@ -115,8 +115,10 @@ PASSES = sizes.pass loadfree.pass &
priority1.pass priority2.pass inherit1.pass &
spin1.pass spin2.pass spin3.pass spin4.pass &
barrier1.pass barrier2.pass barrier3.pass barrier4.pass barrier5.pass &
- exception1.pass exception2.pass exception3.pass &
- cancel9.pass stress1.pass
+ exception1.pass exception2.pass exception3_0.pass exception3.pass &
+ cancel9.pass &
+ affinity1.pass affinity2.pass affinity3.pass affinity4.pass affinity5.pass &
+ stress1.pass
BENCHRESULTS = &
benchtest1.bench benchtest2.bench benchtest3.bench benchtest4.bench benchtest5.bench
@@ -213,6 +215,7 @@ clean: .SYMBOLIC
@ if exist *.o $(RM) *.o
@ if exist *.asm $(RM) *.asm
@ if exist *.exe $(RM) *.exe
+ @ if exist *.manifest $(RM) *.manifest
@ if exist *.pass $(RM) *.pass
@ if exist *.bench $(RM) *.bench
@ if exist *.log $(RM) *.log
@@ -223,7 +226,13 @@ benchtest2.bench:
benchtest3.bench:
benchtest4.bench:
benchtest5.bench:
-barrier1.pass:
+
+affinity1.pass:
+affinity2.pass: affinity1.pass
+affinity3.pass: affinity2.pass
+affinity4.pass: affinity3.pass
+affinity5.pass: affinity4.pass
+barrier1.pass: semaphore4.pass
barrier2.pass: barrier1.pass
barrier3.pass: barrier2.pass
barrier4.pass: barrier3.pass
@@ -267,7 +276,8 @@ equal1.pass: create1.pass
errno1.pass: mutex3.pass
exception1.pass: cancel4.pass
exception2.pass: exception1.pass
-exception3.pass: exception2.pass
+exception3_0.pass: exception2.pass
+exception3.pass: exception3_0.pass
exit1.pass:
exit2.pass: create1.pass
exit3.pass: create1.pass
@@ -279,8 +289,8 @@ join0.pass: create1.pass
join1.pass: create1.pass
join2.pass: create1.pass
join3.pass: join2.pass
+join4.pass: join3.pass
kill1.pass:
-loadfree.pass: pthread.dll
mutex1.pass: self1.pass
mutex1n.pass: mutex1.pass
mutex1e.pass: mutex1.pass
diff --git a/pthreads/tests/affinity1.c b/pthreads/tests/affinity1.c
new file mode 100755
index 000000000..7014d8875
--- /dev/null
+++ b/pthreads/tests/affinity1.c
@@ -0,0 +1,111 @@
+/*
+ * affinity1.c
+ *
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads-win32 - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * http://sources.redhat.com/pthreads-win32/contributors.html
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Basic test of CPU_*() support routines.
+ *
+ */
+
+#include "test.h"
+
+int
+main()
+{
+ unsigned int cpu;
+ cpu_set_t newmask;
+ cpu_set_t src1mask;
+ cpu_set_t src2mask;
+ cpu_set_t src3mask;
+
+ CPU_ZERO(&newmask);
+ CPU_ZERO(&src1mask);
+ memset(&src2mask, 0, sizeof(cpu_set_t));
+ assert(memcmp(&src1mask, &src2mask, sizeof(cpu_set_t)) == 0);
+ assert(CPU_EQUAL(&src1mask, &src2mask));
+ assert(CPU_COUNT(&src1mask) == 0);
+
+ CPU_ZERO(&src1mask);
+ CPU_ZERO(&src2mask);
+ CPU_ZERO(&src3mask);
+
+ for (cpu = 0; cpu < sizeof(cpu_set_t)*8; cpu += 2)
+ {
+ CPU_SET(cpu, &src1mask); /* 0b01010101010101010101010101010101 */
+ }
+ for (cpu = 0; cpu < sizeof(cpu_set_t)*4; cpu++)
+ {
+ CPU_SET(cpu, &src2mask); /* 0b00000000000000001111111111111111 */
+ }
+ for (cpu = sizeof(cpu_set_t)*4; cpu < sizeof(cpu_set_t)*8; cpu += 2)
+ {
+ CPU_SET(cpu, &src2mask); /* 0b01010101010101011111111111111111 */
+ }
+ for (cpu = 0; cpu < sizeof(cpu_set_t)*8; cpu += 2)
+ {
+ CPU_SET(cpu, &src3mask); /* 0b01010101010101010101010101010101 */
+ }
+
+ assert(CPU_COUNT(&src1mask) == (sizeof(cpu_set_t)*4));
+ assert(CPU_COUNT(&src2mask) == ((sizeof(cpu_set_t)*4 + (sizeof(cpu_set_t)*2))));
+ assert(CPU_COUNT(&src3mask) == (sizeof(cpu_set_t)*4));
+ CPU_SET(0, &newmask);
+ CPU_SET(1, &newmask);
+ CPU_SET(3, &newmask);
+ assert(CPU_ISSET(1, &newmask));
+ CPU_CLR(1, &newmask);
+ assert(!CPU_ISSET(1, &newmask));
+ CPU_OR(&newmask, &src1mask, &src2mask);
+ assert(CPU_EQUAL(&newmask, &src2mask));
+ CPU_AND(&newmask, &src1mask, &src2mask);
+ assert(CPU_EQUAL(&newmask, &src1mask));
+ CPU_XOR(&newmask, &src1mask, &src3mask);
+ memset(&src2mask, 0, sizeof(cpu_set_t));
+ assert(memcmp(&newmask, &src2mask, sizeof(cpu_set_t)) == 0);
+
+ /*
+ * Need to confirm the bitwise logical right-shift in CpuCount().
+ * i.e. zeros inserted into MSB on shift because cpu_set_t is
+ * unsigned.
+ */
+ CPU_ZERO(&src1mask);
+ for (cpu = 1; cpu < sizeof(cpu_set_t)*8; cpu += 2)
+ {
+ CPU_SET(cpu, &src1mask); /* 0b10101010101010101010101010101010 */
+ }
+ assert(CPU_ISSET(sizeof(cpu_set_t)*8-1, &src1mask));
+ assert(CPU_COUNT(&src1mask) == (sizeof(cpu_set_t)*4));
+
+ return 0;
+}
diff --git a/pthreads/tests/affinity2.c b/pthreads/tests/affinity2.c
new file mode 100755
index 000000000..225840cf1
--- /dev/null
+++ b/pthreads/tests/affinity2.c
@@ -0,0 +1,102 @@
+/*
+ * affinity2.c
+ *
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads-win32 - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * http://sources.redhat.com/pthreads-win32/contributors.html
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Have the process switch CPUs.
+ *
+ */
+
+#include "test.h"
+
+int
+main()
+{
+ unsigned int cpu;
+ int result;
+ cpu_set_t newmask;
+ cpu_set_t mask;
+ cpu_set_t switchmask;
+ cpu_set_t flipmask;
+
+ CPU_ZERO(&mask);
+ CPU_ZERO(&switchmask);
+ CPU_ZERO(&flipmask);
+
+ for (cpu = 0; cpu < sizeof(cpu_set_t)*8; cpu += 2)
+ {
+ CPU_SET(cpu, &switchmask); /* 0b01010101010101010101010101010101 */
+ }
+ for (cpu = 0; cpu < sizeof(cpu_set_t)*8; cpu++)
+ {
+ CPU_SET(cpu, &flipmask); /* 0b11111111111111111111111111111111 */
+ }
+
+ assert(sched_getaffinity(0, sizeof(cpu_set_t), &newmask) == 0);
+ assert(!CPU_EQUAL(&newmask, &mask));
+
+ result = sched_setaffinity(0, sizeof(cpu_set_t), &newmask);
+ if (result != 0)
+ {
+ int err =
+#if defined(PTW32_USES_SEPARATE_CRT)
+ GetLastError();
+#else
+ errno;
+#endif
+
+ assert(err != ESRCH);
+ assert(err != EFAULT);
+ assert(err != EPERM);
+ assert(err != EINVAL);
+ assert(err != EAGAIN);
+ assert(err == ENOSYS);
+ assert(CPU_COUNT(&mask) == 1);
+ }
+ else
+ {
+ if (CPU_COUNT(&mask) > 1)
+ {
+ CPU_AND(&newmask, &mask, &switchmask); /* Remove every other CPU */
+ assert(sched_setaffinity(0, sizeof(cpu_set_t), &newmask) == 0);
+ assert(sched_getaffinity(0, sizeof(cpu_set_t), &mask) == 0);
+ CPU_XOR(&newmask, &mask, &flipmask); /* Switch to all alternative CPUs */
+ assert(sched_setaffinity(0, sizeof(cpu_set_t), &newmask) == 0);
+ assert(sched_getaffinity(0, sizeof(cpu_set_t), &mask) == 0);
+ assert(!CPU_EQUAL(&newmask, &mask));
+ }
+ }
+
+ return 0;
+}
diff --git a/pthreads/tests/affinity3.c b/pthreads/tests/affinity3.c
new file mode 100755
index 000000000..065dd21a4
--- /dev/null
+++ b/pthreads/tests/affinity3.c
@@ -0,0 +1,100 @@
+/*
+ * affinity3.c
+ *
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads-win32 - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * http://sources.redhat.com/pthreads-win32/contributors.html
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Have the thread switch CPUs.
+ *
+ */
+
+#include "test.h"
+
+int
+main()
+{
+ int result;
+ unsigned int cpu;
+ cpu_set_t newmask;
+ cpu_set_t processCpus;
+ cpu_set_t mask;
+ cpu_set_t switchmask;
+ cpu_set_t flipmask;
+ pthread_t self = pthread_self();
+
+ CPU_ZERO(&mask);
+ CPU_ZERO(&switchmask);
+ CPU_ZERO(&flipmask);
+
+ assert(pthread_getaffinity_np(self, sizeof(cpu_set_t), &processCpus) == 0);
+ printf("This thread has a starting affinity with %d CPUs\n", CPU_COUNT(&processCpus));
+ assert(!CPU_EQUAL(&mask, &processCpus));
+
+ for (cpu = 0; cpu < sizeof(cpu_set_t)*8; cpu += 2)
+ {
+ CPU_SET(cpu, &switchmask); /* 0b01010101010101010101010101010101 */
+ }
+ for (cpu = 0; cpu < sizeof(cpu_set_t)*8; cpu++)
+ {
+ CPU_SET(cpu, &flipmask); /* 0b11111111111111111111111111111111 */
+ }
+
+ result = pthread_setaffinity_np(self, sizeof(cpu_set_t), &processCpus);
+ if (result != 0)
+ {
+ assert(result != ESRCH);
+ assert(result != EFAULT);
+ assert(result != EPERM);
+ assert(result != EINVAL);
+ assert(result != EAGAIN);
+ assert(result == ENOSYS);
+ assert(CPU_COUNT(&mask) == 1);
+ }
+ else
+ {
+ if (CPU_COUNT(&mask) > 1)
+ {
+ CPU_AND(&newmask, &processCpus, &switchmask); /* Remove every other CPU */
+ assert(pthread_setaffinity_np(self, sizeof(cpu_set_t), &newmask) == 0);
+ assert(pthread_getaffinity_np(self, sizeof(cpu_set_t), &mask) == 0);
+ assert(CPU_EQUAL(&mask, &newmask));
+ CPU_XOR(&newmask, &mask, &flipmask); /* Switch to all alternative CPUs */
+ assert(!CPU_EQUAL(&mask, &newmask));
+ assert(pthread_setaffinity_np(self, sizeof(cpu_set_t), &newmask) == 0);
+ assert(pthread_getaffinity_np(self, sizeof(cpu_set_t), &mask) == 0);
+ assert(CPU_EQUAL(&mask, &newmask));
+ }
+ }
+
+ return 0;
+}
diff --git a/pthreads/tests/affinity4.c b/pthreads/tests/affinity4.c
new file mode 100755
index 000000000..31aad46c2
--- /dev/null
+++ b/pthreads/tests/affinity4.c
@@ -0,0 +1,70 @@
+/*
+ * affinity4.c
+ *
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads-win32 - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * http://sources.redhat.com/pthreads-win32/contributors.html
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Test thread CPU affinity setting.
+ *
+ */
+
+#include "test.h"
+
+int
+main()
+{
+ unsigned int cpu;
+ cpu_set_t threadCpus;
+ DWORD_PTR vThreadMask;
+ cpu_set_t keepCpus;
+ pthread_t self = pthread_self();
+
+ CPU_ZERO(&keepCpus);
+ for (cpu = 1; cpu < sizeof(cpu_set_t)*8; cpu += 2)
+ {
+ CPU_SET(cpu, &keepCpus); /* 0b10101010101010101010101010101010 */
+ }
+
+ assert(pthread_getaffinity_np(self, sizeof(cpu_set_t), &threadCpus) == 0);
+ if (CPU_COUNT(&threadCpus) > 1)
+ {
+ CPU_AND(&threadCpus, &threadCpus, &keepCpus);
+ vThreadMask = SetThreadAffinityMask(GetCurrentThread(), (*(PDWORD_PTR)&threadCpus) /* Violating Opacity */);
+ assert(pthread_setaffinity_np(self, sizeof(cpu_set_t), &threadCpus) == 0);
+ vThreadMask = SetThreadAffinityMask(GetCurrentThread(), vThreadMask);
+ assert(vThreadMask != 0);
+ assert(memcmp(&vThreadMask, &threadCpus, sizeof(DWORD_PTR)) == 0);
+ }
+
+ return 0;
+}
diff --git a/pthreads/tests/affinity5.c b/pthreads/tests/affinity5.c
new file mode 100755
index 000000000..8957e28f0
--- /dev/null
+++ b/pthreads/tests/affinity5.c
@@ -0,0 +1,103 @@
+/*
+ * affinity5.c
+ *
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads-win32 - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * http://sources.redhat.com/pthreads-win32/contributors.html
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Test thread CPU affinity inheritance.
+ *
+ */
+
+#include "test.h"
+
+typedef union
+{
+ /* Violates opacity */
+ cpu_set_t cpuset;
+ unsigned long int bits; /* To stop GCC complaining about %lx args to printf */
+} cpuset_to_ulint;
+
+void *
+mythread(void * arg)
+{
+ HANDLE threadH = GetCurrentThread();
+ cpu_set_t *parentCpus = (cpu_set_t*) arg;
+ cpu_set_t threadCpus;
+ DWORD_PTR vThreadMask;
+ cpuset_to_ulint a, b;
+
+ assert(pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t), &threadCpus) == 0);
+ assert(CPU_EQUAL(parentCpus, &threadCpus));
+ vThreadMask = SetThreadAffinityMask(threadH, (*(PDWORD_PTR)&threadCpus) /* Violating Opacity */);
+ assert(vThreadMask != 0);
+ assert(memcmp(&vThreadMask, &threadCpus, sizeof(DWORD_PTR)) == 0);
+ a.cpuset = *parentCpus;
+ b.cpuset = threadCpus;
+ /* Violates opacity */
+ printf("CPU affinity: Parent/Thread = 0x%lx/0x%lx\n", a.bits, b.bits);
+
+ return (void*) 0;
+}
+
+int
+main()
+{
+ unsigned int cpu;
+ pthread_t tid;
+ cpu_set_t threadCpus;
+ DWORD_PTR vThreadMask;
+ cpu_set_t keepCpus;
+ pthread_t self = pthread_self();
+
+ CPU_ZERO(&keepCpus);
+ for (cpu = 1; cpu < sizeof(cpu_set_t)*8; cpu += 2)
+ {
+ CPU_SET(cpu, &keepCpus); /* 0b10101010101010101010101010101010 */
+ }
+
+ assert(pthread_getaffinity_np(self, sizeof(cpu_set_t), &threadCpus) == 0);
+ if (CPU_COUNT(&threadCpus) > 1)
+ {
+ assert(pthread_create(&tid, NULL, mythread, (void*)&threadCpus) == 0);
+ assert(pthread_join(tid, NULL) == 0);
+ CPU_AND(&threadCpus, &threadCpus, &keepCpus);
+ assert(pthread_setaffinity_np(self, sizeof(cpu_set_t), &threadCpus) == 0);
+ vThreadMask = SetThreadAffinityMask(GetCurrentThread(), (*(PDWORD_PTR)&threadCpus) /* Violating Opacity */);
+ assert(vThreadMask != 0);
+ assert(memcmp(&vThreadMask, &threadCpus, sizeof(DWORD_PTR)) == 0);
+ assert(pthread_create(&tid, NULL, mythread, (void*)&threadCpus) == 0);
+ assert(pthread_join(tid, NULL) == 0);
+ }
+
+ return 0;
+}
diff --git a/pthreads/tests/barrier1.c b/pthreads/tests/barrier1.c
index 76f78df66..cff727b9d 100644
--- a/pthreads/tests/barrier1.c
+++ b/pthreads/tests/barrier1.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/barrier2.c b/pthreads/tests/barrier2.c
index 28aa238c5..1afd8d070 100644
--- a/pthreads/tests/barrier2.c
+++ b/pthreads/tests/barrier2.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/barrier3.c b/pthreads/tests/barrier3.c
index dece77068..a3145519b 100644
--- a/pthreads/tests/barrier3.c
+++ b/pthreads/tests/barrier3.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/barrier4.c b/pthreads/tests/barrier4.c
index 042992dfd..7c427e58b 100644
--- a/pthreads/tests/barrier4.c
+++ b/pthreads/tests/barrier4.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/barrier5.c b/pthreads/tests/barrier5.c
index 353384081..86e698380 100644
--- a/pthreads/tests/barrier5.c
+++ b/pthreads/tests/barrier5.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/barrier6.c b/pthreads/tests/barrier6.c
index 76c673779..d4d821454 100644
--- a/pthreads/tests/barrier6.c
+++ b/pthreads/tests/barrier6.c
@@ -1,117 +1,118 @@
-/*
- * barrier6.c
- *
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- *
- * --------------------------------------------------------------------------
- *
- * Destroy the barrier after initial count threads are released then let
- * additional threads attempt to wait on it.
- *
- */
-
-#include "test.h"
-
-enum {
- NUMTHREADS = 31
-};
-
-pthread_barrier_t barrier = NULL;
-pthread_mutex_t mx = PTHREAD_MUTEX_INITIALIZER;
-static int serialThreadCount = 0;
-static int otherThreadCount = 0;
-
-void *
-func(void * arg)
-{
- int result = pthread_barrier_wait(&barrier);
-
- assert(pthread_mutex_lock(&mx) == 0);
-
- if (result == PTHREAD_BARRIER_SERIAL_THREAD)
- {
- serialThreadCount++;
- }
- else if (0 == result)
- {
- otherThreadCount++;
- }
- assert(pthread_mutex_unlock(&mx) == 0);
-
- return NULL;
-}
-
-int
-main()
-{
- int i, j, k;
- pthread_t t[NUMTHREADS + 1];
-
- for (j = 1; j <= NUMTHREADS; j++)
- {
- int howHigh = j/2 + 1;
-
- printf("Barrier height = %d, Total threads %d\n", howHigh, j);
-
- serialThreadCount = 0;
- otherThreadCount = 0;
-
- assert(pthread_barrier_init(&barrier, NULL, howHigh) == 0);
-
- for (i = 1; i <= j; i++)
- {
- assert(pthread_create(&t[i], NULL, func, NULL) == 0);
-
- if (i == howHigh)
- {
- for (k = 1; k <= howHigh; k++)
- {
- assert(pthread_join(t[k], NULL) == 0);
- }
- assert(pthread_barrier_destroy(&barrier) == 0);
- }
- }
-
- for (i = howHigh+1; i <= j; i++)
- {
- assert(pthread_join(t[i], NULL) == 0);
- }
-
- assert(serialThreadCount == 1);
- assert(otherThreadCount == (howHigh - 1));
-
- assert(pthread_barrier_destroy(&barrier) == EINVAL);
- }
-
- assert(pthread_mutex_destroy(&mx) == 0);
-
- return 0;
-}
+/*
+ * barrier6.c
+ *
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads-win32 - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * http://sources.redhat.com/pthreads-win32/contributors.html
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Destroy the barrier after initial count threads are released then let
+ * additional threads attempt to wait on it.
+ *
+ */
+
+#include "test.h"
+
+enum {
+ NUMTHREADS = 31
+};
+
+pthread_barrier_t barrier = NULL;
+pthread_mutex_t mx = PTHREAD_MUTEX_INITIALIZER;
+static int serialThreadCount = 0;
+static int otherThreadCount = 0;
+
+void *
+func(void * arg)
+{
+ int result = pthread_barrier_wait(&barrier);
+
+ assert(pthread_mutex_lock(&mx) == 0);
+
+ if (result == PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ serialThreadCount++;
+ }
+ else if (0 == result)
+ {
+ otherThreadCount++;
+ }
+ assert(pthread_mutex_unlock(&mx) == 0);
+
+ return NULL;
+}
+
+int
+main()
+{
+ int i, j, k;
+ pthread_t t[NUMTHREADS + 1];
+
+ for (j = 1; j <= NUMTHREADS; j++)
+ {
+ int howHigh = j/2 + 1;
+
+ printf("Barrier height = %d, Total threads %d\n", howHigh, j);
+
+ serialThreadCount = 0;
+ otherThreadCount = 0;
+
+ assert(pthread_barrier_init(&barrier, NULL, howHigh) == 0);
+
+ for (i = 1; i <= j; i++)
+ {
+ assert(pthread_create(&t[i], NULL, func, NULL) == 0);
+
+ if (i == howHigh)
+ {
+ for (k = 1; k <= howHigh; k++)
+ {
+ assert(pthread_join(t[k], NULL) == 0);
+ }
+ assert(pthread_barrier_destroy(&barrier) == 0);
+ }
+ }
+
+ for (i = howHigh+1; i <= j; i++)
+ {
+ assert(pthread_join(t[i], NULL) == 0);
+ }
+
+ assert(serialThreadCount == 1);
+ assert(otherThreadCount == (howHigh - 1));
+
+ assert(pthread_barrier_destroy(&barrier) == EINVAL);
+ }
+
+ assert(pthread_mutex_destroy(&mx) == 0);
+
+ return 0;
+}
diff --git a/pthreads/tests/benchlib.c b/pthreads/tests/benchlib.c
index bf60ae515..d8f31ebd9 100644
--- a/pthreads/tests/benchlib.c
+++ b/pthreads/tests/benchlib.c
@@ -5,10 +5,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/benchtest.h b/pthreads/tests/benchtest.h
index 809057810..81f132c8b 100644
--- a/pthreads/tests/benchtest.h
+++ b/pthreads/tests/benchtest.h
@@ -5,10 +5,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/benchtest1.c b/pthreads/tests/benchtest1.c
index 191f98636..ea5810430 100644
--- a/pthreads/tests/benchtest1.c
+++ b/pthreads/tests/benchtest1.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -40,7 +41,6 @@
*/
#include "test.h"
-#include <sys/timeb.h>
#ifdef __GNUC__
#include <stdlib.h>
diff --git a/pthreads/tests/benchtest2.c b/pthreads/tests/benchtest2.c
index 10f3d0ee8..bab680db9 100644
--- a/pthreads/tests/benchtest2.c
+++ b/pthreads/tests/benchtest2.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -43,7 +44,6 @@
*/
#include "test.h"
-#include <sys/timeb.h>
#ifdef __GNUC__
#include <stdlib.h>
diff --git a/pthreads/tests/benchtest3.c b/pthreads/tests/benchtest3.c
index 7d03ed884..fc0e261df 100644
--- a/pthreads/tests/benchtest3.c
+++ b/pthreads/tests/benchtest3.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -40,7 +41,6 @@
*/
#include "test.h"
-#include <sys/timeb.h>
#ifdef __GNUC__
#include <stdlib.h>
diff --git a/pthreads/tests/benchtest4.c b/pthreads/tests/benchtest4.c
index d7cf47c3b..0f59537fe 100644
--- a/pthreads/tests/benchtest4.c
+++ b/pthreads/tests/benchtest4.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -40,7 +41,6 @@
*/
#include "test.h"
-#include <sys/timeb.h>
#ifdef __GNUC__
#include <stdlib.h>
diff --git a/pthreads/tests/benchtest5.c b/pthreads/tests/benchtest5.c
index d262baf11..9371ec5e0 100644
--- a/pthreads/tests/benchtest5.c
+++ b/pthreads/tests/benchtest5.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -40,7 +41,6 @@
*/
#include "test.h"
-#include <sys/timeb.h>
#ifdef __GNUC__
#include <stdlib.h>
diff --git a/pthreads/tests/cancel1.c b/pthreads/tests/cancel1.c
index 23d2726a2..f93c497b4 100644
--- a/pthreads/tests/cancel1.c
+++ b/pthreads/tests/cancel1.c
@@ -6,26 +6,27 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
* http://sources.redhat.com/pthreads-win32/contributors.html
- *
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library in the file COPYING.LIB;
* if not, write to the Free Software Foundation, Inc.,
@@ -34,26 +35,26 @@
* --------------------------------------------------------------------------
*
* Test Synopsis: Test setting cancel state and cancel type.
- * -
+ * -
*
* Test Method (Validation or Falsification):
- * -
+ * -
*
* Requirements Tested:
* - pthread_setcancelstate function
* - pthread_setcanceltype function
*
* Features Tested:
- * -
+ * -
*
* Cases Tested:
- * -
+ * -
*
* Description:
- * -
+ * -
*
* Environment:
- * -
+ * -
*
* Input:
* - None.
@@ -139,7 +140,7 @@ main()
}
/*
- * Code to control or munipulate child threads should probably go here.
+ * Code to control or manipulate child threads should probably go here.
*/
/*
@@ -151,7 +152,7 @@ main()
* Standard check that all threads started.
*/
for (i = 1; i <= NUMTHREADS; i++)
- {
+ {
failed = !threadbag[i].started;
if (failed)
@@ -163,10 +164,10 @@ main()
assert(!failed);
/*
- * Check any results here. Set "failed" and only print ouput on failure.
+ * Check any results here. Set "failed" and only print output on failure.
*/
for (i = 1; i <= NUMTHREADS; i++)
- {
+ {
/* ... */
}
diff --git a/pthreads/tests/cancel2.c b/pthreads/tests/cancel2.c
index 2ee596abb..941061369 100644
--- a/pthreads/tests/cancel2.c
+++ b/pthreads/tests/cancel2.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -95,7 +96,7 @@ struct bag_t_ {
static bag_t threadbag[NUMTHREADS + 1];
-static pthread_mutex_t waitLock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_barrier_t go = NULL;
void *
mythread(void * arg)
@@ -110,18 +111,8 @@ mythread(void * arg)
/* Set to known state and type */
assert(pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) == 0);
-
- switch (bag->threadnum % 2)
- {
- case 0:
- assert(pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL) == 0);
- result = 0;
- break;
- case 1:
- assert(pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL) == 0);
- result = 1;
- break;
- }
+ assert(pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL) == 0);
+ result = 1;
#if !defined(__cplusplus)
__try
@@ -130,14 +121,10 @@ mythread(void * arg)
#endif
{
/* Wait for go from main */
- assert(pthread_mutex_lock(&waitLock) == 0);
- assert(pthread_mutex_unlock(&waitLock) == 0);
- sched_yield();
+ pthread_barrier_wait(&go);
+ pthread_barrier_wait(&go);
- for (;;)
- {
- pthread_testcancel();
- }
+ pthread_testcancel();
}
#if !defined(__cplusplus)
__except(EXCEPTION_EXECUTE_HANDLER)
@@ -160,7 +147,7 @@ mythread(void * arg)
*/
result += 1000;
- return (void *) (size_t)result;
+ return (void *)(size_t)result;
}
int
@@ -171,7 +158,7 @@ main()
pthread_t t[NUMTHREADS + 1];
assert((t[0] = pthread_self()).p != NULL);
- assert(pthread_mutex_lock(&waitLock) == 0);
+ assert(pthread_barrier_init(&go, NULL, NUMTHREADS + 1) == 0);
for (i = 1; i <= NUMTHREADS; i++)
{
@@ -181,23 +168,17 @@ main()
}
/*
- * Code to control or munipulate child threads should probably go here.
+ * Code to control or manipulate child threads should probably go here.
*/
- Sleep(500);
- assert(pthread_mutex_unlock(&waitLock) == 0);
-
- Sleep(500);
+ pthread_barrier_wait(&go);
for (i = 1; i <= NUMTHREADS; i++)
{
assert(pthread_cancel(t[i]) == 0);
}
- /*
- * Give threads time to run.
- */
- Sleep(NUMTHREADS * 100);
+ pthread_barrier_wait(&go);
/*
* Standard check that all threads started.
@@ -223,19 +204,19 @@ main()
void* result = (void*)0;
assert(pthread_join(t[i], &result) == 0);
- fail = ((int)(size_t)result != (int) PTHREAD_CANCELED);
+ fail = (result != PTHREAD_CANCELED);
if (fail)
{
- fprintf(stderr, "Thread %d: started %d: location %d: cancel type %s\n",
+ fprintf(stderr, "Thread %d: started %d: location %d\n",
i,
threadbag[i].started,
- (int)(size_t)result,
- (((int)(size_t)result % 2) == 0) ? "ASYNCHRONOUS" : "DEFERRED");
+ (int)(size_t)result);
}
failed |= fail;
}
assert(!failed);
+ assert(pthread_barrier_destroy(&go) == 0);
/*
* Success.
diff --git a/pthreads/tests/cancel3.c b/pthreads/tests/cancel3.c
index 5020648a6..742cbc4ff 100644
--- a/pthreads/tests/cancel3.c
+++ b/pthreads/tests/cancel3.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -33,7 +34,7 @@
*
* --------------------------------------------------------------------------
*
- * Test Synopsis: Test asynchronous cancelation (alertable or non-alertable).
+ * Test Synopsis: Test asynchronous cancellation (alertable or non-alertable).
*
* Test Method (Validation or Falsification):
* -
@@ -111,7 +112,7 @@ mythread (void *arg)
/*
* We wait up to 10 seconds, waking every 0.1 seconds,
- * for a cancelation to be applied to us.
+ * for a cancellation to be applied to us.
*/
for (bag->count = 0; bag->count < 100; bag->count++)
Sleep (100);
@@ -137,7 +138,7 @@ main ()
}
/*
- * Code to control or munipulate child threads should probably go here.
+ * Code to control or manipulate child threads should probably go here.
*/
Sleep (NUMTHREADS * 100);
@@ -176,9 +177,9 @@ main ()
void* result = (void*)0;
/*
- * The thread does not contain any cancelation points, so
+ * The thread does not contain any cancellation points, so
* a return value of PTHREAD_CANCELED confirms that async
- * cancelation succeeded.
+ * cancellation succeeded.
*/
assert (pthread_join (t[i], &result) == 0);
diff --git a/pthreads/tests/cancel4.c b/pthreads/tests/cancel4.c
index 893f33b12..4267f1728 100644
--- a/pthreads/tests/cancel4.c
+++ b/pthreads/tests/cancel4.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -33,8 +34,8 @@
*
* --------------------------------------------------------------------------
*
- * Test Synopsis: Test cancelation does not occur in deferred
- * cancelation threads with no cancelation points.
+ * Test Synopsis: Test cancellation does not occur in deferred
+ * cancellation threads with no cancellation points.
*
* Test Method (Validation or Falsification):
* -
@@ -113,7 +114,7 @@ mythread(void * arg)
/*
* We wait up to 2 seconds, waking every 0.1 seconds,
- * for a cancelation to be applied to us.
+ * for a cancellation to be applied to us.
*/
for (bag->count = 0; bag->count < 20; bag->count++)
Sleep(100);
@@ -138,7 +139,7 @@ main()
}
/*
- * Code to control or munipulate child threads should probably go here.
+ * Code to control or manipulate child threads should probably go here.
*/
Sleep(500);
@@ -176,9 +177,9 @@ main()
void* result = (void*)0;
/*
- * The thread does not contain any cancelation points, so
+ * The thread does not contain any cancellation points, so
* a return value of PTHREAD_CANCELED indicates that async
- * cancelation occurred.
+ * cancellation occurred.
*/
assert(pthread_join(t[i], &result) == 0);
diff --git a/pthreads/tests/cancel5.c b/pthreads/tests/cancel5.c
index 6c3951634..e78cf08c2 100644
--- a/pthreads/tests/cancel5.c
+++ b/pthreads/tests/cancel5.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -111,7 +112,7 @@ mythread (void *arg)
/*
* We wait up to 10 seconds, waking every 0.1 seconds,
- * for a cancelation to be applied to us.
+ * for a cancellation to be applied to us.
*/
for (bag->count = 0; bag->count < 100; bag->count++)
Sleep (100);
@@ -135,7 +136,7 @@ main ()
}
/*
- * Code to control or munipulate child threads should probably go here.
+ * Code to control or manipulate child threads should probably go here.
*/
Sleep (500);
@@ -174,9 +175,9 @@ main ()
void* result = (void*)((int)(size_t)PTHREAD_CANCELED + 1);
/*
- * The thread does not contain any cancelation points, so
+ * The thread does not contain any cancellation points, so
* a return value of PTHREAD_CANCELED confirms that async
- * cancelation succeeded.
+ * cancellation succeeded.
*/
assert (pthread_join (t[i], &result) == 0);
diff --git a/pthreads/tests/cancel6a.c b/pthreads/tests/cancel6a.c
index 58063d573..3a81eae6d 100644
--- a/pthreads/tests/cancel6a.c
+++ b/pthreads/tests/cancel6a.c
@@ -24,7 +24,7 @@
*
* --------------------------------------------------------------------------
*
- * Test Synopsis: Test double cancelation - asynchronous.
+ * Test Synopsis: Test double cancellation - asynchronous.
* Second attempt should fail (ESRCH).
*
* Test Method (Validation or Falsification):
@@ -100,7 +100,7 @@ mythread(void * arg)
/*
* We wait up to 10 seconds, waking every 0.1 seconds,
- * for a cancelation to be applied to us.
+ * for a cancellation to be applied to us.
*/
for (bag->count = 0; bag->count < 100; bag->count++)
Sleep(100);
@@ -125,7 +125,7 @@ main()
}
/*
- * Code to control or munipulate child threads should probably go here.
+ * Code to control or manipulate child threads should probably go here.
*/
Sleep(500);
@@ -164,9 +164,9 @@ main()
void* result = (void*)0;
/*
- * The thread does not contain any cancelation points, so
+ * The thread does not contain any cancellation points, so
* a return value of PTHREAD_CANCELED confirms that async
- * cancelation succeeded.
+ * cancellation succeeded.
*/
assert(pthread_join(t[i], &result) == 0);
diff --git a/pthreads/tests/cancel6d.c b/pthreads/tests/cancel6d.c
index 37f9ca5f3..f94ed5ac8 100644
--- a/pthreads/tests/cancel6d.c
+++ b/pthreads/tests/cancel6d.c
@@ -24,9 +24,9 @@
*
* --------------------------------------------------------------------------
*
- * Test Synopsis: Test double cancelation - deferred.
+ * Test Synopsis: Test double cancellation - deferred.
* Second attempt should succeed (unless the canceled thread has started
- * cancelation already - not tested here).
+ * cancellation already - not tested here).
*
* Test Method (Validation or Falsification):
* -
@@ -101,7 +101,7 @@ mythread(void * arg)
/*
* We wait up to 10 seconds, waking every 0.1 seconds,
- * for a cancelation to be applied to us.
+ * for a cancellation to be applied to us.
*/
for (bag->count = 0; bag->count < 100; bag->count++)
{
@@ -129,7 +129,7 @@ main()
}
/*
- * Code to control or munipulate child threads should probably go here.
+ * Code to control or manipulate child threads should probably go here.
*/
Sleep(500);
@@ -138,7 +138,7 @@ main()
assert(pthread_cancel(t[i]) == 0);
if (pthread_cancel(t[i]) != 0)
{
- printf("Second cancelation failed but this is expected sometimes.\n");
+ printf("Second cancellation failed but this is expected sometimes.\n");
}
}
diff --git a/pthreads/tests/cancel7.c b/pthreads/tests/cancel7.c
index 5f1390f7b..cdd8b1565 100644
--- a/pthreads/tests/cancel7.c
+++ b/pthreads/tests/cancel7.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -143,7 +144,7 @@ main()
}
/*
- * Code to control or munipulate child threads should probably go here.
+ * Code to control or manipulate child threads should probably go here.
*/
Sleep(500);
diff --git a/pthreads/tests/cancel8.c b/pthreads/tests/cancel8.c
index 7204d19b1..697593f63 100644
--- a/pthreads/tests/cancel8.c
+++ b/pthreads/tests/cancel8.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -144,7 +145,7 @@ main()
}
/*
- * Code to control or munipulate child threads should probably go here.
+ * Code to control or manipulate child threads should probably go here.
*/
Sleep(500);
diff --git a/pthreads/tests/cancel9.c b/pthreads/tests/cancel9.c
index b0091614a..8f0f15144 100644
--- a/pthreads/tests/cancel9.c
+++ b/pthreads/tests/cancel9.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -33,7 +34,7 @@
*
* --------------------------------------------------------------------------
*
- * Test Synopsis: Test true asynchronous cancelation with Alert driver.
+ * Test Synopsis: Test true asynchronous cancellation with Alert driver.
*
* Test Method (Validation or Falsification):
* -
@@ -172,7 +173,7 @@ main ()
Sleep (100);
assert (pthread_cancel (t) == 0);
assert (pthread_join (t, &result) == 0);
- assert (result == PTHREAD_CANCELED && "test_sleep" != NULL);
+ assert (result == PTHREAD_CANCELED && "test_sleep");
printf ("Cancel waiting thread.\n");
assert (pthread_create (&t, NULL, test_wait, NULL) == 0);
@@ -188,7 +189,7 @@ main ()
Sleep (100);
assert (pthread_cancel (t) == 0);
assert (pthread_join (t, &result) == 0);
- assert (result == PTHREAD_CANCELED && "test_udp" != NULL);
+ assert (result == PTHREAD_CANCELED && "test_udp");
}
else
{
diff --git a/pthreads/tests/cleanup0.c b/pthreads/tests/cleanup0.c
index d9fbedccc..888640b7f 100644
--- a/pthreads/tests/cleanup0.c
+++ b/pthreads/tests/cleanup0.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -97,7 +98,7 @@ typedef struct {
CRITICAL_SECTION cs;
} sharedInt_t;
-static sharedInt_t pop_count = {0, {0}};
+static sharedInt_t pop_count;
static void
increment_pop_count(void * arg)
@@ -147,6 +148,8 @@ main()
int i;
pthread_t t[NUMTHREADS + 1];
+ memset(&pop_count, 0, sizeof(sharedInt_t));
+
InitializeCriticalSection(&pop_count.cs);
assert((t[0] = pthread_self()).p != NULL);
@@ -159,7 +162,7 @@ main()
}
/*
- * Code to control or munipulate child threads should probably go here.
+ * Code to control or manipulate child threads should probably go here.
*/
Sleep(500);
@@ -193,7 +196,7 @@ main()
assert(pthread_join(t[i], &result) == 0);
- fail = ((int)(size_t)result == (int) PTHREAD_CANCELED);
+ fail = (result == PTHREAD_CANCELED);
if (fail)
{
diff --git a/pthreads/tests/cleanup1.c b/pthreads/tests/cleanup1.c
index 30d4940b7..a59d05616 100644
--- a/pthreads/tests/cleanup1.c
+++ b/pthreads/tests/cleanup1.c
@@ -6,26 +6,27 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
* http://sources.redhat.com/pthreads-win32/contributors.html
- *
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library in the file COPYING.LIB;
* if not, write to the Free Software Foundation, Inc.,
@@ -36,22 +37,22 @@
* Test Synopsis: Test cleanup handler executes (when thread is canceled).
*
* Test Method (Validation or Falsification):
- * -
+ * -
*
* Requirements Tested:
* -
*
* Features Tested:
- * -
+ * -
*
* Cases Tested:
- * -
+ * -
*
* Description:
- * -
+ * -
*
* Environment:
- * -
+ * -
*
* Input:
* - None.
@@ -97,7 +98,7 @@ typedef struct {
CRITICAL_SECTION cs;
} sharedInt_t;
-static sharedInt_t pop_count = {0, {0}};
+static sharedInt_t pop_count;
static void
#ifdef __CLEANUP_C
@@ -133,10 +134,10 @@ mythread(void * arg)
#endif
pthread_cleanup_push(increment_pop_count, (void *) &pop_count);
/*
- * We don't have true async cancelation - it relies on the thread
+ * We don't have true async cancellation - it relies on the thread
* at least re-entering the run state at some point.
* We wait up to 10 seconds, waking every 0.1 seconds,
- * for a cancelation to be applied to us.
+ * for a cancellation to be applied to us.
*/
for (bag->count = 0; bag->count < 100; bag->count++)
Sleep(100);
@@ -156,6 +157,8 @@ main()
int i;
pthread_t t[NUMTHREADS + 1];
+ memset(&pop_count, 0, sizeof(sharedInt_t));
+
InitializeCriticalSection(&pop_count.cs);
assert((t[0] = pthread_self()).p != NULL);
@@ -168,7 +171,7 @@ main()
}
/*
- * Code to control or munipulate child threads should probably go here.
+ * Code to control or manipulate child threads should probably go here.
*/
Sleep(500);
@@ -188,10 +191,10 @@ main()
for (i = 1; i <= NUMTHREADS; i++)
{
if (!threadbag[i].started)
- {
- failed |= !threadbag[i].started;
- fprintf(stderr, "Thread %d: started %d\n", i, threadbag[i].started);
- }
+ {
+ failed |= !threadbag[i].started;
+ fprintf(stderr, "Thread %d: started %d\n", i, threadbag[i].started);
+ }
}
assert(!failed);
@@ -207,7 +210,7 @@ main()
assert(pthread_join(t[i], &result) == 0);
- fail = ((int)(size_t)result != (int) PTHREAD_CANCELED);
+ fail = (result != PTHREAD_CANCELED);
if (fail)
{
diff --git a/pthreads/tests/cleanup2.c b/pthreads/tests/cleanup2.c
index 67037c255..52a804e6a 100644
--- a/pthreads/tests/cleanup2.c
+++ b/pthreads/tests/cleanup2.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -97,7 +98,7 @@ typedef struct {
CRITICAL_SECTION cs;
} sharedInt_t;
-static sharedInt_t pop_count = {0, {0}};
+static sharedInt_t pop_count;
static void
increment_pop_count(void * arg)
@@ -141,6 +142,8 @@ main()
int i;
pthread_t t[NUMTHREADS + 1];
+ memset(&pop_count, 0, sizeof(sharedInt_t));
+
InitializeCriticalSection(&pop_count.cs);
assert((t[0] = pthread_self()).p != NULL);
@@ -153,7 +156,7 @@ main()
}
/*
- * Code to control or munipulate child threads should probably go here.
+ * Code to control or manipulate child threads should probably go here.
*/
Sleep(1000);
diff --git a/pthreads/tests/cleanup3.c b/pthreads/tests/cleanup3.c
index 62317b3b0..7d6a4b96a 100644
--- a/pthreads/tests/cleanup3.c
+++ b/pthreads/tests/cleanup3.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -98,7 +99,7 @@ typedef struct {
CRITICAL_SECTION cs;
} sharedInt_t;
-static sharedInt_t pop_count = {0, {0}};
+static sharedInt_t pop_count;
static void
increment_pop_count(void * arg)
@@ -146,6 +147,8 @@ main()
int i;
pthread_t t[NUMTHREADS + 1];
+ memset(&pop_count, 0, sizeof(sharedInt_t));
+
InitializeCriticalSection(&pop_count.cs);
assert((t[0] = pthread_self()).p != NULL);
@@ -158,7 +161,7 @@ main()
}
/*
- * Code to control or munipulate child threads should probably go here.
+ * Code to control or manipulate child threads should probably go here.
*/
Sleep(1000);
diff --git a/pthreads/tests/common.mk b/pthreads/tests/common.mk
new file mode 100755
index 000000000..06a21be38
--- /dev/null
+++ b/pthreads/tests/common.mk
@@ -0,0 +1,53 @@
+#
+# Common elements to all makefiles
+#
+
+ALL_KNOWN_TESTS = \
+ affinity1 affinity2 affinity3 affinity4 affinity5 \
+ barrier1 barrier2 barrier3 barrier4 barrier5 barrier6 \
+ cancel1 cancel2 cancel3 cancel4 cancel5 cancel6a cancel6d \
+ cancel7 cancel8 cancel9 \
+ cleanup0 cleanup1 cleanup2 cleanup3 \
+ condvar1 condvar1_1 condvar1_2 condvar2 condvar2_1 \
+ condvar3 condvar3_1 condvar3_2 condvar3_3 \
+ condvar4 condvar5 condvar6 \
+ condvar7 condvar8 condvar9 \
+ count1 \
+ context1 \
+ create1 create2 create3 \
+ delay1 delay2 \
+ detach1 \
+ equal1 \
+ errno1 \
+ exception1 exception2 exception3_0 exception3 \
+ exit1 exit2 exit3 exit4 exit5 \
+ eyal1 \
+ join0 join1 join2 join3 join4 \
+ kill1 \
+ mutex1 mutex1n mutex1e mutex1r \
+ mutex2 mutex2r mutex2e mutex3 mutex3r mutex3e \
+ mutex4 mutex5 mutex6 mutex6n mutex6e mutex6r \
+ mutex6s mutex6es mutex6rs \
+ mutex7 mutex7n mutex7e mutex7r \
+ mutex8 mutex8n mutex8e mutex8r \
+ once1 once2 once3 once4 \
+ priority1 priority2 inherit1 \
+ reuse1 reuse2 \
+ robust1 robust2 robust3 robust4 robust5 \
+ rwlock1 rwlock2 rwlock3 rwlock4 \
+ rwlock2_t rwlock3_t rwlock4_t rwlock5_t rwlock6_t rwlock6_t2 \
+ rwlock5 rwlock6 rwlock7 rwlock8 \
+ self1 self2 \
+ semaphore1 semaphore2 semaphore3 \
+ semaphore4 semaphore4t semaphore5 \
+ sequence1 \
+ sizes \
+ spin1 spin2 spin3 spin4 \
+ stress1 \
+ tsd1 tsd2 \
+ valid1 valid2
+
+TESTS = $(ALL_KNOWN_TESTS)
+
+BENCHTESTS = \
+ benchtest1 benchtest2 benchtest3 benchtest4 benchtest5
diff --git a/pthreads/tests/condvar1.c b/pthreads/tests/condvar1.c
index 380ab1aff..303a87b87 100644
--- a/pthreads/tests/condvar1.c
+++ b/pthreads/tests/condvar1.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/condvar1_1.c b/pthreads/tests/condvar1_1.c
index a05e113b9..565697e5d 100644
--- a/pthreads/tests/condvar1_1.c
+++ b/pthreads/tests/condvar1_1.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/condvar1_2.c b/pthreads/tests/condvar1_2.c
index 3d961f06d..61185518a 100644
--- a/pthreads/tests/condvar1_2.c
+++ b/pthreads/tests/condvar1_2.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/condvar2.c b/pthreads/tests/condvar2.c
index 6e2fa52d2..452b22bea 100644
--- a/pthreads/tests/condvar2.c
+++ b/pthreads/tests/condvar2.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -113,10 +114,10 @@ main()
if (result != 0)
{
fprintf(stderr, "Result = %s\n", error_string[result]);
- fprintf(stderr, "\tWaitersBlocked = %ld\n", cv->nWaitersBlocked);
- fprintf(stderr, "\tWaitersGone = %ld\n", cv->nWaitersGone);
- fprintf(stderr, "\tWaitersToUnblock = %ld\n", cv->nWaitersToUnblock);
- fflush(stderr);
+ fprintf(stderr, "\tWaitersBlocked = %ld\n", cv->nWaitersBlocked);
+ fprintf(stderr, "\tWaitersGone = %ld\n", cv->nWaitersGone);
+ fprintf(stderr, "\tWaitersToUnblock = %ld\n", cv->nWaitersToUnblock);
+ fflush(stderr);
}
assert(result == 0);
}
diff --git a/pthreads/tests/condvar2_1.c b/pthreads/tests/condvar2_1.c
index 3486d2110..dc3675566 100644
--- a/pthreads/tests/condvar2_1.c
+++ b/pthreads/tests/condvar2_1.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/condvar3.c b/pthreads/tests/condvar3.c
index 056334b37..2fed04143 100644
--- a/pthreads/tests/condvar3.c
+++ b/pthreads/tests/condvar3.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/condvar3_1.c b/pthreads/tests/condvar3_1.c
index 33baeb14d..79638fa75 100644
--- a/pthreads/tests/condvar3_1.c
+++ b/pthreads/tests/condvar3_1.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/condvar3_2.c b/pthreads/tests/condvar3_2.c
index 4c3580152..0cb332ced 100644
--- a/pthreads/tests/condvar3_2.c
+++ b/pthreads/tests/condvar3_2.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/condvar3_3.c b/pthreads/tests/condvar3_3.c
index f842440a1..7a5fc651a 100644
--- a/pthreads/tests/condvar3_3.c
+++ b/pthreads/tests/condvar3_3.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/condvar4.c b/pthreads/tests/condvar4.c
index 3f6879b0a..f69e0a97e 100644
--- a/pthreads/tests/condvar4.c
+++ b/pthreads/tests/condvar4.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/condvar5.c b/pthreads/tests/condvar5.c
index 73083a55e..8d678d3a2 100644
--- a/pthreads/tests/condvar5.c
+++ b/pthreads/tests/condvar5.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/condvar6.c b/pthreads/tests/condvar6.c
index 9d0b75d81..fbf0c8711 100644
--- a/pthreads/tests/condvar6.c
+++ b/pthreads/tests/condvar6.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -176,7 +177,7 @@ main()
}
/*
- * Code to control or munipulate child threads should probably go here.
+ * Code to control or manipulate child threads should probably go here.
*/
assert(pthread_mutex_unlock(&start_flag) == 0);
diff --git a/pthreads/tests/condvar7.c b/pthreads/tests/condvar7.c
index 0647e7d91..d0a1e951d 100644
--- a/pthreads/tests/condvar7.c
+++ b/pthreads/tests/condvar7.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,7 +35,7 @@
* --------------------------------------------------------------------------
*
* Test Synopsis:
- * - Test pthread_cond_broadcast with thread cancelation.
+ * - Test pthread_cond_broadcast with thread cancellation.
*
* Test Method (Validation or Falsification):
* - Validation
@@ -186,7 +187,7 @@ main()
}
/*
- * Code to control or munipulate child threads should probably go here.
+ * Code to control or manipulate child threads should probably go here.
*/
assert(pthread_mutex_unlock(&start_flag) == 0);
diff --git a/pthreads/tests/condvar8.c b/pthreads/tests/condvar8.c
index 7c2579d98..a05ccb59c 100644
--- a/pthreads/tests/condvar8.c
+++ b/pthreads/tests/condvar8.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -189,7 +190,7 @@ main()
}
/*
- * Code to control or munipulate child threads should probably go here.
+ * Code to control or manipulate child threads should probably go here.
*/
cvthing.shared = 0;
diff --git a/pthreads/tests/condvar9.c b/pthreads/tests/condvar9.c
index 62d044bf8..910d37b27 100644
--- a/pthreads/tests/condvar9.c
+++ b/pthreads/tests/condvar9.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,7 +35,7 @@
* --------------------------------------------------------------------------
*
* Test Synopsis:
- * - Test multiple pthread_cond_broadcasts with thread cancelation.
+ * - Test multiple pthread_cond_broadcasts with thread cancellation.
*
* Test Method (Validation or Falsification):
* - Validation
@@ -128,7 +129,7 @@ mythread(void * arg)
assert(pthread_mutex_lock(&cvthing.lock) == 0);
/*
- * pthread_cond_timedwait is a cancelation point and we're
+ * pthread_cond_timedwait is a cancellation point and we're
* going to cancel some threads deliberately.
*/
#ifdef _MSC_VER
@@ -199,7 +200,7 @@ main()
}
/*
- * Code to control or munipulate child threads should probably go here.
+ * Code to control or manipulate child threads should probably go here.
*/
cvthing.shared = 0;
diff --git a/pthreads/tests/context1.c b/pthreads/tests/context1.c
index db38ec3a1..284d89f70 100644
--- a/pthreads/tests/context1.c
+++ b/pthreads/tests/context1.c
@@ -1,142 +1,142 @@
-/*
- * File: context1.c
- *
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- *
- * --------------------------------------------------------------------------
- *
- * Test Synopsis: Test context switching method.
- *
- * Test Method (Validation or Falsification):
- * -
- *
- * Requirements Tested:
- * -
- *
- * Features Tested:
- * -
- *
- * Cases Tested:
- * -
- *
- * Description:
- * -
- *
- * Environment:
- * -
- *
- * Input:
- * - None.
- *
- * Output:
- * - File name, Line number, and failed expression on failure.
- * - No output on success.
- *
- * Assumptions:
- * - pthread_create
- * pthread_exit
- *
- * Pass Criteria:
- * - Process returns zero exit status.
- *
- * Fail Criteria:
- * - Process returns non-zero exit status.
- */
-
-#define _WIN32_WINNT 0x400
-
-#include "test.h"
-#include "../implement.h"
-#include "../context.h"
-
-static int washere = 0;
-
-static void * func(void * arg)
-{
- washere = 1;
-
- Sleep(1000);
-
- return 0;
-}
-
-static void
-anotherEnding ()
-{
- /*
- * Switched context
- */
- washere++;
-
- pthread_exit(0);
-}
-
-int
-main()
-{
- pthread_t t;
- HANDLE hThread;
-
- assert(pthread_create(&t, NULL, func, NULL) == 0);
-
- hThread = ((ptw32_thread_t *)t.p)->threadH;
-
- Sleep(500);
-
- SuspendThread(hThread);
-
- if (WaitForSingleObject(hThread, 0) == WAIT_TIMEOUT)
- {
- /*
- * Ok, thread did not exit before we got to it.
- */
- CONTEXT context;
-
- context.ContextFlags = CONTEXT_CONTROL;
-
- GetThreadContext(hThread, &context);
- PTW32_PROGCTR (context) = (DWORD_PTR) anotherEnding;
- SetThreadContext(hThread, &context);
- ResumeThread(hThread);
- }
- else
- {
- printf("Exited early\n");
- fflush(stdout);
- }
-
- Sleep(1000);
-
- assert(washere == 2);
-
- return 0;
-}
-
+/*
+ * File: context1.c
+ *
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads-win32 - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * http://sources.redhat.com/pthreads-win32/contributors.html
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Test Synopsis: Test context switching method.
+ *
+ * Test Method (Validation or Falsification):
+ * -
+ *
+ * Requirements Tested:
+ * -
+ *
+ * Features Tested:
+ * -
+ *
+ * Cases Tested:
+ * -
+ *
+ * Description:
+ * -
+ *
+ * Environment:
+ * -
+ *
+ * Input:
+ * - None.
+ *
+ * Output:
+ * - File name, Line number, and failed expression on failure.
+ * - No output on success.
+ *
+ * Assumptions:
+ * - pthread_create
+ * pthread_exit
+ *
+ * Pass Criteria:
+ * - Process returns zero exit status.
+ *
+ * Fail Criteria:
+ * - Process returns non-zero exit status.
+ */
+
+#define _WIN32_WINNT 0x400
+
+#include "test.h"
+#include "../implement.h"
+#include "../context.h"
+
+static int washere = 0;
+
+static void * func(void * arg)
+{
+ washere = 1;
+
+ Sleep(1000);
+
+ return 0;
+}
+
+static void
+anotherEnding ()
+{
+ /*
+ * Switched context
+ */
+ washere++;
+ pthread_exit(0);
+}
+
+int
+main()
+{
+ pthread_t t;
+ HANDLE hThread;
+
+ assert(pthread_create(&t, NULL, func, NULL) == 0);
+
+ hThread = ((ptw32_thread_t *)t.p)->threadH;
+
+ Sleep(500);
+
+ SuspendThread(hThread);
+
+ if (WaitForSingleObject(hThread, 0) == WAIT_TIMEOUT)
+ {
+ /*
+ * Ok, thread did not exit before we got to it.
+ */
+ CONTEXT context;
+
+ context.ContextFlags = CONTEXT_CONTROL;
+
+ GetThreadContext(hThread, &context);
+ PTW32_PROGCTR (context) = (DWORD_PTR) anotherEnding;
+ SetThreadContext(hThread, &context);
+ ResumeThread(hThread);
+ }
+ else
+ {
+ printf("Exited early\n");
+ fflush(stdout);
+ }
+
+ Sleep(1000);
+
+ assert(washere == 2);
+
+ return 0;
+}
+
diff --git a/pthreads/tests/context2.c b/pthreads/tests/context2.c
new file mode 100755
index 000000000..154948a4f
--- /dev/null
+++ b/pthreads/tests/context2.c
@@ -0,0 +1,157 @@
+/*
+ * File: context2.c
+ *
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads-win32 - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999,2005 Pthreads-win32 contributors
+ *
+ * Contact Email: rpj@callisto.canberra.edu.au
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * http://sources.redhat.com/pthreads-win32/contributors.html
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Test Synopsis: Test context switching method.
+ *
+ * Test Method (Validation or Falsification):
+ * -
+ *
+ * Requirements Tested:
+ * -
+ *
+ * Features Tested:
+ * -
+ *
+ * Cases Tested:
+ * -
+ *
+ * Description:
+ * -
+ *
+ * Environment:
+ * -
+ *
+ * Input:
+ * - None.
+ *
+ * Output:
+ * - File name, Line number, and failed expression on failure.
+ * - No output on success.
+ *
+ * Assumptions:
+ * - pthread_create
+ * pthread_exit
+ *
+ * Pass Criteria:
+ * - Process returns zero exit status.
+ *
+ * Fail Criteria:
+ * - Process returns non-zero exit status.
+ */
+
+#define _WIN32_WINNT 0x400
+
+#include "test.h"
+#include "../implement.h"
+#include "../context.h"
+
+static int washere = 0;
+static volatile size_t tree_counter = 0;
+
+#ifdef _MSC_VER
+# pragma inline_depth(0)
+# pragma optimize("g", off)
+#endif
+
+static size_t tree(size_t depth)
+{
+ if (! depth--)
+ return tree_counter++;
+
+ return tree(depth) + tree(depth);
+}
+
+static void * func(void * arg)
+{
+ washere = 1;
+
+ return (void *) tree(64);
+}
+
+static void
+anotherEnding ()
+{
+ /*
+ * Switched context
+ */
+ washere++;
+ pthread_exit(0);
+}
+
+#ifdef _MSC_VER
+# pragma inline_depth()
+# pragma optimize("", on)
+#endif
+
+int
+main()
+{
+ pthread_t t;
+ HANDLE hThread;
+
+ assert(pthread_create(&t, NULL, func, NULL) == 0);
+
+ hThread = ((ptw32_thread_t *)t.p)->threadH;
+
+ Sleep(500);
+
+ SuspendThread(hThread);
+
+ if (WaitForSingleObject(hThread, 0) == WAIT_TIMEOUT)
+ {
+ /*
+ * Ok, thread did not exit before we got to it.
+ */
+ CONTEXT context;
+
+ context.ContextFlags = CONTEXT_CONTROL;
+
+ GetThreadContext(hThread, &context);
+ PTW32_PROGCTR (context) = (DWORD_PTR) anotherEnding;
+ SetThreadContext(hThread, &context);
+ ResumeThread(hThread);
+ }
+ else
+ {
+ printf("Exited early\n");
+ fflush(stdout);
+ }
+
+ Sleep(1000);
+
+ assert(washere == 2);
+
+ return 0;
+}
diff --git a/pthreads/tests/count1.c b/pthreads/tests/count1.c
index c2386b0e9..c639fd270 100644
--- a/pthreads/tests/count1.c
+++ b/pthreads/tests/count1.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/create1.c b/pthreads/tests/create1.c
index 8c630cb93..63b1bf6eb 100644
--- a/pthreads/tests/create1.c
+++ b/pthreads/tests/create1.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/create2.c b/pthreads/tests/create2.c
index 9b4e86480..9e56d9d40 100644
--- a/pthreads/tests/create2.c
+++ b/pthreads/tests/create2.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/create3.c b/pthreads/tests/create3.c
new file mode 100755
index 000000000..5063d0ba7
--- /dev/null
+++ b/pthreads/tests/create3.c
@@ -0,0 +1,110 @@
+/*
+ * File: create3.c
+ *
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads-win32 - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * http://sources.redhat.com/pthreads-win32/contributors.html
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Test Synopsis:
+ * - Test passing arg to thread function.
+ *
+ * Test Method (Validation or Falsification):
+ * - Statistical, not absolute (depends on sample size).
+ *
+ * Requirements Tested:
+ * -
+ *
+ * Features Tested:
+ * -
+ *
+ * Cases Tested:
+ * -
+ *
+ * Description:
+ * -
+ *
+ * Environment:
+ * -
+ *
+ * Input:
+ * - None.
+ *
+ * Output:
+ * - File name, Line number, and failed expression on failure.
+ * - No output on success.
+ *
+ * Assumptions:
+ * -
+ *
+ * Pass Criteria:
+ * - Process returns zero exit status.
+ *
+ * Fail Criteria:
+ * - Process returns non-zero exit status.
+ */
+
+#include "test.h"
+
+enum {
+ NUMTHREADS = 10000
+};
+
+static int washere = 0;
+
+void * func(void * arg)
+{
+ washere = (int)(size_t)arg;
+ return (void *) 0;
+}
+
+int
+main()
+{
+ pthread_t t;
+ pthread_attr_t attr;
+ void * result = NULL;
+ int i;
+
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+ for (i = 0; i < NUMTHREADS; i++)
+ {
+ washere = 0;
+ assert(pthread_create(&t, &attr, func, (void *)(size_t)1) == 0);
+ assert(pthread_join(t, &result) == 0);
+ assert((int)(size_t)result == 0);
+ assert(washere == 1);
+ }
+
+ return 0;
+}
diff --git a/pthreads/tests/delay1.c b/pthreads/tests/delay1.c
index 83becd890..9c5293e87 100644
--- a/pthreads/tests/delay1.c
+++ b/pthreads/tests/delay1.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/delay2.c b/pthreads/tests/delay2.c
index 071b837f1..5ff6c1deb 100644
--- a/pthreads/tests/delay2.c
+++ b/pthreads/tests/delay2.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/detach1.c b/pthreads/tests/detach1.c
index 89756c7ad..4eb8cb73d 100644
--- a/pthreads/tests/detach1.c
+++ b/pthreads/tests/detach1.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/equal1.c b/pthreads/tests/equal1.c
index 8932bb2aa..2dfa79425 100644
--- a/pthreads/tests/equal1.c
+++ b/pthreads/tests/equal1.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/errno1.c b/pthreads/tests/errno1.c
index 70ce92802..14e8150a9 100644
--- a/pthreads/tests/errno1.c
+++ b/pthreads/tests/errno1.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -135,7 +136,7 @@ main()
}
/*
- * Code to control or munipulate child threads should probably go here.
+ * Code to control or manipulate child threads should probably go here.
*/
Sleep(2000);
pthread_mutex_unlock(&stop_here);
diff --git a/pthreads/tests/exception1.c b/pthreads/tests/exception1.c
index 62a5a63cb..5470ad993 100644
--- a/pthreads/tests/exception1.c
+++ b/pthreads/tests/exception1.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -153,7 +154,7 @@ canceledThread(void * arg)
{
/*
* We wait up to 10 seconds, waking every 0.1 seconds,
- * for a cancelation to be applied to us.
+ * for a cancellation to be applied to us.
*/
for (count = 0; count < 100; count++)
Sleep(100);
@@ -168,7 +169,7 @@ canceledThread(void * arg)
{
/*
* We wait up to 10 seconds, waking every 0.1 seconds,
- * for a cancelation to be applied to us.
+ * for a cancellation to be applied to us.
*/
for (count = 0; count < 100; count++)
Sleep(100);
@@ -205,7 +206,7 @@ main()
}
/*
- * Code to control or munipulate child threads should probably go here.
+ * Code to control or manipulate child threads should probably go here.
*/
Sleep(1000);
diff --git a/pthreads/tests/exception2.c b/pthreads/tests/exception2.c
index faf677d9b..fffe2b558 100644
--- a/pthreads/tests/exception2.c
+++ b/pthreads/tests/exception2.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -125,10 +126,21 @@ main(int argc, char* argv[])
printf("You should see an \"abnormal termination\" message\n");
fflush(stdout);
+
result = system("exception2.exe die");
- exit(0);
+
+ printf("\"exception2.exe die\" returned status %d\n", result);
+
+ /*
+ * result should be 0, 1 or 3 depending on build settings
+ */
+ exit((result == 0 || result == 1 || result == 3) ? 0 : 1);
}
+#if defined(NO_ERROR_DIALOGS)
+ SetErrorMode(SEM_NOGPFAULTERRORBOX);
+#endif
+
assert((mt = pthread_self()).p != NULL);
for (i = 0; i < NUMTHREADS; i++)
@@ -136,7 +148,7 @@ main(int argc, char* argv[])
assert(pthread_create(&et[i], NULL, exceptionedThread, NULL) == 0);
}
- Sleep(1000);
+ Sleep(100);
/*
* Success.
diff --git a/pthreads/tests/exception3.c b/pthreads/tests/exception3.c
index 65bcdbef3..3b9ec6fd9 100644
--- a/pthreads/tests/exception3.c
+++ b/pthreads/tests/exception3.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -73,7 +74,13 @@
#include "test.h"
-#if defined(__cplusplus)
+/*
+ * Note: Due to a buggy C++ runtime in Visual Studio 2005, when we are
+ * built with /MD and an unhandled exception occurs, the runtime does not
+ * properly call the terminate handler specified by set_terminate().
+ */
+#if defined(__cplusplus) \
+ && !(defined(_MSC_VER) && _MSC_VER == 1400 && defined(_DLL) && !defined(_DEBUG))
#if defined(_MSC_VER)
# include <eh.h>
@@ -90,7 +97,7 @@
* Create NUMTHREADS threads in addition to the Main thread.
*/
enum {
- NUMTHREADS = 1
+ NUMTHREADS = 10
};
int caught = 0;
@@ -125,12 +132,24 @@ terminateFunction ()
exit(0);
}
+void
+wrongTerminateFunction ()
+{
+ fputs("This is not the termination routine that should have been called!\n", stderr);
+ exit(1);
+}
+
void *
exceptionedThread(void * arg)
{
int dummy = 0x1;
- (void) set_terminate(&terminateFunction);
+#if defined(PTW32_USES_SEPARATE_CRT) && (defined(__CLEANUP_CXX) || defined(__CLEANUP_SEH))
+ pthread_win32_set_terminate_np(&terminateFunction);
+ set_terminate(&wrongTerminateFunction);
+#else
+ set_terminate(&terminateFunction);
+#endif
throw dummy;
@@ -159,14 +178,12 @@ main()
assert(pthread_create(&et[i], NULL, exceptionedThread, NULL) == 0);
}
- Sleep(NUMTHREADS * 100);
-
- assert(caught == NUMTHREADS);
+ Sleep(NUMTHREADS * 10);
/*
- * Success.
+ * Fail. Should never be reached.
*/
- return 0;
+ return 1;
}
#else /* defined(__cplusplus) */
diff --git a/pthreads/tests/exception3_0.c b/pthreads/tests/exception3_0.c
new file mode 100755
index 000000000..bc06bf335
--- /dev/null
+++ b/pthreads/tests/exception3_0.c
@@ -0,0 +1,187 @@
+/*
+ * File: exception3.c
+ *
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads-win32 - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * http://sources.redhat.com/pthreads-win32/contributors.html
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Test Synopsis: Test running of user supplied terminate() function.
+ *
+ * Test Method (Validation or Falsification):
+ * -
+ *
+ * Requirements Tested:
+ * -
+ *
+ * Features Tested:
+ * -
+ *
+ * Cases Tested:
+ * -
+ *
+ * Description:
+ * -
+ *
+ * Environment:
+ * -
+ *
+ * Input:
+ * - None.
+ *
+ * Output:
+ * - File name, Line number, and failed expression on failure.
+ * - No output on success.
+ *
+ * Assumptions:
+ * - have working pthread_create, pthread_self, pthread_mutex_lock/unlock
+ * pthread_testcancel, pthread_cancel
+ *
+ * Pass Criteria:
+ * - Process returns zero exit status.
+ *
+ * Fail Criteria:
+ * - Process returns non-zero exit status.
+ */
+
+#include "test.h"
+
+/*
+ * Note: Due to a buggy C++ runtime in Visual Studio 2005, when we are
+ * built with /MD and an unhandled exception occurs, the runtime does not
+ * properly call the terminate handler specified by set_terminate().
+ */
+#if defined(__cplusplus) \
+ && !(defined(_MSC_VER) && _MSC_VER == 1400 && defined(_DLL) && !defined(_DEBUG))
+
+#if defined(_MSC_VER)
+# include <eh.h>
+#else
+# if defined(__GNUC__) && __GNUC__ < 3
+# include <new.h>
+# else
+# include <new>
+ using std::set_terminate;
+# endif
+#endif
+
+/*
+ * Create NUMTHREADS threads in addition to the Main thread.
+ */
+enum {
+ NUMTHREADS = 10
+};
+
+int caught = 0;
+CRITICAL_SECTION caughtLock;
+
+void
+terminateFunction ()
+{
+ EnterCriticalSection(&caughtLock);
+ caught++;
+#if 0
+ {
+ FILE * fp = fopen("pthread.log", "a");
+ fprintf(fp, "Caught = %d\n", caught);
+ fclose(fp);
+ }
+#endif
+ LeaveCriticalSection(&caughtLock);
+
+ /*
+ * Notes from the MSVC++ manual:
+ * 1) A term_func() should call exit(), otherwise
+ * abort() will be called on return to the caller.
+ * abort() raises SIGABRT. The default signal handler
+ * for all signals terminates the calling program with
+ * exit code 3.
+ * 2) A term_func() must not throw an exception. Dev: Therefore
+ * term_func() should not call pthread_exit() if an
+ * exception-using version of pthreads-win32 library
+ * is being used (i.e. either pthreadVCE or pthreadVSE).
+ */
+ exit(0);
+}
+
+void *
+exceptionedThread(void * arg)
+{
+ int dummy = 0x1;
+
+ set_terminate(&terminateFunction);
+ assert(set_terminate(&terminateFunction) == &terminateFunction);
+
+ throw dummy;
+
+ return (void *) 2;
+}
+
+int
+main()
+{
+ int i;
+ DWORD et[NUMTHREADS];
+
+ InitializeCriticalSection(&caughtLock);
+
+ for (i = 0; i < NUMTHREADS; i++)
+ {
+ CreateThread(NULL, //Choose default security
+ 0, //Default stack size
+ (LPTHREAD_START_ROUTINE)&exceptionedThread, //Routine to execute
+ NULL, //Thread parameter
+ 0, //Immediately run the thread
+ &et[i] //Thread Id
+ );
+ }
+
+ Sleep(NUMTHREADS * 10);
+
+ DeleteCriticalSection(&caughtLock);
+ /*
+ * Fail. Should never be reached.
+ */
+ return 1;
+}
+
+#else /* defined(__cplusplus) */
+
+#include <stdio.h>
+
+int
+main()
+{
+ fprintf(stderr, "Test N/A for this compiler environment.\n");
+ return 0;
+}
+
+#endif /* defined(__cplusplus) */
diff --git a/pthreads/tests/exit1.c b/pthreads/tests/exit1.c
index 38f218211..352942452 100644
--- a/pthreads/tests/exit1.c
+++ b/pthreads/tests/exit1.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -45,6 +46,5 @@ main(int argc, char * argv[])
pthread_exit((void *) 0);
/* Not reached */
- assert(0);
- return 0;
+ return 1;
}
diff --git a/pthreads/tests/exit2.c b/pthreads/tests/exit2.c
index b9f785edf..7438c865e 100644
--- a/pthreads/tests/exit2.c
+++ b/pthreads/tests/exit2.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/exit3.c b/pthreads/tests/exit3.c
index 18859e4ee..6c01a0261 100644
--- a/pthreads/tests/exit3.c
+++ b/pthreads/tests/exit3.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/exit4.c b/pthreads/tests/exit4.c
index 06dd8b1ee..e41383895 100644
--- a/pthreads/tests/exit4.c
+++ b/pthreads/tests/exit4.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -136,7 +137,7 @@ main()
}
/*
- * Code to control or munipulate child threads should probably go here.
+ * Code to control or manipulate child threads should probably go here.
*/
Sleep(500);
diff --git a/pthreads/tests/exit5.c b/pthreads/tests/exit5.c
index ac98f996c..c9ecf44e4 100644
--- a/pthreads/tests/exit5.c
+++ b/pthreads/tests/exit5.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -140,7 +141,7 @@ main()
}
/*
- * Code to control or munipulate child threads should probably go here.
+ * Code to control or manipulate child threads should probably go here.
*/
Sleep(500);
diff --git a/pthreads/tests/eyal1.c b/pthreads/tests/eyal1.c
index 72b5697e9..5da95ff5d 100644
--- a/pthreads/tests/eyal1.c
+++ b/pthreads/tests/eyal1.c
@@ -5,10 +5,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -142,13 +143,10 @@ waste_time (int n)
static int
do_work_unit (int who, int n)
{
- int i;
static int nchars = 0;
double f = 0.0;
- if (quiet)
- i = 0;
- else {
+ if (!quiet) {
/*
* get lock on stdout
*/
@@ -157,7 +155,7 @@ do_work_unit (int who, int n)
/*
* do our job
*/
- i = printf ("%c", "0123456789abcdefghijklmnopqrstuvwxyz"[who]);
+ (void) printf ("%c", "0123456789abcdefghijklmnopqrstuvwxyz"[who]);
if (!(++nchars % 50))
printf ("\n");
diff --git a/pthreads/tests/inherit1.c b/pthreads/tests/inherit1.c
index 24ceec557..d09cfc773 100644
--- a/pthreads/tests/inherit1.c
+++ b/pthreads/tests/inherit1.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/join0.c b/pthreads/tests/join0.c
index d888e9d6b..f5c040eb5 100644
--- a/pthreads/tests/join0.c
+++ b/pthreads/tests/join0.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/join1.c b/pthreads/tests/join1.c
index 337af832d..a04127915 100644
--- a/pthreads/tests/join1.c
+++ b/pthreads/tests/join1.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/join2.c b/pthreads/tests/join2.c
index b3b85ee81..8864f221a 100644
--- a/pthreads/tests/join2.c
+++ b/pthreads/tests/join2.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/join3.c b/pthreads/tests/join3.c
index 44380ace3..35368667d 100644
--- a/pthreads/tests/join3.c
+++ b/pthreads/tests/join3.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/join4.c b/pthreads/tests/join4.c
new file mode 100755
index 000000000..cbe96d29a
--- /dev/null
+++ b/pthreads/tests/join4.c
@@ -0,0 +1,87 @@
+/*
+ * Test for pthread_timedjoin_np() timing out.
+ *
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads-win32 - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * http://sources.redhat.com/pthreads-win32/contributors.html
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Depends on API functions: pthread_create().
+ */
+
+#include "test.h"
+
+void *
+func(void * arg)
+{
+ Sleep(1200);
+ return arg;
+}
+
+int
+main(int argc, char * argv[])
+{
+ pthread_t id;
+ struct timespec abstime;
+ void* result = (void*)-1;
+ PTW32_STRUCT_TIMEB currSysTime;
+ const DWORD NANOSEC_PER_MILLISEC = 1000000;
+
+ assert(pthread_create(&id, NULL, func, (void *)(size_t)999) == 0);
+
+ /*
+ * Let thread start before we attempt to join it.
+ */
+ Sleep(100);
+
+ PTW32_FTIME(&currSysTime);
+
+ abstime.tv_sec = (long)currSysTime.time;
+ abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm;
+
+ /* Test for pthread_timedjoin_np timeout */
+ abstime.tv_sec += 1;
+ assert(pthread_timedjoin_np(id, &result, &abstime) == ETIMEDOUT);
+ assert((int)(size_t)result == -1);
+
+ /* Test for pthread_tryjoin_np behaviour before thread has exited */
+ assert(pthread_tryjoin_np(id, &result) == EBUSY);
+ assert((int)(size_t)result == -1);
+
+ Sleep(500);
+
+ /* Test for pthread_tryjoin_np behaviour after thread has exited */
+ assert(pthread_tryjoin_np(id, &result) == 0);
+ assert((int)(size_t)result == 999);
+
+ /* Success. */
+ return 0;
+}
diff --git a/pthreads/tests/kill1.c b/pthreads/tests/kill1.c
index fd1eaee2b..84ca3c00b 100644
--- a/pthreads/tests/kill1.c
+++ b/pthreads/tests/kill1.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/mutex1.c b/pthreads/tests/mutex1.c
index 918c90330..6d9beaf83 100644
--- a/pthreads/tests/mutex1.c
+++ b/pthreads/tests/mutex1.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/mutex1e.c b/pthreads/tests/mutex1e.c
index d32adb3a1..9d0a32eca 100644
--- a/pthreads/tests/mutex1e.c
+++ b/pthreads/tests/mutex1e.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/mutex1n.c b/pthreads/tests/mutex1n.c
index fcfc1347c..7e306cfa4 100644
--- a/pthreads/tests/mutex1n.c
+++ b/pthreads/tests/mutex1n.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/mutex1r.c b/pthreads/tests/mutex1r.c
index 15083f27a..fb2de7eab 100644
--- a/pthreads/tests/mutex1r.c
+++ b/pthreads/tests/mutex1r.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/mutex2.c b/pthreads/tests/mutex2.c
index 377468e90..8bd490f32 100644
--- a/pthreads/tests/mutex2.c
+++ b/pthreads/tests/mutex2.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/mutex2e.c b/pthreads/tests/mutex2e.c
index 7df6073d2..dd17ccd8c 100644
--- a/pthreads/tests/mutex2e.c
+++ b/pthreads/tests/mutex2e.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/mutex2r.c b/pthreads/tests/mutex2r.c
index c96e366f1..740d60736 100644
--- a/pthreads/tests/mutex2r.c
+++ b/pthreads/tests/mutex2r.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/mutex3.c b/pthreads/tests/mutex3.c
index bc1429e0b..94ca2daee 100644
--- a/pthreads/tests/mutex3.c
+++ b/pthreads/tests/mutex3.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/mutex3e.c b/pthreads/tests/mutex3e.c
index 66cfcb71c..40911fc89 100644
--- a/pthreads/tests/mutex3e.c
+++ b/pthreads/tests/mutex3e.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/mutex3r.c b/pthreads/tests/mutex3r.c
index 8fa7f2547..891692b4d 100644
--- a/pthreads/tests/mutex3r.c
+++ b/pthreads/tests/mutex3r.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/mutex4.c b/pthreads/tests/mutex4.c
index 6d36e0aa1..220c26011 100644
--- a/pthreads/tests/mutex4.c
+++ b/pthreads/tests/mutex4.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/mutex5.c b/pthreads/tests/mutex5.c
index a71f9d893..6d1237936 100644
--- a/pthreads/tests/mutex5.c
+++ b/pthreads/tests/mutex5.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/mutex6.c b/pthreads/tests/mutex6.c
index 15649fc8d..79a896b8b 100644
--- a/pthreads/tests/mutex6.c
+++ b/pthreads/tests/mutex6.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -86,8 +87,5 @@ main()
assert(lockCount == 2);
- exit(0);
-
- /* Never reached */
return 0;
}
diff --git a/pthreads/tests/mutex6e.c b/pthreads/tests/mutex6e.c
index 908a51ba1..d6f695466 100644
--- a/pthreads/tests/mutex6e.c
+++ b/pthreads/tests/mutex6e.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -101,9 +102,6 @@ main()
assert(pthread_mutexattr_destroy(&mxAttr) == 0);
- exit(0);
-
- /* Never reached */
return 0;
}
diff --git a/pthreads/tests/mutex6es.c b/pthreads/tests/mutex6es.c
index d4b624959..6fa2424f0 100644
--- a/pthreads/tests/mutex6es.c
+++ b/pthreads/tests/mutex6es.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -86,9 +87,6 @@ main()
assert(pthread_mutex_destroy(&mutex) == 0);
- exit(0);
-
- /* Never reached */
return 0;
}
diff --git a/pthreads/tests/mutex6n.c b/pthreads/tests/mutex6n.c
index 9cb309c2c..cf3581169 100644
--- a/pthreads/tests/mutex6n.c
+++ b/pthreads/tests/mutex6n.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -91,17 +92,14 @@ main()
assert(lockCount == 1);
- assert(pthread_mutex_unlock(&mutex) == IS_ROBUST?EPERM:0);
+ assert(pthread_mutex_unlock(&mutex) == (IS_ROBUST?EPERM:0));
Sleep (100);
- assert(lockCount == IS_ROBUST?1:2);
+ assert(lockCount == (IS_ROBUST?1:2));
END_MUTEX_STALLED_ROBUST(mxAttr)
- exit(0);
-
- /* Never reached */
return 0;
}
diff --git a/pthreads/tests/mutex6r.c b/pthreads/tests/mutex6r.c
index 9d81ad849..41fc6914b 100644
--- a/pthreads/tests/mutex6r.c
+++ b/pthreads/tests/mutex6r.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -100,8 +101,5 @@ main()
assert(pthread_mutexattr_destroy(&mxAttr) == 0);
- exit(0);
-
- /* Never reached */
return 0;
}
diff --git a/pthreads/tests/mutex6rs.c b/pthreads/tests/mutex6rs.c
index 4242fd627..d17566d7c 100644
--- a/pthreads/tests/mutex6rs.c
+++ b/pthreads/tests/mutex6rs.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -85,8 +86,5 @@ main()
assert(pthread_mutex_destroy(&mutex) == 0);
- exit(0);
-
- /* Never reached */
return 0;
}
diff --git a/pthreads/tests/mutex6s.c b/pthreads/tests/mutex6s.c
index 8b82dc3fa..2b13eba2f 100644
--- a/pthreads/tests/mutex6s.c
+++ b/pthreads/tests/mutex6s.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -86,8 +87,5 @@ main()
assert(lockCount == 2);
- exit(0);
-
- /* Never reached */
return 0;
}
diff --git a/pthreads/tests/mutex7.c b/pthreads/tests/mutex7.c
index 4137c351d..3110ca778 100644
--- a/pthreads/tests/mutex7.c
+++ b/pthreads/tests/mutex7.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -75,8 +76,5 @@ main()
assert(lockCount == 2);
- exit(0);
-
- /* Never reached */
return 0;
}
diff --git a/pthreads/tests/mutex7e.c b/pthreads/tests/mutex7e.c
index 80981b3e1..1fc1a15f4 100644
--- a/pthreads/tests/mutex7e.c
+++ b/pthreads/tests/mutex7e.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -100,9 +101,6 @@ main()
assert(pthread_mutexattr_destroy(&mxAttr) == 0);
- exit(0);
-
- /* Never reached */
return 0;
}
diff --git a/pthreads/tests/mutex7n.c b/pthreads/tests/mutex7n.c
index 87ba10a57..e8d280fb6 100644
--- a/pthreads/tests/mutex7n.c
+++ b/pthreads/tests/mutex7n.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -92,9 +93,6 @@ main()
assert(pthread_mutexattr_destroy(&mxAttr) == 0);
- exit(0);
-
- /* Never reached */
return 0;
}
diff --git a/pthreads/tests/mutex7r.c b/pthreads/tests/mutex7r.c
index 4e4ae8a9a..3e0ae135a 100644
--- a/pthreads/tests/mutex7r.c
+++ b/pthreads/tests/mutex7r.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -100,8 +101,5 @@ main()
assert(pthread_mutexattr_destroy(&mxAttr) == 0);
- exit(0);
-
- /* Never reached */
return 0;
}
diff --git a/pthreads/tests/mutex8.c b/pthreads/tests/mutex8.c
index f2636786c..35ce5629c 100644
--- a/pthreads/tests/mutex8.c
+++ b/pthreads/tests/mutex8.c
@@ -35,7 +35,6 @@
*/
#include "test.h"
-#include <sys/timeb.h>
static int lockCount = 0;
diff --git a/pthreads/tests/mutex8e.c b/pthreads/tests/mutex8e.c
index a36056673..ec2838f7b 100644
--- a/pthreads/tests/mutex8e.c
+++ b/pthreads/tests/mutex8e.c
@@ -42,7 +42,6 @@
*/
#include "test.h"
-#include <sys/timeb.h>
static int lockCount;
diff --git a/pthreads/tests/mutex8n.c b/pthreads/tests/mutex8n.c
index 0c6d97d7f..0fa290ce4 100644
--- a/pthreads/tests/mutex8n.c
+++ b/pthreads/tests/mutex8n.c
@@ -42,7 +42,6 @@
*/
#include "test.h"
-#include <sys/timeb.h>
static int lockCount;
diff --git a/pthreads/tests/mutex8r.c b/pthreads/tests/mutex8r.c
index 434b9af8e..1b9f00f03 100644
--- a/pthreads/tests/mutex8r.c
+++ b/pthreads/tests/mutex8r.c
@@ -42,7 +42,6 @@
*/
#include "test.h"
-#include <sys/timeb.h>
static int lockCount;
diff --git a/pthreads/tests/once1.c b/pthreads/tests/once1.c
index daec112d7..3a7f2e8cd 100644
--- a/pthreads/tests/once1.c
+++ b/pthreads/tests/once1.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/once2.c b/pthreads/tests/once2.c
index 84e3f4bf6..ffd6bfe10 100644
--- a/pthreads/tests/once2.c
+++ b/pthreads/tests/once2.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -54,8 +55,8 @@ typedef struct {
CRITICAL_SECTION cs;
} sharedInt_t;
-static sharedInt_t numOnce = {0, {0}};
-static sharedInt_t numThreads = {0, {0}};
+static sharedInt_t numOnce;
+static sharedInt_t numThreads;
void
myfunc(void)
@@ -83,6 +84,9 @@ main()
pthread_t t[NUM_THREADS][NUM_ONCE];
int i, j;
+ memset(&numOnce, 0, sizeof(sharedInt_t));
+ memset(&numThreads, 0, sizeof(sharedInt_t));
+
InitializeCriticalSection(&numThreads.cs);
InitializeCriticalSection(&numOnce.cs);
@@ -91,7 +95,11 @@ main()
once[j] = o;
for (i = 0; i < NUM_THREADS; i++)
- assert(pthread_create(&t[i][j], NULL, mythread, (void *)(size_t)j) == 0);
+ {
+ /* GCC build: create was failing with EAGAIN after 790 threads */
+ while (0 != pthread_create(&t[i][j], NULL, mythread, (void *)(size_t)j))
+ sched_yield();
+ }
}
for (j = 0; j < NUM_ONCE; j++)
diff --git a/pthreads/tests/once3.c b/pthreads/tests/once3.c
index ef1229043..6c7728607 100644
--- a/pthreads/tests/once3.c
+++ b/pthreads/tests/once3.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -60,8 +61,8 @@ typedef struct {
CRITICAL_SECTION cs;
} sharedInt_t;
-static sharedInt_t numOnce = {0, {0}};
-static sharedInt_t numThreads = {0, {0}};
+static sharedInt_t numOnce;
+static sharedInt_t numThreads;
void
myfunc(void)
@@ -72,7 +73,7 @@ myfunc(void)
LeaveCriticalSection(&numOnce.cs);
/* Simulate slow once routine so that following threads pile up behind it */
Sleep(10);
- /* test for cancelation late so we're sure to have waiters. */
+ /* Test for cancellation late so we're sure to have waiters. */
pthread_testcancel();
}
@@ -81,12 +82,18 @@ mythread(void * arg)
{
/*
* Cancel every thread. These threads are deferred cancelable only, so
- * only the thread performing the once routine (my_func) will see it (there are
- * no other cancelation points here). The result will be that every thread
- * eventually cancels only when it becomes the new 'once' thread.
+ * this thread will see it only when it performs the once routine (my_func).
+ * The result will be that every thread eventually cancels only when it
+ * becomes the new 'once' thread.
*/
assert(pthread_cancel(pthread_self()) == 0);
+ /*
+ * Now we block on the 'once' control.
+ */
assert(pthread_once(&once[(int)(size_t)arg], myfunc) == 0);
+ /*
+ * We should never get to here.
+ */
EnterCriticalSection(&numThreads.cs);
numThreads.i++;
LeaveCriticalSection(&numThreads.cs);
@@ -98,7 +105,16 @@ main()
{
pthread_t t[NUM_THREADS][NUM_ONCE];
int i, j;
+
+#if defined(PTW32_CONFIG_MSVC6) && defined(__CLEANUP_CXX)
+ puts("If this test fails or hangs, rebuild the library with /EHa instead of /EHs.");
+ puts("(This is a known issue with Microsoft VC++6.0.)");
+ fflush(stdout);
+#endif
+ memset(&numOnce, 0, sizeof(sharedInt_t));
+ memset(&numThreads, 0, sizeof(sharedInt_t));
+
InitializeCriticalSection(&numThreads.cs);
InitializeCriticalSection(&numOnce.cs);
@@ -108,7 +124,9 @@ main()
for (i = 0; i < NUM_THREADS; i++)
{
- assert(pthread_create(&t[i][j], NULL, mythread, (void *)(size_t)j) == 0);
+ /* GCC build: create was failing with EAGAIN after 790 threads */
+ while (0 != pthread_create(&t[i][j], NULL, mythread, (void *)(size_t)j))
+ sched_yield();
}
}
diff --git a/pthreads/tests/once4.c b/pthreads/tests/once4.c
index f5be64486..b708aae69 100644
--- a/pthreads/tests/once4.c
+++ b/pthreads/tests/once4.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -58,8 +59,8 @@ typedef struct {
CRITICAL_SECTION cs;
} sharedInt_t;
-static sharedInt_t numOnce = {0, {0}};
-static sharedInt_t numThreads = {0, {0}};
+static sharedInt_t numOnce;
+static sharedInt_t numThreads;
typedef struct {
int threadnum;
@@ -94,7 +95,7 @@ myinitfunc(void)
LeaveCriticalSection(&numOnce.cs);
/* Simulate slow once routine so that following threads pile up behind it */
Sleep(10);
- /* test for cancelation late so we're sure to have waiters. */
+ /* test for cancellation late so we're sure to have waiters. */
pthread_testcancel();
}
@@ -107,7 +108,7 @@ mythread(void * arg)
/*
* Cancel every thread. These threads are deferred cancelable only, so
* only the thread performing the init_routine will see it (there are
- * no other cancelation points here). The result will be that every thread
+ * no other cancellation points here). The result will be that every thread
* eventually cancels only when it becomes the new initter.
*/
pthread_t self = pthread_self();
@@ -139,7 +140,16 @@ main()
{
pthread_t t[NUM_THREADS][NUM_ONCE];
int i, j;
-
+
+#if defined(PTW32_CONFIG_MSVC6) && defined(__CLEANUP_CXX)
+ puts("If this test fails or hangs, rebuild the library with /EHa instead of /EHs.");
+ puts("(This is a known issue with Microsoft VC++6.0.)");
+ fflush(stdout);
+#endif
+
+ memset(&numOnce, 0, sizeof(sharedInt_t));
+ memset(&numThreads, 0, sizeof(sharedInt_t));
+
InitializeCriticalSection(&print_lock);
InitializeCriticalSection(&numThreads.cs);
InitializeCriticalSection(&numOnce.cs);
@@ -166,7 +176,9 @@ main()
bag_t * bag = &threadbag[i][j];
bag->threadnum = i;
bag->oncenum = j;
- assert(pthread_create(&t[i][j], NULL, mythread, (void *) bag) == 0);
+ /* GCC build: create was failing with EAGAIN after 790 threads */
+ while (0 != pthread_create(&t[i][j], NULL, mythread, (void *)bag))
+ sched_yield();
}
}
diff --git a/pthreads/tests/openmp1.c b/pthreads/tests/openmp1.c
index ee36e75c8..b5791e2ea 100644
--- a/pthreads/tests/openmp1.c
+++ b/pthreads/tests/openmp1.c
@@ -28,7 +28,7 @@ void *_thread(void* Id) {
if (Verbose && i%1000==0) {
int tid = omp_get_thread_num();
# pragma omp critical
- printf("thread %d : tid %d handles %d\n",(int)Id,tid,i);
+ printf("thread %d : tid %d handles %d\n",(int)(size_t)Id,tid,i);
}
#endif
@@ -43,9 +43,9 @@ void *_thread(void* Id) {
#ifdef _OPENMP
# pragma omp critical
#endif
- printf("Id %d : %s : %d(should be %d)\n",(int)Id, __FUNCTION__, Sum,ShouldSum);
+ printf("Id %d : %s : %d(should be %d)\n",(int)(size_t)Id, __FUNCTION__, Sum,ShouldSum);
}
- if (Sum == ShouldSum) ThreadOK[(int)Id] = 1;
+ if (Sum == ShouldSum) ThreadOK[(int)(size_t)Id] = 1;
return NULL;
}
@@ -61,7 +61,7 @@ void MainThread() {
int tid = omp_get_thread_num();
# pragma omp critical
printf("Main : tid %d\n",tid);
- _thread((void *)tid);
+ _thread((void *)(size_t)tid);
#endif
}
return;
diff --git a/pthreads/tests/priority1.c b/pthreads/tests/priority1.c
index 40316cc64..d77420f88 100644
--- a/pthreads/tests/priority1.c
+++ b/pthreads/tests/priority1.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/priority2.c b/pthreads/tests/priority2.c
index 7d4648f90..c4552e625 100644
--- a/pthreads/tests/priority2.c
+++ b/pthreads/tests/priority2.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/reuse1.c b/pthreads/tests/reuse1.c
index 1a7dff0e0..bcf8571ca 100644
--- a/pthreads/tests/reuse1.c
+++ b/pthreads/tests/reuse1.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/reuse2.c b/pthreads/tests/reuse2.c
index 362e547d9..93643b90e 100644
--- a/pthreads/tests/reuse2.c
+++ b/pthreads/tests/reuse2.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/robust1.c b/pthreads/tests/robust1.c
index 100a8545b..4bb479ac7 100644
--- a/pthreads/tests/robust1.c
+++ b/pthreads/tests/robust1.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/robust2.c b/pthreads/tests/robust2.c
index 2b3917a6e..795a17ffa 100644
--- a/pthreads/tests/robust2.c
+++ b/pthreads/tests/robust2.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/robust3.c b/pthreads/tests/robust3.c
index cbf99df73..e9d05c7dd 100644
--- a/pthreads/tests/robust3.c
+++ b/pthreads/tests/robust3.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/robust4.c b/pthreads/tests/robust4.c
index 136a183bd..35d5b84f8 100644
--- a/pthreads/tests/robust4.c
+++ b/pthreads/tests/robust4.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/robust5.c b/pthreads/tests/robust5.c
index c67d12482..82e592e9b 100644
--- a/pthreads/tests/robust5.c
+++ b/pthreads/tests/robust5.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/runorder.mk b/pthreads/tests/runorder.mk
new file mode 100755
index 000000000..8eba0e3da
--- /dev/null
+++ b/pthreads/tests/runorder.mk
@@ -0,0 +1,149 @@
+#
+# Common rules that define the run order of tests
+#
+benchtest1.bench:
+benchtest2.bench:
+benchtest3.bench:
+benchtest4.bench:
+benchtest5.bench:
+
+affinity1.pass:
+affinity2.pass: affinity1.pass
+affinity3.pass: affinity2.pass self1.pass create3.pass
+affinity4.pass: affinity3.pass self1.pass create3.pass
+affinity5.pass: affinity4.pass self1.pass create3.pass
+barrier1.pass: semaphore4.pass
+barrier2.pass: barrier1.pass semaphore4.pass
+barrier3.pass: barrier2.pass semaphore4.pass self1.pass create3.pass join4.pass
+barrier4.pass: barrier3.pass semaphore4.pass self1.pass create3.pass join4.pass mutex8.pass
+barrier5.pass: barrier4.pass semaphore4.pass self1.pass create3.pass join4.pass mutex8.pass
+barrier6.pass: barrier5.pass semaphore4.pass self1.pass create3.pass join4.pass mutex8.pass
+cancel1.pass: self1.pass create3.pass
+cancel2.pass: self1.pass create3.pass join4.pass barrier6.pass
+cancel3.pass: self1.pass create3.pass join4.pass context1.pass
+cancel4.pass: cancel3.pass self1.pass create3.pass join4.pass
+cancel5.pass: cancel3.pass self1.pass create3.pass join4.pass
+cancel6a.pass: cancel3.pass self1.pass create3.pass join4.pass
+cancel6d.pass: cancel3.pass self1.pass create3.pass join4.pass
+cancel7.pass: self1.pass create3.pass join4.pass kill1.pass
+cancel8.pass: cancel7.pass self1.pass mutex8.pass kill1.pass
+cancel9.pass: cancel8.pass self1.pass create3.pass join4.pass mutex8.pass kill1.pass
+cleanup0.pass: self1.pass create3.pass join4.pass mutex8.pass cancel5.pass
+cleanup1.pass: cleanup0.pass
+cleanup2.pass: cleanup1.pass
+cleanup3.pass: cleanup2.pass
+condvar1.pass: self1.pass create3.pass semaphore1.pass mutex8.pass
+condvar1_1.pass: condvar1.pass
+condvar1_2.pass: join2.pass
+condvar2.pass: condvar1.pass
+condvar2_1.pass: condvar2.pass join2.pass
+condvar3.pass: create1.pass condvar2.pass
+condvar3_1.pass: condvar3.pass join2.pass
+condvar3_2.pass: condvar3_1.pass
+condvar3_3.pass: condvar3_2.pass
+condvar4.pass: create1.pass
+condvar5.pass: condvar4.pass
+condvar6.pass: condvar5.pass
+condvar7.pass: condvar6.pass cleanup1.pass
+condvar8.pass: condvar7.pass
+condvar9.pass: condvar8.pass
+context1.pass: cancel1.pass
+count1.pass: join1.pass
+create1.pass: mutex2.pass
+create2.pass: create1.pass
+create3.pass: create2.pass
+delay1.pass: self1.pass create3.pass
+delay2.pass: delay1.pass
+detach1.pass: join0.pass
+equal1.pass: self1.pass create1.pass
+errno1.pass: mutex3.pass
+exception1.pass: cancel4.pass
+exception2.pass: exception1.pass
+exception3_0.pass: exception2.pass
+exception3.pass: exception3_0.pass
+exit1.pass: self1.pass create3.pass
+exit2.pass: create1.pass
+exit3.pass: create1.pass
+exit4.pass: self1.pass create3.pass
+exit5.pass: exit4.pass kill1.pass
+eyal1.pass: self1.pass create3.pass mutex8.pass tsd1.pass
+inherit1.pass: join1.pass priority1.pass
+join0.pass: create1.pass
+join1.pass: create1.pass
+join2.pass: create1.pass
+join3.pass: join2.pass
+join4.pass: join3.pass
+kill1.pass: self1.pass
+mutex1.pass: mutex5.pass
+mutex1n.pass: mutex1.pass
+mutex1e.pass: mutex1.pass
+mutex1r.pass: mutex1.pass
+mutex2.pass: mutex1.pass
+mutex2r.pass: mutex2.pass
+mutex2e.pass: mutex2.pass
+mutex3.pass: create1.pass
+mutex3r.pass: mutex3.pass
+mutex3e.pass: mutex3.pass
+mutex4.pass: mutex3.pass
+mutex5.pass: sizes.pass
+mutex6.pass: mutex4.pass
+mutex6n.pass: mutex4.pass
+mutex6e.pass: mutex4.pass
+mutex6r.pass: mutex4.pass
+mutex6s.pass: mutex6.pass
+mutex6rs.pass: mutex6r.pass
+mutex6es.pass: mutex6e.pass
+mutex7.pass: mutex6.pass
+mutex7n.pass: mutex6n.pass
+mutex7e.pass: mutex6e.pass
+mutex7r.pass: mutex6r.pass
+mutex8.pass: mutex7.pass
+mutex8n.pass: mutex7n.pass
+mutex8e.pass: mutex7e.pass
+mutex8r.pass: mutex7r.pass
+once1.pass: create1.pass
+once2.pass: once1.pass
+once3.pass: once2.pass
+once4.pass: once3.pass
+priority1.pass: join1.pass
+priority2.pass: priority1.pass barrier3.pass
+reuse1.pass: create3.pass
+reuse2.pass: reuse1.pass
+robust1.pass: mutex8r.pass
+robust2.pass: mutex8r.pass
+robust3.pass: robust2.pass
+robust4.pass: robust3.pass
+robust5.pass: robust4.pass
+rwlock1.pass: condvar6.pass
+rwlock2.pass: rwlock1.pass
+rwlock3.pass: rwlock2.pass join2.pass
+rwlock4.pass: rwlock3.pass
+rwlock5.pass: rwlock4.pass
+rwlock6.pass: rwlock5.pass
+rwlock7.pass: rwlock6.pass
+rwlock8.pass: rwlock7.pass
+rwlock2_t.pass: rwlock2.pass
+rwlock3_t.pass: rwlock2_t.pass
+rwlock4_t.pass: rwlock3_t.pass
+rwlock5_t.pass: rwlock4_t.pass
+rwlock6_t.pass: rwlock5_t.pass
+rwlock6_t2.pass: rwlock6_t.pass
+self1.pass: sizes.pass
+self2.pass: self1.pass equal1.pass create1.pass
+semaphore1.pass: sizes.pass
+semaphore2.pass: semaphore1.pass
+semaphore3.pass: semaphore2.pass
+semaphore4.pass: semaphore3.pass cancel1.pass
+semaphore4t.pass: semaphore4.pass
+semaphore5.pass: semaphore4.pass
+sequence1.pass: reuse2.pass
+sizes.pass:
+spin1.pass: self1.pass create3.pass mutex8.pass
+spin2.pass: spin1.pass
+spin3.pass: spin2.pass
+spin4.pass: spin3.pass
+stress1.pass: create3.pass mutex8.pass barrier6.pass
+tsd1.pass: barrier5.pass join1.pass
+tsd2.pass: tsd1.pass
+valid1.pass: join1.pass
+valid2.pass: valid1.pass
diff --git a/pthreads/tests/rwlock1.c b/pthreads/tests/rwlock1.c
index 3d08ac993..e76e920ea 100644
--- a/pthreads/tests/rwlock1.c
+++ b/pthreads/tests/rwlock1.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/rwlock2.c b/pthreads/tests/rwlock2.c
index 07518ebde..e9aff3248 100644
--- a/pthreads/tests/rwlock2.c
+++ b/pthreads/tests/rwlock2.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/rwlock2_t.c b/pthreads/tests/rwlock2_t.c
index 4267ddbc8..b4767c7ff 100644
--- a/pthreads/tests/rwlock2_t.c
+++ b/pthreads/tests/rwlock2_t.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/rwlock3.c b/pthreads/tests/rwlock3.c
index d30f04088..08bda6e23 100644
--- a/pthreads/tests/rwlock3.c
+++ b/pthreads/tests/rwlock3.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/rwlock3_t.c b/pthreads/tests/rwlock3_t.c
index 6419de13e..bedcedac2 100644
--- a/pthreads/tests/rwlock3_t.c
+++ b/pthreads/tests/rwlock3_t.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/rwlock4.c b/pthreads/tests/rwlock4.c
index a19a00132..b1ff7e0ef 100644
--- a/pthreads/tests/rwlock4.c
+++ b/pthreads/tests/rwlock4.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/rwlock4_t.c b/pthreads/tests/rwlock4_t.c
index 58b3602fb..770dffbc0 100644
--- a/pthreads/tests/rwlock4_t.c
+++ b/pthreads/tests/rwlock4_t.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/rwlock5.c b/pthreads/tests/rwlock5.c
index 3b4054756..2d6e80ccd 100644
--- a/pthreads/tests/rwlock5.c
+++ b/pthreads/tests/rwlock5.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/rwlock5_t.c b/pthreads/tests/rwlock5_t.c
index 4a94658fb..8bba06b80 100644
--- a/pthreads/tests/rwlock5_t.c
+++ b/pthreads/tests/rwlock5_t.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/rwlock6.c b/pthreads/tests/rwlock6.c
index f667ce5ce..af523b44f 100644
--- a/pthreads/tests/rwlock6.c
+++ b/pthreads/tests/rwlock6.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/rwlock6_t.c b/pthreads/tests/rwlock6_t.c
index 71cbe220a..0616d7213 100644
--- a/pthreads/tests/rwlock6_t.c
+++ b/pthreads/tests/rwlock6_t.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/rwlock6_t2.c b/pthreads/tests/rwlock6_t2.c
index b8b0df9f2..c37b86631 100644
--- a/pthreads/tests/rwlock6_t2.c
+++ b/pthreads/tests/rwlock6_t2.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/self1.c b/pthreads/tests/self1.c
index c0946f725..8893f6e63 100644
--- a/pthreads/tests/self1.c
+++ b/pthreads/tests/self1.c
@@ -1,69 +1,70 @@
-/*
- * self1.c
- *
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- *
- * --------------------------------------------------------------------------
- *
- * Test for pthread_self().
- *
- * Depends on API functions:
- * pthread_self()
- *
- * Implicitly depends on:
- * pthread_getspecific()
- * pthread_setspecific()
- */
-
-#include "test.h"
-
-int
-main(int argc, char * argv[])
-{
- /*
- * This should always succeed unless the system has no
- * resources (memory) left.
- */
- pthread_t self;
-
-#if defined(PTW32_STATIC_LIB) && !(defined(_MSC_VER) || defined(__MINGW32__))
- pthread_win32_process_attach_np();
-#endif
-
- self = pthread_self();
-
- assert(self.p != NULL);
-
-#if defined(PTW32_STATIC_LIB) && !(defined(_MSC_VER) || defined(__MINGW32__))
- pthread_win32_process_detach_np();
-#endif
- return 0;
-}
+/*
+ * self1.c
+ *
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads-win32 - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * http://sources.redhat.com/pthreads-win32/contributors.html
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Test for pthread_self().
+ *
+ * Depends on API functions:
+ * pthread_self()
+ *
+ * Implicitly depends on:
+ * pthread_getspecific()
+ * pthread_setspecific()
+ */
+
+#include "test.h"
+
+int
+main(int argc, char * argv[])
+{
+ /*
+ * This should always succeed unless the system has no
+ * resources (memory) left.
+ */
+ pthread_t self;
+
+#if defined(PTW32_STATIC_LIB) && !(defined(_MSC_VER) || defined(__MINGW32__))
+ pthread_win32_process_attach_np();
+#endif
+
+ self = pthread_self();
+
+ assert(self.p != NULL);
+
+#if defined(PTW32_STATIC_LIB) && !(defined(_MSC_VER) || defined(__MINGW32__))
+ pthread_win32_process_detach_np();
+#endif
+ return 0;
+}
diff --git a/pthreads/tests/self2.c b/pthreads/tests/self2.c
index 28e57252e..3fff003da 100644
--- a/pthreads/tests/self2.c
+++ b/pthreads/tests/self2.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/semaphore1.c b/pthreads/tests/semaphore1.c
index 8fc91ee02..938f0b59e 100644
--- a/pthreads/tests/semaphore1.c
+++ b/pthreads/tests/semaphore1.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -85,7 +86,12 @@ thr(void * arg)
if ( result == -1 )
{
- int err = errno;
+ int err =
+#if defined(PTW32_USES_SEPARATE_CRT)
+ GetLastError();
+#else
+ errno;
+#endif
if (err != EAGAIN)
{
printf("thread: sem_trywait 1: expecting error %s: got %s\n",
@@ -126,7 +132,12 @@ main()
if (result2 == -1)
{
- int err = errno;
+ int err =
+#if defined(PTW32_USES_SEPARATE_CRT)
+ GetLastError();
+#else
+ errno;
+#endif
if (err != EAGAIN)
{
printf("main: sem_trywait 1: expecting error %s: got %s\n",
diff --git a/pthreads/tests/semaphore2.c b/pthreads/tests/semaphore2.c
index af4d0ea70..de56cb310 100644
--- a/pthreads/tests/semaphore2.c
+++ b/pthreads/tests/semaphore2.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/semaphore3.c b/pthreads/tests/semaphore3.c
index a0dfcb6f6..842313066 100644
--- a/pthreads/tests/semaphore3.c
+++ b/pthreads/tests/semaphore3.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -80,41 +81,43 @@ sem_t s;
void *
thr (void * arg)
{
- assert(sem_wait(&s) == 0);
assert(pthread_detach(pthread_self()) == 0);
+ assert(sem_wait(&s) == 0);
return NULL;
}
int
main()
{
- int value = 0;
- int i;
- pthread_t t[MAX_COUNT+1];
+ int value = 0;
+ int i;
+ pthread_t t[MAX_COUNT+1];
- assert(sem_init(&s, PTHREAD_PROCESS_PRIVATE, 0) == 0);
- assert(sem_getvalue(&s, &value) == 0);
-// printf("Value = %d\n", value); fflush(stdout);
- assert(value == 0);
+ assert(sem_init(&s, PTHREAD_PROCESS_PRIVATE, 0) == 0);
+ assert(sem_getvalue(&s, &value) == 0);
+ //printf("Value = %d\n", value); fflush(stdout);
+ assert(value == 0);
- for (i = 1; i <= MAX_COUNT; i++)
- {
- assert(pthread_create(&t[i], NULL, thr, NULL) == 0);
- do {
- sched_yield();
- assert(sem_getvalue(&s, &value) == 0);
- } while (value != -i);
-// printf("Value = %d\n", value); fflush(stdout);
- assert(-value == i);
- }
+ for (i = 1; i <= MAX_COUNT; i++)
+ {
+ assert(pthread_create(&t[i], NULL, thr, NULL) == 0);
+ do
+ {
+ sched_yield();
+ assert(sem_getvalue(&s, &value) == 0);
+ }
+ while (value != -i);
+ //printf("1:Value = %d\n", value); fflush(stdout);
+ assert(-value == i);
+ }
- for (i = MAX_COUNT - 1; i >= 0; i--)
- {
- assert(sem_post(&s) == 0);
- assert(sem_getvalue(&s, &value) == 0);
-// printf("Value = %d\n", value); fflush(stdout);
- assert(-value == i);
- }
+ for (i = MAX_COUNT - 1; i >= 0; i--)
+ {
+ assert(sem_post(&s) == 0);
+ assert(sem_getvalue(&s, &value) == 0);
+ //printf("2:Value = %d\n", value); fflush(stdout);
+ assert(-value == i);
+ }
return 0;
}
diff --git a/pthreads/tests/semaphore4.c b/pthreads/tests/semaphore4.c
index 3a28c7b50..eab1d8908 100644
--- a/pthreads/tests/semaphore4.c
+++ b/pthreads/tests/semaphore4.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/semaphore4t.c b/pthreads/tests/semaphore4t.c
index 97bc7f88a..56044eca4 100644
--- a/pthreads/tests/semaphore4t.c
+++ b/pthreads/tests/semaphore4t.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/semaphore5.c b/pthreads/tests/semaphore5.c
index 812723433..3644b7343 100644
--- a/pthreads/tests/semaphore5.c
+++ b/pthreads/tests/semaphore5.c
@@ -1,103 +1,104 @@
-/*
- * File: semaphore5.c
- *
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- *
- * --------------------------------------------------------------------------
- *
- * Test Synopsis: Verify sem_destroy EBUSY race avoidance
- * -
- *
- * Test Method (Validation or Falsification):
- * - Validation
- *
- * Requirements Tested:
- * -
- *
- * Features Tested:
- * -
- *
- * Cases Tested:
- * -
- *
- * Description:
- * -
- *
- * Environment:
- * -
- *
- * Input:
- * - None.
- *
- * Output:
- * - File name, Line number, and failed expression on failure.
- * - No output on success.
- *
- * Assumptions:
- * -
- *
- * Pass Criteria:
- * - Process returns zero exit status.
- *
- * Fail Criteria:
- * - Process returns non-zero exit status.
- */
-
-// #define ASSERT_TRACE
-
-#include "test.h"
-
-void *
-thr(void * arg)
-{
- assert(sem_post((sem_t *)arg) == 0);
-
- return 0;
-}
-
-
-int
-main()
-{
- pthread_t t;
- sem_t s;
-
- assert(sem_init(&s, PTHREAD_PROCESS_PRIVATE, 0) == 0);
- assert(pthread_create(&t, NULL, thr, (void *)&s) == 0);
-
- assert(sem_wait(&s) == 0);
- assert(sem_destroy(&s) == 0);
-
- assert(pthread_join(t, NULL) == 0);
-
- return 0;
-}
-
+/*
+ * File: semaphore5.c
+ *
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads-win32 - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * http://sources.redhat.com/pthreads-win32/contributors.html
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Test Synopsis: Verify sem_destroy EBUSY race avoidance
+ * -
+ *
+ * Test Method (Validation or Falsification):
+ * - Validation
+ *
+ * Requirements Tested:
+ * -
+ *
+ * Features Tested:
+ * -
+ *
+ * Cases Tested:
+ * -
+ *
+ * Description:
+ * -
+ *
+ * Environment:
+ * -
+ *
+ * Input:
+ * - None.
+ *
+ * Output:
+ * - File name, Line number, and failed expression on failure.
+ * - No output on success.
+ *
+ * Assumptions:
+ * -
+ *
+ * Pass Criteria:
+ * - Process returns zero exit status.
+ *
+ * Fail Criteria:
+ * - Process returns non-zero exit status.
+ */
+
+// #define ASSERT_TRACE
+
+#include "test.h"
+
+void *
+thr(void * arg)
+{
+ assert(sem_post((sem_t *)arg) == 0);
+
+ return 0;
+}
+
+
+int
+main()
+{
+ pthread_t t;
+ sem_t s;
+
+ assert(sem_init(&s, PTHREAD_PROCESS_PRIVATE, 0) == 0);
+ assert(pthread_create(&t, NULL, thr, (void *)&s) == 0);
+
+ assert(sem_wait(&s) == 0);
+ assert(sem_destroy(&s) == 0);
+
+ assert(pthread_join(t, NULL) == 0);
+
+ return 0;
+}
+
diff --git a/pthreads/tests/sequence1.c b/pthreads/tests/sequence1.c
index 46388eebd..51c3da7cb 100644
--- a/pthreads/tests/sequence1.c
+++ b/pthreads/tests/sequence1.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/spin1.c b/pthreads/tests/spin1.c
index 00ecd11b1..82af2ca70 100644
--- a/pthreads/tests/spin1.c
+++ b/pthreads/tests/spin1.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/spin2.c b/pthreads/tests/spin2.c
index b13c29c4e..267cd5c3a 100644
--- a/pthreads/tests/spin2.c
+++ b/pthreads/tests/spin2.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/spin3.c b/pthreads/tests/spin3.c
index bbf8bfb22..e5a89cf57 100644
--- a/pthreads/tests/spin3.c
+++ b/pthreads/tests/spin3.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/spin4.c b/pthreads/tests/spin4.c
index 3a4fd6f24..917104794 100644
--- a/pthreads/tests/spin4.c
+++ b/pthreads/tests/spin4.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/stress1.c b/pthreads/tests/stress1.c
index 7c787dcfb..3b55a660f 100644
--- a/pthreads/tests/stress1.c
+++ b/pthreads/tests/stress1.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/test.h b/pthreads/tests/test.h
index 042e87b68..4b3cf591c 100644
--- a/pthreads/tests/test.h
+++ b/pthreads/tests/test.h
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -44,6 +45,7 @@
#include <windows.h>
#include <stdio.h>
+#include <sys/timeb.h>
#define PTW32_THREAD_NULL_ID {NULL,0}
@@ -53,19 +55,19 @@
#define rand_r( _seed ) \
( _seed == _seed? rand() : rand() )
-#if defined(__MINGW32__)
-#include <stdint.h>
+#if defined(PTW32_CONFIG_MINGW)
+# include <stdint.h>
#elif defined(__BORLANDC__)
-#define int64_t ULONGLONG
+# define int64_t ULONGLONG
#else
-#define int64_t _int64
+# define int64_t _int64
#endif
#if defined(_MSC_VER) && _MSC_VER >= 1400
# define PTW32_FTIME(x) _ftime64_s(x)
# define PTW32_STRUCT_TIMEB struct __timeb64
#elif ( defined(_MSC_VER) && _MSC_VER >= 1300 ) || \
- ( defined(__MINGW32__) && __MSVCRT_VERSION__ >= 0x0601 )
+ ( defined(PTW32_CONFIG_MINGW) && __MSVCRT_VERSION__ >= 0x0601 )
# define PTW32_FTIME(x) _ftime64(x)
# define PTW32_STRUCT_TIMEB struct __timeb64
#else
diff --git a/pthreads/tests/tryentercs.c b/pthreads/tests/tryentercs.c
index 13a6e096d..f94e914eb 100644
--- a/pthreads/tests/tryentercs.c
+++ b/pthreads/tests/tryentercs.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/tryentercs2.c b/pthreads/tests/tryentercs2.c
index a1c4d97f3..2df8cd827 100644
--- a/pthreads/tests/tryentercs2.c
+++ b/pthreads/tests/tryentercs2.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/tsd1.c b/pthreads/tests/tsd1.c
index 84d78886c..55c8aed80 100644
--- a/pthreads/tests/tsd1.c
+++ b/pthreads/tests/tsd1.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/tsd2.c b/pthreads/tests/tsd2.c
index 16e69948c..9f73c08c0 100644
--- a/pthreads/tests/tsd2.c
+++ b/pthreads/tests/tsd2.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/valid1.c b/pthreads/tests/valid1.c
index a3913fd04..132667952 100644
--- a/pthreads/tests/valid1.c
+++ b/pthreads/tests/valid1.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/tests/valid2.c b/pthreads/tests/valid2.c
index b9671798b..5b04fa6b5 100644
--- a/pthreads/tests/valid2.c
+++ b/pthreads/tests/valid2.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
diff --git a/pthreads/version.rc b/pthreads/version.rc
index 02d779c2e..93ed3b75d 100644
--- a/pthreads/version.rc
+++ b/pthreads/version.rc
@@ -1,388 +1,404 @@
-/* This is an implementation of the threads API of POSIX 1003.1-2001.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include <winver.h>
-#include "pthread.h"
-
-/*
- * Note: the correct __CLEANUP_* macro must be defined corresponding to
- * the definition used for the object file builds. This is done in the
- * relevent makefiles for the command line builds, but users should ensure
- * that their resource compiler knows what it is too.
- * If using the default (no __CLEANUP_* defined), pthread.h will define it
- * as __CLEANUP_C.
- */
-#if defined(_WIN64)
-# define PTW32_ARCH "64 bit"
-#else
-# define PTW32_ARCH "32 bit"
-#endif
-
-#if defined(PTW32_RC_MSC)
-# if defined(__CLEANUP_C)
-# define PTW32_VERSIONINFO_NAME "pthreadVC\0"
-# define PTW32_VERSIONINFO_DESCRIPTION "MS C " PTW32_ARCH "\0"
-# elif defined(__CLEANUP_CXX)
-# define PTW32_VERSIONINFO_NAME "pthreadVCE\0"
-# define PTW32_VERSIONINFO_DESCRIPTION "MS C++ " PTW32_ARCH "\0"
-# elif defined(__CLEANUP_SEH)
-# define PTW32_VERSIONINFO_NAME "pthreadVSE\0"
-# define PTW32_VERSIONINFO_DESCRIPTION "MS C SEH " PTW32_ARCH "\0"
-# else
-# error Resource compiler doesn't know which cleanup style you're using - see version.rc
-# endif
-#elif defined(__GNUC__)
-# if defined(__CLEANUP_C)
-# define PTW32_VERSIONINFO_NAME "pthreadGC\0"
-# define PTW32_VERSIONINFO_DESCRIPTION "GNU C " PTW32_ARCH "\0"
-# elif defined(__CLEANUP_CXX)
-# define PTW32_VERSIONINFO_NAME "pthreadGCE\0"
-# define PTW32_VERSIONINFO_DESCRIPTION "GNU C++ " PTW32_ARCH "\0"
-# else
-# error Resource compiler doesn't know which cleanup style you're using - see version.rc
-# endif
-#elif defined(__BORLANDC__)
-# if defined(__CLEANUP_C)
-# define PTW32_VERSIONINFO_NAME "pthreadBC\0"
-# define PTW32_VERSIONINFO_DESCRIPTION "BORLAND C " PTW32_ARCH "\0"
-# elif defined(__CLEANUP_CXX)
-# define PTW32_VERSIONINFO_NAME "pthreadBCE\0"
-# define PTW32_VERSIONINFO_DESCRIPTION "BORLAND C++ " PTW32_ARCH "\0"
-# else
-# error Resource compiler doesn't know which cleanup style you're using - see version.rc
-# endif
-#elif defined(__WATCOMC__)
-# if defined(__CLEANUP_C)
-# define PTW32_VERSIONINFO_NAME "pthreadWC\0"
-# define PTW32_VERSIONINFO_DESCRIPTION "WATCOM C " PTW32_ARCH "\0"
-# elif defined(__CLEANUP_CXX)
-# define PTW32_VERSIONINFO_NAME "pthreadWCE\0"
-# define PTW32_VERSIONINFO_DESCRIPTION "WATCOM C++ " PTW32_ARCH "\0"
-# else
-# error Resource compiler doesn't know which cleanup style you're using - see version.rc
-# endif
-#else
-# error Resource compiler doesn't know which compiler you're using - see version.rc
-#endif
-
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION PTW32_VERSION
- PRODUCTVERSION PTW32_VERSION
- FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
- FILEFLAGS 0
- FILEOS VOS__WINDOWS32
- FILETYPE VFT_DLL
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "040904b0"
- BEGIN
- VALUE "ProductName", "POSIX Threads for Windows LPGL\0"
- VALUE "ProductVersion", PTW32_VERSION_STRING
- VALUE "FileVersion", PTW32_VERSION_STRING
- VALUE "FileDescription", PTW32_VERSIONINFO_DESCRIPTION
- VALUE "InternalName", PTW32_VERSIONINFO_NAME
- VALUE "OriginalFilename", PTW32_VERSIONINFO_NAME
- VALUE "CompanyName", "Open Source Software community LGPL\0"
- VALUE "LegalCopyright", "Copyright (C) Project contributors 2011\0"
- VALUE "Comments", "http://sourceware.org/pthreads-win32/\0"
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x409, 1200
- END
-END
-
-/*
-VERSIONINFO Resource
-
-The VERSIONINFO resource-definition statement creates a version-information
-resource. The resource contains such information about the file as its
-version number, its intended operating system, and its original filename.
-The resource is intended to be used with the Version Information functions.
-
-versionID VERSIONINFO fixed-info { block-statement...}
-
-versionID
- Version-information resource identifier. This value must be 1.
-
-fixed-info
- Version information, such as the file version and the intended operating
- system. This parameter consists of the following statements.
-
-
- Statement Description
- --------------------------------------------------------------------------
- FILEVERSION
- version Binary version number for the file. The version
- consists of two 32-bit integers, defined by four
- 16-bit integers. For example, "FILEVERSION 3,10,0,61"
- is translated into two doublewords: 0x0003000a and
- 0x0000003d, in that order. Therefore, if version is
- defined by the DWORD values dw1 and dw2, they need
- to appear in the FILEVERSION statement as follows:
- HIWORD(dw1), LOWORD(dw1), HIWORD(dw2), LOWORD(dw2).
- PRODUCTVERSION
- version Binary version number for the product with which the
- file is distributed. The version parameter is two
- 32-bit integers, defined by four 16-bit integers.
- For more information about version, see the
- FILEVERSION description.
- FILEFLAGSMASK
- fileflagsmask Bits in the FILEFLAGS statement are valid. If a bit
- is set, the corresponding bit in FILEFLAGS is valid.
- FILEFLAGSfileflags Attributes of the file. The fileflags parameter must
- be the combination of all the file flags that are
- valid at compile time. For 16-bit Windows, this
- value is 0x3f.
- FILEOSfileos Operating system for which this file was designed.
- The fileos parameter can be one of the operating
- system values given in the Remarks section.
- FILETYPEfiletype General type of file. The filetype parameter can be
- one of the file type values listed in the Remarks
- section.
- FILESUBTYPE
- subtype Function of the file. The subtype parameter is zero
- unless the type parameter in the FILETYPE statement
- is VFT_DRV, VFT_FONT, or VFT_VXD. For a list of file
- subtype values, see the Remarks section.
-
-block-statement
- Specifies one or more version-information blocks. A block can contain
- string information or variable information. For more information, see
- StringFileInfo Block or VarFileInfo Block.
-
-Remarks
-
-To use the constants specified with the VERSIONINFO statement, you must
-include the Winver.h or Windows.h header file in the resource-definition file.
-
-The following list describes the parameters used in the VERSIONINFO statement:
-
-fileflags
- A combination of the following values.
-
- Value Description
-
- VS_FF_DEBUG File contains debugging information or is compiled
- with debugging features enabled.
- VS_FF_PATCHED File has been modified and is not identical to the
- original shipping file of the same version number.
- VS_FF_PRERELEASE File is a development version, not a commercially
- released product.
- VS_FF_PRIVATEBUILD File was not built using standard release procedures.
- If this value is given, the StringFileInfo block must
- contain a PrivateBuild string.
- VS_FF_SPECIALBUILD File was built by the original company using standard
- release procedures but is a variation of the standard
- file of the same version number. If this value is
- given, the StringFileInfo block must contain a
- SpecialBuild string.
-
-fileos
- One of the following values.
-
- Value Description
-
- VOS_UNKNOWN The operating system for which the file was designed
- is unknown.
- VOS_DOS File was designed for MS-DOS.
- VOS_NT File was designed for Windows Server 2003 family,
- Windows XP, Windows 2000, or Windows NT.
- VOS__WINDOWS16 File was designed for 16-bit Windows.
- VOS__WINDOWS32 File was designed for 32-bit Windows.
- VOS_DOS_WINDOWS16 File was designed for 16-bit Windows running with
- MS-DOS.
- VOS_DOS_WINDOWS32 File was designed for 32-bit Windows running with
- MS-DOS.
- VOS_NT_WINDOWS32 File was designed for Windows Server 2003 family,
- Windows XP, Windows 2000, or Windows NT.
-
- The values 0x00002L, 0x00003L, 0x20000L and 0x30000L are reserved.
-
-filetype
- One of the following values.
-
- Value Description
-
- VFT_UNKNOWN File type is unknown.
- VFT_APP File contains an application.
- VFT_DLL File contains a dynamic-link library (DLL).
- VFT_DRV File contains a device driver. If filetype is
- VFT_DRV, subtype contains a more specific
- description of the driver.
- VFT_FONT File contains a font. If filetype is VFT_FONT,
- subtype contains a more specific description of the
- font.
- VFT_VXD File contains a virtual device.
- VFT_STATIC_LIB File contains a static-link library.
-
- All other values are reserved for use by Microsoft.
-
-subtype
- Additional information about the file type.
-
- If filetype specifies VFT_DRV, this parameter can be one of the
- following values.
-
- Value Description
-
- VFT2_UNKNOWN Driver type is unknown.
- VFT2_DRV_COMM File contains a communications driver.
- VFT2_DRV_PRINTER File contains a printer driver.
- VFT2_DRV_KEYBOARD File contains a keyboard driver.
- VFT2_DRV_LANGUAGE File contains a language driver.
- VFT2_DRV_DISPLAY File contains a display driver.
- VFT2_DRV_MOUSE File contains a mouse driver.
- VFT2_DRV_NETWORK File contains a network driver.
- VFT2_DRV_SYSTEM File contains a system driver.
- VFT2_DRV_INSTALLABLE File contains an installable driver.
- VFT2_DRV_SOUND File contains a sound driver.
- VFT2_DRV_VERSIONED_PRINTER File contains a versioned printer driver.
-
- If filetype specifies VFT_FONT, this parameter can be one of the
- following values.
-
- Value Description
-
- VFT2_UNKNOWN Font type is unknown.
- VFT2_FONT_RASTER File contains a raster font.
- VFT2_FONT_VECTOR File contains a vector font.
- VFT2_FONT_TRUETYPE File contains a TrueType font.
-
- If filetype specifies VFT_VXD, this parameter must be the virtual-device
- identifier included in the virtual-device control block.
-
- All subtype values not listed here are reserved for use by Microsoft.
-
-langID
- One of the following language codes.
-
- Code Language Code Language
-
- 0x0401 Arabic 0x0415 Polish
- 0x0402 Bulgarian 0x0416 Portuguese (Brazil)
- 0x0403 Catalan 0x0417 Rhaeto-Romanic
- 0x0404 Traditional Chinese 0x0418 Romanian
- 0x0405 Czech 0x0419 Russian
- 0x0406 Danish 0x041A Croato-Serbian (Latin)
- 0x0407 German 0x041B Slovak
- 0x0408 Greek 0x041C Albanian
- 0x0409 U.S. English 0x041D Swedish
- 0x040A Castilian Spanish 0x041E Thai
- 0x040B Finnish 0x041F Turkish
- 0x040C French 0x0420 Urdu
- 0x040D Hebrew 0x0421 Bahasa
- 0x040E Hungarian 0x0804 Simplified Chinese
- 0x040F Icelandic 0x0807 Swiss German
- 0x0410 Italian 0x0809 U.K. English
- 0x0411 Japanese 0x080A Mexican Spanish
- 0x0412 Korean 0x080C Belgian French
- 0x0413 Dutch 0x0C0C Canadian French
- 0x0414 Norwegian ā€“ Bokmal 0x100C Swiss French
- 0x0810 Swiss Italian 0x0816 Portuguese (Portugal)
- 0x0813 Belgian Dutch 0x081A Serbo-Croatian (Cyrillic)
- 0x0814 Norwegian ā€“ Nynorsk
-
-charsetID
- One of the following character-set identifiers.
-
- Identifier Character Set
-
- 0 7-bit ASCII
- 932 Japan (Shift %Gā€“%@ JIS X-0208)
- 949 Korea (Shift %Gā€“%@ KSC 5601)
- 950 Taiwan (Big5)
- 1200 Unicode
- 1250 Latin-2 (Eastern European)
- 1251 Cyrillic
- 1252 Multilingual
- 1253 Greek
- 1254 Turkish
- 1255 Hebrew
- 1256 Arabic
-
-string-name
- One of the following predefined names.
-
- Name Description
-
- Comments Additional information that should be displayed for
- diagnostic purposes.
- CompanyName Company that produced the file%Gā€”%@for example,
- "Microsoft Corporation" or "Standard Microsystems
- Corporation, Inc." This string is required.
- FileDescription File description to be presented to users. This
- string may be displayed in a list box when the user
- is choosing files to install%Gā€”%@for example,
- "Keyboard Driver for AT-Style Keyboards". This
- string is required.
- FileVersion Version number of the file%Gā€”%@for example,
- "3.10" or "5.00.RC2". This string is required.
- InternalName Internal name of the file, if one exists ā€” for
- example, a module name if the file is a dynamic-link
- library. If the file has no internal name, this
- string should be the original filename, without
- extension. This string is required.
- LegalCopyright Copyright notices that apply to the file. This
- should include the full text of all notices, legal
- symbols, copyright dates, and so on ā€” for example,
- "Copyright (C) Microsoft Corporation 1990ā€“1999".
- This string is optional.
- LegalTrademarks Trademarks and registered trademarks that apply to
- the file. This should include the full text of all
- notices, legal symbols, trademark numbers, and so on.
- This string is optional.
- OriginalFilename Original name of the file, not including a path.
- This information enables an application to determine
- whether a file has been renamed by a user. The
- format of the name depends on the file system for
- which the file was created. This string is required.
- PrivateBuild Information about a private version of the file ā€” for
- example, "Built by TESTER1 on \TESTBED". This string
- should be present only if VS_FF_PRIVATEBUILD is
- specified in the fileflags parameter of the root
- block.
- ProductName Name of the product with which the file is
- distributed. This string is required.
- ProductVersion Version of the product with which the file is
- distributed ā€” for example, "3.10" or "5.00.RC2".
- This string is required.
- SpecialBuild Text that indicates how this version of the file
- differs from the standard version ā€” for example,
- "Private build for TESTER1 solving mouse problems
- on M250 and M250E computers". This string should be
- present only if VS_FF_SPECIALBUILD is specified in
- the fileflags parameter of the root block.
- */
+/* This is an implementation of the threads API of POSIX 1003.1-2001.
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads-win32 - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * http://sources.redhat.com/pthreads-win32/contributors.html
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include <winver.h>
+#include "pthread.h"
+
+/*
+ * Note: the correct __CLEANUP_* macro must be defined corresponding to
+ * the definition used for the object file builds. This is done in the
+ * relevent makefiles for the command line builds, but users should ensure
+ * that their resource compiler knows what it is too.
+ * If using the default (no __CLEANUP_* defined), pthread.h will define it
+ * as __CLEANUP_C.
+ */
+
+#if defined(PTW32_RC_MSC)
+# if defined(PTW32_ARCHx64)
+# define PTW32_ARCH "x64"
+# elif defined(PTW32_ARCHx86)
+# define PTW32_ARCH "x86"
+# endif
+# if defined(__CLEANUP_C)
+# define PTW32_VERSIONINFO_NAME "pthreadVC2.DLL\0"
+# define PTW32_VERSIONINFO_DESCRIPTION "MS C " PTW32_ARCH "\0"
+# elif defined(__CLEANUP_CXX)
+# define PTW32_VERSIONINFO_NAME "pthreadVCE2.DLL\0"
+# define PTW32_VERSIONINFO_DESCRIPTION "MS C++ " PTW32_ARCH "\0"
+# elif defined(__CLEANUP_SEH)
+# define PTW32_VERSIONINFO_NAME "pthreadVSE2.DLL\0"
+# define PTW32_VERSIONINFO_DESCRIPTION "MS C SEH " PTW32_ARCH "\0"
+# else
+# error Resource compiler doesn't know which cleanup style you're using - see version.rc
+# endif
+#elif defined(__GNUC__)
+# if defined(_M_X64)
+# define PTW32_ARCH "x64 (mingw64)"
+# else
+# define PTW32_ARCH "x86 (mingw32)"
+# endif
+# if defined(__CLEANUP_C)
+# define PTW32_VERSIONINFO_NAME "pthreadGC2.DLL\0"
+# define PTW32_VERSIONINFO_DESCRIPTION "GNU C " PTW32_ARCH "\0"
+# elif defined(__CLEANUP_CXX)
+# define PTW32_VERSIONINFO_NAME "pthreadGCE2.DLL\0"
+# define PTW32_VERSIONINFO_DESCRIPTION "GNU C++ " PTW32_ARCH "\0"
+# else
+# error Resource compiler doesn't know which cleanup style you're using - see version.rc
+# endif
+#elif defined(__BORLANDC__)
+# if defined(_M_X64)
+# define PTW32_ARCH "x64 (Borland)"
+# else
+# define PTW32_ARCH "x86 (Borland)"
+# endif
+# if defined(__CLEANUP_C)
+# define PTW32_VERSIONINFO_NAME "pthreadBC2.DLL\0"
+# define PTW32_VERSIONINFO_DESCRIPTION "BORLAND C " PTW32_ARCH "\0"
+# elif defined(__CLEANUP_CXX)
+# define PTW32_VERSIONINFO_NAME "pthreadBCE2.DLL\0"
+# define PTW32_VERSIONINFO_DESCRIPTION "BORLAND C++ " PTW32_ARCH "\0"
+# else
+# error Resource compiler doesn't know which cleanup style you're using - see version.rc
+# endif
+#elif defined(__WATCOMC__)
+# if defined(_M_X64)
+# define PTW32_ARCH "x64 (Watcom)"
+# else
+# define PTW32_ARCH "x86 (Watcom)"
+# endif
+# if defined(__CLEANUP_C)
+# define PTW32_VERSIONINFO_NAME "pthreadWC2.DLL\0"
+# define PTW32_VERSIONINFO_DESCRIPTION "WATCOM C " PTW32_ARCH "\0"
+# elif defined(__CLEANUP_CXX)
+# define PTW32_VERSIONINFO_NAME "pthreadWCE2.DLL\0"
+# define PTW32_VERSIONINFO_DESCRIPTION "WATCOM C++ " PTW32_ARCH "\0"
+# else
+# error Resource compiler doesn't know which cleanup style you're using - see version.rc
+# endif
+#else
+# error Resource compiler doesn't know which compiler you're using - see version.rc
+#endif
+
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION PTW32_VERSION
+ PRODUCTVERSION PTW32_VERSION
+ FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
+ FILEFLAGS 0
+ FILEOS VOS__WINDOWS32
+ FILETYPE VFT_DLL
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "ProductName", "POSIX Threads for Windows LPGL\0"
+ VALUE "ProductVersion", PTW32_VERSION_STRING
+ VALUE "FileVersion", PTW32_VERSION_STRING
+ VALUE "FileDescription", PTW32_VERSIONINFO_DESCRIPTION
+ VALUE "InternalName", PTW32_VERSIONINFO_NAME
+ VALUE "OriginalFilename", PTW32_VERSIONINFO_NAME
+ VALUE "CompanyName", "Open Source Software community LGPL\0"
+ VALUE "LegalCopyright", "Copyright (C) Project contributors 2012\0"
+ VALUE "Comments", "http://sourceware.org/pthreads-win32/\0"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END
+
+/*
+VERSIONINFO Resource
+
+The VERSIONINFO resource-definition statement creates a version-information
+resource. The resource contains such information about the file as its
+version number, its intended operating system, and its original filename.
+The resource is intended to be used with the Version Information functions.
+
+versionID VERSIONINFO fixed-info { block-statement...}
+
+versionID
+ Version-information resource identifier. This value must be 1.
+
+fixed-info
+ Version information, such as the file version and the intended operating
+ system. This parameter consists of the following statements.
+
+
+ Statement Description
+ --------------------------------------------------------------------------
+ FILEVERSION
+ version Binary version number for the file. The version
+ consists of two 32-bit integers, defined by four
+ 16-bit integers. For example, "FILEVERSION 3,10,0,61"
+ is translated into two doublewords: 0x0003000a and
+ 0x0000003d, in that order. Therefore, if version is
+ defined by the DWORD values dw1 and dw2, they need
+ to appear in the FILEVERSION statement as follows:
+ HIWORD(dw1), LOWORD(dw1), HIWORD(dw2), LOWORD(dw2).
+ PRODUCTVERSION
+ version Binary version number for the product with which the
+ file is distributed. The version parameter is two
+ 32-bit integers, defined by four 16-bit integers.
+ For more information about version, see the
+ FILEVERSION description.
+ FILEFLAGSMASK
+ fileflagsmask Bits in the FILEFLAGS statement are valid. If a bit
+ is set, the corresponding bit in FILEFLAGS is valid.
+ FILEFLAGSfileflags Attributes of the file. The fileflags parameter must
+ be the combination of all the file flags that are
+ valid at compile time. For 16-bit Windows, this
+ value is 0x3f.
+ FILEOSfileos Operating system for which this file was designed.
+ The fileos parameter can be one of the operating
+ system values given in the Remarks section.
+ FILETYPEfiletype General type of file. The filetype parameter can be
+ one of the file type values listed in the Remarks
+ section.
+ FILESUBTYPE
+ subtype Function of the file. The subtype parameter is zero
+ unless the type parameter in the FILETYPE statement
+ is VFT_DRV, VFT_FONT, or VFT_VXD. For a list of file
+ subtype values, see the Remarks section.
+
+block-statement
+ Specifies one or more version-information blocks. A block can contain
+ string information or variable information. For more information, see
+ StringFileInfo Block or VarFileInfo Block.
+
+Remarks
+
+To use the constants specified with the VERSIONINFO statement, you must
+include the Winver.h or Windows.h header file in the resource-definition file.
+
+The following list describes the parameters used in the VERSIONINFO statement:
+
+fileflags
+ A combination of the following values.
+
+ Value Description
+
+ VS_FF_DEBUG File contains debugging information or is compiled
+ with debugging features enabled.
+ VS_FF_PATCHED File has been modified and is not identical to the
+ original shipping file of the same version number.
+ VS_FF_PRERELEASE File is a development version, not a commercially
+ released product.
+ VS_FF_PRIVATEBUILD File was not built using standard release procedures.
+ If this value is given, the StringFileInfo block must
+ contain a PrivateBuild string.
+ VS_FF_SPECIALBUILD File was built by the original company using standard
+ release procedures but is a variation of the standard
+ file of the same version number. If this value is
+ given, the StringFileInfo block must contain a
+ SpecialBuild string.
+
+fileos
+ One of the following values.
+
+ Value Description
+
+ VOS_UNKNOWN The operating system for which the file was designed
+ is unknown.
+ VOS_DOS File was designed for MS-DOS.
+ VOS_NT File was designed for Windows Server 2003 family,
+ Windows XP, Windows 2000, or Windows NT.
+ VOS__WINDOWS16 File was designed for 16-bit Windows.
+ VOS__WINDOWS32 File was designed for 32-bit Windows.
+ VOS_DOS_WINDOWS16 File was designed for 16-bit Windows running with
+ MS-DOS.
+ VOS_DOS_WINDOWS32 File was designed for 32-bit Windows running with
+ MS-DOS.
+ VOS_NT_WINDOWS32 File was designed for Windows Server 2003 family,
+ Windows XP, Windows 2000, or Windows NT.
+
+ The values 0x00002L, 0x00003L, 0x20000L and 0x30000L are reserved.
+
+filetype
+ One of the following values.
+
+ Value Description
+
+ VFT_UNKNOWN File type is unknown.
+ VFT_APP File contains an application.
+ VFT_DLL File contains a dynamic-link library (DLL).
+ VFT_DRV File contains a device driver. If filetype is
+ VFT_DRV, subtype contains a more specific
+ description of the driver.
+ VFT_FONT File contains a font. If filetype is VFT_FONT,
+ subtype contains a more specific description of the
+ font.
+ VFT_VXD File contains a virtual device.
+ VFT_STATIC_LIB File contains a static-link library.
+
+ All other values are reserved for use by Microsoft.
+
+subtype
+ Additional information about the file type.
+
+ If filetype specifies VFT_DRV, this parameter can be one of the
+ following values.
+
+ Value Description
+
+ VFT2_UNKNOWN Driver type is unknown.
+ VFT2_DRV_COMM File contains a communications driver.
+ VFT2_DRV_PRINTER File contains a printer driver.
+ VFT2_DRV_KEYBOARD File contains a keyboard driver.
+ VFT2_DRV_LANGUAGE File contains a language driver.
+ VFT2_DRV_DISPLAY File contains a display driver.
+ VFT2_DRV_MOUSE File contains a mouse driver.
+ VFT2_DRV_NETWORK File contains a network driver.
+ VFT2_DRV_SYSTEM File contains a system driver.
+ VFT2_DRV_INSTALLABLE File contains an installable driver.
+ VFT2_DRV_SOUND File contains a sound driver.
+ VFT2_DRV_VERSIONED_PRINTER File contains a versioned printer driver.
+
+ If filetype specifies VFT_FONT, this parameter can be one of the
+ following values.
+
+ Value Description
+
+ VFT2_UNKNOWN Font type is unknown.
+ VFT2_FONT_RASTER File contains a raster font.
+ VFT2_FONT_VECTOR File contains a vector font.
+ VFT2_FONT_TRUETYPE File contains a TrueType font.
+
+ If filetype specifies VFT_VXD, this parameter must be the virtual-device
+ identifier included in the virtual-device control block.
+
+ All subtype values not listed here are reserved for use by Microsoft.
+
+langID
+ One of the following language codes.
+
+ Code Language Code Language
+
+ 0x0401 Arabic 0x0415 Polish
+ 0x0402 Bulgarian 0x0416 Portuguese (Brazil)
+ 0x0403 Catalan 0x0417 Rhaeto-Romanic
+ 0x0404 Traditional Chinese 0x0418 Romanian
+ 0x0405 Czech 0x0419 Russian
+ 0x0406 Danish 0x041A Croato-Serbian (Latin)
+ 0x0407 German 0x041B Slovak
+ 0x0408 Greek 0x041C Albanian
+ 0x0409 U.S. English 0x041D Swedish
+ 0x040A Castilian Spanish 0x041E Thai
+ 0x040B Finnish 0x041F Turkish
+ 0x040C French 0x0420 Urdu
+ 0x040D Hebrew 0x0421 Bahasa
+ 0x040E Hungarian 0x0804 Simplified Chinese
+ 0x040F Icelandic 0x0807 Swiss German
+ 0x0410 Italian 0x0809 U.K. English
+ 0x0411 Japanese 0x080A Mexican Spanish
+ 0x0412 Korean 0x080C Belgian French
+ 0x0413 Dutch 0x0C0C Canadian French
+ 0x0414 Norwegian ā€“ Bokmal 0x100C Swiss French
+ 0x0810 Swiss Italian 0x0816 Portuguese (Portugal)
+ 0x0813 Belgian Dutch 0x081A Serbo-Croatian (Cyrillic)
+ 0x0814 Norwegian ā€“ Nynorsk
+
+charsetID
+ One of the following character-set identifiers.
+
+ Identifier Character Set
+
+ 0 7-bit ASCII
+ 932 Japan (Shift %Gā€“%@ JIS X-0208)
+ 949 Korea (Shift %Gā€“%@ KSC 5601)
+ 950 Taiwan (Big5)
+ 1200 Unicode
+ 1250 Latin-2 (Eastern European)
+ 1251 Cyrillic
+ 1252 Multilingual
+ 1253 Greek
+ 1254 Turkish
+ 1255 Hebrew
+ 1256 Arabic
+
+string-name
+ One of the following predefined names.
+
+ Name Description
+
+ Comments Additional information that should be displayed for
+ diagnostic purposes.
+ CompanyName Company that produced the file%Gā€”%@for example,
+ "Microsoft Corporation" or "Standard Microsystems
+ Corporation, Inc." This string is required.
+ FileDescription File description to be presented to users. This
+ string may be displayed in a list box when the user
+ is choosing files to install%Gā€”%@for example,
+ "Keyboard Driver for AT-Style Keyboards". This
+ string is required.
+ FileVersion Version number of the file%Gā€”%@for example,
+ "3.10" or "5.00.RC2". This string is required.
+ InternalName Internal name of the file, if one exists ā€” for
+ example, a module name if the file is a dynamic-link
+ library. If the file has no internal name, this
+ string should be the original filename, without
+ extension. This string is required.
+ LegalCopyright Copyright notices that apply to the file. This
+ should include the full text of all notices, legal
+ symbols, copyright dates, and so on ā€” for example,
+ "Copyright (C) Microsoft Corporation 1990ā€“1999".
+ This string is optional.
+ LegalTrademarks Trademarks and registered trademarks that apply to
+ the file. This should include the full text of all
+ notices, legal symbols, trademark numbers, and so on.
+ This string is optional.
+ OriginalFilename Original name of the file, not including a path.
+ This information enables an application to determine
+ whether a file has been renamed by a user. The
+ format of the name depends on the file system for
+ which the file was created. This string is required.
+ PrivateBuild Information about a private version of the file ā€” for
+ example, "Built by TESTER1 on \TESTBED". This string
+ should be present only if VS_FF_PRIVATEBUILD is
+ specified in the fileflags parameter of the root
+ block.
+ ProductName Name of the product with which the file is
+ distributed. This string is required.
+ ProductVersion Version of the product with which the file is
+ distributed ā€” for example, "3.10" or "5.00.RC2".
+ This string is required.
+ SpecialBuild Text that indicates how this version of the file
+ differs from the standard version ā€” for example,
+ "Private build for TESTER1 solving mouse problems
+ on M250 and M250E computers". This string should be
+ present only if VS_FF_SPECIALBUILD is specified in
+ the fileflags parameter of the root block.
+ */
diff --git a/pthreads/w32_CancelableWait.c b/pthreads/w32_CancelableWait.c
index 070633e0f..b30d65e3d 100644
--- a/pthreads/w32_CancelableWait.c
+++ b/pthreads/w32_CancelableWait.c
@@ -8,10 +8,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -34,6 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"