From 23a11e845def9532518350d460da78b7dd254b5d Mon Sep 17 00:00:00 2001 From: patrikjuvonen <22572159+patrikjuvonen@users.noreply.github.com> Date: Wed, 28 Dec 2022 00:46:33 +0200 Subject: [PATCH] Update pthreads-win32-2.9.0 to pthreads4w-3.0.0 --- vendor/pthreads/include/ANNOUNCE | 483 - vendor/pthreads/include/BUGS | 141 - vendor/pthreads/include/Bmakefile | 268 - vendor/pthreads/include/CONTRIBUTORS | 140 - vendor/pthreads/include/COPYING | 150 - vendor/pthreads/include/COPYING.LIB | 504 - vendor/pthreads/include/ChangeLog | 11000 ++++++++-------- vendor/pthreads/include/FAQ | 451 - vendor/pthreads/include/GNUmakefile | 593 - vendor/pthreads/include/LICENSE | 202 + vendor/pthreads/include/MAINTAINERS | 4 - vendor/pthreads/include/Makefile | 514 - vendor/pthreads/include/NEWS | 1241 -- vendor/pthreads/include/Nmakefile | 24 - vendor/pthreads/include/Nmakefile.tests | 260 - vendor/pthreads/include/PROGRESS | 4 - vendor/pthreads/include/README | 601 - vendor/pthreads/include/README.Borland | 57 - vendor/pthreads/include/README.CV | 3036 ----- vendor/pthreads/include/README.NONPORTABLE | 783 -- vendor/pthreads/include/README.Watcom | 62 - vendor/pthreads/include/README.WinCE | 6 - vendor/pthreads/include/TODO | 7 - vendor/pthreads/include/WinCE-PORT | 222 - vendor/pthreads/include/_ptw32.h | 215 + vendor/pthreads/include/attr.c | 53 - vendor/pthreads/include/autostatic.c | 69 - vendor/pthreads/include/barrier.c | 47 - vendor/pthreads/include/builddmc.bat | 9 - vendor/pthreads/include/cancel.c | 44 - vendor/pthreads/include/cleanup.c | 74 +- vendor/pthreads/include/condvar.c | 50 - vendor/pthreads/include/config.h | 59 +- vendor/pthreads/include/context.h | 64 +- vendor/pthreads/include/create.c | 283 +- vendor/pthreads/include/dll.c | 131 +- vendor/pthreads/include/errno.c | 55 +- vendor/pthreads/include/exit.c | 44 - vendor/pthreads/include/fork.c | 39 - vendor/pthreads/include/global.c | 82 +- vendor/pthreads/include/implement.h | 541 +- vendor/pthreads/include/md5.sum | 189 - vendor/pthreads/include/misc.c | 50 - vendor/pthreads/include/mutex.c | 62 - vendor/pthreads/include/need_errno.h | 63 +- vendor/pthreads/include/nonportable.c | 47 - vendor/pthreads/include/private.c | 54 - vendor/pthreads/include/pthread.c | 206 +- vendor/pthreads/include/pthread.dsp | 142 - vendor/pthreads/include/pthread.dsw | 29 - vendor/pthreads/include/pthread.h | 930 +- .../pthreads/include/pthread_attr_destroy.c | 48 +- .../include/pthread_attr_getaffinity_np.c | 54 + .../include/pthread_attr_getdetachstate.c | 48 +- .../include/pthread_attr_getinheritsched.c | 48 +- .../include/pthread_attr_getname_np.c | 51 + .../include/pthread_attr_getschedparam.c | 48 +- .../include/pthread_attr_getschedpolicy.c | 57 +- .../pthreads/include/pthread_attr_getscope.c | 46 +- .../include/pthread_attr_getstackaddr.c | 52 +- .../include/pthread_attr_getstacksize.c | 50 +- vendor/pthreads/include/pthread_attr_init.c | 52 +- .../include/pthread_attr_setaffinity_np.c | 54 + .../include/pthread_attr_setdetachstate.c | 48 +- .../include/pthread_attr_setinheritsched.c | 48 +- .../include/pthread_attr_setname_np.c | 96 + .../include/pthread_attr_setschedparam.c | 48 +- .../include/pthread_attr_setschedpolicy.c | 48 +- .../pthreads/include/pthread_attr_setscope.c | 46 +- .../include/pthread_attr_setstackaddr.c | 50 +- .../include/pthread_attr_setstacksize.c | 50 +- .../include/pthread_barrier_destroy.c | 58 +- .../pthreads/include/pthread_barrier_init.c | 46 +- .../pthreads/include/pthread_barrier_wait.c | 64 +- .../include/pthread_barrierattr_destroy.c | 46 +- .../include/pthread_barrierattr_getpshared.c | 46 +- .../include/pthread_barrierattr_init.c | 46 +- .../include/pthread_barrierattr_setpshared.c | 46 +- vendor/pthreads/include/pthread_cancel.c | 86 +- .../pthreads/include/pthread_cond_destroy.c | 80 +- vendor/pthreads/include/pthread_cond_init.c | 68 +- vendor/pthreads/include/pthread_cond_signal.c | 60 +- vendor/pthreads/include/pthread_cond_wait.c | 93 +- .../include/pthread_condattr_destroy.c | 46 +- .../include/pthread_condattr_getpshared.c | 46 +- .../pthreads/include/pthread_condattr_init.c | 46 +- .../include/pthread_condattr_setpshared.c | 46 +- vendor/pthreads/include/pthread_delay_np.c | 66 +- vendor/pthreads/include/pthread_detach.c | 74 +- vendor/pthreads/include/pthread_equal.c | 46 +- vendor/pthreads/include/pthread_exit.c | 56 +- .../pthreads/include/pthread_getconcurrency.c | 48 +- vendor/pthreads/include/pthread_getname_np.c | 69 + .../pthreads/include/pthread_getschedparam.c | 62 +- vendor/pthreads/include/pthread_getspecific.c | 46 +- .../pthreads/include/pthread_getunique_np.c | 48 +- .../include/pthread_getw32threadhandle_np.c | 50 +- vendor/pthreads/include/pthread_join.c | 58 +- vendor/pthreads/include/pthread_key_create.c | 48 +- vendor/pthreads/include/pthread_key_delete.c | 172 +- vendor/pthreads/include/pthread_kill.c | 81 +- .../include/pthread_mutex_consistent.c | 104 +- .../pthreads/include/pthread_mutex_destroy.c | 54 +- vendor/pthreads/include/pthread_mutex_init.c | 94 +- vendor/pthreads/include/pthread_mutex_lock.c | 150 +- .../include/pthread_mutex_timedlock.c | 191 +- .../pthreads/include/pthread_mutex_trylock.c | 98 +- .../pthreads/include/pthread_mutex_unlock.c | 88 +- .../include/pthread_mutexattr_destroy.c | 46 +- .../include/pthread_mutexattr_getkind_np.c | 46 +- .../include/pthread_mutexattr_getpshared.c | 46 +- .../include/pthread_mutexattr_getrobust.c | 46 +- .../include/pthread_mutexattr_gettype.c | 46 +- .../pthreads/include/pthread_mutexattr_init.c | 47 +- .../include/pthread_mutexattr_setkind_np.c | 46 +- .../include/pthread_mutexattr_setpshared.c | 46 +- .../include/pthread_mutexattr_setrobust.c | 46 +- .../include/pthread_mutexattr_settype.c | 46 +- .../include/pthread_num_processors_np.c | 48 +- vendor/pthreads/include/pthread_once.c | 68 +- .../pthreads/include/pthread_rwlock_destroy.c | 56 +- vendor/pthreads/include/pthread_rwlock_init.c | 48 +- .../pthreads/include/pthread_rwlock_rdlock.c | 52 +- .../include/pthread_rwlock_timedrdlock.c | 52 +- .../include/pthread_rwlock_timedwrlock.c | 60 +- .../include/pthread_rwlock_tryrdlock.c | 52 +- .../include/pthread_rwlock_trywrlock.c | 52 +- .../pthreads/include/pthread_rwlock_unlock.c | 48 +- .../pthreads/include/pthread_rwlock_wrlock.c | 60 +- .../include/pthread_rwlockattr_destroy.c | 46 +- .../include/pthread_rwlockattr_getpshared.c | 46 +- .../include/pthread_rwlockattr_init.c | 46 +- .../include/pthread_rwlockattr_setpshared.c | 46 +- vendor/pthreads/include/pthread_self.c | 176 +- vendor/pthreads/include/pthread_setaffinity.c | 240 + .../pthreads/include/pthread_setcancelstate.c | 58 +- .../pthreads/include/pthread_setcanceltype.c | 60 +- .../pthreads/include/pthread_setconcurrency.c | 48 +- vendor/pthreads/include/pthread_setname_np.c | 190 + .../pthreads/include/pthread_setschedparam.c | 66 +- vendor/pthreads/include/pthread_setspecific.c | 66 +- .../pthreads/include/pthread_spin_destroy.c | 64 +- vendor/pthreads/include/pthread_spin_init.c | 52 +- vendor/pthreads/include/pthread_spin_lock.c | 60 +- .../pthreads/include/pthread_spin_trylock.c | 60 +- vendor/pthreads/include/pthread_spin_unlock.c | 58 +- vendor/pthreads/include/pthread_testcancel.c | 58 +- .../include/pthread_timechange_handler_np.c | 54 +- .../pthreads/include/pthread_timedjoin_np.c | 185 + vendor/pthreads/include/pthread_tryjoin_np.c | 170 + .../include/pthread_win32_attach_detach_np.c | 161 +- vendor/pthreads/include/ptw32_MCS_lock.c | 261 +- vendor/pthreads/include/ptw32_OLL_lock.c | 734 -- .../include/ptw32_callUserDestroyRoutines.c | 80 +- vendor/pthreads/include/ptw32_calloc.c | 48 +- .../include/ptw32_cond_check_need_init.c | 54 +- vendor/pthreads/include/ptw32_getprocessors.c | 50 +- vendor/pthreads/include/ptw32_is_attr.c | 50 +- .../include/ptw32_mutex_check_need_init.c | 70 +- vendor/pthreads/include/ptw32_new.c | 70 +- .../include/ptw32_processInitialize.c | 140 +- .../pthreads/include/ptw32_processTerminate.c | 82 +- vendor/pthreads/include/ptw32_relmillisecs.c | 192 +- vendor/pthreads/include/ptw32_reuse.c | 120 +- .../include/ptw32_rwlock_cancelwrwait.c | 48 +- .../include/ptw32_rwlock_check_need_init.c | 54 +- vendor/pthreads/include/ptw32_semwait.c | 165 +- .../include/ptw32_spinlock_check_need_init.c | 54 +- vendor/pthreads/include/ptw32_threadDestroy.c | 74 +- vendor/pthreads/include/ptw32_threadStart.c | 262 +- vendor/pthreads/include/ptw32_throw.c | 135 +- vendor/pthreads/include/ptw32_timespec.c | 69 +- vendor/pthreads/include/ptw32_tkAssocCreate.c | 52 +- .../pthreads/include/ptw32_tkAssocDestroy.c | 50 +- vendor/pthreads/include/rwlock.c | 51 - vendor/pthreads/include/sched.c | 53 - vendor/pthreads/include/sched.h | 302 +- .../pthreads/include/sched_get_priority_max.c | 52 +- .../pthreads/include/sched_get_priority_min.c | 52 +- vendor/pthreads/include/sched_getscheduler.c | 52 +- vendor/pthreads/include/sched_setaffinity.c | 349 + vendor/pthreads/include/sched_setscheduler.c | 54 +- vendor/pthreads/include/sched_yield.c | 46 +- vendor/pthreads/include/sem_close.c | 48 +- vendor/pthreads/include/sem_destroy.c | 139 +- vendor/pthreads/include/sem_getvalue.c | 138 +- vendor/pthreads/include/sem_init.c | 192 +- vendor/pthreads/include/sem_open.c | 59 +- vendor/pthreads/include/sem_post.c | 151 +- vendor/pthreads/include/sem_post_multiple.c | 180 +- vendor/pthreads/include/sem_timedwait.c | 283 +- vendor/pthreads/include/sem_trywait.c | 133 +- vendor/pthreads/include/sem_unlink.c | 48 +- vendor/pthreads/include/sem_wait.c | 228 +- vendor/pthreads/include/semaphore.c | 69 - vendor/pthreads/include/semaphore.h | 203 +- vendor/pthreads/include/signal.c | 54 +- vendor/pthreads/include/spin.c | 46 - vendor/pthreads/include/sync.c | 43 - vendor/pthreads/include/tsd.c | 44 - vendor/pthreads/include/version.rc | 394 - vendor/pthreads/include/w32_CancelableWait.c | 76 +- vendor/pthreads/premake5.lua | 4 +- 203 files changed, 14263 insertions(+), 23313 deletions(-) delete mode 100644 vendor/pthreads/include/ANNOUNCE delete mode 100644 vendor/pthreads/include/BUGS delete mode 100644 vendor/pthreads/include/Bmakefile delete mode 100644 vendor/pthreads/include/CONTRIBUTORS delete mode 100644 vendor/pthreads/include/COPYING delete mode 100644 vendor/pthreads/include/COPYING.LIB delete mode 100644 vendor/pthreads/include/FAQ delete mode 100644 vendor/pthreads/include/GNUmakefile create mode 100644 vendor/pthreads/include/LICENSE delete mode 100644 vendor/pthreads/include/MAINTAINERS delete mode 100644 vendor/pthreads/include/Makefile delete mode 100644 vendor/pthreads/include/NEWS delete mode 100644 vendor/pthreads/include/Nmakefile delete mode 100644 vendor/pthreads/include/Nmakefile.tests delete mode 100644 vendor/pthreads/include/PROGRESS delete mode 100644 vendor/pthreads/include/README delete mode 100644 vendor/pthreads/include/README.Borland delete mode 100644 vendor/pthreads/include/README.CV delete mode 100644 vendor/pthreads/include/README.NONPORTABLE delete mode 100644 vendor/pthreads/include/README.Watcom delete mode 100644 vendor/pthreads/include/README.WinCE delete mode 100644 vendor/pthreads/include/TODO delete mode 100644 vendor/pthreads/include/WinCE-PORT create mode 100644 vendor/pthreads/include/_ptw32.h delete mode 100644 vendor/pthreads/include/attr.c delete mode 100644 vendor/pthreads/include/autostatic.c delete mode 100644 vendor/pthreads/include/barrier.c delete mode 100644 vendor/pthreads/include/builddmc.bat delete mode 100644 vendor/pthreads/include/cancel.c delete mode 100644 vendor/pthreads/include/condvar.c delete mode 100644 vendor/pthreads/include/exit.c delete mode 100644 vendor/pthreads/include/fork.c delete mode 100644 vendor/pthreads/include/md5.sum delete mode 100644 vendor/pthreads/include/misc.c delete mode 100644 vendor/pthreads/include/mutex.c delete mode 100644 vendor/pthreads/include/nonportable.c delete mode 100644 vendor/pthreads/include/private.c delete mode 100644 vendor/pthreads/include/pthread.dsp delete mode 100644 vendor/pthreads/include/pthread.dsw create mode 100644 vendor/pthreads/include/pthread_attr_getaffinity_np.c create mode 100644 vendor/pthreads/include/pthread_attr_getname_np.c create mode 100644 vendor/pthreads/include/pthread_attr_setaffinity_np.c create mode 100644 vendor/pthreads/include/pthread_attr_setname_np.c create mode 100644 vendor/pthreads/include/pthread_getname_np.c create mode 100644 vendor/pthreads/include/pthread_setaffinity.c create mode 100644 vendor/pthreads/include/pthread_setname_np.c create mode 100644 vendor/pthreads/include/pthread_timedjoin_np.c create mode 100644 vendor/pthreads/include/pthread_tryjoin_np.c delete mode 100644 vendor/pthreads/include/ptw32_OLL_lock.c delete mode 100644 vendor/pthreads/include/rwlock.c delete mode 100644 vendor/pthreads/include/sched.c create mode 100644 vendor/pthreads/include/sched_setaffinity.c delete mode 100644 vendor/pthreads/include/semaphore.c delete mode 100644 vendor/pthreads/include/spin.c delete mode 100644 vendor/pthreads/include/sync.c delete mode 100644 vendor/pthreads/include/tsd.c delete mode 100644 vendor/pthreads/include/version.rc diff --git a/vendor/pthreads/include/ANNOUNCE b/vendor/pthreads/include/ANNOUNCE deleted file mode 100644 index 950c86ff03..0000000000 --- a/vendor/pthreads/include/ANNOUNCE +++ /dev/null @@ -1,483 +0,0 @@ -PTHREADS-WIN32 RELEASE 2.9.0 (2012-05-25) ------------------------------------------ -Web Site: http://sourceware.org/pthreads-win32/ -FTP Site: ftp://sourceware.org/pub/pthreads-win32 -Maintainer: Ross Johnson - - -We are pleased to announce the availability of a new release of -Pthreads-win32, an Open Source Software implementation of the -Threads component of the POSIX 1003.1 2001 Standard for Microsoft's -Win32 environment. Some functions from other sections of POSIX -1003.1 2001 are also supported including semaphores and scheduling -functions. - -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. - -Pthreads-win32 is free software, distributed under the GNU Lesser -General Public License (LGPL). - - -Acknowledgements ----------------- -This library is based originally on a Win32 pthreads -implementation contributed by John Bossom. - -The implementation of Condition Variables uses algorithms developed -by Alexander Terekhov and Louis Thomas. - -The implementation of POSIX mutexes has been improved by Thomas Pfaff -and later by Alexander Terekhov. - -The implementation of Spinlocks and Barriers was contributed -by Ross Johnson. - -The implementation of read/write locks was contributed by -Aurelio Medina and improved by Alexander Terekhov. - -Many others have contributed significant time and effort to solve crutial -problems in order to make the library workable, robust and reliable. - -Thanks to Xavier Leroy for granting permission to use and modify his -LinuxThreads manual pages. - -Thanks to The Open Group for making the Single Unix Specification -publicly available - many of the manual pages included in the package -were extracted from it. - -There is also a separate CONTRIBUTORS file. This file and others are -on the web site: - - http://sourceware.org/pthreads-win32 - -As much as possible, the ChangeLog file acknowledges contributions to the -code base in more detail. - - -Changes since the last release ------------------------------- -These are now documented in the NEWS file. -See the ChangeLog file also. - - -Known Bugs ----------- -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: - - _POSIX_THREADS - _POSIX_THREAD_SAFE_FUNCTIONS - _POSIX_THREAD_ATTR_STACKSIZE - _POSIX_THREAD_PRIORITY_SCHEDULING - _POSIX_SEMAPHORES - _POSIX_READER_WRITER_LOCKS - _POSIX_SPIN_LOCKS - _POSIX_BARRIERS - - -The following POSIX 1003.1 2001 options are defined and set to -1: - - _POSIX_THREAD_ATTR_STACKADDR - _POSIX_THREAD_PRIO_INHERIT - _POSIX_THREAD_PRIO_PROTECT - _POSIX_THREAD_PROCESS_SHARED - - -The following POSIX 1003.1 2001 limits are defined and set: - - _POSIX_THREAD_THREADS_MAX - _POSIX_SEM_VALUE_MAX - _POSIX_SEM_NSEMS_MAX - _POSIX_THREAD_KEYS_MAX - _POSIX_THREAD_DESTRUCTOR_ITERATIONS - PTHREAD_STACK_MIN - PTHREAD_THREADS_MAX - SEM_VALUE_MAX - SEM_NSEMS_MAX - PTHREAD_KEYS_MAX - PTHREAD_DESTRUCTOR_ITERATIONS - - -The following functions are implemented: - - --------------------------- - PThreads - --------------------------- - pthread_attr_init - pthread_attr_destroy - pthread_attr_getdetachstate - pthread_attr_getstackaddr - pthread_attr_getstacksize - pthread_attr_setdetachstate - pthread_attr_setstackaddr - pthread_attr_setstacksize - - pthread_create - pthread_detach - pthread_equal - pthread_exit - pthread_join - pthread_once - pthread_self - - pthread_cancel - pthread_cleanup_pop - pthread_cleanup_push - pthread_setcancelstate - pthread_setcanceltype - pthread_testcancel - - --------------------------- - Thread Specific Data - --------------------------- - pthread_key_create - pthread_key_delete - pthread_setspecific - pthread_getspecific - - --------------------------- - Mutexes - --------------------------- - pthread_mutexattr_init - pthread_mutexattr_destroy - pthread_mutexattr_getpshared - pthread_mutexattr_setpshared - pthread_mutexattr_gettype - pthread_mutexattr_settype (types: PTHREAD_MUTEX_DEFAULT - PTHREAD_MUTEX_NORMAL - PTHREAD_MUTEX_ERRORCHECK - PTHREAD_MUTEX_RECURSIVE ) - pthread_mutexattr_getrobust - pthread_mutexattr_setrobust (values: PTHREAD_MUTEX_STALLED - PTHREAD_MUTEX_ROBUST) - pthread_mutex_init - pthread_mutex_destroy - pthread_mutex_lock - pthread_mutex_trylock - pthread_mutex_timedlock - pthread_mutex_unlock - pthread_mutex_consistent - - --------------------------- - Condition Variables - --------------------------- - pthread_condattr_init - pthread_condattr_destroy - pthread_condattr_getpshared - pthread_condattr_setpshared - - pthread_cond_init - pthread_cond_destroy - pthread_cond_wait - pthread_cond_timedwait - pthread_cond_signal - pthread_cond_broadcast - - --------------------------- - Read/Write Locks - --------------------------- - pthread_rwlock_init - pthread_rwlock_destroy - pthread_rwlock_tryrdlock - pthread_rwlock_trywrlock - pthread_rwlock_rdlock - pthread_rwlock_timedrdlock - pthread_rwlock_rwlock - pthread_rwlock_timedwrlock - pthread_rwlock_unlock - pthread_rwlockattr_init - pthread_rwlockattr_destroy - pthread_rwlockattr_getpshared - pthread_rwlockattr_setpshared - - --------------------------- - Spin Locks - --------------------------- - pthread_spin_init - pthread_spin_destroy - pthread_spin_lock - pthread_spin_unlock - pthread_spin_trylock - - --------------------------- - Barriers - --------------------------- - pthread_barrier_init - pthread_barrier_destroy - pthread_barrier_wait - pthread_barrierattr_init - pthread_barrierattr_destroy - pthread_barrierattr_getpshared - pthread_barrierattr_setpshared - - --------------------------- - Semaphores - --------------------------- - sem_init - sem_destroy - sem_post - sem_wait - sem_trywait - sem_timedwait - sem_getvalue (# free if +ve, # of waiters if -ve) - sem_open (returns an error ENOSYS) - sem_close (returns an error ENOSYS) - sem_unlink (returns an error ENOSYS) - - --------------------------- - RealTime Scheduling - --------------------------- - pthread_attr_getschedparam - pthread_attr_setschedparam - pthread_attr_getinheritsched - pthread_attr_setinheritsched - pthread_attr_getschedpolicy (only supports SCHED_OTHER) - pthread_attr_setschedpolicy (only supports SCHED_OTHER) - pthread_getschedparam - pthread_setschedparam - pthread_getconcurrency - pthread_setconcurrency - pthread_attr_getscope - pthread_attr_setscope (only supports PTHREAD_SCOPE_SYSTEM) - sched_get_priority_max - sched_get_priority_min - sched_rr_get_interval (returns an error ENOTSUP) - sched_setscheduler (only supports SCHED_OTHER) - sched_getscheduler (only supports SCHED_OTHER) - sched_yield - - --------------------------- - Signals - --------------------------- - pthread_sigmask - pthread_kill (only supports zero sig value, - for thread validity checking) - - --------------------------- - Non-portable routines (see the README.NONPORTABLE file for usage) - --------------------------- - pthread_getw32threadhandle_np - pthread_timechange_handler_np - pthread_delay_np - pthread_getunique_np - pthread_mutexattr_getkind_np - pthread_mutexattr_setkind_np (types: PTHREAD_MUTEX_FAST_NP, - PTHREAD_MUTEX_ERRORCHECK_NP, - PTHREAD_MUTEX_RECURSIVE_NP, - PTHREAD_MUTEX_ADAPTIVE_NP, - PTHREAD_MUTEX_TIMED_NP) - pthread_num_processors_np - (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 - --------------------------- - PTHREAD_ONCE_INIT - PTHREAD_MUTEX_INITIALIZER - PTHREAD_RECURSIVE_MUTEX_INITIALIZER - PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP - PTHREAD_ERRORCHECK_MUTEX_INITIALIZER - PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP - PTHREAD_COND_INITIALIZER - PTHREAD_RWLOCK_INITIALIZER - PTHREAD_SPINLOCK_INITIALIZER - - -The library includes two non-API functions for creating cancellation -points in applications and libraries: - - pthreadCancelableWait - pthreadCancelableTimedWait - - -The following functions are not implemented: - - --------------------------- - RealTime Scheduling - --------------------------- - pthread_mutex_getprioceiling - pthread_mutex_setprioceiling - pthread_mutex_attr_getprioceiling - pthread_mutex_attr_getprotocol - pthread_mutex_attr_setprioceiling - pthread_mutex_attr_setprotocol - - --------------------------- - Fork Handlers - --------------------------- - pthread_atfork - - --------------------------- - Stdio - --------------------------- - flockfile - ftrylockfile - funlockfile - getc_unlocked - getchar_unlocked - putc_unlocked - putchar_unlocked - - --------------------------- - Thread-Safe C Runtime Library - --------------------------- - readdir_r - getgrgid_r - getgrnam_r - getpwuid_r - getpwnam_r - - --------------------------- - Signals - --------------------------- - sigtimedwait - sigwait - sigwaitinfo - - --------------------------- - General - --------------------------- - sysconf - - --------------------------- - Thread-Safe C Runtime Library (macros) - --------------------------- - strtok_r - asctime_r - ctime_r - gmtime_r - localtime_r - rand_r - - -Availability ------------- - -The prebuilt DLL, export libs (for both MSVC and Mingw32), and the header -files (pthread.h, semaphore.h, sched.h) are available along with the -complete source code. - -The source code can be found at: - - ftp://sources.redhat.com/pub/pthreads-win32 - -and as individual source code files at - - ftp://sources.redhat.com/pub/pthreads-win32/source - -The pre-built DLL, export libraries and include files can be found at: - - ftp://sources.redhat.com/pub/pthreads-win32/dll-latest - - - -Mailing List ------------- - -There is a mailing list for discussing pthreads on Win32. To join, -send email to: - - pthreads-win32-subscribe@sourceware.cygnus.com - - -Application Development Environments ------------------------------------- - -See the README file for more information. - -MSVC: -MSVC using SEH works. Distribute pthreadVSE.dll with your application. -MSVC using C++ EH works. Distribute pthreadVCE.dll with your application. -MSVC using C setjmp/longjmp works. Distribute pthreadVC.dll with your application. - - -Mingw32: -See the FAQ, Questions 6 and 10. - -Mingw using C++ EH works. Distribute pthreadGCE.dll with your application. -Mingw using C setjmp/longjmp works. Distribute pthreadGC.dll with your application. - - -Cygwin: (http://sourceware.cygnus.com/cygwin/) -Developers using Cygwin do not need pthreads-win32 since it has POSIX threads -support. Refer to its documentation for details and extent. - - -UWIN: -UWIN is a complete Unix-like environment for Windows from AT&T. Pthreads-win32 -doesn't currently support UWIN (and vice versa), but that may change in the -future. - -Generally: -For convenience, the following pre-built files are available on the FTP site -(see Availability above): - - pthread.h - for POSIX threads - semaphore.h - for POSIX semaphores - sched.h - for POSIX scheduling - pthreadVCE.dll - built with MSVC++ compiler using C++ EH - pthreadVCE.lib - pthreadVC.dll - built with MSVC compiler using C setjmp/longjmp - pthreadVC.lib - pthreadVSE.dll - built with MSVC compiler using SEH - pthreadVSE.lib - pthreadGCE.dll - built with Mingw32 G++ 2.95.2-1 - pthreadGC.dll - built with Mingw32 GCC 2.95.2-1 using setjmp/longjmp - libpthreadGCE.a - derived from pthreadGCE.dll - libpthreadGC.a - derived from pthreadGC.dll - gcc.dll - needed if distributing applications that use - pthreadGCE.dll (but see the FAQ Q 10 for the latest - related information) - -These are the only files you need in order to build POSIX threads -applications for Win32 using either MSVC or Mingw32. - -See the FAQ file in the source tree for additional information. - - -Documentation -------------- - -For the authoritative reference, see the online POSIX -standard reference at: - - http://www.OpenGroup.org - -For POSIX Thread API programming, several reference books are -available: - - Programming with POSIX Threads - David R. Butenhof - Addison-Wesley (pub) - - Pthreads Programming - By Bradford Nichols, Dick Buttlar & Jacqueline Proulx Farrell - O'Reilly (pub) - -On the web: see the links at the bottom of the pthreads-win32 site: - - http://sources.redhat.com/pthreads-win32/ - - Currently, there is no documentation included in the package apart - from the copious comments in the source code. - - - -Enjoy! - -Ross Johnson diff --git a/vendor/pthreads/include/BUGS b/vendor/pthreads/include/BUGS deleted file mode 100644 index 285ba4eb98..0000000000 --- a/vendor/pthreads/include/BUGS +++ /dev/null @@ -1,141 +0,0 @@ ----------- -Known bugs ----------- - -1. Not strictly a bug, more of a gotcha. - - Under MS VC++ (only tested with version 6.0), a term_func - set via the standard C++ set_terminate() function causes the - application to abort. - - Notes from the MSVC++ manual: - 1) A term_func() should call exit(), otherwise - abort() will be called on return to the caller. - A call to abort() raises SIGABRT and the default signal handler - for all signals terminates the calling program with - exit code 3. - 2) A term_func() must not throw an exception. Therefore - term_func() should not call pthread_exit(), which - works by throwing an exception (pthreadVCE or pthreadVSE) - or by calling longjmp (pthreadVC). - - Workaround: avoid using pthread_exit() in C++ applications. Exit - threads by dropping through the end of the thread routine. - -2. Cancellation problems in C++ builds - - Milan Gardian - - [Note: It's not clear if this problem isn't simply due to the context - switch in pthread_cancel() which occurs unless the QueueUserAPCEx - library and driver are installed and used. Just like setjmp/longjmp, - this is probably not going to work well in C++. In any case, unless for - some very unusual reason you really must use the C++ build then please - use the C build pthreadVC2.dll or pthreadGC2.dll, i.e. for C++ - applications.] - - This is suspected to be a compiler bug in VC6.0, and also seen in - VC7.0 and VS .NET 2003. The GNU C++ compiler does not have a problem - with this, and it has been reported that the Intel C++ 8.1 compiler - and Visual C++ 2005 Express Edition Beta2 pass tests\semaphore4.c - (which exposes the bug). - - Workaround [rpj - 2 Feb 2002] - ----------------------------- - [Please note: this workaround did not solve a similar problem in - snapshot-2004-11-03 or later, even though similar symptoms were seen. - tests\semaphore4.c fails in that snapshot for the VCE version of the - DLL.] - - The problem disappears when /Ob0 is used, i.e. /O2 /Ob0 works OK, - but if you want to use inlining optimisation you can be much more - specific about where it's switched off and on by using a pragma. - - So the inlining optimisation is interfering with the way that cleanup - handlers are run. It appears to relate to auto-inlining of class methods - since this is the only auto inlining that is performed at /O1 optimisation - (functions with the "inline" qualifier are also inlined, but the problem - doesn't appear to involve any such functions in the library or testsuite). - - In order to confirm the inlining culprit, the following use of pragmas - eliminate the problem but I don't know how to make it transparent, putting - it in, say, pthread.h where pthread_cleanup_push defined as a macro. - - #pragma inline_depth(0) - pthread_cleanup_push(handlerFunc, (void *) &arg); - - /* ... */ - - pthread_cleanup_pop(0); - #pragma inline_depth() - - Note the empty () pragma value after the pop macro. This resets depth to the - default. Or you can specify a non-zero depth here. - - The pragma is also needed (and now used) within the library itself wherever - cleanup handlers are used (condvar.c and rwlock.c). - - Use of these pragmas allows compiler optimisations /O1 and /O2 to be - used for either or both the library and applications. - - Experimenting further, I found that wrapping the actual cleanup handler - function with #pragma auto_inline(off|on) does NOT work. - - MSVC6.0 doesn't appear to support the C99 standard's _Pragma directive, - however, later versions may. This form is embeddable inside #define - macros, which would be ideal because it would mean that it could be added - to the push/pop macro definitions in pthread.h and hidden from the - application programmer. - - [/rpj] - - Original problem description - ---------------------------- - - The cancellation (actually, cleanup-after-cancel) tests fail when using VC - (professional) optimisation switches (/O1 or /O2) in pthreads library. I - have not investigated which concrete optimisation technique causes this - problem (/Og, /Oi, /Ot, /Oy, /Ob1, /Gs, /Gf, /Gy, etc.), but here is a - summary of builds and corresponding failures: - - * pthreads VSE (optimised tests): OK - * pthreads VCE (optimised tests): Failed "cleanup1" test (runtime) - - * pthreads VSE (DLL in CRT, optimised tests): OK - * pthreads VCE (DLL in CRT, optimised tests): Failed "cleanup1" test - (runtime) - - Please note that while in VSE version of the pthreads library the - optimisation does not really have any impact on the tests (they pass OK), in - VCE version addition of optimisation (/O2 in this case) causes the tests to - fail uniformly - either in "cleanup0" or "cleanup1" test cases. - - Please note that all the tests above use default pthreads DLL (no - optimisations, linked with either static or DLL CRT, based on test type). - Therefore the problem lies not within the pthreads DLL but within the - compiled client code (the application using pthreads -> involvement of - "pthread.h"). - - I think the message of this section is that usage of VCE version of pthreads - in applications relying on cancellation/cleanup AND using optimisations for - creation of production code is highly unreliable for the current version of - the pthreads library. - -3. The Borland Builder 5.5 version of the library produces memory read exceptions -in some tests. - -4. pthread_barrier_wait() can deadlock if the number of potential calling -threads for a particular barrier is greater than the barrier count parameter -given to pthread_barrier_init() for that barrier. - -This is due to the very lightweight implementation of pthread-win32 barriers. -To cope with more than "count" possible waiters, barriers must effectively -implement all the same safeguards as condition variables, making them much -"heavier" than at present. - -The workaround is to ensure that no more than "count" threads attempt to wait -at the barrier. - -5. Canceling a thread blocked on pthread_once appears not to work in the MSVC++ -version of the library "pthreadVCE.dll". The test case "once3.c" hangs. I have no -clues on this at present. All other versions pass this test ok - pthreadsVC.dll, -pthreadsVSE.dll, pthreadsGC.dll and pthreadsGCE.dll. diff --git a/vendor/pthreads/include/Bmakefile b/vendor/pthreads/include/Bmakefile deleted file mode 100644 index ea25dec4fd..0000000000 --- a/vendor/pthreads/include/Bmakefile +++ /dev/null @@ -1,268 +0,0 @@ -# This makefile is compatible with BCB make. Use "make -fBMakefile" to compile. -# -# The variables $DLLDEST and $LIBDEST hold the destination directories for the -# dll and the lib, respectively. Probably all that needs to change is $DEVROOT. -# -# Currently only the recommended pthreadBC.dll is built by this makefile. -# - - -DLL_VER = 2 - -DEVROOT = . - -DLLDEST = $(DEVROOT)\DLL -LIBDEST = $(DEVROOT)\DLL - -DLLS = pthreadBC$(DLL_VER).dll - -OPTIM = /O2 - -RC = brcc32 -RCFLAGS = -i. - -CFLAGS = /q /I. /D_WIN32_WINNT=0x400 /DHAVE_PTW32_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 - - -all: clean $(DLLS) - -realclean: clean - if exist pthread*.dll del pthread*.dll - if exist pthread*.lib del pthread*.lib - if exist *.stamp del *.stamp - -clean: - if exist *.obj del *.obj - if exist *.ilk del *.ilk - if exist *.ilc del *.ilc - if exist *.ild del *.ild - if exist *.ilf del *.ilf - if exist *.ils del *.ils - if exist *.tds del *.tds - if exist *.pdb del *.pdb - if exist *.exp del *.exp - if exist *.map del *.map - if exist *.o del *.o - if exist *.i del *.i - if exist *.res del *.res - - -install: $(DLLS) - copy pthread*.dll $(DLLDEST) - copy pthread*.lib $(LIBDEST) - -$(DLLS): $(DLL_OBJS) version.res - ilink32 /Tpd /Gi c0d32x.obj $(DLL_OBJS), \ - $@, ,\ - cw32mti.lib import32.lib, ,\ - version.res - -.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/vendor/pthreads/include/CONTRIBUTORS b/vendor/pthreads/include/CONTRIBUTORS deleted file mode 100644 index da31ff266c..0000000000 --- a/vendor/pthreads/include/CONTRIBUTORS +++ /dev/null @@ -1,140 +0,0 @@ -Contributors (in approximate order of appearance) - -[See also the ChangeLog file where individuals are -attributed in log entries. Likewise in the FAQ file.] - -Ben Elliston bje at cygnus dot com - Initiated the project; - setup the project infrastructure (CVS, web page, etc.); - early prototype routines. -Ross Johnson Ross dot Johnson at dot homemail dot com dot au - early prototype routines; - ongoing project coordination/maintenance; - implementation of spin locks and barriers; - various enhancements; - bug fixes; - documentation; - testsuite. -Robert Colquhoun rjc at trump dot net dot au - Early bug fixes. -John E. Bossom John dot Bossom at cognos dot com - Contributed substantial original working implementation; - bug fixes; - ongoing guidance and standards interpretation. -Anders Norlander anorland at hem2 dot passagen dot se - Early enhancements and runtime checking for supported - Win32 routines. -Tor Lillqvist tml at iki dot fi - General enhancements; - early bug fixes to condition variables. -Scott Lightner scott at curriculum dot com - Bug fix. -Kevin Ruland Kevin dot Ruland at anheuser-busch dot com - Various bug fixes. -Mike Russo miker at eai dot com - Bug fix. -Mark E. Armstrong avail at pacbell dot net - Bug fixes. -Lorin Hochstein lmh at xiphos dot ca - general bug fixes; bug fixes to condition variables. -Peter Slacik Peter dot Slacik at tatramed dot sk - Bug fixes. -Mumit Khan khan at xraylith dot wisc dot edu - Fixes to work with Mingw32. -Milan Gardian mg at tatramed dot sk - Bug fixes and reports/analyses of obscure problems. -Aurelio Medina aureliom at crt dot com - First implementation of read-write locks. -Graham Dumpleton Graham dot Dumpleton at ra dot pad dot otc dot telstra dot com dot au - Bug fix in condition variables. -Tristan Savatier tristan at mpegtv dot com - WinCE port. -Erik Hensema erik at hensema dot xs4all dot nl - Bug fixes. -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. -Fred Forester fforest at eticomm dot net -Kevin D. Clark kclark at cabletron dot com -David Baggett dmb at itasoftware dot com - Bug fixes. -Paul Redondo paul at matchvision dot com -Scott McCaskill scott at 3dfx dot com - Bug fixes. -Jef Gearhart jgearhart at tpssys dot com - Bug fix. -Arthur Kantor akantor at bexusa dot com - Mutex enhancements. -Steven Reddie smr at essemer dot com dot au - Bug fix. -Alexander Terekhov TEREKHOV at de dot ibm dot com - Re-implemented and improved read-write locks; - (with Louis Thomas) re-implemented and improved - condition variables; - enhancements to semaphores; - enhancements to mutexes; - new mutex implementation in 'futex' style; - suggested a robust implementation of pthread_once - similar to that implemented by V.Kliathcko; - system clock change handling re CV timeouts; - bug fixes. -Thomas Pfaff tpfaff at gmx dot net - Changes to make C version usable with C++ applications; - re-implemented mutex routines to avoid Win32 mutexes - and TryEnterCriticalSection; - procedure to fix Mingw32 thread-safety issues. -Franco Bez franco dot bez at gmx dot de - procedure to fix Mingw32 thread-safety issues. -Louis Thomas lthomas at arbitrade dot com - (with Alexander Terekhov) re-implemented and improved - condition variables. -David Korn dgk at research dot att dot com - Ported to UWIN. -Phil Frisbie, Jr. phil at hawksoft dot com - Bug fix. -Ralf Brese Ralf dot Brese at pdb4 dot siemens dot de - Bug fix. -prionx at juno dot com prionx at juno dot com - Bug fixes. -Max Woodbury mtew at cds dot duke dot edu - POSIX versioning conditionals; - reduced namespace pollution; - idea to separate routines to reduce statically - linked image sizes. -Rob Fanner rfanner at stonethree dot com - Bug fix. -Michael Johnson michaelj at maine dot rr dot com - Bug fix. -Nicolas Barry boozai at yahoo dot com - Bug fixes. -Piet van Bruggen pietvb at newbridges dot nl - Bug fix. -Makoto Kato raven at oldskool dot jp - AMD64 port. -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. -Will Bryant will dot bryant at ecosm dot com - Borland compiler patch and makefile. -Anuj Goyal anuj dot goyal at gmail dot com - Port to Digital Mars compiler. -Gottlob Frege gottlobfrege at gmail dot com - re-implemented pthread_once (version 2) - (pthread_once cancellation added by rpj). -Vladimir Kliatchko vladimir at kliatchko dot com - reimplemented pthread_once with the same form - as described by A.Terekhov (later version 2); - implementation of MCS (Mellor-Crummey/Scott) locks. -Ramiro Polla ramiro.polla at gmail dot com - static library auto init/cleanup on application - start/exit via RT hooks (MSC and GCC compilers only). -Daniel Richard G. skunk at iSKUNK dot org - Patches and cleanups for x86 and x64, particularly - across a range of MS build environments. -John Kamp john dot kamp at globalgraphics dot com - Patches to fix various problems on x64; brutal testing - particularly using high memory run environments. - diff --git a/vendor/pthreads/include/COPYING b/vendor/pthreads/include/COPYING deleted file mode 100644 index 5cfea0d0ed..0000000000 --- a/vendor/pthreads/include/COPYING +++ /dev/null @@ -1,150 +0,0 @@ - pthreads-win32 - a POSIX threads library for Microsoft Windows - - -This file is Copyrighted ------------------------- - - This file is covered under the following Copyright: - - Copyright (C) 2001,2006 Ross P. Johnson - All rights reserved. - - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -Pthreads-win32 is covered by the GNU Lesser General Public License ------------------------------------------------------------------- - - Pthreads-win32 is open 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 version 2.1 of the - License. - - Pthreads-win32 is several binary link libraries, several modules, - associated interface definition files and scripts used to control - its compilation and installation. - - Pthreads-win32 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. - - A copy of the GNU Lesser General Public License is distributed with - pthreads-win32 under the filename: - - COPYING.LIB - - You should have received a copy of the version 2.1 GNU Lesser General - Public License with pthreads-win32; if not, write to: - - Free Software Foundation, Inc. - 59 Temple Place - Suite 330 - Boston, MA 02111-1307 - USA - - The contact addresses for pthreads-win32 is as follows: - - Web: http://sources.redhat.com/pthreads-win32 - Email: Ross Johnson - Please use: Firstname.Lastname@homemail.com.au - - - -Pthreads-win32 copyrights and exception files ---------------------------------------------- - - With the exception of the files listed below, Pthreads-win32 - is covered under the following GNU Lesser General Public License - Copyrights: - - Pthreads-win32 - POSIX Threads Library for Win32 - Copyright(C) 1998 John E. Bossom - Copyright(C) 1999,2006 Pthreads-win32 contributors - - The current list of contributors is contained - in the file CONTRIBUTORS included with the source - code distribution. The current list of CONTRIBUTORS - can also be seen at the following WWW location: - http://sources.redhat.com/pthreads-win32/contributors.html - - Contact Email: Ross Johnson - Please use: Firstname.Lastname@homemail.com.au - - These files are not covered under one of the Copyrights listed above: - - COPYING - COPYING.LIB - tests/rwlock7.c - - This file, COPYING, is distributed under the Copyright found at the - top of this file. It is important to note that you may distribute - verbatim copies of this file but you may not modify this file. - - The file COPYING.LIB, which contains a copy of the version 2.1 - GNU Lesser General Public License, is itself copyrighted by the - Free Software Foundation, Inc. Please note that the Free Software - Foundation, Inc. does NOT have a copyright over Pthreads-win32, - only the COPYING.LIB that is supplied with pthreads-win32. - - The file tests/rwlock7.c is derived from code written by - Dave Butenhof for his book 'Programming With POSIX(R) Threads'. - The original code was obtained by free download from his website - http://home.earthlink.net/~anneart/family/Threads/source.html - and did not contain a copyright or author notice. It is assumed to - be freely distributable. - - In all cases one may use and distribute these exception files freely. - And because one may freely distribute the LGPL covered files, the - entire pthreads-win32 source may be freely used and distributed. - - - -General Copyleft and License info ---------------------------------- - - For general information on Copylefts, see: - - http://www.gnu.org/copyleft/ - - For information on GNU Lesser General Public Licenses, see: - - http://www.gnu.org/copyleft/lesser.html - http://www.gnu.org/copyleft/lesser.txt - - -Why pthreads-win32 did not use the GNU General Public License -------------------------------------------------------------- - - The goal of the pthreads-win32 project has been to - provide a quality and complete implementation of the POSIX - threads API for Microsoft Windows within the limits imposed - by virtue of it being a stand-alone library and not - linked directly to other POSIX compliant libraries. For - example, some functions and features, such as those based - on POSIX signals, are missing. - - Pthreads-win32 is a library, available in several different - versions depending on supported compilers, and may be used - as a dynamically linked module or a statically linked set of - binary modules. It is not an application on it's own. - - It was fully intended that pthreads-win32 be usable with - commercial software not covered by either the GPL or the LGPL - licenses. Pthreads-win32 has many contributors to it's - code base, many of whom have done so because they have - used the library in commercial or proprietry software - projects. - - Releasing pthreads-win32 under the LGPL ensures that the - library can be used widely, while at the same time ensures - that bug fixes and improvements to the pthreads-win32 code - itself is returned to benefit all current and future users - of the library. - - Although pthreads-win32 makes it possible for applications - that use POSIX threads to be ported to Win32 platforms, the - broader goal of the project is to encourage the use of open - standards, and in particular, to make it just a little easier - for developers writing Win32 applications to consider - widening the potential market for their products. diff --git a/vendor/pthreads/include/COPYING.LIB b/vendor/pthreads/include/COPYING.LIB deleted file mode 100644 index b1e3f5a263..0000000000 --- a/vendor/pthreads/include/COPYING.LIB +++ /dev/null @@ -1,504 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - 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.1 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; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! - - diff --git a/vendor/pthreads/include/ChangeLog b/vendor/pthreads/include/ChangeLog index 7c6ba3956f..f48750a055 100644 --- a/vendor/pthreads/include/ChangeLog +++ b/vendor/pthreads/include/ChangeLog @@ -1,5211 +1,5789 @@ -2012-03-18 Ross Johnson - - * 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 - - * pthread_cond_wait.c (pragma inline_depth): this is almost redundant - now nevertheless fixed thei controlling MSC_VER from "< 800" to - "< 1400" (i.e. any prior to VC++ 8.0). - * pthread_once.ci (pragma inline_depth): Likewise. - * pthread_rwlock_timedwrlock.ci (pragma inline_depth): Likewise. - * pthread_rwlock_wrlock.ci (pragma inline_depth): Likewise. - * sem_timedwait.ci (pragma inline_depth): Likewise. - * sem_wait.ci (pragma inline_depth): Likewise. - -2011-07-05 Ross Johnson - - * pthread_win32_attach_detach_np.c: Use strncat_s if available - to removei a compile warning; MingW supports this routine but we - continue to use strncat anyway there because it is secure if - given the correct parameters; fix strncat param 3 to avoid - buffer overrun exploitation potential. - -2011-07-03 Ross Johnson - - * pthread_spin_unlock.c (EPERM): Return success if unlocking a lock - that is not locked, because single CPU machines wrap a - PTHREAD_MUTEX_NORMAL mutex, which returns success in this case. - * pthread_win32_attach_detach_np.c (QUSEREX.DLL): Load from an - absolute path only which must be the Windows System folder. - -2011-07-03 Daniel Richard G. - - * Makefile (_WIN32_WINNT): Removed; duplicate definition in - implement.h; more cleanup and enhancements. - -2011-07-02 Daniel Richard G. - - * Makefile: Cleanups and implovements. - * ptw32_MCS_locks.c: Casting fixes. - * implement.h: Interlocked call and argument casting macro fixes - to support older and newer build environments. - -2011-07-01 Ross Johnson - - * *.[ch] (PTW32_INTERLOCKED_*): Redo 23 and 64 bit versions of these - macros and re-apply in code to undo the incorrect changes from - 2011-06-29; remove some size_t casts which should not be required - and may be problematic.a - There are now two sets of macros: - PTW32_INTERLOCKED_*_LONG which work only on 32 bit integer variables; - PTW32_INTERLOCKED_*_SIZE which work on size_t integer variables, i.e. - LONG for 32 bit systems and LONGLONG for 64 bit systems. - * implement.h (MCS locks): nextFlag and waitFlag are now HANDLE type. - * ptw32_MCS_locks.c: Likewise. - * pthread.h (#include ): Removed. - * ptw32_throw.c (#include ): Added. - * ptw32_threadStart.c (#include ): Added. - * implement.h (#include ): Added. - -2011-06-30 Ross Johnson - - * pthread_once.c: Tighten 'if' statement casting; fix interlocked - pointer cast for 64 bit compatibility (missed yesterday); remove - the superfluous static cleanup routine and call the release routine - directly if popped. - * create.c (stackSize): Now type size_t. - * pthread.h (struct ptw32_thread_t_): Rearrange to fix element alignments. - -2011-06-29 Daniel Richard G. - - * ptw32_relmillisecs.c (ftime): - _ftime64_s() is only available in MSVC 2005 or later; - _ftime64() is available in MinGW or MSVC 2002 or later; - _ftime() is always available. - * pthread.h (long long): Not defined in older MSVC 6. - * implement.h (long long): Likewise. - * pthread_getunique_np.c (long long): Likewise. - -2011-06-29 Ross Johnson - - * *.[ch] (PTW32_INTERLOCKED_*): These macros should now work for - both 32 and 64 bit builds. The MingW versions are all inlined asm - while the MSVC versions expand to their Interlocked* or Interlocked*64 - counterparts appropriately. The argument type have also been changed - to cast to the appropriate value or pointer size for the architecture. - -2011-05-29 Ross Johnson - - * *.[ch] (#ifdef): Extended cleanup to whole project. - -2011-05-29 Daniel Richard G. - - * Makefile (CC): Define CC to allow use of other compatible - compilers such as the Intel compilter icl. - * implement.h (#if): Fix forms like #if HAVE_SOMETHING. - * pthread.h: Likewise. - * sched.h: Likewise; PTW32_LEVEL_* becomes PTW32_SCHED_LEVEL_*. - * semaphore.h: Likewise. - -2011-05-11 Ross Johnson - - * ptw32_callUserDestroyRoutines.c (terminate): Altered includes - to match ptw32_threadStart.c. - * GNUmakefile (GCE-inlined-debug, DOPT): Fixed. - -2011-04-31 Ross Johnson - - * (robust mutexes): Added this API. The API is not - mandatory for implementations that don't support PROCESS_SHARED - mutexes, nevertheless it was considered useful both functionally - and for source-level compatibility. - -2011-03-26 Ross Johnson - - * pthread_getunique_np.c: New non-POSIX interface for compatibility - with some other implementations; returns a 64 bit sequence number - that is unique to each thread in the process. - * pthread.h (pthread_getunique_np): Added. - * global.c: Add global sequence counter for above. - * implement.h: Likewise. - -2011-03-25 Ross Johnson - - * (cancelLock): Convert to an MCS lock and rename to stateLock. - * (threadLock): Likewise. - * (keyLock): Likewise. - * pthread_mutex*.c: First working robust mutexes. - -2011-03-11 Ross Johnson - - * implement.h (PTW32_INTERLOCKED_*CREMENT macros): increment/decrement - using ++/-- instead of add/subtract 1. - * ptw32_MCS_lock.c: Make casts consistent. - -2011-03-09 Ross Johnson - - * implement.h (ptw32_thread_t_): Add process unique sequence number. - * global.c: Replace global Critical Section objects with MCS - queue locks. - * implement.h: Likewise. - * pthread_cond_destroy.c: Likewise. - * pthread_cond_init.c: Likewise. - * pthread_detach.c: Likewise. - * pthread_join.c: Likewise. - * pthread_kill.c: Likewise. - * pthread_mutex_destroy.c: Likewise. - * pthread_rwlock_destroy.c: Likewise. - * pthread_spin_destroy.c: Likewise. - * pthread_timechange_handler_np.c: Likewise. - * ptw32_cond_check_need_init.c: Likewise. - * ptw32_mutex_check_need_init.c: Likewise. - * ptw32_processInitialize.c: Likewise. - * ptw32_processTerminate.c: Likewise. - * ptw32_reuse.c: Likewise. - * ptw32_rwlock_check_need_init.c: Likewise. - * ptw32_spinlock_check_need_init.c: Likewise. - -2011-03-06 Ross Johnson - - * several (MINGW64): Cast and call fixups for 64 bit compatibility; - clean build via x86_64-w64-mingw32 cross toolchain on Linux i686 - targeting x86_64 win64. - * ptw32_threadStart.c (ptw32_threadStart): Routine no longer attempts - to pass [unexpected C++] exceptions out of scope but ends the thread - normally setting EINTR as the exit status. - * ptw32_throw.c: Fix C++ exception throwing warnings; ignore - informational warning. - * implement.h: Likewise with the corresponding header definition. - -2011-03-04 Ross Johnson - - * implement.h (PTW32_INTERLOCKED_*): Mingw32 does not provide - the __sync_* intrinsics so implemented them here as macro - assembler routines. MSVS Interlocked* are emmitted as intrinsics - wherever possible, so we want mingw to match it; Extended to - include all interlocked routines used by the library; implemented - x86_64 versions also. - * ptw32_InterlockedCompareExchange.c: No code remaining here. - * ptw32_MCS_lock.c: Converted interlocked calls to use new macros. - * pthread_barrier_wait.c: Likewise. - * pthread_once.c: Likewise. - * ptw32_MCS_lock.c (ptw32_mcs_node_substitute): Name changed to - ptw32_mcs_node_transfer. - -2011-02-28 Ross Johnson - - * ptw32_relmillisecs.c: If possible, use _ftime64_s or _ftime64 - before resorting to _ftime. - -2011-02-27 Ross Johnson - - * sched_setscheduler.c: Ensure the handle is closed after use. - * sched_getscheduler.c: Likewise. - * pthread.h: Remove POSIX compatibility macros; don't define - timespec if already defined. - * context.h: Changes for 64 bit. - * pthread_cancel.c: Likewise. - * pthread_exit.c: Likewise. - * pthread_spin_destroy.c: Likewise. - * pthread_timechange_handler_np.c: Likewise. - * ptw32_MCS_lock.c: Likewise; some of these changes may - not be compatible with pre Windows 2000 systems; reverse the order of - the includes. - * ptw32_threadStart.c: Likewise. - * ptw32_throw.c: Likewise. - -2011-02-13 Ross Johnson - - * pthread_self: Add comment re returning 'nil' value to - indicate failure only to win32 threads that call us. - * pthread_attr_setstackaddr: Fix comments; note this - function and it's compliment are now removed from SUSv4. - -2011-02-12 Ross Johnson - - README.NONPORTABLE: Record a description of an obvious - method for nulling/comparing/hashing pthread_t using a - union; plus and investigation of a change of type for - pthread_t (to a union) to neutralise any padding bits and - bytes if they occur in pthread_t (the current pthread_t struct - does not contain padding AFAIK, but porting the library to a - future architecture may introduce them). Padding affects - byte-by-byte copies and compare operations. - -2010-11-16 Ross Johnson - - * ChangeLog: Add this entry ;-) - Restore entries from 2007 through 2009 that went missing - at the last update. - -2010-06-19 Ross Johnson - - * ptw32_MCS_lock.c (ptw32_mcs_node_substitute): Fix variable - names to avoid using C++ keyword ("new"). - * implement.h (ptw32_mcs_node_substitute): Likewise. - * pthread_barrier_wait.c: Fix signed/unsigned comparison warning. - -2010-06-18 Ramiro Polla - - * autostatic.c: New file; call pthread_win32_process_*() - libary init/cleanup routines automatically on application start - when statically linked. - * pthread.c (autostatic.c): Included. - * pthread.h (declspec): Remove import/export defines if compiler - is MINGW. - * sched.h (declspec): Likewise. - * semaphore.h (declspec): Likewise. - * need_errno.h (declspec): Likewise. - * Makefile (autostatic.obj): Add for small static builds. - * GNUmakefile (autostatic.o): Likewise. - * NEWS (Version 2.9.0): Add changes. - * README.NONPORTABLE (pthread_win32_process_*): Update - description. - -2010-06-15 Ramiro Polla - - * Makefile: Remove linkage with the winsock library by default. - * GNUmakefile: Likewise. - * pthread_getspecific.c: Likewise by removing calls to WSA - functions. - * config.h (RETAIN_WSALASTERROR): Can be defined if necessary. - -2010-01-26 Ross Johnson - - * ptw32_MCS_lock.c (ptw32_mcs_node_substitute): New routine - to allow relocating the lock owners thread-local node to somewhere - else, e.g. to global space so that another thread can release the - lock. Used in pthread_barrier_wait. - (ptw32_mcs_lock_try_acquire): New routine. - * pthread_barrier_init: Only one semaphore is used now. - * pthread_barrier_wait: Added an MCS guard lock with the last thread - to leave the barrier releasing the lock. This removes a deadlock bug - observed when there are greater than barrier-count threads - attempting to cross. - * pthread_barrier_destroy: Added an MCS guard lock. - -2009-03-03 Stephan O'Farrill - - * pthread_attr_getschedpolicy.c: Add "const" to function parameter - in accordance with SUSv3 (POSIX). - * pthread_attr_getinheritsched.c: Likewise. - * pthread_mutexattr_gettype.c: Likewise. - -2008-06-06 Robert Kindred - - * ptw32_throw.c (ptw32_throw): Remove possible reference to NULL - pointer. (At the same time made the switch block conditionally - included only if exitCode is needed - RPJ.) - * pthread_testcancel.c (pthread_testcancel): Remove duplicate and - misplaced pthread_mutex_unlock(). - -2008-02-21 Sebastian Gottschalk - - * pthread_attr_getdetachstate.c (pthread_attr_getdetachstate): - Remove potential and superfluous null pointer assignment. - -2007-11-22 Ivan Pizhenko - - * pthread.h (gmtime_r): gmtime returns 0 if tm represents a time - prior to 1/1/1970. Notice this to prevent raising an exception. - * pthread.h (localtime_r): Likewise for localtime. - -2007-07-14 Marcel Ruff - - * errno.c (_errno): Fix test for pthread_self() success. - * need_errno.h: Remove unintentional line wrap from #if line. - -2007-07-14 Mike Romanchuk - - * pthread.h (timespec): Fix tv_sec type. - -2007-01-07 Sinan Kaya - - * need_errno.h: Fix declaration of _errno - the local version of - _errno() is used, e.g. by WinCE. - -2007-01-06 Ross Johnson - - * ptw32_semwait.c: Add check for invalid sem_t after acquiring the - sem_t state guard mutex and before affecting changes to sema state. - -2007-01-06 Marcel Ruff - - * error.c: Fix reference to pthread handle exitStatus member for - builds that use NEED_ERRNO (i.e. WINCE). - * context.h: Add support for ARM processor (WinCE). - * mutex.c (process.h): Exclude for WINCE. - * create.c: Likewise. - * exit.c: Likewise. - * implement.h: Likewise. - * pthread_detach.c (signal.h): Exclude for WINCE. - * pthread_join.c: Likewise. - * pthread_kill.c: Likewise. - * pthread_rwlock_init.c (errno.h): Remove - included by pthread.h. - * pthread_rwlock_destroy.c: Likewise. - * pthread_rwlock_rdlock.c: Likewise. - * pthread_rwlock_timedrdlock.c: Likewise. - * pthread_rwlock_timedwrlock.c: Likewise. - * pthread_rwlock_tryrdlock.c: Likewise. - * pthread_rwlock_trywrlock.c: likewise. - * pthread_rwlock_unlock.c: Likewise. - * pthread_rwlock_wrlock.c: Likewise. - * pthread_rwlockattr_destroy.c: Likewise. - * pthread_rwlockattr_getpshared.c: Likewise. - * pthread_rwlockattr_init.c: Likewise. - * pthread_rwlockattr_setpshared.c: Likewise. - -2007-01-06 Romano Paolo Tenca - - * pthread_cond_destroy.c: Replace sem_wait() with non-cancelable - ptw32_semwait() since pthread_cond_destroy() is not a cancelation - point. - * implement.h (ptw32_spinlock_check_need_init): Add prototype. - * ptw32_MCS_lock.c: Reverse order of includes. - -2007-01-06 Eric Berge - - * pthread_cond_destroy.c: Add LeaveCriticalSection before returning - after errors. - -2007-01-04 Ross Johnson - - * ptw32_InterlockedCompareExchange.c: Conditionally skip for - Win64 as not required. - * pthread_win32_attach_detach_np.c (pthread_win32_process_attach_np): - Test for InterlockedCompareExchange is not required for Win64. - * context.h: New file. Included by pthread_cancel.h and any tests - that need it (e.g. context1.c). - * pthread_cancel.c: Architecture-dependent context macros moved - to context.h. - -2007-01-04 Kip Streithorst - - * implement.h (PTW32_INTERLOCKED_COMPARE_EXCHANGE): Add Win64 - support. - -2006-12-20 Ross Johnson - - * sem_destroy.c: Fix the race involving invalidation of the sema; - fix incorrect return of EBUSY resulting from the mutex trylock - on the private mutex guard. - * sem_wait.c: Add check for invalid sem_t after acquiring the - sem_t state guard mutex and before affecting changes to sema state. - * sem_trywait.c: Likewise. - * sem_timedwait.c: Likewise. - * sem_getvalue.c: Likewise. - * sem_post.c: Similar. - * sem_post_multiple.c: Likewise. - * sem_init.c: Set max Win32 semaphore count to SEM_VALUE_MAX (was - _POSIX_SEM_VALUE_MAX, which is a lower value - the minimum). - - * pthread_win32_attach_detach_np.c (pthread_win32_process_attach_np): - Load COREDLL.DLL under WINCE to check existence of - InterlockedCompareExchange() routine. This used to be done to test - for TryEnterCriticalSection() but was removed when this was no - longer needed. - -2006-01-25 Prashant Thakre - - * pthread_cancel.c: Added _M_IA64 register context support. - -2005-05-13 Ross Johnson - - * pthread_kill.c (pthread_kill): Remove check for Win32 thread - priority (to confirm HANDLE validity). Useless since thread HANDLEs - a not recycle-unique. - -2005-05-30 Vladimir Kliatchko - - * pthread_once.c: Re-implement using an MCS queue-based lock. The form - of pthread_once is as proposed by Alexander Terekhov (see entry of - 2005-03-13). The MCS lock implementation does not require a unique - 'name' to identify the lock between threads. Attempts to get the Event - or Semaphore based versions of pthread_once to a satisfactory level - of robustness have thus far failed. The last problem (avoiding races - involving non recycle-unique Win32 HANDLEs) was giving everyone - grey hair trying to solve it. - - * ptw32_MCS_lock.c: New MCS queue-based lock implementation. These - locks are efficient: they have very low overhead in the uncontended case; - are efficient in contention and minimise cache-coherence updates in - managing the user level FIFO queue; do not require an ABI change in the - library. - -2005-05-27 Alexander Gottwald - - * pthread.h: Some things, like HANDLE, were only defined if - PTW32_LEVEL was >= 3. They should always be defined. - -2005-05-25 Vladimir Kliatchko - - * pthread_once.c: Eliminate all priority operations and other - complexity by replacing the event with a semaphore. The advantage - of the change is the ability to release just one waiter if the - init_routine thread is cancelled yet still release all waiters when - done. Simplify once_control state checks to improve efficiency - further. - -2005-05-24 Mikael Magnusson - - * GNUmakefile: Patched to allow cross-compile with mingw32 on Linux. - It uses macros instead of referencing dlltool, gcc and g++ directly; - added a call to ranlib. For example the GC static library can be - built with: - make CC=i586-mingw32msvc-gcc RC=i586-mingw32msvc-windres \ - RANLIB=i586-mingw32msvc-ranlib clean GC-static - -2005-05-13 Ross Johnson - - * pthread_win32_attach_detach_np.c (pthread_win32_thread_detach_np): - Move on-exit-only stuff from ptw32_threadDestroy() to here. - * ptw32_threadDestroy.c: It's purpose is now only to reclaim thread - resources for detached threads, or via pthread_join() or - pthread_detach() on joinable threads. - * ptw32_threadStart.c: Calling user destruct routines has moved to - pthread_win32_thread_detach_np(); call pthread_win32_thread_detach_np() - directly if statically linking, otherwise do so via dllMain; store - thread return value in thread struct for all cases, including - cancellation and exception exits; thread abnormal exits go via - pthread_win32_thread_detach_np. - * pthread_join.c (pthread_join): Don't try to get return code from - Win32 thread - always get it from he thread struct. - * pthread_detach.c (pthread_detach): reduce extent of the thread - existence check since we now don't care if the Win32 thread HANDLE has - been closed; reclaim thread resources if the thread has exited already. - * ptw32_throw.c (ptw32_throw): For Win32 threads that are not implicit, - only Call thread cleanup if statically linking, otherwise leave it to - dllMain. - * sem_post.c (_POSIX_SEM_VALUE_MAX): Change to SEM_VALUE_MAX. - * sem_post_multiple.c: Likewise. - * sem_init.c: Likewise. - -2005-05-10 Ross Johnson - - * pthread_join.c (pthread_join): Add missing check for thread ID - reference count in thread existence test; reduce extent of the - existence test since we don't care if the Win32 thread HANDLE has - been closed. - -2005-05-09 Ross Johnson - - * ptw32_callUserDestroyRoutines.c: Run destructor process (i.e. - loop over all keys calling destructors) up to - PTHREAD_DESTRUCTOR_ITERATIONS times if TSD value isn't NULL yet; - modify assoc management. - * pthread_key_delete.c: Modify assoc management. - * ptw32_tkAssocDestroy.c: Fix error in assoc removal from chains. - * pthread.h - (_POSIX_THREAD_DESTRUCTOR_ITERATIONS): Define to value specified by - POSIX. - (_POSIX_THREAD_KEYS_MAX): Define to value specified by POSIX. - (PTHREAD_KEYS_MAX): Redefine [upward] to minimum required by POSIX. - (SEM_NSEMS_MAX): Define to implementation value. - (SEM_VALUE_MAX): Define to implementation value. - (_POSIX_SEM_NSEMS_MAX): Redefine to value specified by POSIX. - (_POSIX_SEM_VALUE_MAX): Redefine to value specified by POSIX. - -2005-05-06 Ross Johnson - - * signal.c (sigwait): Add a cancellation point to this otherwise - no-op. - * sem_init.c (sem_init): Check for and return ERANGE error. - * sem_post.c (sem_post): Likewise. - * sem_post_multiple.c (sem_post_multiple): Likewise. - * manual (directory): Added; see ChangeLog inside. - -2005-05-02 Ross Johnson - - * implement.h (struct pthread_key_t_): Change threadsLock to keyLock - so as not to be confused with the per thread lock 'threadlock'; - change all references to it. - * implement.h (struct ThreadKeyAssoc): Remove lock; add prevKey - and prevThread pointers; re-implemented all routines that use this - struct. The effect of this is to save one handle per association, - which could potentially equal the number of keys multiplied by the - number of threads, accumulating over time - and to free the - association memory as soon as it is no longer referenced by either - the key or the thread. Previously, the handle and memory were - released only after BOTH key and thread no longer referenced the - association. That is, often no association resources were released - until the process itself exited. In addition, at least one race - condition has been removed - where two threads could attempt to - release the association resources simultaneously - one via - ptw32_callUserDestroyRoutines and the other via - pthread_key_delete. - - thanks to Richard Hughes at Aculab for discovering the problem. - * pthread_key_create.c: See above. - * pthread_key_delete.c: See above. - * pthread_setspecific.c: See above. - * ptw32_callUserDestroyRoutines.c: See above. - * ptw32_tkAssocCreate.c: See above. - * ptw32_tkAssocDestroy.c: See above. - -2005-04-27 Ross Johnson - - * sem_wait.c (ptw32_sem_wait_cleanup): after cancellation re-attempt - to acquire the semaphore to avoid a race with a late sem_post. - * sem_timedwait.c: Modify comments. - -2005-04-25 Ross Johnson - - * ptw32_relmillisecs.c: New module; converts future abstime to - milliseconds relative to 'now'. - * pthread_mutex_timedlock.c: Use new ptw32_relmillisecs routine in - place of internal code; remove the NEED_SEM code - this routine is now - implemented for builds that define NEED_SEM (WinCE etc) - * sem_timedwait.c: Likewise; after timeout or cancellation, - re-attempt to acquire the semaphore in case one has been posted since - the timeout/cancel occurred. Thanks to Stefan Mueller. - * Makefile: Add ptw32_relmillisecs.c module; remove - ptw32_{in,de}crease_semaphore.c modules. - * GNUmakefile: Likewise. - * Bmakefile: Likewise. - - * sem_init.c: Re-write the NEED_SEM code to be consistent with the - non-NEED_SEM code, but retaining use of an event in place of the w32 sema - for w32 systems that don't include semaphores (WinCE); - the NEED_SEM versions of semaphores has been broken for a long time but is - now fixed and supports all of the same routines as the non-NEED_SEM case. - * sem_destroy.c: Likewise. - * sem_wait.c: Likewise. - * sem_post.c: Likewise. - * sem_post_multple.c: Likewise. - * implement.h: Likewise. - * sem_timedwait.c: Likewise; this routine is now - implemented for builds that define NEED_SEM (WinCE etc). - * sem_trywait.c: Likewise. - * sem_getvalue.c: Likewise. - - * pthread_once.c: Yet more changes, reverting closer to Gottlob Frege's - first design, but retaining cancellation, priority boosting, and adding - preservation of W32 error codes to make pthread_once transparent to - GetLastError. - -2005-04-11 Ross Johnson - - * pthread_once.c (pthread_once): Added priority boosting to - solve starvation problem after once_routine cancellation. - See notes in file. - -2005-04-06 Kevin Lussier - - * Makefile: Added debug targets for all versions of the library. - -2005-04-01 Ross Johnson - - * GNUmakefile: Add target to build libpthreadGC1.a as a static link - library. - * Makefile: Likewise for pthreadGC1.lib. - -2005-04-01 Kevin Lussier - - * sem_timedwait.c (sem_timedwait): Increase size of temp variables to - avoid int overflows for large timeout values. - * implement.h (int64_t): Include or define. - -2005-03-31 Dimitar Panayotov ^M - - * pthread.h: Fix conditional defines for static linking. - * sched.h: Liekwise. - * semaphore.h: Likewise. - * dll.c (PTW32_STATIC_LIB): Module is conditionally included - in the build. - -2005-03-16 Ross Johnson ^M - - * pthread_setcancelstate.c: Undo the last change. - -2005-03-16 Ross Johnson ^M - - * pthread_setcancelstate.c: Don't check for an async cancel event - if the library is using alertable async cancel.. - -2005-03-14 Ross Johnson - - * pthread_once.c (pthread_once): Downgrade interlocked operations to simple - memory operations where these are protected by the critical section; edit - comments. - -2005-03-13 Ross Johnson - - * pthread_once.c (pthread_once): Completely redesigned; a change was - required to the ABI (pthread_once_t_), and resulting in a version - compatibility index increment. - - NOTES: - The design (based on pseudo code contributed by Gottlob Frege) avoids - creating a kernel object if there is no contention. See URL for details:- - http://sources.redhat.com/ml/pthreads-win32/2005/msg00029.html - 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 - 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 - design because it is able to mark the event as closed (forever). - - When uncontested, a CS operation is equivalent to an Interlocked operation - in speed. So, in the final design with cancelability, an uncontested - once_control operation involves a minimum of five interlocked operations - (including the LeaveCS operation). - - ALTERNATIVES: - An alternative design from Alexander Terekhov proposed using a named mutex, - as sketched below:- - - if (!once_control) { // May be in TLS - named_mutex::guard guard(&once_control2); - if (!once_control2) { - - once_control2 = true; - } - once_control = true; - } - - A more detailed description of this can be found here:- - http://groups.yahoo.com/group/boost/message/15442 - - [Although the definition of a suitable PTHREAD_ONCE_INIT precludes use of the - TLS located flag, this is not critical.] - - There are three primary concerns though:- - 1) The [named] mutex is 'created' even in the uncontended case. - 2) A system wide unique name must be generated. - 3) Win32 mutexes are VERY slow even in the uncontended case. An uncontested - Win32 mutex lock operation can be 50 (or more) times slower than an - uncontested EnterCS operation. - - Ultimately, the named mutex trick is making use of the global locks maintained - by the kernel. - - * pthread.h (pthread_once_t_): One flag and an event HANDLE added. - (PTHREAD_ONCE_INIT): Additional values included. - -2005-03-08 Ross Johnson - - * pthread_once.c (pthread_once): Redesigned to elliminate potential - starvation problem. - - reported by Gottlob Frege - - * ptw32_threadDestroy.c (ptw32_threadDestroy): Implicit threads were - not closing their Win32 thread duplicate handle. - - reported by Dmitrii Semii - -2005-01-25 Ralf Kubis - - * Attempted acquisition of recursive mutex was causing waiting - threads to not be woken when the mutex is released. - - * GNUmakefile (GCE): Generate correct version resource comments. - -2005-01-01 Konstantin Voronkov - - * pthread_mutex_lock.c (pthread_mutex_lock): The new atomic exchange - mutex algorithm is known to allow a thread to steal the lock off - FIFO waiting threads. The next waiting FIFO thread gets a spurious - wake-up and must attempt to re-acquire the lock. The woken thread - was setting itself as the mutex's owner before the re-acquisition. - -2004-11-22 Ross Johnson - - * pthread_cond_wait.c (ptw32_cond_wait_cleanup): Undo change - from 2004-11-02. - * Makefile (DLL_VER): Added for DLL naming suffix - see README. - * GNUmakefile (DLL_VER): Likewise. - * Wmakefile (DLL_VER): Likewise. - * Bmakefile (DLL_VER): Likewise. - * pthread.dsw (version.rc): Added to MSVS workspace. - -2004-11-20 Boudewijn Dekker - - * pthread_getspecific.c (pthread_getspecific): Check for - invalid (NULL) key argument. - -2004-11-19 Ross Johnson - - * config.h (PTW32_THREAD_ID_REUSE_INCREMENT): Added to allow - building the library for either unique thread IDs like Solaris - or non-unique thread IDs like Linux; allows application developers - to override the library's default insensitivity to some apps - that may not be strictly POSIX compliant. - * version.rc: New resource module to encode version information - within the DLL. - * pthread.h: Added PTW32_VERSION* defines and grouped sections - required by resource compiler together; bulk of file is skipped - if RC_INVOKED. Defined some error numbers and other names for - Borland compiler. - -2004-11-02 Ross Johnson - - * pthread_cond_wait.c (ptw32_cond_wait_cleanup): Lock CV mutex at - start of cleanup handler rather than at the end. - * implement.h (PTW32_THREAD_REUSE_EMPTY): Renamed from *_BOTTOM. - (ptw32_threadReuseBottom): New global variable. - * global.c (ptw32_threadReuseBottom): Declare new variable. - * ptw32_reuse.c (ptw32_reuse): Change reuse LIFO stack to LILO queue - to more evenly distribute use of reusable thread IDs; use renamed - PTW32_THREAD_REUSE_EMPTY. - * ptw32_processTerminate.c (ptw2_processTerminate): Use renamed - PTW32_THREAD_REUSE_EMPTY. - -2004-10-31 Ross Johnson - - * implement.h (PThreadState): Add new state value - 'PThreadStateCancelPending'. - * pthread_testcancel.c (pthread_testcancel): Use new thread - '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() - 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 - 'PThreadStateCancelPending' state. - -2004-10-29 Ross Johnson - - * implement.h (pthread_t): Renamed to ptw32_thread_t; struct contains - all thread state. - * pthread.h (ptw32_handle_t): New general purpose struct to serve - as a handle for various reusable object IDs - currently only used - by pthread_t; contains a pointer to ptw32_thread_t (thread state) - and a general purpose uint for use as a reuse counter or flags etc. - (pthread_t): typedef'ed to ptw32_handle_t; the uint is the reuse - counter that allows the library to maintain unique POSIX thread IDs. - When the pthread struct reuse stack was introduced, threads would - often acquire an identical ID to a previously destroyed thread. The - same was true for the pre-reuse stack library, by virtue of pthread_t - 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. - * sem_timedwait.c (ptw32_sem_timedwait_cleanup): Likewise. - -2004-10-22 Ross Johnson - - * sem_init.c (sem_init): Introduce a 'lock' element in order to - replace the interlocked operations with conventional serialisation. - This is needed in order to be able to atomically modify the sema - value and perform Win32 sema release operations. Win32 semaphores are - used instead of events in order to support efficient multiple posting. - If the whole modify/release isn't atomic, a race between - sem_timedwait() and sem_post() could result in a release when there is - no waiting semaphore, which would cause too many threads to proceed. - * sem_wait.c (sem_wait): Use new 'lock'element. - * sem_timedwait.c (sem_timedwait): Likewise. - * sem_trywait.c (sem_trywait): Likewise. - * sem_post.c (sem_post): Likewise. - * sem_post_multiple.c (sem_post_multiple): Likewise. - * sem_getvalue.c (sem_getvalue): Likewise. - * ptw32_semwait.c (ptw32_semwait): Likewise. - * sem_destroy.c (sem_destroy): Likewise; also tightened the conditions - for semaphore destruction; in particular, a semaphore will not be - destroyed if it has waiters. - * sem_timedwait.c (sem_timedwait): Added cancel cleanup handler to - restore sema value when cancelled. - * sem_wait.c (sem_wait): Likewise. - -2004-10-21 Ross Johnson - - * pthread_mutex_unlock.c (pthread_mutex_unlock): Must use PulseEvent() - rather than SetEvent() to reset the event if there are no waiters. - -2004-10-19 Ross Johnson - - * sem_init.c (sem_init): New semaphore model based on the same idea - as mutexes, i.e. user space interlocked check to avoid - unnecessarily entering kernel space. Wraps the Win32 semaphore and - 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 - 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 - 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. - * sem_post.c (sem_post): Likewise. - * sem_trywait.c (sem_trywait): Likewise. - * sem_timedwait.c (sem_timedwait): Likewise. - * sem_post_multiple.c (sem_post_multiple): Likewise. - * sem_getvalue.c (sem_getvalue): Likewise. - * ptw32_semwait.c (ptw32_semwait): Likewise. - * implement.h (sem_t_): Add counter element. - -2004-10-15 Ross Johnson - - * implement.h (pthread_mutex_t_): Use an event in place of - the POSIX semaphore. - * pthread_mutex_init.c: Create the event; remove semaphore init. - * pthread_mutex_destroy.c: Delete the event. - * pthread_mutex_lock.c: Replace the semaphore wait with the event wait. - * pthread_mutex_trylock.c: Likewise. - * pthread_mutex_timedlock.c: Likewise. - * pthread_mutex_unlock.c: Set the event. - -2004-10-14 Ross Johnson - - * pthread_mutex_lock.c (pthread_mutex_lock): New algorithm using - Terekhov's xchg based variation of Drepper's cmpxchg model. - Theoretically, xchg uses fewer clock cycles than cmpxchg (using IA-32 - as a reference), however, in my opinion bus locking dominates the - equation on smp systems, so the model with the least number of bus - lock operations in the execution path should win, which is Terekhov's - variant. On IA-32 uni-processor systems, it's faster to use the - CMPXCHG instruction without locking the bus than to use the XCHG - instruction, which always locks the bus. This makes the two variants - equal for the non-contended lock (fast lane) execution path on up - IA-32. Testing shows that the xchg variant is faster on up IA-32 as - well if the test forces higher lock contention frequency, even though - kernel calls should be dominating the times (on up IA-32, both - variants used CMPXCHG instructions and neither locked the bus). - * pthread_mutex_timedlock.c pthread_mutex_timedlock(): Similarly. - * pthread_mutex_trylock.c (pthread_mutex_trylock): Similarly. - * pthread_mutex_unlock.c (pthread_mutex_unlock): Similarly. - * ptw32_InterlockedCompareExchange.c (ptw32_InterlockExchange): New - function. - (PTW32_INTERLOCKED_EXCHANGE): Sets up macro to use inlined - ptw32_InterlockedExchange. - * implement.h (PTW32_INTERLOCKED_EXCHANGE): Set default to - InterlockedExchange(). - * Makefile: Building using /Ob2 so that asm sections within inline - functions are inlined. - -2004-10-08 Ross Johnson - - * pthread_mutex_destroy.c (pthread_mutex_destroy): Critical Section - element is no longer required. - * pthread_mutex_init.c (pthread_mutex_init): Likewise. - * pthread_mutex_lock.c (pthread_mutex_lock): New algorithm following - Drepper's paper at http://people.redhat.com/drepper/futex.pdf, but - using the existing semaphore in place of the futex described in the - paper. Idea suggested by Alexander Terekhov - see: - http://sources.redhat.com/ml/pthreads-win32/2003/msg00108.html - * pthread_mutex_timedlock.c pthread_mutex_timedlock(): Similarly. - * pthread_mutex_trylock.c (pthread_mutex_trylock): Similarly. - * pthread_mutex_unlock.c (pthread_mutex_unlock): Similarly. - * pthread_barrier_wait.c (pthread_barrier_wait): Use inlined version - of InterlockedCompareExchange() if possible - determined at - build-time. - * pthread_spin_destroy.c pthread_spin_destroy(): Likewise. - * pthread_spin_lock.c pthread_spin_lock():Likewise. - * pthread_spin_trylock.c (pthread_spin_trylock):Likewise. - * pthread_spin_unlock.c (pthread_spin_unlock):Likewise. - * ptw32_InterlockedCompareExchange.c: Sets up macro for inlined use. - * implement.h (pthread_mutex_t_): Remove Critical Section element. - (PTW32_INTERLOCKED_COMPARE_EXCHANGE): Set to default non-inlined - version of InterlockedCompareExchange(). - * private.c: Include ptw32_InterlockedCompareExchange.c first for - inlining. - * GNUmakefile: Add commandline option to use inlined - InterlockedCompareExchange(). - * Makefile: Likewise. - -2004-09-27 Ross Johnson - - * pthread_mutex_lock.c (pthread_mutex_lock): Separate - PTHREAD_MUTEX_NORMAL logic since we do not need to keep or check some - state required by other mutex types; do not check mutex pointer arg - for validity - leave this to the system since we are only checking - for NULL pointers. This should improve speed of NORMAL mutexes and - marginally improve speed of other type. - * pthread_mutex_trylock.c (pthread_mutex_trylock): Likewise. - * pthread_mutex_unlock.c (pthread_mutex_unlock): Likewise; also avoid - entering the critical section for the no-waiters case, with approx. - 30% reduction in lock/unlock overhead for this case. - * pthread_mutex_timedlock.c (pthread_mutex_timedlock): Likewise; also - no longer keeps mutex if post-timeout second attempt succeeds - this - will assist applications that wish to impose strict lock deadlines, - rather than simply to escape from frozen locks. - -2004-09-09 Tristan Savatier - * pthread.h (struct pthread_once_t_): Qualify the 'done' element - as 'volatile'. - * pthread_once.c: Concerned about possible race condition, - specifically on MPU systems re concurrent access to multibyte types. - [Maintainer's note: the race condition is harmless on SPU systems - and only a problem on MPU systems if concurrent access results in an - exception (presumably generated by a hardware interrupt). There are - other instances of similar harmless race conditions that have not - been identified as issues.] - -2004-09-09 Ross Johnson - - * pthread.h: Declare additional types as volatile. - -2004-08-27 Ross Johnson - - * pthread_barrier_wait.c (pthread_barrier_wait): Remove excessive code - by substituting the internal non-cancelable version of sem_wait - (ptw32_semwait). - -2004-08-25 Ross Johnson - - * pthread_join.c (pthread_join): Rewrite and re-order the conditional - tests in an attempt to improve efficiency and remove a race - condition. - -2004-08-23 Ross Johnson - - * create.c (pthread_create): Don't create a thread if the thread - id pointer location (first arg) is inaccessible. A memory - protection fault will result if the thread id arg isn't an accessible - location. This is consistent with GNU/Linux but different to - Solaris or MKS (and possibly others), which accept NULL as meaning - 'don't return the created thread's ID'. Applications that run - using pthreads-win32 will run on all other POSIX threads - implementations, at least w.r.t. this feature. - - It was decided not to copy the Solaris et al behaviour because, - although it would have simplified some application porting (but only - from Solaris to Windows), the feature is not technically necessary, - and the alternative segfault behaviour helps avoid buggy application - code. - -2004-07-01 Anuj Goyal - - * builddmc.bat: New; Windows bat file to build the library. - * config.h (__DMC__): Support for Digital Mars compiler. - * create.c (__DMC__): Likewise. - * pthread_exit.c (__DMC__): Likewise. - * pthread_join.c (__DMC__): Likewise. - * ptw32_threadDestroy.c (__DMC__): Likewise. - * ptw32_threadStart.c (__DMC__): Likewise. - * ptw32_throw.c (__DMC__): Likewise. - -2004-06-29 Anuj Goyal - - * pthread.h (__DMC__): Initial support for Digital Mars compiler. - -2004-06-29 Will Bryant - - * README.Borland: New; description of Borland changes. - * Bmakefile: New makefile for the Borland make utility. - * ptw32_InterlockedCompareExchange.c: - Add Borland compatible asm code. - -2004-06-26 Jason Bard - - * pthread.h (HAVE_STRUCT_TIMESPEC): If undefined, define it - to avoid timespec struct redefined errors elsewhere in an - application. - -2004-06-21 Ross Johnson - - * pthread.h (PTHREAD_RECURSIVE_MUTEX_INITIALIZER): Mutex - initialiser added for compatibility with Linux threads and - others; currently not included in SUSV3. - * pthread.h (PTHREAD_ERRORCHECK_MUTEX_INITIALIZER): Likewise. - * pthread.h (PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP): Likewise. - * pthread.h (PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP): Likewise. - - * ptw32_mutex_check_need_init.c (ptw32_mutex_check_need_init): - Add new initialisers. - - * pthread_mutex_lock.c (pthread_mutex_lock): Check for new - initialisers. - * pthread_mutex_trylock.c (pthread_mutex_trylock): Likewise. - * pthread_mutex_timedlock.c (pthread_mutex_timedlock): Likewise. - * pthread_mutex_unlock.c (pthread_mutex_unlock): Likewise. - * pthread_mutex_destroy.c (pthread_mutex_destroy): Likewise. - -2004-05-20 Ross Johnson - - * README.NONPORTABLE: Document pthread_win32_test_features_np(). - * FAQ: Update various answers. - -2004-05-19 Ross Johnson - - * Makefile: Don't define _WIN32_WINNT on compiler command line. - * GNUmakefile: Likewise. - -2004-05-16 Ross Johnson - - * pthread_cancel.c (pthread_cancel): Adapted to use auto-detected - QueueUserAPCEx features at run-time. - (ptw32_RegisterCancelation): Drop in replacement for QueueUserAPCEx() - if it can't be used. Provides older style non-preemptive async - cancelation. - * 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 - possible. - * implement.h: Add definitions and prototypes related to QueueUserAPC. - -2004-05-16 Panagiotis E. Hadjidoukas - - * QueueUserAPCEx (separate contributed package): Provides preemptive - 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. - -2004-05-06 Makoto Kato - - * pthread.h (DWORD_PTR): Define typedef for older MSVC. - * pthread_cancel.c (AMD64): Add architecture specific Context register. - * ptw32_getprocessors.c: Use correct types (DWORD_PTR) for mask - variables. - -2004-04-06 P. van Bruggen - - * ptw32_threadDestroy.c: Destroy threadLock mutex to - close a memory leak. - -2004-02-13 Gustav Hallberg - - * pthread_equal.c: Remove redundant equality logic. - -2003-12-10 Philippe Di Cristo - - * sem_timedwait.c (sem_timedwait): Fix timeout calculations. - -2003-10-20 Alexander Terekhov - - * pthread_mutex_timedlock.c (ptw32_semwait): Move to individual module. - * ptw32_semwait.c: New module. - * pthread_cond_wait.c (ptw32_cond_wait_cleanup): Replace cancelable - sem_wait() call with non-cancelable ptw32_semwait() call. - * pthread.c (private.c): Re-order for inlining. GNU C warned that - function ptw32_semwait() was defined 'inline' after it was called. - * pthread_cond_signal.c (ptw32_cond_unblock): Likewise. - * pthread_delay_np.c: Disable Watcom warning with comment. - * *.c (process.h): Remove include from .c files. This is conditionally - included by the common project include files. - -2003-10-20 James Ewing - - * ptw32_getprocessors.c: Some Win32 environments don't have - GetProcessAffinityMask(), so always return CPU count = 1 for them. - * config.h (NEED_PROCESSOR_AFFINITY_MASK): Define for WinCE. - -2003-10-15 Ross Johnson - - * Re-indented all .c files using default GNU style to remove assorted - editor ugliness (used GNU indent utility in default style). - -2003-10-15 Alex Blanco - - * sem_init.c (sem_init): Would call CreateSemaphore even if the sema - struct calloc failed; was not freeing calloced memory if either - CreateSemaphore or CreateEvent failed. - -2003-10-14 Ross Johnson - - * pthread.h: Add Watcom compiler compatibility. Esssentially just add - the cdecl attribute to all exposed function prototypes so that Watcom - generates function call code compatible with non-Watcom built libraries. - By default, Watcom uses registers to pass function args if possible rather - than pushing to stack. - * semaphore.h: Likewise. - * sched.h: Likewise. - * pthread_cond_wait.c (ptw32_cond_wait_cleanup): Define with cdecl attribute - for Watcom compatibility. This routine is called via pthread_cleanup_push so - it had to match function arg definition. - * Wmakefile: New makefile for Watcom builds. - -2003-09-14 Ross Johnson - - * pthread_setschedparam.c (pthread_setschedparam): Attempt to map - all priority levels between max and min (as returned by - sched_get_priority_min/max) to reasonable Win32 priority levels - i.e. - levels between THREAD_PRIORITY_LOWEST/IDLE to THREAD_PRIORITY_LOWEST and - between THREAD_PRIORITY_HIGHEST/TIME_CRITICAL to THREAD_PRIORITY_HIGHEST - while others remain unchanged; record specified thread priority level - for return by pthread_getschedparam. - - Note that, previously, specified levels not matching Win32 priority levels - would silently leave the current thread priority unaltered. - - * pthread_getschedparam.c (pthread_getschedparam): Return the priority - level specified by the latest pthread_setschedparam or pthread_create rather - than the actual running thread priority as returned by GetThreadPriority - as - required by POSIX. I.e. temporary or adjusted actual priority levels are not - returned by this routine. - - * pthread_create.c (pthread_create): For priority levels specified via - pthread attributes, attempt to map all priority levels between max and - min (as returned by sched_get_priority_min/max) to reasonable Win32 - priority levels; record priority level given via attributes, or - inherited from parent thread, for later return by pthread_getschedparam. - - * ptw32_new.c (ptw32_new): Initialise pthread_t_ sched_priority element. - - * pthread_self.c (pthread_self): Set newly created implicit POSIX thread - sched_priority to Win32 thread's current actual priority. Temporarily - altered priorities can't be avoided in this case. - - * implement.h (struct pthread_t_): Add new sched_priority element. - -2003-09-12 Ross Johnson - - * sched_get_priority_min.c (sched_get_priority_min): On error should return -1 - with errno set. - * sched_get_priority_max.c (sched_get_priority_max): Likewise. - -2003-09-03 Ross Johnson - - * w32_cancelableWait.c (ptw32_cancelable_wait): Allow cancelation - of implicit POSIX threads as well. - -2003-09-02 Ross Johnson - - * pthread_win32_attach_detach_np.c (pthread_win32_thread_detach_np): - Add comment. - - * pthread_exit.c (pthread_exit): Fix to recycle the POSIX thread handle in - addition to calling user TSD destructors. Move the implicit POSIX thread exit - handling to ptw32_throw to centralise the logic. - - * ptw32_throw.c (ptw32_throw): Implicit POSIX threads have no point - to jump or throw to, so cleanup and exit the thread here in this case. For - processes using the C runtime, the exit code will be set to the POSIX - reason for the throw (i.e. PTHREAD_CANCEL or the value given to pthread_exit). - Note that pthread_exit() already had similar logic, which has been moved to - here. - - * ptw32_threadDestroy.c (ptw32_threadDestroy): Don't close the Win32 handle - of implicit POSIX threads - expect this to be done by Win32? - -2003-09-01 Ross Johnson - - * pthread_self.c (pthread_self): The newly aquired pthread_t must be - assigned to the reuse stack, not freed, if the routine fails somehow. - -2003-08-13 Ross Johnson - - * pthread_getschedparam.c (pthread_getschedparam): An invalid thread ID - parameter was returning an incorrect error value; now uses a more exhaustive - check for validity. - - * pthread_setschedparam.c (pthread_setschedparam): Likewise. - - * pthread_join.c (pthread_join): Now uses a more exhaustive - check for validity. - - * pthread_detach.c (pthread_detach): Likewise. - - * pthread_cancel.c (pthread_cancel): Likewise. - - * ptw32_threadDestroy.c (ptw32_threadDestroy): pthread_t structs are - never freed - push them onto a stack for reuse. - - * ptw32_new.c (ptw32_new): Check for reusable pthread_t before dynamically - allocating new memory for the struct. - - * pthread_kill.c (pthread_kill): New file; new routine; takes only a zero - signal arg so that applications can check the thread arg for validity; checks - that the underlying Win32 thread HANDLE is valid. - - * pthread.h (pthread_kill): Add prototype. - - * ptw32_reuse.c (ptw32_threadReusePop): New file; new routine; pop a - pthread_t off the reuse stack. pthread_t_ structs that have been destroyed, i.e. - have exited detached or have been joined, are cleaned up and put onto a reuse - stack. Consequently, thread IDs are no longer freed once calloced. The library - will attempt to get a struct off this stack before asking the system to alloc - new memory when creating threads. The stack is guarded by a global mutex. - (ptw32_threadReusePush): New routine; push a pthread_t onto the reuse stack. - - * implement.h (ptw32_threadReusePush): Add new prototype. - (ptw32_threadReusePop): Likewise. - (pthread_t): Add new element. - - * ptw32_processTerminate.c (ptw32_processTerminate): Delete the thread - reuse lock; free all thread ID structs on the thread reuse stack. - - * ptw32_processInitialize.c (ptw32_processInitialize): Initialise the - thread reuse lock. - -2003-07-19 Ross Johnson - - * GNUmakefile: modified to work under MsysDTK environment. - * pthread_spin_lock.c (pthread_spin_lock): Check for NULL arg. - * pthread_spin_unlock.c (pthread_spin_unlock): Likewise. - * pthread_spin_trylock.c (pthread_spin_trylock): Likewise; - fix incorrect pointer value if lock is dynamically initialised by - this function. - * sem_init.c (sem_init): Initialise sem_t value to quell compiler warning. - * sem_destroy.c (sem_destroy): Likewise. - * ptw32_threadStart.c (non-MSVC code sections): Include rather - than old-style ; fix all std:: namespace entities such as - std::terminate_handler instances and associated methods. - * ptw32_callUserDestroyRoutines.c (non-MSVC code sections): Likewise. - -2003-06-24 Piet van Bruggen - - * pthread_spin_destroy.c (pthread_spin_destroy): Was not freeing the - spinlock struct. - -2003-06-22 Nicolas Barry - - * pthread_mutex_destroy.c (pthread_mutex_destroy): When called - with a recursive mutex that was locked by the current thread, the - function was failing with a success return code. - -2003-05-15 Steven Reddie - - * pthread_win32_attach_detach_np.c (pthread_win32_process_detach_np): - NULLify ptw32_selfThreadKey after the thread is destroyed, otherwise - destructors calling pthreads routines might resurrect it again, creating - memory leaks. Call the underlying Win32 Tls routine directly rather than - pthread_setspecific(). - (pthread_win32_thread_detach_np): Likewise. - -2003-05-14 Viv - - * pthread.dsp: Change /MT compile flag to /MD. - -2003-03-04 Alexander Terekhov - - * pthread_mutex_timedlock.c (pthread_mutex_timedlock): Fix failure to - set ownership of mutex on second grab after abstime timeout. - - bug reported by Robert Strycek - -2002-12-17 Thomas Pfaff - - * pthread_mutex_lock.c (ptw32_semwait): New static routine to provide - a non-cancelable sem_wait() function. This is consistent with the - way that pthread_mutex_timedlock.c does it. - (pthread_mutex_lock): Use ptw32_semwait() instead of sem_wait(). - -2002-12-11 Thomas Pfaff - - * pthread_mutex_trylock.c: Should return EBUSY rather than EDEADLK. - * pthread_mutex_destroy.c: Remove redundant ownership test (the - trylock call does this for us); do not destroy a recursively locked - mutex. - -2002-09-20 Michael Johnson - - * pthread_cond_destroy.c (pthread_cond_destroy): - When two different threads exist, and one is attempting to - destroy a condition variable while the other is attempting to - initialize a condition variable that was created with - PTHREAD_COND_INITIALIZER, a deadlock can occur. Shrink - the ptw32_cond_list_lock critical section to fix it. - -2002-07-31 Ross Johnson - - * ptw32_threadStart.c (ptw32_threadStart): Thread cancelLock - destruction moved to ptw32_threadDestroy(). - - * ptw32_threadDestroy.c (ptw32_threadDestroy): Destroy - the thread's cancelLock. Moved here from ptw32_threadStart.c - to cleanup implicit threads as well. - -2002-07-30 Alexander Terekhov - - * pthread_cond_wait.c (ptw32_cond_wait_cleanup): - Remove code designed to avoid/prevent spurious wakeup - problems. It is believed that the sem_timedwait() call - is consuming a CV signal that it shouldn't and this is - breaking the avoidance logic. - -2002-07-30 Ross Johnson - - * sem_timedwait.c (sem_timedwait): Tighten checks for - unreasonable abstime values - that would result in - unexpected timeout values. - - * w32_CancelableWait.c (ptw32_cancelable_wait): - Tighten up return value checking and add comments. - - -2002-06-08 Ross Johnson - - * sem_getvalue.c (sem_getvalue): Now returns a value for the - NEED_SEM version (i.e. earlier versions of WinCE). - - -2002-06-04 Rob Fanner - - * sem_getvalue.c (sem_getvalue): The Johnson M. Hart - approach didn't work - we are forced to take an - intrusive approach. We try to decrement the sema - and then immediately release it again to get the - value. There is a small probability that this may - block other threads, but only momentarily. - -2002-06-03 Ross Johnson - - * sem_init.c (sem_init): Initialise Win32 semaphores - to _POSIX_SEM_VALUE_MAX (which this implementation - defines in pthread.h) so that sem_getvalue() can use - the trick described in the comments in sem_getvalue(). - * pthread.h (_POSIX_SEM_VALUE_MAX): Defined. - (_POSIX_SEM_NSEMS_MAX): Defined - not used but may be - useful for source code portability. - -2002-06-03 Rob Fanner - - * sem_getvalue.c (sem_getvalue): Did not work on NT. - Use approach suggested by Johnson M. Hart in his book - "Win32 System Programming". - -2002-02-28 Ross Johnson - - * errno.c: Compiler directive was incorrectly including code. - * pthread.h: Conditionally added some #defines from config.h - needed when not building the library. e.g. NEED_ERRNO, NEED_SEM. - (PTW32_DLLPORT): Now only defined if _DLL defined. - (_errno): Compiler directive was incorrectly including prototype. - * sched.h: Conditionally added some #defines from config.h - needed when not building the library. - * semaphore.h: Replace an instance of NEED_SEM that should - have been NEED_ERRNO. This change currently has nil effect. - - * GNUmakefile: Correct some recent changes. - - * Makefile: Add rule to generate pre-processor output. - -2002-02-23 Ross Johnson - - * pthread_rwlock_timedrdlock.c: New - untested. - * pthread_rwlock_timedwrlock.c: New - untested. - - * Testsuite passed (except known MSVC++ problems) - - * pthread_cond_destroy.c: Expand the time change - critical section to solve deadlock problem. - - * pthread.c: Add all remaining C modules. - * pthread.h: Use dllexport/dllimport attributes on functions - to avoid using pthread.def. - * sched.h: Likewise. - * semaphore.h: Likewise. - * GNUmakefile: Add new targets for single translation - unit build to maximise inlining potential; generate - pthread.def automatically. - * Makefile: Likewise, but no longer uses pthread.def. - -2002-02-20 Ross Johnson - - * pthread_cond_destroy.c (pthread_cond_destroy): - Enter the time change critical section earlier. - -2002-02-17 Ross Johnson - - * nonportable.c (pthread_delay_np): Make a true - cancelation point. Deferred cancels will interrupt the - wait. - -2002-02-07 Ross Johnson - - Reduced name space pollution. - ----------------------------- - When the appropriate symbols are defined, the headers - will restrict the definitions of new names. In particular, - it must be possible to NOT include the - header and related definitions with some combination - of symbol definitions. Secondly, it should be possible - that additional definitions should be limited to POSIX - compliant symbols by the definition of appropriate symbols. - - * pthread.h: POSIX conditionals. - * sched.h: POSIX conditionals. - * semaphore.h: POSIX conditionals. - - * semaphore.c: Included . - (sem_init): Changed magic 0x7FFFFFFFL to INT_MAX. - (sem_getvalue): Trial version. - - Reduce executable size. - ----------------------- - When linking with the static library, only those - routines actually called, either directly or indirectly - should be included. - - [Gcc has the -ffunction-segments option to do this but MSVC - doesn't have this feature as far as I can determine. Other - compilers are undetermined as well. - rpj] - - * semaphore.c: All routines are now in separate compilation units; - This file is used to congregate the separate modules for - potential inline optimisation and backward build compatibility. - * sem_close.c: Separated routine from semaphore.c. - * ptw32_decrease_semaphore.c: Likewise. - * sem_destroy.c: Likewise. - * sem_getvalue.c: Likewise. - * ptw32_increase_semaphore.c: Likewise. - * sem_init.c: Likewise. - * sem_open.c: Likewise. - * sem_post.c: Likewise. - * sem_post_multiple.c: Likewise. - * sem_timedwait.c: Likewise. - * sem_trywait.c: Likewise. - * sem_unlink.c: Likewise. - * sem_wait.c: Likewise. - -2002-02-04 Ross Johnson - - The following extends the idea above to the rest of pthreads-win32 - rpj - - * attr.c: All routines are now in separate compilation units; - This file is used to congregate the separate modules for - potential inline optimisation and backward build compatibility. - * pthread_attr_destroy.c: Separated routine from attr.c. - * pthread_attr_getdetachstate.c: Likewise. - * pthread_attr_getscope.c: Likewise. - * pthread_attr_getstackaddr.c: Likewise. - * pthread_attr_getstacksize.c: Likewise. - * pthread_attr_init.c: Likewise. - * pthread_attr_is_attr.c: Likewise. - * pthread_attr_setdetachstate.c: Likewise. - * pthread_attr_setscope.c: Likewise. - * pthread_attr_setstackaddr.c: Likewise. - * pthread_attr_setstacksize.c: Likewise. - - * pthread.c: Agregation of agregate modules for super-inlineability. - -2002-02-02 Ross Johnson - - * 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 - arises if a thread is canceling and then receives a subsequent - async cancel request. - * private.c: Likewise. - * condvar.c: Place pragmas around cleanup_push/pop to turn - off inline optimisation (/Obn where n>0 - MSVC only). Various - optimisation switches in MSVC turn this on, which interferes with - the way that cleanup handlers are run in C++ EH and SEH - code. Application code compiled with inline optimisation must - also wrap cleanup_push/pop blocks with the pragmas, e.g. - #pragma inline_depth(0) - pthread_cleanup_push(...) - ... - pthread_cleanup_pop(...) - #pragma inline_depth(8) - * rwlock.c: Likewise. - * mutex.c: Remove attempts to inline some functions. - * signal.c: Modify misleading comment. - -2002-02-01 Ross Johnson - - * semaphore.c (sem_trywait): Fix missing errno return - for systems that define NEED_SEM (e.g. early WinCE). - * mutex.c (pthread_mutex_timedlock): Return ENOTSUP - for systems that define NEED_SEM since they don't - have sem_trywait(). - -2002-01-27 Ross Johnson - - * mutex.c (pthread_mutex_timedlock): New function suggested by - Alexander Terekhov. The logic required to implement this - properly came from Alexander, with some collaboration - with Thomas Pfaff. - (pthread_mutex_unlock): Wrap the waiters check and sema - post in a critical section to prevent a race with - pthread_mutex_timedlock. - (ptw32_timed_semwait): New function; - returns a special result if the absolute timeout parameter - represents a time already passed when called; used by - pthread_mutex_timedwait(). Have deliberately not reused - the name "ptw32_sem_timedwait" because they are not the same - routine. - * condvar.c (ptw32_cond_timedwait): Use the new sem_timedwait() - instead of ptw32_sem_timedwait(), which now has a different - function. See previous. - * implement.h: Remove prototype for ptw32_sem_timedwait. - See next. - (pthread_mutex_t_): Add critical section element for access - to lock_idx during mutex post-timeout processing. - * semaphore.h (sem_timedwait): See next. - * semaphore.c (sem_timedwait): See next. - * private.c (ptw32_sem_timedwait): Move to semaphore.c - and rename as sem_timedwait(). - -2002-01-18 Ross Johnson - - * sync.c (pthread_join): Was getting the exit code from the - calling thread rather than the joined thread if - defined(__MINGW32__) && !defined(__MSVCRT__). - -2002-01-15 Ross Johnson - - * 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 - 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. - - * spin.c (pthread_spin_init): Edit renamed function call. - * nonportable.c (pthread_num_processors_np): New. - (pthread_getprocessors_np): Renamed to ptw32_getprocessors - and moved to private.c. - * private.c (pthread_getprocessors): Moved here from - nonportable.c. - * pthread.def (pthread_getprocessors_np): Removed - from export list. - - * rwlock.c (pthread_rwlockattr_init): New. - (pthread_rwlockattr_destroy): New. - (pthread_rwlockattr_getpshared): New. - (pthread_rwlockattr_setpshared): New. - -2002-01-14 Ross Johnson - - * attr.c (pthread_attr_setscope): Fix struct pointer - indirection error introduced 2002-01-04. - (pthread_attr_getscope): Likewise. - -2002-01-12 Ross Johnson - - * pthread.dsp (SOURCE): Add missing source files. - -2002-01-08 Ross Johnson - - * mutex.c (pthread_mutex_trylock): use - ptw32_interlocked_compare_exchange function pointer - rather than ptw32_InterlockedCompareExchange() directly - to retain portability to non-iX86 processors, - e.g. WinCE etc. The pointer will point to the native - OS version of InterlockedCompareExchange() if the - OS supports it (see ChangeLog entry of 2001-10-17). - -2002-01-07 Thomas Pfaff , Alexander Terekhov - - * mutex.c (pthread_mutex_init): Remove critical - section calls. - (pthread_mutex_destroy): Likewise. - (pthread_mutex_unlock): Likewise. - (pthread_mutex_trylock): Likewise; uses - ptw32_InterlockedCompareExchange() to avoid need for - critical section; library is no longer i386 compatible; - recursive mutexes now increment the lock count rather - than return EBUSY; errorcheck mutexes return EDEADLCK - rather than EBUSY. This behaviour is consistent with the - Solaris pthreads implementation. - * implement.h (pthread_mutex_t_): Remove critical - section element - no longer needed. - - -2002-01-04 Ross Johnson - - * attr.c (pthread_attr_setscope): Add more error - checking and actually store the scope value even - though it's not really necessary. - (pthread_attr_getscope): Return stored value. - * implement.h (pthread_attr_t_): Add new scope element. - * ANNOUNCE: Fix out of date comment next to - pthread_attr_setscope in conformance section. - -2001-12-21 Alexander Terekhov - - * mutex.c (pthread_mutex_lock): Decrementing lock_idx was - not thread-safe. - (pthread_mutex_trylock): Likewise. - -2001-10-26 prionx@juno.com - - * semaphore.c (sem_init): Fix typo and missing bracket - in conditionally compiled code. Only older versions of - WinCE require this code, hence it doesn't normally get - tested; somehow when sem_t reverted to an opaque struct - the calloc NULL check was left in the conditionally included - section. - (sem_destroy): Likewise, the calloced sem_t wasn't being freed. - -2001-10-25 Ross Johnson - - * GNUmakefile (libwsock32): Add to linker flags for - WSAGetLastError() and WSASetLastError(). - * Makefile (wsock32.lib): Likewise. - * create.c: Minor mostly inert changes. - * implement.h (PTW32_MAX): Move into here and renamed - from sched.h. - (PTW32_MIN): Likewise. - * GNUmakefile (TEST_ICE): Define if testing internal - implementation of InterlockedCompareExchange. - * Makefile (TEST_ICE): Likewise. - * private.c (TEST_ICE): Likewise. - -2001-10-24 Ross Johnson - - * attr.c (pthread_attr_setstacksize): Quell warning - from LCC by conditionally compiling the stacksize - validity check. LCC correctly warns that the condition - (stacksize < PTHREAD_STACK_MIN) is suspicious - because STACK_MIN is 0 and stacksize is of type - size_t (or unsigned int). - -2001-10-17 Ross Johnson - - * barrier.c: Move _LONG and _LPLONG defines into - implement.h; rename to PTW32_INTERLOCKED_LONG and - PTW32_INTERLOCKED_LPLONG respectively. - * spin.c: Likewise; ptw32_interlocked_compare_exchange used - in place of InterlockedCompareExchange directly. - * global.c (ptw32_interlocked_compare_exchange): Add - prototype for this new routine pointer to be used when - InterlockedCompareExchange isn't supported by Windows. - * nonportable.c (pthread_win32_process_attach_np): Check for - support of InterlockedCompareExchange in kernel32 and assign its - address to ptw32_interlocked_compare_exchange if it exists, or - our own ix86 specific implementation ptw32_InterlockedCompareExchange. - *private.c (ptw32_InterlockedCompareExchange): An - implementation of InterlockedCompareExchange() which is - specific to ix86; written directly in assembler for either - MSVC or GNU C; needed because Windows 95 doesn't support - InterlockedCompareExchange(). - - * sched.c (sched_get_priority_min): Extend to return - THREAD_PRIORITY_IDLE. - (sched_get_priority_max): Extend to return - THREAD_PRIORITY_CRITICAL. - -2001-10-15 Ross Johnson - - * spin.c (pthread_spin_lock): PTHREAD_SPINLOCK_INITIALIZER - was causing a program fault. - (pthread_spin_init): Could have alloced memory - without freeing under some error conditions. - - * mutex.c (pthread_mutex_init): Move memory - allocation of mutex struct after checking for - PROCESS_SHARED. - -2001-10-12 Ross Johnson - - * spin.c (pthread_spin_unlock): Was not returning - EPERM if the spinlock was not locked, for multi CPU - machines. - -2001-10-08 Ross Johnson - - * spin.c (pthread_spin_trylock): Was not returning - EBUSY for multi CPU machines. - -2001-08-24 Ross Johnson - - * condvar.c (pthread_cond_destroy): Remove cv element - that is no longer used. - * implement.h: Likewise. - -2001-08-23 Alexander Terekhov - - * condvar.c (pthread_cond_destroy): fix bug with - respect to deadlock in the case of concurrent - _destroy/_unblock; a condition variable can be destroyed - immediately after all the threads that are blocked on - it are awakened. - -2001-08-23 Phil Frisbie, Jr. - - * tsd.c (pthread_getspecific): Preserve the last - winsock error [from WSAGetLastError()]. - -2001-07-18 Scott McCaskill - - * mutex.c (pthread_mutexattr_init): Return ENOMEM - immediately and don't dereference the NULL pointer - if calloc fails. - (pthread_mutexattr_getpshared): Don't dereference - a pointer that is possibly NULL. - * barrier.c (pthread_barrierattr_init): Likewise - (pthread_barrierattr_getpshared): Don't dereference - a pointer that is possibly NULL. - * condvar.c (pthread_condattr_getpshared): Don't dereference - a pointer that is possibly NULL. - -2001-07-15 Ross Johnson - - * rwlock.c (pthread_rwlock_wrlock): Is allowed to be - a cancelation point; re-enable deferred cancelability - around the CV call. - -2001-07-10 Ross Johnson - - * barrier.c: Still more revamping. The exclusive access - mutex isn't really needed so it has been removed and replaced - by an InterlockedDecrement(). nSerial has been removed. - iStep is now dual-purpose. The process shared attribute - is now stored in the barrier struct. - * implement.h (pthread_barrier_t_): Lost some/gained one - elements. - * private.c (ptw32_threadStart): Removed some comments. - -2001-07-10 Ross Johnson - - * barrier.c: Revamped to fix the race condition. Two alternating - semaphores are used instead of the PulseEvent. Also improved - overall throughput by returning PTHREAD_BARRIER_SERIAL_THREAD - to the first waking thread. - * implement.h (pthread_barrier_t_): Revamped. - -2001-07-09 Ross Johnson - - * barrier.c: Fix several bugs in all routines. Now passes - tests/barrier5.c which is fairly rigorous. There is still - a non-optimal work-around for a race condition between - the barrier breeched event signal and event wait. Basically - the last (signalling) thread to hit the barrier yields - to allow any other threads, which may have lost the race, - to complete. - -2001-07-07 Ross Johnson - - * barrier.c: Changed synchronisation mechanism to a - Win32 manual reset Event and use PulseEvent to signal - waiting threads. If the implementation continued to use - a semaphore it would require a second semaphore and - some management to use them alternately as barriers. A - single semaphore allows threads to cascade from one barrier - through the next, leaving some threads blocked at the first. - * implement.h (pthread_barrier_t_): As per above. - * general: Made a number of other routines inlinable. - -2001-07-07 Ross Johnson - - * spin.c: Revamped and working; included static initialiser. - Now beta level. - * barrier.c: Likewise. - * condvar.c: Macro constant change; inline auto init routine. - * mutex.c: Likewise. - * rwlock.c: Likewise. - * private.c: Add support for spinlock initialiser. - * global.c: Likewise. - * implement.h: Likewise. - * pthread.h (PTHREAD_SPINLOCK_INITIALIZER): Fix typo. - -2001-07-05 Ross Johnson - - * barrier.c: Remove static initialisation - irrelevent - 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(). - -2001-07-05 Ross Johnson - - * spin.c: New module implementing spin locks. - * barrier.c: New module implementing barriers. - * pthread.h (_POSIX_SPIN_LOCKS): defined. - (_POSIX_BARRIERS): Defined. - (pthread_spin_*): Defined. - (pthread_barrier*): Defined. - (PTHREAD_BARRIER_SERIAL_THREAD): Defined. - * implement.h (pthread_spinlock_t_): Defined. - (pthread_barrier_t_): Defined. - (pthread_barrierattr_t_): Defined. - - * mutex.c (pthread_mutex_lock): Return with the error - if an auto-initialiser initialisation fails. - - * nonportable.c (pthread_getprocessors_np): New; gets the - number of available processors for the current process. - -2001-07-03 Ross Johnson - - * pthread.h (_POSIX_READER_WRITER_LOCKS): Define it - if not already defined. - -2001-07-01 Alexander Terekhov - - * condvar.c: Fixed lost signal bug reported by Timur Aydin - (taydin@snet.net). - [RPJ (me) didn't translate the original algorithm - correctly.] - * semaphore.c: Added sem_post_multiple; this is a useful - routine, but it doesn't appear to be standard. For now it's - not an exported function. - -2001-06-25 Ross Johnson - - * create.c (pthread_create): Add priority inheritance - attributes. - * mutex.c (pthread_mutex_lock): Remove some overhead for - PTHREAD_MUTEX_NORMAL mutex types. Specifically, avoid - calling pthread_self() and pthread_equal() to check/set - the mutex owner. Introduce a new pseudo owner for this - type. Test results suggest increases in speed of up to - 90% for non-blocking locks. - This is the default type of mutex used internally by other - synchronising objects, ie. condition variables and - read-write locks. The test rwlock7.c shows about a - 30-35% speed increase over snapshot 2001-06-06. The - price of this is that the application developer - must ensure correct behaviour, or explicitly set the - mutex to a safer type such as PTHREAD_MUTEX_ERRORCHECK. - For example, PTHREAD_MUTEX_NORMAL (or PTHREAD_MUTEX_DEFAULT) - type mutexes will not return an error if a thread which is not - the owner calls pthread_mutex_unlock. The call will succeed - in unlocking the mutex if it is currently locked, but a - subsequent unlock by the true owner will then fail with EPERM. - This is however consistent with some other implementations. - (pthread_mutex_unlock): Likewise. - (pthread_mutex_trylock): Likewise. - (pthread_mutex_destroy): Likewise. - * attr.c (pthread_attr_init): PTHREAD_EXPLICIT_SCHED is the - default inheritance attribute; THREAD_PRIORITY_NORMAL is - the default priority for new threads. - * sched.c (pthread_attr_setschedpolicy): Added routine. - (pthread_attr_getschedpolicy): Added routine. - (pthread_attr_setinheritsched): Added routine. - (pthread_attr_getinheritsched): Added routine. - * pthread.h (sched_rr_set_interval): Added as a macro; - returns -1 with errno set to ENOSYS. - -2001-06-23 Ross Johnson - - *sched.c (pthread_attr_setschedparam): Add priority range - check. - (sched_setscheduler): New function; checks for a valid - pid and policy; checks for permission to set information - in the target process; expects pid to be a Win32 process ID, - not a process handle; the only scheduler policy allowed is - SCHED_OTHER. - (sched_getscheduler): Likewise, but checks for permission - to query. - * pthread.h (SCHED_*): Moved to sched.h as defined in the - POSIX standard. - * sched.h (SCHED_*): Moved from pthread.h. - (pid_t): Defined if necessary. - (sched_setscheduler): Defined. - (sched_getscheduler): Defined. - * pthread.def (sched_setscheduler): Exported. - (sched_getscheduler): Likewise. - -2001-06-23 Ralf Brese - - * create.c (pthread_create): Set thread priority from - thread attributes. - -2001-06-18 Ross Johnson - - * Made organisational-only changes to UWIN additions. - * dll.c (dllMain): Moved UWIN process attach code - to pthread_win32_process_attach_np(); moved - instance of pthread_count to global.c. - * global.c (pthread_count): Moved from dll.c. - * nonportable.c (pthread_win32_process_attach_np): - Moved _UWIN code to here from dll.c. - * implement.h (pthread_count): Define extern int. - * create.c (pthread_count): Remove extern int. - * private.c (pthread_count): Likewise. - * exit.c (pthread_count): Likewise. - -2001-06-18 David Korn - - * dll.c: Added changes necessary to work with UWIN. - * create.c: Likewise. - * pthread.h: Likewise. - * misc.c: Likewise. - * exit.c: Likewise. - * private.c: Likewise. - * implement.h: Likewise. - There is some room at the start of struct pthread_t_ - to implement the signal semantics in UWIN's posix.dll - although this is not yet complete. - * Nmakefile: Compatible with UWIN's Nmake utility. - * Nmakefile.tests: Likewise - for running the tests. - -2001-06-08 Ross Johnson - - * semaphore.h (sem_t): Fixed for compile and test. - * implement.h (sem_t_): Likewise. - * semaphore.c: Likewise. - * private.c (ptw32_sem_timedwait): Updated to use new - opaque sem_t. - -2001-06-06 Ross Johnson - - * semaphore.h (sem_t): Is now an opaque pointer; - moved actual definition to implement.h. - * implement.h (sem_t_): Move here from semaphore.h; - was the definition of sem_t. - * semaphore.c: Wherever necessary, changed use of sem - from that of a pointer to a pointer-pointer; added - extra checks for a valid sem_t; NULL sem_t when - it is destroyed; added extra checks when creating - and destroying sem_t elements in the NEED_SEM - code branches; changed from using a pthread_mutex_t - ((*sem)->mutex) to CRITICAL_SECTION ((*sem)->sem_lock_cs) - in NEED_SEM branches for access serialisation. - -2001-06-06 Ross Johnson - - * mutex.c (pthread_mutexattr_init): Remove - ptw32_mutex_default_kind. - -2001-06-05 Ross Johnson - - * nonportable.c (pthread_mutex_setdefaultkind_np): - Remove - should not have been included in the first place. - (pthread_mutex_getdefaultkind_np): Likewise. - * global.c (ptw32_mutex_default_kind): Likewise. - * mutex.c (pthread_mutex_init): Remove use of - ptw32_mutex_default_kind. - * pthread.h (pthread_mutex_setdefaultkind_np): Likewise. - (pthread_mutex_getdefaultkind_np): Likewise. - * pthread.def (pthread_mutexattr_setkind_np): Added. - (pthread_mutexattr_getkind_np): Likewise. - - * README: Many changes that should have gone in before - the last snapshot. - * README.NONPORTABLE: New - referred to by ANNOUNCE - but never created; documents the non-portable routines - included in the library - moved from README with new - routines added. - * ANNOUNCE (pthread_mutexattr_setkind_np): Added to - compliance list. - (pthread_mutexattr_getkind_np): Likewise. - -2001-06-04 Ross Johnson - - * condvar.c: Add original description of the algorithm as - developed by Terekhov and Thomas, plus reference to - README.CV. - -2001-06-03 Alexander Terekhov , Louis Thomas - - * condvar.c (pthread_cond_init): Completely revamped. - (pthread_cond_destroy): Likewise. - (ptw32_cond_wait_cleanup): Likewise. - (ptw32_cond_timedwait): Likewise. - (ptw32_cond_unblock): New general signaling routine. - (pthread_cond_signal): Now calls ptw32_cond_unblock. - (pthread_cond_broadcast): Likewise. - * implement.h (pthread_cond_t_): Revamped. - * README.CV: New; explanation of the above changes. - -2001-05-30 Ross Johnson - - * pthread.h (rand_r): Fake using _seed argument to quell - compiler warning (compiler should optimise this away later). - - * GNUmakefile (OPT): Leave symbolic information out of the library - and increase optimisation level - for smaller faster prebuilt - dlls. - -2001-05-29 Milan Gardian - - * Makefile: fix typo. - * pthreads.h: Fix problems with stdcall/cdecl conventions, in particular - remove the need for PT_STDCALL everywhere; remove warning supression. - * (errno): Fix the longstanding "inconsistent dll linkage" problem - with errno; now also works with /MD debugging libs - - warnings emerged when compiling pthreads library with /MD (or /MDd) - compiler switch, instead of /MT (or /MTd) (i.e. when compiling pthreads - using Multithreaded DLL CRT instead of Multithreaded statically linked - CRT). - * create.c (pthread_create): Likewise; fix typo. - * private.c (ptw32_threadStart): Eliminate use of terminate() which doesn't - throw exceptions. - * Remove unnecessary #includes from a number of modules - - [I had to #include malloc.h in implement.h for gcc - rpj]. - -2001-05-29 Thomas Pfaff - - * pthread.h (PTHREAD_MUTEX_DEFAULT): New; equivalent to - PTHREAD_MUTEX_DEFAULT_NP. - * (PTHREAD_MUTEX_NORMAL): Similarly. - * (PTHREAD_MUTEX_ERRORCHECK): Similarly. - * (PTHREAD_MUTEX_RECURSIVE): Similarly. - * (pthread_mutex_setdefaultkind_np): New; Linux compatibility stub - for pthread_mutexattr_settype. - * (pthread_mutexattr_getkind_np): New; Linux compatibility stub - for pthread_mutexattr_gettype. - * mutex.c (pthread_mutexattr_settype): New; allow - the following types of mutex: - PTHREAD_MUTEX_DEFAULT_NP - PTHREAD_MUTEX_NORMAL_NP - PTHREAD_MUTEX_ERRORCHECK_NP - PTHREAD_MUTEX_RECURSIVE_NP - * Note that PTHREAD_MUTEX_DEFAULT is equivalent to - PTHREAD_MUTEX_NORMAL - ie. mutexes should no longer - be recursive by default, and a thread will deadlock if it - tries to relock a mutex it already owns. This is inline with - other pthreads implementations. - * (pthread_mutex_lock): Process the lock request - according to the mutex type. - * (pthread_mutex_init): Eliminate use of Win32 mutexes as the - basis of POSIX mutexes - instead, a combination of one critical section - and one semaphore are used in conjunction with Win32 Interlocked* routines. - * (pthread_mutex_destroy): Likewise. - * (pthread_mutex_lock): Likewise. - * (pthread_mutex_trylock): Likewise. - * (pthread_mutex_unlock): Likewise. - * Use longjmp/setjmp to implement cancelation 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 - Milan Gardian's patches above. - -2001-02-07 Alexander Terekhov - - * rwlock.c: Revamped. - * implement.h (pthread_rwlock_t_): Redefined. - This implementation does not have reader/writer starvation problem. - Rwlock attempts to behave more like a normal mutex with - races and scheduling policy determining who is more important; - It also supports recursive locking, - has less synchronization overhead (no broadcasts at all, - readers are not blocked on any condition variable) and seem to - be faster than the current implementation [W98 appears to be - approximately 15 percent faster at least - on top of speed increase - from Thomas Pfaff's changes to mutex.c - rpj]. - -2000-12-29 Ross Johnson - - * Makefile: Back-out "for" loops which don't work. - - * GNUmakefile: Remove the fake.a target; add the "realclean" - target; don't remove built libs under the "clean" target. - - * config.h: Add a guard against multiple inclusion. - - * semaphore.h: Add some defines from config.h to make - semaphore.h independent of config.h when building apps. - - * pthread.h (_errno): Back-out previous fix until we know how to - fix it properly. - - * implement.h (lockCount): Add missing element to pthread_mutex_t_. - - * sync.c (pthread_join): Spelling fix in comment. - - * private.c (ptw32_threadStart): Reset original termination - function (C++). - (ptw32_threadStart): Cleanup detached threads early in case - the library is statically linked. - (ptw32_callUserDestroyRoutines): Remove [SEH] __try block from - destructor call so that unhandled exceptions will be passed through - to the system; call terminate() from [C++] try block for the same - reason. - - * tsd.c (pthread_getspecific): Add comment. - - * mutex.c (pthread_mutex_init): Initialise new elements in - pthread_mutex_t. - (pthread_mutex_unlock): Invert "pthread_equal()" test. - -2000-12-28 Ross Johnson - - * semaphore.c (mode_t): Use ifndef HAVE_MODE_T to include definition. - - * config.h.in (HAVE_MODE_T): Added. - (_UWIN): Start adding defines for the UWIN package. - - * private.c (ptw32_threadStart): Unhandled exceptions are - now passed through to the system to deal with. This is consistent - with normal Windows behaviour. C++ applications may use - set_terminate() to override the default behaviour which is - to call ptw32_terminate(). Ptw32_terminate() cleans up some - POSIX thread stuff before calling the system default function - which calls abort(). The users termination function should conform - to standard C++ semantics which is to not return. It should - exit the thread (call pthread_exit()) or exit the application. - * private.c (ptw32_terminate): Added as the default set_terminate() - function. It calls the system default function after cleaning up - some POSIX thread stuff. - - * implement.h (ptw32_try_enter_critical_section): Move - declaration. - * global.c (ptw32_try_enter_critical_section): Moved - from dll.c. - * dll.c: Move process and thread attach/detach code into - functions in nonportable.c. - * nonportable.c (pthread_win32_process_attach_np): Process - attach code from dll.c is now available to static linked - applications. - * nonportable.c (pthread_win32_process_detach_np): Likewise. - * nonportable.c (pthread_win32_thread_attach_np): Likewise. - * nonportable.c (pthread_win32_thread_detach_np): Likewise. - - * pthread.h: Add new non-portable prototypes for static - linked applications. - - * GNUmakefile (OPT): Increase optimisation flag and remove - debug info flag. - - * pthread.def: Add new non-portable exports for static - linked applications. - -2000-12-11 Ross Johnson - - * FAQ: Update Answer 6 re getting a fully working - Mingw32 built library. - -2000-10-10 Steven Reddie - - * misc.c (pthread_self): Restore Win32 "last error" - cleared by TlsGetValue() call in - pthread_getspecific() - -2000-09-20 Arthur Kantor - - * mutex.c (pthread_mutex_lock): Record the owner - of the mutex. This requires also keeping count of - recursive locks ourselves rather than leaving it - to Win32 since we need to know when to NULL the - thread owner when the mutex is unlocked. - (pthread_mutex_trylock): Likewise. - (pthread_mutex_unlock): Check that the calling - thread owns the mutex, decrement the recursive - lock count, and NULL the owner if zero. Return - EPERM if the mutex is owned by another thread. - * implement.h (pthread_mutex_t_): Add ownerThread - and lockCount members. - -2000-09-13 Jef Gearhart - - * mutex.c (pthread_mutex_init): Call - TryEnterCriticalSection through the pointer - rather than directly so that the dll can load - on Windows versions that can't resolve the - function, eg. Windows 95 - -2000-09-09 Ross Johnson - - * pthread.h (ctime_r): Fix arg. - -2000-09-08 Ross Johnson - - * GNUmakefile(_WIN32_WINNT=0x400): Define in CFLAGS; - doesn't seem to be needed though. - - * cancel.c (pthread_cancel): Must get "self" through - calling pthread_self() which will ensure a POSIX thread - struct is built for non-POSIX threads; return an error - if this fails - - Ollie Leahy - (pthread_setcancelstate): Likewise. - (pthread_setcanceltype): Likewise. - * misc.c (ptw32_cancelable_wait): Likewise. - - * private.c (ptw32_tkAssocCreate): Remove unused #if 0 - wrapped code. - - * pthread.h (ptw32_get_exception_services_code): - Needed to be forward declared unconditionally. - -2000-09-06 Ross Johnson - - * cancel.c (pthread_cancel): If called from the main - thread "self" would be NULL; get "self" via pthread_self() - instead of directly from TLS so that an implicit - pthread object is created. - - * misc.c (pthread_equal): Strengthen test for NULLs. - -2000-09-02 Ross Johnson - - * condvar.c (ptw32_cond_wait_cleanup): Ensure that all - waking threads check if they are the last, and notify - the broadcaster if so - even if an error occurs in the - waiter. - - * semaphore.c (_decrease_semaphore): Should be - a call to ptw32_decrease_semaphore. - (_increase_semaphore): Should be a call to - ptw32_increase_semaphore. - - * misc.c (ptw32_cancelable_wait): Renamed from - CancelableWait. - * rwlock.c (_rwlock_check*): Renamed to - ptw32_rwlock_check*. - * mutex.c (_mutex_check*): Renamed to ptw32_mutex_check*. - * condvar.c (cond_timed*): Renamed to ptw32_cond_timed*. - (_cond_check*): Renamed to ptw32_cond_check*. - (cond_wait_cleanup*): Rename to ptw32_cond_wait_cleanup*. - (ptw32_cond_timedwait): Add comments. - -2000-08-22 Ross Johnson - - * private.c (ptw32_throw): Fix exception test; - move exceptionInformation declaration. - - * tsd.c (pthread_key_create): newkey wrongly declared. - - * pthread.h: Fix comment block. - -2000-08-18 Ross Johnson - - * mutex.c (pthread_mutex_destroy): Check that the mutex isn't - held; invalidate the mutex as early as possible to avoid - contention; not perfect - FIXME! - - * rwlock.c (pthread_rwlock_init): Remove redundant assignment - to "rw". - (pthread_rwlock_destroy): Invalidate the rwlock before - freeing up any of it's resources - to avoid contention. - - * private.c (ptw32_tkAssocCreate): Change assoc->lock - to use a dynamically initialised mutex - only consumes - a W32 mutex or critical section when first used, - not before. - - * mutex.c (pthread_mutex_init): Remove redundant assignment - to "mx". - (pthread_mutexattr_destroy): Set attribute to NULL - before freeing it's memory - to avoid contention. - - * implement.h (PTW32_EPS_CANCEL/PTW32_EPS_EXIT): - Must be defined for all compilers - used as generic - exception selectors by ptw32_throw(). - - * Several: Fix typos from scripted edit session - yesterday. - - * nonportable.c (pthread_mutexattr_setforcecs_np): - Moved this function from mutex.c. - (pthread_getw32threadhandle_np): New function to - return the win32 thread handle that the POSIX - thread is using. - * mutex.c (pthread_mutexattr_setforcecs_np): - Moved to new file "nonportable.c". - - * pthread.h (PTW32_BUILD): Only redefine __except - and catch compiler keywords if we aren't building - the library (ie. PTW32_BUILD is not defined) - - this is safer than defining and then undefining - if not building the library. - * implement.h: Remove __except and catch undefines. - * Makefile (CFLAGS): Define PTW32_BUILD. - * GNUmakefile (CFLAGS): Define PTW32_BUILD. - - * All appropriate: Change Pthread_exception* to - ptw32_exception* to be consistent with internal - identifier naming. - - * private.c (ptw32_throw): New function to provide - a generic exception throw for all internal - exceptions and EH schemes. - (ptw32_threadStart): pthread_exit() value is now - returned via the thread structure exitStatus - element. - * exit.c (pthread_exit): pthread_exit() value is now - returned via the thread structure exitStatus - element. - * cancel.c (ptw32_cancel_self): Now uses ptw32_throw. - (pthread_setcancelstate): Ditto. - (pthread_setcanceltype): Ditto. - (pthread_testcancel): Ditto. - (pthread_cancel): Ditto. - * misc.c (CancelableWait): Ditto. - * exit.c (pthread_exit): Ditto. - * All applicable: Change PTW32_ prefix to - PTW32_ prefix to remove leading underscores - from private library identifiers. - -2000-08-17 Ross Johnson - - * All applicable: Change _pthread_ prefix to - ptw32_ prefix to remove leading underscores - from private library identifiers (single - and double leading underscores are reserved in the - ANSI C standard for compiler implementations). - - * tsd.c (pthread_create_key): Initialise temporary - key before returning it's address to avoid race - conditions. - -2000-08-13 Ross Johnson - - * errno.c: Add _MD precompile condition; thus far - had no effect when using /MD compile option but I - thnk it should be there. - - * exit.c: Add __cplusplus to various #if lines; - was compiling SEH code even when VC++ had - C++ compile options. - - * private.c: ditto. - - * create.c (pthread_create): Add PT_STDCALL macro to - function pointer arg in _beginthread(). - - * pthread.h: PT_STDCALL really does need to be defined - in both this and impliment.h; don't set it to __cdecl - - this macro is only used to extend function pointer - casting for functions that will be passed as parameters. - (~PThreadCleanup): add cast and group expression. - (_errno): Add _MD compile conditional. - (PtW32NoCatchWarn): Change pragma message. - - * implement.h: Move and change PT_STDCALL define. - - * need_errno.h: Add _MD to compilation conditional. - - * GNUmakefile: Substantial rewrite for new naming - convention; set for nil optimisation (turn it up - when we have a working library build; add target - "fake.a" to build a libpthreadw32.a from the VC++ - built DLL pthreadVCE.dll. - - * pthread.def (LIBRARY): Don't specify in the .def - file - it is specified on the linker command line - since we now use the same .def file for variously - named .dlls. - - * Makefile: Substantial rewrite for new naming - convention; default nmake target only issues a - help message; run nmake with specific target - corresponding to the EH scheme being used. - - * README: Update information; add naming convention - explanation. - - * ANNOUNCE: Update information. - -2000-08-12 Ross Johnson - - * 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. - - * implement.h: Remove #include ; we - use our own local semaphore.h. - -2000-08-10 Ross Johnson - - * cleanup.c (pthread_pop_cleanup): Remove _pthread - prefix from __except and catch keywords; implement.h - now simply undefines ptw32__except and - ptw32_catch if defined; VC++ was not textually - substituting ptw32_catch etc back to catch as - it was redefined; the reason for using the prefixed - version was to make it clear that it was not using - the pthread.h redefined catch keyword. - - * private.c (ptw32_threadStart): Ditto. - (ptw32_callUserDestroyRoutines): Ditto. - - * implement.h (ptw32__except): Remove #define. - (ptw32_catch): Remove #define. - - * GNUmakefile (pthread.a): New target to build - libpthread32.a from pthread.dll using dlltool. - - * buildlib.bat: Duplicate cl commands with args to - build C++ EH version of pthread.dll; use of .bat - files is redundant now that nmake compatible - Makefile is included; used as a kludge only now. - - * Makefile: Localise some macros and fix up the clean: - target to extend it and work properly. - - * CONTRIBUTORS: Add contributors. - - * ANNOUNCE: Updated. - - * README: Updated. - -2000-08-06 Ross Johnson - - * pthread.h: Remove #warning - VC++ doesn't accept it. - -2000-08-05 Ross Johnson - - * 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 - pthread_exit() to work. - -2000-08-03 Ross Johnson - - * pthread.h: Add a base class ptw32_exception for - library internal exceptions and change the "catch" - re-define macro to use it. - -2000-08-02 Ross Johnson - - * GNUmakefile (CFLAGS): Add -mthreads. - Add new targets to generate cpp and asm output. - - * sync.c (pthread_join): Remove dead code. - -2000-07-25 Tristan Savatier - - * sched.c (sched_get_priority_max): Handle different WinCE and - Win32 priority values together. - (sched_get_priority_min): Ditto. - -2000-07-25 Ross Johnson - - * create.c (pthread_create): Force new threads to wait until - pthread_create has the new thread's handle; we also retain - a local copy of the handle for internal use until - pthread_create returns. - - * private.c (ptw32_threadStart): Initialise ei[]. - (ptw32_threadStart): When beginthread is used to start the - thread, force waiting until the creator thread had the - thread handle. - - * cancel.c (ptw32_cancel_thread): Include context switch - code for defined(_X86_) environments in addition to _M_IX86. - - * rwlock.c (pthread_rwlock_destroy): Assignment changed - to avoid compiler warning. - - * private.c (ptw32_get_exception_services_code): Cast - NULL return value to avoid compiler warning. - - * cleanup.c (pthread_pop_cleanup): Initialise "cleanup" variable - to avoid compiler warnings. - - * misc.c (ptw32_new): Change "new" variable to "t" to avoid - confusion with the C++ keyword of the same name. - - * condvar.c (cond_wait_cleanup): Initialise lastWaiter variable. - (cond_timedwait): Remove unused local variables. to avoid - compiler warnings. - - * dll.c (dllMain): Remove 2000-07-21 change - problem - appears to be in pthread_create(). - -2000-07-22 Ross Johnson - - * tsd.c (pthread_key_create): If a destructor was given - and the pthread_mutex_init failed, then would try to - reference a NULL pointer (*key); eliminate this section of - code by using a dynamically initialised mutex - (PTHREAD_MUTEX_INITIALIZER). - - * tsd.c (pthread_setspecific): Return an error if - unable to set the value; simplify cryptic conditional. - - * tsd.c (pthread_key_delete): Locking threadsLock relied - on mutex_lock returning an error if the key has no destructor. - ThreadsLock is only initialised if the key has a destructor. - Making this mutex a static could reduce the number of mutexes - used by an application since it is actually created only at - first use and it's often destroyed soon after. - -2000-07-22 Ross Johnson - - * FAQ: Added Q5 and Q6. - -2000-07-21 David Baggett - - * dll.c: Include resource leakage work-around. This is a - partial FIXME which doesn't stop all leakage. The real - problem needs to be found and fixed. - -2000-07-21 Ross Johnson - - * create.c (pthread_create): Set threadH to 0 (zero) - everywhere. Some assignments were using NULL. Maybe - it should be NULL everywhere - need to check. (I know - they are nearly always the same thing - but not by - definition.) - - * misc.c (pthread_self): Try to catch NULL thread handles - at the point where they might be generated, even though - they should always be valid at this point. - - * tsd.c (pthread_setspecific): return an error value if - pthread_self() returns NULL. - - * sync.c (pthread_join): return an error value if - pthread_self() returns NULL. - - * signal.c (pthread_sigmask): return an error value if - pthread_self() returns NULL. - -2000-03-02 Ross Johnson - - * attr.c (pthread_attr_init): Set default stacksize to zero (0) - rather than PTHREAD_STACK_MIN even though these are now the same. - - * pthread.h (PTHREAD_STACK_MIN): Lowered to 0. - -2000-01-28 Ross Johnson - - * mutex.c (pthread_mutex_init): Free mutex if it has been alloced; - if critical sections can be used instead of Win32 mutexes, test - that the critical section works and return an error if not. - -2000-01-07 Ross Johnson - - * cleanup.c (pthread_pop_cleanup): Include SEH code only if MSC is not - compiling as C++. - (pthread_push_cleanup): Include SEH code only if MSC is not - compiling as C++. - - * pthread.h: Include SEH code only if MSC is not - compiling as C++. - - * implement.h: Include SEH code only if MSC is not - compiling as C++. - - * cancel.c (ptw32_cancel_thread): Add _M_IX86 check. - (pthread_testcancel): Include SEH code only if MSC is not - compiling as C++. - (ptw32_cancel_self): Include SEH code only if MSC is not - compiling as C++. - -2000-01-06 Erik Hensema - - * Makefile: Remove inconsistencies in 'cl' args - -2000-01-04 Ross Johnson - - * private.c (ptw32_get_exception_services_code): New; returns - value of EXCEPTION_PTW32_SERVICES. - (ptw32_processInitialize): Remove initialisation of - ptw32_exception_services which is no longer needed. - - * pthread.h (ptw32_exception_services): Remove extern. - (ptw32_get_exception_services_code): Add function prototype; - use this to return EXCEPTION_PTW32_SERVICES value instead of - using the ptw32_exception_services variable which I had - trouble exporting through pthread.def. - - * global.c (ptw32_exception_services): Remove declaration. - -1999-11-22 Ross Johnson - - * implement.h: Forward declare ptw32_new(); - - * misc.c (ptw32_new): New; alloc and initialise a new pthread_t. - (pthread_self): New thread struct is generated by new routine - ptw32_new(). - - * create.c (pthread_create): New thread struct is generated - by new routine ptw32_new(). - -1999-11-21 Ross Johnson - - * global.c (ptw32_exception_services): Declare new variable. - - * private.c (ptw32_threadStart): Destroy thread's - cancelLock mutex; make 'catch' and '__except' usageimmune to - redfinitions in pthread.h. - (ptw32_processInitialize): Init new constant ptw32_exception_services. - - * create.c (pthread_create): Initialise thread's cancelLock - mutex. - - * cleanup.c (pthread_pop_cleanup): Make 'catch' and '__except' - usage immune to redfinition s in pthread.h. - - * private.c: Ditto. - - * pthread.h (catch): Redefine 'catch' so that C++ applications - won't catch our internal exceptions. - (__except): ditto for __except. - - * implement.h (ptw32_catch): Define internal version - of 'catch' because 'catch' is redefined by pthread.h. - (__except): ditto for __except. - (struct pthread_t_): Add cancelLock mutex for async cancel - safety. - -1999-11-21 Jason Nye , Erik Hensema - - * cancel.c (ptw32_cancel_self): New; part of the async - cancellation implementation. - (ptw32_cancel_thread): Ditto; this function is X86 - processor specific. - (pthread_setcancelstate): Add check for pending async - cancel request and cancel the calling thread if - required; add async-cancel safety lock. - (pthread_setcanceltype): Ditto. - -1999-11-13 Erik Hensema - - * configure.in (AC_OUTPUT): Put generated output into GNUmakefile - rather than Makefile. Makefile will become the MSC nmake compatible - version - -1999-11-13 John Bossom (John.Bossom@cognos.com> - - * misc.c (pthread_self): Add a note about GetCurrentThread - returning a pseudo-handle - -1999-11-10 Todd Owen - - * dll.c (dllMain): Free kernel32 ASAP. - If TryEnterCriticalSection is not being used, then free - the kernel32.dll handle now, rather than leaving it until - DLL_PROCESS_DETACH. - - Note: this is not a pedantic exercise in freeing unused - resources! It is a work-around for a bug in Windows 95 - (see microsoft knowledge base article, Q187684) which - does Bad Things when FreeLibrary is called within - the DLL_PROCESS_DETACH code, in certain situations. - Since w95 just happens to be a platform which does not - provide TryEnterCriticalSection, the bug will be - effortlessly avoided. - -1999-11-10 Ross Johnson - - * sync.c (pthread_join): Make it a deferred cancelation point. - - * misc.c (pthread_self): Explicitly initialise implicitly - created thread state to default values. - -1999-11-05 Tristan Savatier - - * pthread.h (winsock.h): Include unconditionally. - (ETIMEDOUT): Change fallback value to that defined by winsock.h. - - * general: Patched for portability to WinCE. The details are - described in the file WinCE-PORT. Follow the instructions - in README.WinCE to make the appropriate changes in config.h. - -1999-10-30 Erik Hensema - - * create.c (pthread_create): Explicitly initialise thread state to - default values. - - * cancel.c (pthread_setcancelstate): Check for NULL 'oldstate' - for compatibility with Solaris pthreads; - (pthread_setcanceltype): ditto: - -1999-10-23 Erik Hensema - - * pthread.h (ctime_r): Fix incorrect argument "_tm" - -1999-10-21 Aurelio Medina - - * pthread.h (_POSIX_THREADS): Only define it if it isn't - already defined. Projects may need to define this on - the CC command line under Win32 as it doesn't have unistd.h - -1999-10-17 Ross Johnson - - * rwlock.c (pthread_rwlock_destroy): Add cast to remove compile - warning. - - * condvar.c (pthread_cond_broadcast): Only release semaphores - if there are waiting threads. - -1999-10-15 Lorin Hochstein , Peter Slacik - - * condvar.c (cond_wait_cleanup): New static cleanup handler for - cond_timedwait; - (cond_timedwait): pthread_cleanup_push args changed; - canceling a thread while it's in pthread_cond_wait - will now decrement the waiters count and cleanup if it's the - last waiter. - -1999-10-15 Graham Dumpleton - - * condvar.c (cond_wait_cleanup): the last waiter will now reset the CV's - wasBroadcast flag - -Thu Sep 16 1999 Ross Johnson - - * rwlock.c (pthread_rwlock_destroy): Add serialisation. - (_rwlock_check_need_init): Check for detroyed rwlock. - * rwlock.c: Check return codes from _rwlock_check_need_init(); - modify comments; serialise access to rwlock objects during - operations; rename rw_mutex to rw_lock. - * implement.h: Rename rw_mutex to rw_lock. - * mutex.c (pthread_mutex_destroy): Add serialisation. - (_mutex_check_need_init): Check for detroyed mutex. - * condvar.c (pthread_cond_destroy): Add serialisation. - (_cond_check_need_init): Check for detroyed condvar. - * mutex.c: Modify comments. - * condvar.c: Modify comments. - -1999-08-10 Aurelio Medina - - * implement.h (pthread_rwlock_t_): Add. - * pthread.h (pthread_rwlock_t): Add. - (PTHREAD_RWLOCK_INITIALIZER): Add. - Add rwlock function prototypes. - * rwlock.c: New module. - * pthread.def: Add new rwlock functions. - * private.c (ptw32_processInitialize): initialise - ptw32_rwlock_test_init_lock critical section. - * global.c (ptw32_rwlock_test_init_lock): Add. - - * mutex.c (pthread_mutex_destroy): Don't free mutex memory - if mutex is PTHREAD_MUTEX_INITIALIZER and has not been - initialised yet. - -1999-08-08 Milan Gardian - - * mutex.c (pthread_mutex_destroy): Free mutex memory. - -1999-08-22 Ross Johnson - - * exit.c (pthread_exit): Fix reference to potentially - uninitialised pointer. - -1999-08-21 Ross Johnson - - * private.c (ptw32_threadStart): Apply fix of 1999-08-19 - this time to C++ and non-trapped C versions. Ommitted to - do this the first time through. - -1999-08-19 Ross Johnson - - * private.c (ptw32_threadStart): Return exit status from - the application thread startup routine. - - Milan Gardian - -1999-08-18 John Bossom - - * exit.c (pthread_exit): Put status into pthread_t->exitStatus - * private.c (ptw32_threadStart): Set pthread->exitStatus - on exit of try{} block. - * sync.c (pthread_join): use pthread_exitStatus value if the - thread exit doesn't return a value (for Mingw32 CRTDLL - which uses endthread instead of _endthreadex). - -Tue Aug 17 20:17:58 CDT 1999 Mumit Khan - - * create.c (pthread_create): Add CRTDLL suppport. - * exit.c (pthread_exit): Likewise. - * private.c (ptw32_threadStart): Likewise. - (ptw32_threadDestroy): Likewise. - * sync.c (pthread_join): Likewise. - * tests/join1.c (main): Warn about partial support for CRTDLL. - -Tue Aug 17 20:00:08 1999 Mumit Khan - - * Makefile.in (LD): Delete entry point. - * acconfig.h (STDCALL): Delete unused macro. - * configure.in: Remove test for STDCALL. - * config.h.in: Regenerate. - * errno.c (_errno): Fix self type. - * pthread.h (PT_STDCALL): Move from here to - * implement.h (PT_STDCALL): here. - (ptw32_threadStart): Fix prototype. - * private.c (ptw32_threadStart): Likewise. - -1999-08-14 Ross Johnson - - * exit.c (pthread_exit): Don't call pthread_self() but - get thread handle directly from TSD for efficiency. - -1999-08-12 Ross Johnson - - * private.c (ptw32_threadStart): ei[] only declared if _MSC_VER. - - * exit.c (pthread_exit): Check for implicitly created threads - to avoid raising an unhandled exception. - -1999-07-12 Peter Slacik - - * condvar.c (pthread_cond_destroy): Add critical section. - (cond_timedwait): Add critical section; check for timeout - waiting on semaphore. - (pthread_cond_broadcast): Add critical section. - -1999-07-09 Lorin Hochstein , John Bossom - - The problem was that cleanup handlers were not executed when - pthread_exit() was called. - - * implement.h (pthread_t_): Add exceptionInformation element for - C++ per-thread exception information. - (general): Define and rename exceptions. - -1999-07-09 Ross Johnson - - * misc.c (CancelableWait): PTW32_EPS_CANCEL (SEH) and - ptw32_exception_cancel (C++) used to identify the exception. - - * cancel.c (pthread_testcancel): PTW32_EPS_CANCEL (SEH) and - ptw32_exception_cancel (C++) used to identify the exception. - - * exit.c (pthread_exit): throw/raise an exception to return to - ptw32_threadStart() to exit the thread. PTW32_EPS_EXIT (SEH) - and ptw32_exception_exit (C++) used to identify the exception. - - * private.c (ptw32_threadStart): Add pthread_exit exception trap; - clean up and exit the thread directly rather than via pthread_exit(). - -Sun May 30 00:25:02 1999 Ross Johnson - - * semaphore.h (mode_t): Conditionally typedef it. - -Fri May 28 13:33:05 1999 Mark E. Armstrong - - * condvar.c (pthread_cond_broadcast): Fix possible memory fault - -Thu May 27 13:08:46 1999 Peter Slacik - - * condvar.c (pthread_cond_broadcast): Fix logic bug - -Thu May 27 13:08:46 1999 Bossom, John - - * condvar.c (pthread_cond_broadcast): optimise sem_post loop - -Fri May 14 12:13:18 1999 Mike Russo - - * attr.c (pthread_attr_setdetachstate): Fix logic bug - -Sat May 8 09:42:30 1999 Ross Johnson - - * pthread.def (sem_open): Add. - (sem_close): Add. - (sem_unlink): Add. - (sem_getvalue): Add. - - * FAQ (Question 3): Add. - -Thu Apr 8 01:16:23 1999 Ross Johnson - - * semaphore.c (sem_open): New function; returns an error (ENOSYS). - (sem_close): ditto. - (sem_unlink): ditto. - (sem_getvalue): ditto. - - * semaphore.h (_POSIX_SEMAPHORES): define. - -Wed Apr 7 14:09:52 1999 Ross Johnson - - * errno.c (_REENTRANT || _MT): Invert condition. - - * pthread.h (_errno): Conditionally include prototype. - -Wed Apr 7 09:37:00 1999 Ross Johnson - - * *.c (comments): Remove individual attributions - these are - documented sufficiently elsewhere. - - * implement.h (pthread.h): Remove extraneous include. - -Sun Apr 4 11:05:57 1999 Ross Johnson - - * sched.c (sched.h): Include. - - * sched.h: New file for POSIX 1b scheduling. - - * pthread.h: Move opaque structures to implement.h; move sched_* - prototypes out and into sched.h. - - * implement.h: Add opaque structures from pthread.h. - - * sched.c (sched_yield): New function. - - * condvar.c (ptw32_sem_*): Rename to sem_*; except for - ptw32_sem_timedwait which is an private function. - -Sat Apr 3 23:28:00 1999 Ross Johnson - - * Makefile.in (OBJS): Add errno.o. - -Fri Apr 2 11:08:50 1999 Ross Johnson - - * implement.h (ptw32_sem_*): Remove prototypes now defined in - semaphore.h. - - * pthread.h (sempahore.h): Include. - - * semaphore.h: New file for POSIX 1b semaphores. - - * semaphore.c (ptw32_sem_timedwait): Moved to private.c. - - * pthread.h (ptw32_sem_t): Change to sem_t. - - * private.c (ptw32_sem_timedwait): Moved from semaphore.c; - set errno on error. - - * pthread.h (pthread_t_): Add per-thread errno element. - -Fri Apr 2 11:08:50 1999 John Bossom - - * semaphore.c (ptw32_sem_*): Change to sem_*; these functions - will be exported from the library; set errno on error. - - * errno.c (_errno): New file. New function. - -Fri Mar 26 14:11:45 1999 Tor Lillqvist - - * semaphore.c (ptw32_sem_timedwait): Check for negative - milliseconds. - -Wed Mar 24 11:32:07 1999 John Bossom - - * misc.c (CancelableWait): Initialise exceptionInformation[2]. - (pthread_self): Get a real Win32 thread handle for implicit threads. - - * cancel.c (pthread_testcancel): Initialise exceptionInformation[2]. - - * implement.h (SE_INFORMATION): Fix values. - - * private.c (ptw32_threadDestroy): Close the thread handle. - -Fri Mar 19 12:57:27 1999 Ross Johnson - - * cancel.c (comments): Update and cleanup. - -Fri Mar 19 09:12:59 1999 Ross Johnson - - * private.c (ptw32_threadStart): status returns PTHREAD_CANCELED. - - * pthread.h (PTHREAD_CANCELED): defined. - -Tue Mar 16 1999 Ross Johnson - - * all: Add GNU LGPL and Copyright and Warranty. - -Mon Mar 15 00:20:13 1999 Ross Johnson - - * condvar.c (pthread_cond_init): fix possible uninitialised use - of cv. - -Sun Mar 14 21:01:59 1999 Ross Johnson - - * condvar.c (pthread_cond_destroy): don't do full cleanup if - static initialised cv has never been used. - (cond_timedwait): check result of auto-initialisation. - -Thu Mar 11 09:01:48 1999 Ross Johnson - - * pthread.h (pthread_mutex_t): revert to (pthread_mutex_t *); - define a value to serve as PTHREAD_MUTEX_INITIALIZER. - (pthread_mutex_t_): remove staticinit and valid elements. - (pthread_cond_t): revert to (pthread_cond_t_ *); - define a value to serve as PTHREAD_COND_INITIALIZER. - (pthread_cond_t_): remove staticinit and valid elements. - - * mutex.c (pthread_mutex_t args): adjust indirection of references. - (all functions): check for PTHREAD_MUTEX_INITIALIZER value; - check for NULL (invalid). - - * condvar.c (pthread_cond_t args): adjust indirection of references. - (all functions): check for PTHREAD_COND_INITIALIZER value; - check for NULL (invalid). - -Wed Mar 10 17:18:12 1999 Ross Johnson - - * misc.c (CancelableWait): Undo changes from Mar 8 and 7. - -Mon Mar 8 11:18:59 1999 Ross Johnson - - * misc.c (CancelableWait): Ensure cancelEvent handle is the lowest - indexed element in the handles array. Enhance test for abandoned - objects. - - * pthread.h (PTHREAD_MUTEX_INITIALIZER): Trailing elements not - initialised are set to zero by the compiler. This avoids the - problem of initialising the opaque critical section element in it. - (PTHREAD_COND_INITIALIZER): Ditto. - - * semaphore.c (ptw32_sem_timedwait): Check sem == NULL earlier. - -Sun Mar 7 12:31:14 1999 Ross Johnson - - * condvar.c (pthread_cond_init): set semaphore initial value - to 0, not 1. cond_timedwait was returning signaled immediately. - - * misc.c (CancelableWait): Place the cancel event handle first - in the handle table for WaitForMultipleObjects. This ensures that - the cancel event is recognised and acted apon if both objects - happen to be signaled together. - - * private.c (ptw32_cond_test_init_lock): Initialise and destroy. - - * implement.h (ptw32_cond_test_init_lock): Add extern. - - * global.c (ptw32_cond_test_init_lock): Add declaration. - - * condvar.c (pthread_cond_destroy): check for valid initialised CV; - flag destroyed CVs as invalid. - (pthread_cond_init): pthread_cond_t is no longer just a pointer. - This is because PTHREAD_COND_INITIALIZER needs state info to reside - in pthread_cond_t so that it can initialise on first use. Will work on - making pthread_cond_t (and other objects like it) opaque again, if - possible, later. - (cond_timedwait): add check for statically initialisation of - CV; initialise on first use. - (pthread_cond_signal): check for valid CV. - (pthread_cond_broadcast): check for valid CV. - (_cond_check_need_init): Add. - - * pthread.h (PTHREAD_COND_INITIALIZER): Fix. - (pthread_cond_t): no longer a pointer to pthread_cond_t_. - (pthread_cond_t_): add 'staticinit' and 'valid' elements. - -Sat Mar 6 1999 Ross Johnson - - * implement.h: Undate comments. - -Sun Feb 21 1999 Ross Johnson - - * pthread.h (PTHREAD_MUTEX_INITIALIZER): missing braces around - cs element initialiser. - -1999-02-21 Ben Elliston - - * pthread.h (pthread_exit): The return type of this function is - void, not int. - - * exit.c (pthread_exit): Do not return 0. - -Sat Feb 20 16:03:30 1999 Ross Johnson - - * dll.c (DLLMain): Expand TryEnterCriticalSection support test. - - * mutex.c (pthread_mutex_trylock): The check for - ptw32_try_enter_critical_section == NULL should have been - removed long ago. - -Fri Feb 19 16:03:30 1999 Ross Johnson - - * sync.c (pthread_join): Fix pthread_equal() test. - - * mutex.c (pthread_mutex_trylock): Check mutex != NULL before - using it. - -Thu Feb 18 16:17:30 1999 Ross Johnson - - * misc.c (pthread_equal): Fix inverted result. - - * Makefile.in: Use libpthread32.a as the name of the DLL export - library instead of pthread.lib. - - * condvar.c (pthread_cond_init): cv could have been used unitialised; - initialise. - - * create.c (pthread_create): parms could have been used unitialised; - initialise. - - * pthread.h (struct pthread_once_t_): Remove redefinition. - -Sat Feb 13 03:03:30 1999 Ross Johnson - - * pthread.h (struct pthread_once_t_): Replaced. - - * misc.c (pthread_once): Replace with John Bossom's version; - has lighter weight serialisation; fixes problem of not holding - competing threads until after the init_routine completes. - -Thu Feb 11 13:34:14 1999 Ross Johnson - - * misc.c (CancelableWait): Change C++ exception throw. - - * sync.c (pthread_join): Change FIXME comment - issue resolved. - -Wed Feb 10 12:49:11 1999 Ross Johnson - - * configure: Various temporary changes. - - Kevin Ruland - - * README: Update. - - * pthread.def (pthread_attr_getstackaddr): uncomment - (pthread_attr_setstackaddr): uncomment - -Fri Feb 5 13:42:30 1999 Ross Johnson - - * semaphore.c: Comment format changes. - -Thu Feb 4 10:07:28 1999 Ross Johnson - - * global.c: Remove ptw32_exception instantiation. - - * cancel.c (pthread_testcancel): Change C++ exception throw. - - * implement.h: Remove extern declaration. - -Wed Feb 3 13:04:44 1999 Ross Johnson - - * cleanup.c: Rename ptw32_*_cleanup() to pthread_*_cleanup(). - - * pthread.def: Ditto. - - * pthread.h: Ditto. - - * pthread.def (pthread_cleanup_push): Remove from export list; - the function is defined as a macro under all compilers. - (pthread_cleanup_pop): Ditto. - - * pthread.h: Remove #if defined(). - -Wed Feb 3 10:13:48 1999 Ross Johnson - - * sync.c (pthread_join): Check for NULL value_ptr arg; - check for detached threads. - -Tue Feb 2 18:07:43 1999 Ross Johnson - - * implement.h: Add #include . - Change sem_t to ptw32_sem_t. - -Tue Feb 2 18:07:43 1999 Kevin Ruland - - * signal.c (pthread_sigmask): Add and modify casts. - Reverse LHS/RHS bitwise assignments. - - * pthread.h: Remove #include . - (PTW32_ATTR_VALID): Add cast. - (struct pthread_t_): Add sigmask element. - - * dll.c: Add "extern C" for DLLMain. - (DllMain): Add cast. - - * create.c (pthread_create): Set sigmask in thread. - - * condvar.c: Remove #include. Change sem_* to ptw32_sem_*. - - * attr.c: Changed #include. - - * Makefile.in: Additional targets and changes to build the library - as a DLL. - -Fri Jan 29 11:56:28 1999 Ross Johnson - - * Makefile.in (OBJS): Add semaphore.o to list. - - * semaphore.c (ptw32_sem_timedwait): Move from private.c. - Rename sem_* to ptw32_sem_*. - - * pthread.h (pthread_cond_t): Change type of sem_t. - _POSIX_SEMAPHORES no longer defined. - - * semaphore.h: Contents moved to implement.h. - Removed from source tree. - - * implement.h: Add semaphore function prototypes and rename all - functions to prepend 'ptw32_'. They are - now private to the pthreads-win32 implementation. - - * private.c: Change #warning. - Move ptw32_sem_timedwait() to semaphore.c. - - * cleanup.c: Change #warning. - - * misc.c: Remove #include - - * pthread.def: Cleanup CVS merge conflicts. - - * global.c: Ditto. - - * ChangeLog: Ditto. - - * cleanup.c: Ditto. - -Sun Jan 24 01:34:52 1999 Ross Johnson - - * semaphore.c (sem_wait): Remove second arg to - pthreadCancelableWait() call. - -Sat Jan 23 17:36:40 1999 Ross Johnson - - * pthread.def: Add new functions to export list. - - * pthread.h (PTHREAD_MUTEX_AUTO_CS_NP): New. - (PTHREAD_MUTEX_FORCE_CS_NP): New. - - * README: Updated. - -Fri Jan 22 14:31:59 1999 Ross Johnson - - * Makefile.in (CFLAGS): Remove -fhandle-exceptions. Not needed - with egcs. Add -g for debugging. - - * create.c (pthread_create): Replace __stdcall with PT_STDCALL - macro. This is a hack and must be fixed. - - * misc.c (CancelableWait): Remove redundant statement. - - * mutex.c (pthread_mutexattr_init): Cast calloc return value. - - * misc.c (CancelableWait): Add cast. - (pthread_self): Add cast. - - * exit.c (pthread_exit): Add cast. - - * condvar.c (pthread_condattr_init): Cast calloc return value. - - * cleanup.c: Reorganise conditional compilation. - - * attr.c (pthread_attr_init): Remove unused 'result'. - Cast malloc return value. - - * private.c (ptw32_callUserDestroyRoutines): Redo conditional - compilation. - - * misc.c (CancelableWait): C++ version uses 'throw'. - - * cancel.c (pthread_testcancel): Ditto. - - * implement.h (class ptw32_exception): Define for C++. - - * pthread.h: Fix C, C++, and Win32 SEH condition compilation - mayhem around pthread_cleanup_* defines. C++ version now uses John - Bossom's cleanup handlers. - (pthread_attr_t): Make 'valid' unsigned. - Define '_timeb' as 'timeb' for Ming32. - Define PT_STDCALL as nothing for Mingw32. May be temporary. - - * cancel.c (pthread_testcancel): Cast return value. - -Wed Jan 20 09:31:28 1999 Ross Johnson - - * pthread.h (pthread_mutexattr_t): Changed to a pointer. - - * mutex.c (pthread_mutex_init): Conditionally create Win32 mutex - - from John Bossom's implementation. - (pthread_mutex_destroy): Conditionally close Win32 mutex - - from John Bossom's implementation. - (pthread_mutexattr_init): Replaced by John Bossom's version. - (pthread_mutexattr_destroy): Ditto. - (pthread_mutexattr_getpshared): New function from John Bossom's - implementation. - (pthread_mutexattr_setpshared): New function from John Bossom's - implementation. - -Tue Jan 19 18:27:42 1999 Ross Johnson - - * pthread.h (pthreadCancelableTimedWait): New prototype. - (pthreadCancelableWait): Remove second argument. - - * misc.c (CancelableWait): New static function is - pthreadCancelableWait() renamed. - (pthreadCancelableWait): Now just calls CancelableWait() with - INFINITE timeout. - (pthreadCancelableTimedWait): Just calls CancelableWait() - with passed in timeout. - -Tue Jan 19 18:27:42 1999 Scott Lightner - - * private.c (ptw32_sem_timedwait): 'abstime' arg really is - absolute time. Calculate relative time to wait from current - time before passing timeout to new routine - pthreadCancelableTimedWait(). - -Tue Jan 19 10:27:39 1999 Ross Johnson - - * pthread.h (pthread_mutexattr_setforcecs_np): New prototype. - - * mutex.c (pthread_mutexattr_init): Init 'pshared' and 'forcecs' - attributes to 0. - (pthread_mutexattr_setforcecs_np): New function (not portable). - - * pthread.h (pthread_mutex_t): - Add 'mutex' element. Set to NULL in PTHREAD_MUTEX_INITIALIZER. - The pthread_mutex_*() routines will try to optimise performance - by choosing either mutexes or critical sections as the basis - for pthread mutexes for each indevidual mutex. - (pthread_mutexattr_t_): Add 'forcecs' element. - Some applications may choose to force use of critical sections - if they know that:- - the mutex is PROCESS_PRIVATE and, - either the OS supports TryEnterCriticalSection() or - pthread_mutex_trylock() will never be called on the mutex. - This attribute will be setable via a non-portable routine. - - Note: We don't yet support PROCESS_SHARED mutexes, so the - implementation as it stands will default to Win32 mutexes only if - the OS doesn't support TryEnterCriticalSection. On Win9x, and early - versions of NT 'forcecs' will need to be set in order to get - critical section based mutexes. - -Sun Jan 17 12:01:26 1999 Ross Johnson - - * pthread.h (PTHREAD_MUTEX_INITIALIZER): Init new 'staticinit' - value to '1' and existing 'valid' value to '1'. - - * global.c (ptw32_mutex_test_init_lock): Add. - - * implement.h (ptw32_mutex_test_init_lock.): Add extern. - - * private.c (ptw32_processInitialize): Init critical section for - global lock used by _mutex_check_need_init(). - (ptw32_processTerminate): Ditto (:s/Init/Destroy/). - - * dll.c (dllMain): Move call to FreeLibrary() so that it is only - called once when the process detaches. - - * mutex.c (_mutex_check_need_init): New static function to test - and init PTHREAD_MUTEX_INITIALIZER mutexes. Provides serialised - access to the internal state of the uninitialised static mutex. - Called from pthread_mutex_trylock() and pthread_mutex_lock() which - do a quick unguarded test to check if _mutex_check_need_init() - needs to be called. This is safe as the test is conservative - and is repeated inside the guarded section of - _mutex_check_need_init(). Thus in all calls except the first - calls to lock static mutexes, the additional overhead to lock any - mutex is a single memory fetch and test for zero. - - * pthread.h (pthread_mutex_t_): Add 'staticinit' member. Mutexes - initialised by PTHREAD_MUTEX_INITIALIZER aren't really initialised - until the first attempt to lock it. Using the 'valid' - flag (which flags the mutex as destroyed or not) to record this - information would be messy. It is possible for a statically - initialised mutex such as this to be destroyed before ever being - used. - - * mutex.c (pthread_mutex_trylock): Call _mutex_check_need_init() - to test/init PTHREAD_MUTEX_INITIALIZER mutexes. - (pthread_mutex_lock): Ditto. - (pthread_mutex_unlock): Add check to ensure we don't try to unlock - an unitialised static mutex. - (pthread_mutex_destroy): Add check to ensure we don't try to delete - a critical section that we never created. Allows us to destroy - a static mutex that has never been locked (and hence initialised). - (pthread_mutex_init): Set 'staticinit' flag to 0 for the new mutex. - -Sun Jan 17 12:01:26 1999 Ross Johnson - - * private.c (ptw32_sem_timedwait): Move from semaphore.c. - - * semaphore.c : Remove redundant #includes. - (ptw32_sem_timedwait): Move to private.c. - (sem_wait): Add missing abstime arg to pthreadCancelableWait() call. - -Fri Jan 15 23:38:05 1999 Ross Johnson - - * condvar.c (cond_timedwait): Remove comment. - -Fri Jan 15 15:41:28 1999 Ross Johnson - - * pthread.h: Add new 'abstime' arg to pthreadCancelableWait() - prototype. - - * condvar.c (cond_timedwait): New generalised function called by - both pthread_cond_wait() and pthread_cond_timedwait(). This is - essentially pthread_cond_wait() renamed and modified to add the - 'abstime' arg and call the new ptw32_sem_timedwait() instead of - sem_wait(). - (pthread_cond_wait): Now just calls the internal static - function cond_timedwait() with an INFINITE wait. - (pthread_cond_timedwait): Now implemented. Calls the internal - static function cond_timedwait(). - - * implement.h (ptw32_sem_timedwait): New internal function - prototype. - - * misc.c (pthreadCancelableWait): Added new 'abstime' argument - to allow shorter than INFINITE wait. - - * semaphore.c (ptw32_sem_timedwait): New function for internal - use. This is essentially sem_wait() modified to add the - 'abstime' arg and call the modified (see above) - pthreadCancelableWait(). - -Thu Jan 14 14:27:13 1999 Ross Johnson - - * cleanup.c: Correct _cplusplus to __cplusplus wherever used. - - * Makefile.in: Add CC=g++ and add -fhandle-exceptions to CFLAGS. - The derived Makefile will compile all units of the package as C++ - so that those which include try/catch exception handling should work - properly. The package should compile ok if CC=gcc, however, exception - handling will not be included and thus thread cancellation, for - example, will not work. - - * cleanup.c (ptw32_pop_cleanup): Add #warning to compile this - file as C++ if using a cygwin32 environment. Perhaps the whole package - should be compiled using g++ under cygwin. - - * private.c (ptw32_threadStart): Change #error directive - into #warning and bracket for __CYGWIN__ and derivative compilers. - -Wed Jan 13 09:34:52 1999 Ross Johnson - - * build.bat: Delete old binaries before compiling/linking. - -Tue Jan 12 09:58:38 1999 Tor Lillqvist - - * dll.c: The Microsoft compiler pragmas probably are more - appropriately protected by _MSC_VER than by _WIN32. - - * pthread.h: Define ETIMEDOUT. This should be returned by - pthread_cond_timedwait which is not implemented yet as of - snapshot-1999-01-04-1305. It was implemented in the older version. - The Microsoft compiler pragmas probably are more appropriately - protected by _MSC_VER than by _WIN32. - - * pthread.def: pthread_mutex_destroy was missing from the def file - - * condvar.c (pthread_cond_broadcast): Ensure we only wait on threads - if there were any waiting on the condition. - I think pthread_cond_broadcast should do the WaitForSingleObject - only if cv->waiters > 0? Otherwise it seems to hang, at least in the - testg thread program from glib. - -Tue Jan 12 09:58:38 1999 Ross Johnson - - * condvar.c (pthread_cond_timedwait): Fix function description - comments. - - * semaphore.c (sem_post): Correct typo in comment. - -Mon Jan 11 20:33:19 1999 Ross Johnson - - * pthread.h: Re-arrange conditional compile of pthread_cleanup-* - macros. - - * cleanup.c (ptw32_push_cleanup): Provide conditional - compile of cleanup->prev. - -1999-01-11 Tor Lillqvist - - * condvar.c (pthread_cond_init): Invert logic when testing the - return value from calloc(). - -Sat Jan 9 14:32:08 1999 Ross Johnson - - * implement.h: Compile-time switch for CYGWIN derived environments - to use CreateThread instead of _beginthreadex. Ditto for ExitThread. - Patch provided by Anders Norlander . - -Tue Jan 5 16:33:04 1999 Ross Johnson - - * cleanup.c (ptw32_pop_cleanup): Add C++ version of __try/__except - block. Move trailing "}" out of #ifdef _WIN32 block left there by - (rpj's) mistake. - - * private.c: Remove #include which is included by pthread.h. - -1998-12-11 Ben Elliston - - * README: Update info about subscribing to the mailing list. - -Mon Jan 4 11:23:40 1999 Ross Johnson - - * all: No code changes, just cleanup. - - remove #if 0 /* Pre Bossom */ enclosed code. - - Remove some redundant #includes. - * pthread.h: Update implemented/unimplemented routines list. - * Tag the bossom merge branch getting ready to merge back to main - trunk. - -Tue Dec 29 13:11:16 1998 Ross Johnson - - * implement.h: Move the following struct definitions to pthread.h: - pthread_t_, pthread_attr_t_, pthread_mutex_t_, pthread_mutex_t_, - pthread_mutexattr_t_, pthread_key_t_, pthread_cond_t_, - pthread_condattr_t_, pthread_once_t_. - - * pthread.h: Add "_" prefix to pthread_push_cleanup and - pthread_pop_cleanup internal routines, and associated struct and - typedefs. - - * buildlib.bat: Add compile command for semaphore.c - - * pthread.def: Comment out pthread_atfork routine name. - Now unimplemented. - - * tsd.c (pthread_setspecific): Rename tkAssocCreate to - ptw32_tkAssocCreate. - (pthread_key_delete): Rename tkAssocDestroy to - ptw32_tkAssocDestroy. - - * sync.c (pthread_join): Rename threadDestroy to ptw32_threadDestroy - - * sched.c (is_attr): attr is now **attr (was *attr), so add extra - NULL pointer test. - (pthread_attr_setschedparam): Increase redirection for attr which is - now a **. - (pthread_attr_getschedparam): Ditto. - (pthread_setschedparam): Change thread validation and rename "thread" - Win32 thread Handle element name to match John Bossom's version. - (pthread_getschedparam): Ditto. - - * private.c (ptw32_threadDestroy): Rename call to - callUserDestroyRoutines() as ptw32_callUserDestroyRoutines() - - * misc.c: Add #include "implement.h". - - * dll.c: Remove defined(KLUDGE) wrapped code. - - * fork.c: Remove redefinition of ENOMEM. - Remove pthread_atfork() and fork() with #if 0/#endif. - - * create.c (pthread_create): Rename threadStart and threadDestroy calls - to ptw32_threadStart and ptw32_threadDestroy. - - * implement.h: Rename "detachedstate" to "detachstate". - - * attr.c: Rename "detachedstate" to "detachstate". - -Mon Dec 28 09:54:39 1998 John Bossom - - * semaphore.c: Initial version. - * semaphore.h: Initial version. - -Mon Dec 28 09:54:39 1998 Ross Johnson - - * pthread.h (pthread_attr_t_): Change to *pthread_attr_t. - -Mon Dec 28 09:54:39 1998 John Bossom, Ben Elliston - - * attr.c (pthread_attr_setstacksize): Merge with John's version. - (pthread_attr_getstacksize): Merge with John's version. - (pthread_attr_setstackaddr): Merge with John's version. - (pthread_attr_getstackaddr): Merge with John's version. - (pthread_attr_init): Merge with John's version. - (pthread_attr_destroy): Merge with John's version. - (pthread_attr_getdetachstate): Merge with John's version. - (pthread_attr_setdetachstate): Merge with John's version. - (is_attr): attr is now **attr (was *attr), so add extra NULL pointer - test. - -Mon Dec 28 09:54:39 1998 Ross Johnson - - * implement.h (pthread_attr_t_): Add and rename elements in JEB's - version to correspond to original, so that it can be used with - original attr routines. - - * pthread.h: Add #endif at end which was truncated in merging. - -Sun Dec 20 14:51:58 1998 Ross Johnson - - * misc.c (pthreadCancelableWait): New function by John Bossom. Non-standard - but provides a hook that can be used to implement cancellation points in - applications that use this library. - - * pthread.h (pthread_cleanup_pop): C++ (non-WIN32) version uses - try/catch to emulate John Bossom's WIN32 __try/__finally behaviour. - In the WIN32 version __finally block, add a test for AbnormalTermination otherwise - cleanup is only run if the cleanup_pop execute arg is non-zero. Cancellation - should cause the cleanup to run irrespective of the execute arg. - - * condvar.c (pthread_condattr_init): Replaced by John Bossom's version. - (pthread_condattr_destroy): Replaced by John Bossom's version. - (pthread_condattr_getpshared): Replaced by John Bossom's version. - (pthread_condattr_setpshared): Replaced by John Bossom's version. - (pthread_cond_init): Replaced by John Bossom's version. - Fix comment (refered to mutex rather than condition variable). - (pthread_cond_destroy): Replaced by John Bossom's version. - (pthread_cond_wait): Replaced by John Bossom's version. - (pthread_cond_timedwait): Replaced by John Bossom's version. - (pthread_cond_signal): Replaced by John Bossom's version. - (pthread_cond_broadcast): Replaced by John Bossom's version. - -Thu Dec 17 19:10:46 1998 Ross Johnson - - * tsd.c (pthread_key_create): Replaced by John Bossom's version. - (pthread_key_delete): Replaced by John Bossom's version. - (pthread_setspecific): Replaced by John Bossom's version. - (pthread_getspecific): Replaced by John Bossom's version. - -Mon Dec 7 09:44:40 1998 John Bossom - - * cancel.c (pthread_setcancelstate): Replaced. - (pthread_setcanceltype): Replaced. - (pthread_testcancel): Replaced. - (pthread_cancel): Replaced. - - * exit.c (pthread_exit): Replaced. - - * misc.c (pthread_self): Replaced. - (pthread_equal): Replaced. - - * sync.c (pthread_detach): Replaced. - (pthread_join): Replaced. - - * create.c (pthread_create): Replaced. - - * private.c (ptw32_processInitialize): New. - (ptw32_processTerminate): New. - (ptw32_threadStart): New. - (ptw32_threadDestroy): New. - (ptw32_cleanupStack): New. - (ptw32_tkAssocCreate): New. - (ptw32_tkAssocDestroy): New. - (ptw32_callUserDestroyRoutines): New. - - * implement.h: Added non-API structures and declarations. - - * dll.c (PthreadsEntryPoint): Cast return value of GetProcAddress - to resolve compile warning from MSVC. - - * dll.c (DLLmain): Replaced. - * dll.c (PthreadsEntryPoint): - Re-applied Anders Norlander's patch:- - Initialize ptw32_try_enter_critical_section at startup - and release kernel32 handle when DLL is being unloaded. - -Sun Dec 6 21:54:35 1998 Ross Johnson - - * buildlib.bat: Fix args to CL when building the .DLL - - * cleanup.c (ptw32_destructor_run_all): Fix TSD key management. - This is a tidy-up before TSD and Thread management is completely - replaced by John Bossom's code. - - * tsd.c (pthread_key_create): Fix TSD key management. - - * global.c (ptw32_key_virgin_next): Initialise. - - * build.bat: New DOS script to compile and link a pthreads app - using Microsoft's CL compiler linker. - * buildlib.bat: New DOS script to compile all the object files - and create pthread.lib and pthread.dll using Microsoft's CL - compiler linker. - -1998-12-05 Anders Norlander - - * implement.h (ptw32_try_enter_critical_section): New extern - * dll.c (ptw32_try_enter_critical_section): New pointer to - TryEnterCriticalSection if it exists; otherwise NULL. - * dll.c (PthreadsEntryPoint): - Initialize ptw32_try_enter_critical_section at startup - and release kernel32 handle when DLL is being unloaded. - * mutex.c (pthread_mutex_trylock): Replaced check for NT with - a check if ptw32_try_enter_critical_section is valid - pointer to a function. Call ptw32_try_enter_critical_section - instead of TryEnterCriticalSection to avoid errors on Win95. - -Thu Dec 3 13:32:00 1998 Ross Johnson - - * README: Correct cygwin32 compatibility statement. - -Sun Nov 15 21:24:06 1998 Ross Johnson - - * cleanup.c (ptw32_destructor_run_all): Declare missing void * arg. - Fixup CVS merge conflicts. - -1998-10-30 Ben Elliston - - * condvar.c (cond_wait): Fix semantic error. Test for equality - instead of making an assignment. - -Fri Oct 30 15:15:50 1998 Ross Johnson - - * cleanup.c (ptw32_handler_push): Fixed bug appending new - handler to list reported by Peter Slacik - . - (new_thread): Rename poorly named local variable to - "new_handler". - -Sat Oct 24 18:34:59 1998 Ross Johnson - - * global.c: Add TSD key management array and index declarations. - - * implement.h: Ditto for externs. - -Fri Oct 23 00:08:09 1998 Ross Johnson - - * implement.h (PTW32_TSD_KEY_REUSE): Add enum. - - * private.c (ptw32_delete_thread): Add call to - ptw32_destructor_run_all() to clean up the threads keys. - - * cleanup.c (ptw32_destructor_run_all): Check for no more dirty - keys to run destructors on. Assume that the destructor call always - succeeds and set the key value to NULL. - -Thu Oct 22 21:44:44 1998 Ross Johnson - - * tsd.c (pthread_setspecific): Add key management code. - (pthread_key_create): Ditto. - (pthread_key_delete): Ditto. - - * implement.h (struct ptw32_tsd_key): Add status member. - - * tsd.c: Add description of pthread_key_delete() from the - standard as a comment. - -Fri Oct 16 17:38:47 1998 Ross Johnson - - * cleanup.c (ptw32_destructor_run_all): Fix and improve - stepping through the key table. - -Thu Oct 15 14:05:01 1998 Ross Johnson - - * private.c (ptw32_new_thread): Remove init of destructorstack. - No longer an element of pthread_t. - - * tsd.c (pthread_setspecific): Fix type declaration and cast. - (pthread_getspecific): Ditto. - (pthread_getspecific): Change error return value to NULL if key - is not in use. - -Thu Oct 15 11:53:21 1998 Ross Johnson - - * global.c (ptw32_tsd_key_table): Fix declaration. - - * implement.h(ptw32_TSD_keys_TlsIndex): Add missing extern. - (ptw32_tsd_mutex): Ditto. - - * create.c (ptw32_start_call): Fix "keys" array declaration. - Add comment. - - * tsd.c (pthread_setspecific): Fix type declaration and cast. - (pthread_getspecific): Ditto. - - * cleanup.c (ptw32_destructor_run_all): Declare missing loop - counter. - -Wed Oct 14 21:09:24 1998 Ross Johnson - - * private.c (ptw32_new_thread): Increment ptw32_threads_count. - (ptw32_delete_thread): Decrement ptw32_threads_count. - Remove some comments. - - * exit.c (ptw32_exit): : Fix two pthread_mutex_lock() calls that - should have been pthread_mutex_unlock() calls. - (ptw32_vacuum): Remove call to ptw32_destructor_pop_all(). - - * create.c (pthread_create): Fix two pthread_mutex_lock() calls that - should have been pthread_mutex_unlock() calls. - - * global.c (ptw32_tsd_mutex): Add mutex for TSD operations. - - * tsd.c (pthread_key_create): Add critical section. - (pthread_setspecific): Ditto. - (pthread_getspecific): Ditto. - (pthread_key_delete): Ditto. - - * sync.c (pthread_join): Fix two pthread_mutex_lock() calls that - should have been pthread_mutex_unlock() calls. - -Mon Oct 12 00:00:44 1998 Ross Johnson - - * implement.h (ptw32_tsd_key_table): New. - - * create.c (ptw32_start_call): Initialise per-thread TSD keys - to NULL. - - * misc.c (pthread_once): Correct typo in comment. - - * implement.h (ptw32_destructor_push): Remove. - (ptw32_destructor_pop): Remove. - (ptw32_destructor_run_all): Rename from ptw32_destructor_pop_all. - (PTW32_TSD_KEY_DELETED): Add enum. - (PTW32_TSD_KEY_INUSE): Add enum. - - * cleanup.c (ptw32_destructor_push): Remove. - (ptw32_destructor_pop): Remove. - (ptw32_destructor_run_all): Totally revamped TSD. - - * dll.c (ptw32_TSD_keys_TlsIndex): Initialise. - - * tsd.c (pthread_setspecific): Totally revamped TSD. - (pthread_getspecific): Ditto. - (pthread_create): Ditto. - (pthread_delete): Ditto. - -Sun Oct 11 22:44:55 1998 Ross Johnson - - * global.c (ptw32_tsd_key_table): Add new global. - - * implement.h (ptw32_tsd_key_t and struct ptw32_tsd_key): - Add. - (struct _pthread): Remove destructorstack. - - * cleanup.c (ptw32_destructor_run_all): Rename from - ptw32_destructor_pop_all. The key destructor stack was made - global rather than per-thread. No longer removes destructor nodes - from the stack. Comments updated. - -1998-10-06 Ben Elliston - - * condvar.c (cond_wait): Use POSIX, not Win32 mutex calls. - (pthread_cond_broadcast): Likewise. - (pthread_cond_signal): Likewise. - -1998-10-05 Ben Elliston - - * pthread.def: Update. Some functions aren't available yet, others - are macros in . - - * tests/join.c: Remove; useless. - -Mon Oct 5 14:25:08 1998 Ross Johnson - - * pthread.def: New file for building the DLL. - -1998-10-05 Ben Elliston - - * misc.c (pthread_equal): Correct inverted logic bug. - (pthread_once): Use the POSIX mutex primitives, not Win32. Remove - irrelevant FIXME comment. - - * global.c (PTHREAD_MUTEX_INITIALIZER): Move to pthread.h. - - * pthread.h (PTHREAD_MUTEX_INITIALIZER): Define. - (pthread_mutex_t): Reimplement as a struct containing a valid - flag. If the flag is ever down upon entry to a mutex operation, - we call pthread_mutex_create() to initialise the object. This - fixes the problem of how to handle statically initialised objects - that can't call InitializeCriticalSection() due to their context. - (PTHREAD_ONCE_INIT): Define. - - * mutex.c (pthread_mutex_init): Set valid flag. - (pthread_mutex_destroy): Clear valid flag. - (pthread_mutex_lock): Check and handle the valid flag. - (pthread_mutex_unlock): Likewise. - (pthread_mutex_trylock): Likewise. - - * tests/mutex3.c: New file; test for the static initialisation - macro. Passes. - - * tests/create1.c: New file; test pthread_create(). Passes. - - * tests/equal.c: Poor test; remove. - - * tests/equal1.c New file; test pthread_equal(). Passes. - - * tests/once1.c: New file; test for pthread_once(). Passes. - - * tests/self.c: Remove; rename to self1.c. - - * tests/self1.c: This is the old self.c. - - * tests/self2.c: New file. Test pthread_self() with a single - thread. Passes. - - * tests/self3.c: New file. Test pthread_self() with a couple of - threads to ensure their thread IDs differ. Passes. - -1998-10-04 Ben Elliston - - * tests/mutex2.c: Test pthread_mutex_trylock(). Passes. - - * tests/mutex1.c: New basic test for mutex functions (it passes). - (main): Eliminate warning. - - * configure.in: Test for __stdcall, not _stdcall. Typo. - - * configure: Regenerate. - - * attr.c (pthread_attr_setstackaddr): Remove FIXME comment. Win32 - does know about ENOSYS after all. - (pthread_attr_setstackaddr): Likewise. - -1998-10-03 Ben Elliston - - * configure.in: Test for the `_stdcall' keyword. Define `STDCALL' - to `_stdcall' if we have it, null otherwise. - - * configure: Regenerate. - - * acconfig.h (STDCALL): New define. - - * config.h.in: Regenerate. - - * create.c (ptw32_start_call): Add STDCALL prefix. - - * mutex.c (pthread_mutex_init): Correct function signature. - - * attr.c (pthread_attr_init): Only zero out the `sigmask' member - if we have the sigset_t type. - - * pthread.h: No need to include . It doesn't even exist - on Win32! Again, an artifact of cross-compilation. - (pthread_sigmask): Only provide if we have the sigset_t type. - - * process.h: Remove. This was a stand-in before we started doing - native compilation under Win32. - - * pthread.h (pthread_mutex_init): Make `attr' argument const. - -1998-10-02 Ben Elliston - - * COPYING: Remove. - - * COPYING.LIB: Add. This library is under the LGPL. - -1998-09-13 Ben Elliston - - * configure.in: Test for required system features. - - * configure: Generate. - - * acconfig.h: New file. - - * config.h.in: Generate. - - * Makefile.in: Renamed from Makefile. - - * COPYING: Import from a recent GNU package. - - * config.guess: Likewise. - - * config.sub: Likewise. - - * install-sh: Likewise. - - * config.h: Remove. - - * Makefile: Likewise. - -1998-09-12 Ben Elliston - - * windows.h: No longer needed; remove. - - * windows.c: Likewise. - -Sat Sep 12 20:09:24 1998 Ross Johnson - - * windows.h: Remove error number definitions. These are in - - * tsd.c: Add comment explaining rationale for not building - POSIX TSD on top of Win32 TLS. - -1998-09-12 Ben Elliston - - * {most}.c: Include to get POSIX error values. - - * signal.c (pthread_sigmask): Only provide if HAVE_SIGSET_T is - defined. - - * config.h: #undef features, don't #define them. This will be - generated by autoconf very soon. - -1998-08-11 Ben Elliston - - * Makefile (LIB): Define. - (clean): Define target. - (all): Build a library not just the object files. - - * pthread.h: Provide a definition for struct timespec if we don't - already have one. - - * windows.c (TlsGetValue): Bug fix. - -Thu Aug 6 15:19:22 1998 Ross Johnson - - * misc.c (pthread_once): Fix arg 1 of EnterCriticalSection() - and LeaveCriticalSection() calls to pass address-of lock. - - * fork.c (pthread_atfork): Typecast (void (*)(void *)) funcptr - in each ptw32_handler_push() call. - - * exit.c (ptw32_exit): Fix attr arg in - pthread_attr_getdetachstate() call. - - * private.c (ptw32_new_thread): Typecast (HANDLE) NULL. - (ptw32_delete_thread): Ditto. - - * implement.h: (PTW32_MAX_THREADS): Add define. This keeps - changing in an attempt to make thread administration data types - opaque and cleanup DLL startup. - - * dll.c (PthreadsEntryPoint): - (ptw32_virgins): Remove malloc() and free() calls. - (ptw32_reuse): Ditto. - (ptw32_win32handle_map): Ditto. - (ptw32_threads_mutex_table): Ditto. - - * global.c (_POSIX_THREAD_THREADS_MAX): Initialise with - PTW32_MAX_THREADS. - (ptw32_virgins): Ditto. - (ptw32_reuse): Ditto. - (ptw32_win32handle_map): Ditto. - (ptw32_threads_mutex_table): Ditto. - - * create.c (pthread_create): Typecast (HANDLE) NULL. - Typecast (unsigned (*)(void *)) start_routine. - - * condvar.c (pthread_cond_init): Add address-of operator & to - arg 1 of pthread_mutex_init() call. - (pthread_cond_destroy): Add address-of operator & to - arg 1 of pthread_mutex_destroy() call. - - * cleanup.c (ptw32_destructor_pop_all): Add (int) cast to - pthread_getspecific() arg. - (ptw32_destructor_pop): Add (void *) cast to "if" conditional. - (ptw32_destructor_push): Add (void *) cast to - ptw32_handler_push() "key" arg. - (malloc.h): Add include. - - * implement.h (ptw32_destructor_pop): Add prototype. - - * tsd.c (implement.h): Add include. - - * sync.c (pthread_join): Remove target_thread_mutex and it's - initialisation. Rename getdetachedstate to getdetachstate. - Remove unused variable "exitcode". - (pthread_detach): Remove target_thread_mutex and it's - initialisation. Rename getdetachedstate to getdetachstate. - Rename setdetachedstate to setdetachstate. - - * signal.c (pthread_sigmask): Rename SIG_SET to SIG_SETMASK. - Cast "set" to (long *) in assignment to passify compiler warning. - Add address-of operator & to thread->attr.sigmask in memcpy() call - and assignment. - (pthread_sigmask): Add address-of operator & to thread->attr.sigmask - in memcpy() call and assignment. - - * windows.h (THREAD_PRIORITY_ERROR_RETURN): Add. - (THREAD_PRIORITY_LOWEST): Add. - (THREAD_PRIORITY_HIGHEST): Add. - - * sched.c (is_attr): Add function. - (implement.h): Add include. - (pthread_setschedparam): Rename all instances of "sched_policy" - to "sched_priority". - (pthread_getschedparam): Ditto. - -Tue Aug 4 16:57:58 1998 Ross Johnson - - * private.c (ptw32_delete_thread): Fix typo. Add missing ';'. - - * global.c (ptw32_virgins): Change types from pointer to - array pointer. - (ptw32_reuse): Ditto. - (ptw32_win32handle_map): Ditto. - (ptw32_threads_mutex_table): Ditto. - - * implement.h(ptw32_virgins): Change types from pointer to - array pointer. - (ptw32_reuse): Ditto. - (ptw32_win32handle_map): Ditto. - (ptw32_threads_mutex_table): Ditto. - - * private.c (ptw32_delete_thread): Fix "entry" should be "thread". - - * misc.c (pthread_self): Add extern for ptw32_threadID_TlsIndex. - - * global.c: Add comment. - - * misc.c (pthread_once): Fix member -> dereferences. - Change ptw32_once_flag to once_control->flag in "if" test. - -Tue Aug 4 00:09:30 1998 Ross Johnson - - * implement.h(ptw32_virgins): Add extern. - (ptw32_virgin_next): Ditto. - (ptw32_reuse): Ditto. - (ptw32_reuse_top): Ditto. - (ptw32_win32handle_map): Ditto. - (ptw32_threads_mutex_table): Ditto. - - * global.c (ptw32_virgins): Changed from array to pointer. - Storage allocation for the array moved into dll.c. - (ptw32_reuse): Ditto. - (ptw32_win32handle_map): Ditto. - (ptw32_threads_mutex_table): Ditto. - - * dll.c (PthreadsEntryPoint): Set up thread admin storage when - DLL is loaded. - - * fork.c (pthread_atfork): Fix function pointer arg to all - ptw32_handler_push() calls. Change "arg" arg to NULL in child push. - - * exit.c: Add windows.h and process.h includes. - (ptw32_exit): Add local detachstate declaration. - (ptw32_exit): Fix incorrect name for pthread_attr_getdetachstate(). - - * pthread.h (_POSIX_THREAD_ATTR_STACKSIZE): Move from global.c - (_POSIX_THREAD_ATTR_STACKADDR): Ditto. - - * create.c (pthread_create): Fix #if should be #ifdef. - (ptw32_start_call): Remove usused variables. - - * process.h: Create. - - * windows.h: Move _beginthreadex and _endthreadex into - process.h - -Mon Aug 3 21:19:57 1998 Ross Johnson - - * condvar.c (pthread_cond_init): Add NULL attr to - pthread_mutex_init() call - default attributes will be used. - (cond_wait): Fix typo. - (cond_wait): Fix typo - cv was ev. - (pthread_cond_broadcast): Fix two identical typos. - - * cleanup.c (ptw32_destructor_pop_all): Remove _ prefix from - PTHREAD_DESTRUCTOR_ITERATIONS. - - * pthread.h: Move _POSIX_* values into posix.h - - * pthread.h: Fix typo in pthread_mutex_init() prototype. - - * attr.c (pthread_attr_init): Fix error in priority member init. - - * windows.h (THREAD_PRIORITY_NORMAL): Add. - - * pthread.h (sched_param): Add missing ';' to struct definition. - - * attr.c (pthread_attr_init): Remove obsolete pthread_attr_t - member initialisation - cancelstate, canceltype, cancel_pending. - (is_attr): Make arg "attr" a const. - - * implement.h (PTW32_HANDLER_POP_LIFO): Remove definition. - (PTW32_HANDLER_POP_FIFO): Ditto. - (PTW32_VALID): Add missing newline escape (\). - (ptw32_handler_node): Make element "next" a pointer. - -1998-08-02 Ben Elliston - - * windows.h: Remove duplicate TlsSetValue() prototype. Add - TlsGetValue() prototype. - (FALSE): Define. - (TRUE): Likewise. - Add forgotten errno values. Guard against multiple #includes. - - * windows.c: New file. Implement stubs for Win32 functions. - - * Makefile (SRCS): Remove. Not explicitly needed. - (CFLAGS): Add -Wall for all warnings with GCC. - -Sun Aug 2 19:03:42 1998 Ross Johnson - - * config.h: Create. This is a temporary stand-in for autoconf yet - to be done. - (HAVE_SIGNAL_H): Add. - - * pthread.h: Minor rearrangement for temporary config.h. - -Fri Jul 31 14:00:29 1998 Ross Johnson - - * cleanup.c (ptw32_destructor_pop): Implement. Removes - destructors associated with a key without executing them. - (ptw32_destructor_pop_all): Add FIXME comment. - - * tsd.c (pthread_key_delete): Add call to ptw32_destructor_pop(). - -Fri Jul 31 00:05:45 1998 Ross Johnson - - * tsd.c (pthread_key_create): Update to properly associate - the destructor routine with the key. - (pthread_key_delete): Add FIXME comment. - - * exit.c (ptw32_vacuum): Add call to - ptw32_destructor_pop_all(). - - * implement.h (ptw32_handler_pop_all): Add prototype. - (ptw32_destructor_pop_all): Ditto. - - * cleanup.c (ptw32_destructor_push): Implement. This is just a - call to ptw32_handler_push(). - (ptw32_destructor_pop_all): Implement. This is significantly - different to ptw32_handler_pop_all(). - - * Makefile (SRCS): Create. Preliminary. - - * windows.h: Create. Contains Win32 definitions for compile - testing. This is just a standin for the real one. - - * pthread.h (SIG_UNBLOCK): Fix typo. Was SIG_BLOCK. - (windows.h): Add include. Required for CRITICAL_SECTION. - (pthread_cond_t): Move enum declaration outside of struct - definition. - (unistd.h): Add include - may be temporary. - - * condvar.c (windows.h): Add include. - - * implement.h (PTW32_THIS): Remove - no longer required. - (PTW32_STACK): Use pthread_self() instead of PTW32_THIS. - -Thu Jul 30 23:12:45 1998 Ross Johnson - - * implement.h: Remove ptw32_find_entry() prototype. - - * private.c: Extend comments. - Remove ptw32_find_entry() - no longer needed. - - * create.c (ptw32_start_call): Add call to TlsSetValue() to - store the thread ID. - - * dll.c (PthreadsEntryPoint): Implement. This is called - whenever a process loads the DLL. Used to initialise thread - local storage. - - * implement.h: Add ptw32_threadID_TlsIndex. - Add ()s around PTW32_VALID expression. - - * misc.c (pthread_self): Re-implement using Win32 TLS to store - the threads own ID. - -Wed Jul 29 11:39:03 1998 Ross Johnson - - * private.c: Corrections in comments. - (ptw32_new_thread): Alter "if" flow to be more natural. - - * cleanup.c (ptw32_handler_push): Same as below. - - * create.c (pthread_create): Same as below. - - * private.c (ptw32_new_thread): Rename "new" to "new_thread". - Since when has a C programmer been required to know C++? - -Tue Jul 28 14:04:29 1998 Ross Johnson - - * implement.h: Add PTW32_VALID macro. - - * sync.c (pthread_join): Modify to use the new thread - type and ptw32_delete_thread(). Rename "target" to "thread". - Remove extra local variable "target". - (pthread_detach): Ditto. - - * signal.c (pthread_sigmask): Move init of "us" out of inner block. - Fix instance of "this" should have been "us". Rename "us" to "thread". - - * sched.c (pthread_setschedparam): Modify to use the new thread - type. - (pthread_getschedparam): Ditto. - - * private.c (ptw32_find_thread): Fix return type and arg. - - * implement.h: Remove PTW32_YES and PTW32_NO. - (ptw32_new_thread): Add prototype. - (ptw32_find_thread): Ditto. - (ptw32_delete_thread): Ditto. - (ptw32_new_thread_entry): Remove prototype. - (ptw32_find_thread_entry): Ditto. - (ptw32_delete_thread_entry): Ditto. - ( PTW32_NEW, PTW32_INUSE, PTW32_EXITED, PTW32_REUSE): - Add. - - - * create.c (pthread_create): Minor rename "us" to "new" (I need - these cues but it doesn't stop me coming out with some major bugs - at times). - Load start_routine and arg into the thread so the wrapper can - call it. - - * exit.c (pthread_exit): Fix pthread_this should be pthread_self. - - * cancel.c (pthread_setcancelstate): Change - ptw32_threads_thread_t * to pthread_t and init with - pthread_this(). - (pthread_setcanceltype): Ditto. - - * exit.c (ptw32_exit): Add new pthread_t arg. - Rename ptw32_delete_thread_entry to ptw32_delete_thread. - Rename "us" to "thread". - (pthread_exit): Call ptw32_exit with added thread arg. - - * create.c (ptw32_start_call): Insert missing ")". - Add "us" arg to ptw32_exit() call. - (pthread_create): Modify to use new thread allocation scheme. - - * private.c: Added detailed explanation of the new thread - allocation scheme. - (ptw32_new_thread): Totally rewritten to use - new thread allocation scheme. - (ptw32_delete_thread): Ditto. - (ptw32_find_thread): Obsolete. - -Mon Jul 27 17:46:37 1998 Ross Johnson - - * create.c (pthread_create): Start of rewrite. Not completed yet. - - * private.c (ptw32_new_thread_entry): Start of rewrite. Not - complete. - - * implement.h (ptw32_threads_thread): Rename, remove thread - member, add win32handle and ptstatus members. - (ptw32_t): Add. - - * pthread.h: pthread_t is no longer mapped directly to a Win32 - HANDLE type. This is so we can let the Win32 thread terminate and - reuse the HANDLE while pthreads holds it's own thread ID until - the last waiting join exits. - -Mon Jul 27 00:20:37 1998 Ross Johnson - - * private.c (ptw32_delete_thread_entry): Destroy the thread - entry attribute object before deleting the thread entry itself. - - * attr.c (pthread_attr_init): Initialise cancel_pending = FALSE. - (pthread_attr_setdetachstate): Rename "detached" to "detachedstate". - (pthread_attr_getdetachstate): Ditto. - - * exit.c (ptw32_exit): Fix incorrect check for detachedstate. - - * implement.h (ptw32_call_t): Remove env member. - -Sun Jul 26 13:06:12 1998 Ross Johnson - - * implement.h (ptw32_new_thread_entry): Fix prototype. - (ptw32_find_thread_entry): Ditto. - (ptw32_delete_thread_entry): Ditto. - (ptw32_exit): Add prototype. - - * exit.c (ptw32_exit): New function. Called from pthread_exit() - and ptw32_start_call() to exit the thread. It allows an extra - argument which is the return code passed to _endthreadex(). - (ptw32_exit): Move thread entry delete call from ptw32_vacuum() - into here. Add more explanation of thread entry deletion. - (ptw32_exit): Clarify comment. - - * create.c (ptw32_start_call): Change pthread_exit() call to - ptw32_exit() call. - - * exit.c (ptw32_vacuum): Add thread entry deletion code - moved from ptw32_start_call(). See next item. - (pthread_exit): Remove longjmp(). Add mutex lock around thread table - manipulation code. This routine now calls _enthreadex(). - - * create.c (ptw32_start_call): Remove setjmp() call and move - cleanup code out. Call pthread_exit(NULL) to terminate the thread. - -1998-07-26 Ben Elliston - - * tsd.c (pthread_getspecific): Update comments. - - * mutex.c (pthread_mutexattr_setpshared): Not supported; remove. - (pthread_mutexattr_getpshared): Likewise. - - * pthread.h (pthread_mutexattr_setpshared): Remove prototype. - (pthread_mutexattr_getpshared): Likewise. - -Sun Jul 26 00:09:59 1998 Ross Johnson - - * sync.c: Rename all instances of ptw32_count_mutex to - ptw32_table_mutex. - - * implement.h: Rename ptw32_count_mutex to - ptw32_table_mutex. - - * global.c: Rename ptw32_count_mutex to - ptw32_table_mutex. - - * create.c (pthread_create): Add critical sections. - (ptw32_start_call): Rename ptw32_count_mutex to - ptw32_table_mutex. - - * cancel.c (pthread_setcancelstate): Fix indirection bug and rename - "this" to "us". - - * signal.c (pthread_sigmask): Rename "this" to "us" and fix some - minor syntax errors. Declare "us" and initialise it. - - * sync.c (pthread_detach): Rename "this" to "target". - - * pthread.h: Converting PTHREAD_* defines to alias the (const int) - values in global.c. - - * global.c: Started converting PTHREAD_* defines to (const int) as - a part of making the eventual pthreads DLL binary compatible - through version changes. - - * condvar.c (cond_wait): Add cancelation point. This applies the - point to both pthread_cond_wait() and pthread_cond_timedwait(). - - * exit.c (pthread_exit): Rename "this" to "us". - - * implement.h: Add comment. - - * sync.c (pthread_join): I've satisfied myself that pthread_detach() - does set the detached attribute in the thread entry attributes - to PTHREAD_CREATE_DETACHED. "if" conditions were changed to test - that attribute instead of a separate flag. - - * create.c (pthread_create): Rename "this" to "us". - (pthread_create): cancelstate and canceltype are not attributes - so the copy to thread entry attribute storage was removed. - Only the thread itself can change it's cancelstate or canceltype, - ie. the thread must exist already. - - * private.c (ptw32_delete_thread_entry): Mutex locks removed. - Mutexes must be applied at the caller level. - (ptw32_new_thread_entry): Ditto. - (ptw32_new_thread_entry): Init cancelstate, canceltype, and - cancel_pending to default values. - (ptw32_new_thread_entry): Rename "this" to "new". - (ptw32_find_thread_entry): Rename "this" to "entry". - (ptw32_delete_thread_entry): Rename "thread_entry" to "entry". - - * create.c (ptw32_start_call): Mutexes changed to - ptw32_count_mutex. All access to the threads table entries is - under the one mutex. Otherwise chaos reigns. - -Sat Jul 25 23:16:51 1998 Ross Johnson - - * implement.h (ptw32_threads_thread): Move cancelstate and - canceltype members out of pthread_attr_t into here. - - * fork.c (fork): Add comment. - -1998-07-25 Ben Elliston - - * fork.c (fork): Autoconfiscate. - -Sat Jul 25 00:00:13 1998 Ross Johnson - - * create.c (ptw32_start_call): Set thread priority. Ensure our - thread entry is removed from the thread table but only if - pthread_detach() was called and there are no waiting joins. - (pthread_create): Set detach flag in thread entry if the - thread is created PTHREAD_CREATE_DETACHED. - - * pthread.h (pthread_attr_t): Rename member "detachedstate". - - * attr.c (pthread_attr_init): Rename attr members. - - * exit.c (pthread_exit): Fix indirection mistake. - - * implement.h (PTW32_THREADS_TABLE_INDEX): Add. - - * exit.c (ptw32_vacuum): Fix incorrect args to - ptw32_handler_pop_all() calls. - Make thread entry removal conditional. - - * sync.c (pthread_join): Add multiple join and async detach handling. - - * implement.h (PTW32_THREADS_TABLE_INDEX): Add. - - * global.c (ptw32_threads_mutex_table): Add. - - * implement.h (ptw32_once_flag): Remove. - (ptw32_once_lock): Ditto. - (ptw32_threads_mutex_table): Add. - - * global.c (ptw32_once_flag): Remove. - (ptw32_once_lock): Ditto. - - * sync.c (pthread_join): Fix tests involving new return value - from ptw32_find_thread_entry(). - (pthread_detach): Ditto. - - * private.c (ptw32_find_thread_entry): Failure return code - changed from -1 to NULL. - -Fri Jul 24 23:09:33 1998 Ross Johnson - - * create.c (pthread_create): Change . to -> in sigmask memcpy() args. - - * pthread.h: (pthread_cancel): Add function prototype. - (pthread_testcancel): Ditto. - -1998-07-24 Ben Elliston - - * pthread.h (pthread_condattr_t): Rename dummy structure member. - (pthread_mutexattr_t): Likewise. - -Fri Jul 24 21:13:55 1998 Ross Johnson - - * cancel.c (pthread_cancel): Implement. - (pthread_testcancel): Implement. - - * exit.c (pthread_exit): Add comment explaining the longjmp(). - - * implement.h (ptw32_threads_thread_t): New member cancelthread. - (PTW32_YES): Define. - (PTW32_NO): Define. - (RND_SIZEOF): Remove. - - * create.c (pthread_create): Rename cancelability to cancelstate. - - * pthread.h (pthread_attr_t): Rename cancelability to cancelstate. - (PTHREAD_CANCELED): Define. - -1998-07-24 Ben Elliston - - * pthread.h (SIG_BLOCK): Define if not already defined. - (SIG_UNBLOCK): Likewise. - (SIG_SETMASK): Likewise. - (pthread_attr_t): Add signal mask member. - (pthread_sigmask): Add function prototype. - - * signal.c (pthread_sigmask): Implement. - - * create.c: #include to get a prototype for memcpy(). - (pthread_create): New threads inherit their creator's signal - mask. Copy the signal mask to the new thread structure if we know - about signals. - -Fri Jul 24 16:33:17 1998 Ross Johnson - - * fork.c (pthread_atfork): Add all the necessary push calls. - Local implementation semantics: - If we get an ENOMEM at any time then ALL handlers - (including those from previous pthread_atfork() calls) will be - popped off each of the three atfork stacks before we return. - (fork): Add all the necessary pop calls. Add the thread cancellation - and join calls to the child fork. - Add #includes. - - * implement.h: (ptw32_handler_push): Fix return type and stack arg - type in prototype. - (ptw32_handler_pop): Fix stack arg type in prototype. - (ptw32_handler_pop_all): Fix stack arg type in prototype. - - * cleanup.c (ptw32_handler_push): Change return type to int and - return ENOMEM if malloc() fails. - - * sync.c (pthread_detach): Use equality test, not assignment. - - * create.c (ptw32_start_call): Add call to Win32 CloseHandle() - if thread is detached. - -1998-07-24 Ben Elliston - - * sync.c (pthread_detach): Close the Win32 thread handle to - emulate detached (or daemon) threads. - -Fri Jul 24 03:00:25 1998 Ross Johnson - - * sync.c (pthread_join): Save valueptr arg in joinvalueptr for - pthread_exit() to use. - - * private.c (ptw32_new_thread_entry): Initialise joinvalueptr to - NULL. - - * create.c (ptw32_start_call): Rewrite to facilitate joins. - pthread_exit() will do a longjmp() back to here. Does appropriate - cleanup and exit/return from the thread. - (pthread_create): _beginthreadex() now passes a pointer to our - thread table entry instead of just the call member of that entry. - - * implement.h (ptw32_threads_thread): New member - void ** joinvalueptr. - (ptw32_call_t): New member jmpbuf env. - - * exit.c (pthread_exit): Major rewrite to handle joins and handing - value pointer to joining thread. Uses longjmp() back to - ptw32_start_call(). - - * create.c (pthread_create): Ensure values of new attribute members - are copied to the thread attribute object. - - * attr.c (pthread_attr_destroy): Fix merge conflicts. - (pthread_attr_getdetachstate): Fix merge conflicts. - (pthread_attr_setdetachstate): Fix merge conflicts. - - * pthread.h: Fix merge conflicts. - - * sync.c (pthread_join): Fix merge conflicts. - -Fri Jul 24 00:21:21 1998 Ross Johnson - - * sync.c (pthread_join): Add check for valid and joinable - thread. - (pthread_detach): Implement. After checking for a valid and joinable - thread, it's still a no-op. - - * private.c (ptw32_find_thread_entry): Bug prevented returning - an error value in some cases. - - * attr.c (pthread_attr_setdetachedstate): Implement. - (pthread_attr_getdetachedstate): Implement. - - * implement.h: Move more hidden definitions into here from - pthread.h. - -1998-07-24 Ben Elliston - - * pthread.h (PTHREAD_CREATE_JOINABLE): Define. - (PTHREAD_CREATE_DETACHED): Likewise. - (pthread_attr_t): Add new structure member `detached'. - (pthread_attr_getdetachstate): Add function prototype. - (pthread_attr_setdetachstate): Likewise. - - * sync.c (pthread_join): Return if the target thread is detached. - - * attr.c (pthread_attr_init): Initialise cancelability and - canceltype structure members. - (pthread_attr_getdetachstate): Implement. - (pthread_attr_setdetachstate): Likewise. - - * implement.h (PTW32_CANCEL_DEFAULTS): Remove. Bit fields - proved to be too cumbersome. Set the defaults in attr.c using the - public PTHREAD_CANCEL_* constants. - - * cancel.c: New file. - - * pthread.h (sched_param): Define this type. - (pthread_attr_getschedparam): Add function prototype. - (pthread_attr_setschedparam): Likewise. - (pthread_setcancelstate): Likewise. - (pthread_setcanceltype): Likewise. - (sched_get_priority_min): Likewise. - (sched_get_priority_max): Likewise. - (pthread_mutexattr_setprotocol): Remove; not supported. - (pthread_mutexattr_getprotocol): Likewise. - (pthread_mutexattr_setprioceiling): Likewise. - (pthread_mutexattr_getprioceiling): Likewise. - (pthread_attr_t): Add canceltype member. Update comments. - (SCHED_OTHER): Define this scheduling policy constant. - (SCHED_FIFO): Likewise. - (SCHED_RR): Likewise. - (SCHED_MIN): Define the lowest possible value for this constant. - (SCHED_MAX): Likewise, the maximum possible value. - (PTHREAD_CANCEL_ASYNCHRONOUS): Redefine. - (PTHREAD_CANCEL_DEFERRED): Likewise. - - * sched.c: New file. - (pthread_setschedparam): Implement. - (pthread_getschedparam): Implement. - (sched_get_priority_max): Validate policy argument. - (sched_get_priority_min): Likewise. - - * mutex.c (pthread_mutexattr_setprotocol): Remove; not supported. - (pthread_mutexattr_getprotocol): Likewise. - (pthread_mutexattr_setprioceiling): Likewise. - (pthread_mutexattr_getprioceiling): Likewise. - -Fri Jul 24 00:21:21 1998 Ross Johnson - - * create.c (pthread_create): Arg to ptw32_new_thread_entry() - changed. See next entry. Move mutex locks out. Changes made yesterday - and today allow us to start the new thread running rather than - temporarily suspended. - - * private.c (ptw32_new_thread_entry): ptw32_thread_table - was changed back to a table of thread structures rather than pointers. - As such we're trading storage for increaded speed. This routine - was modified to work with the new table. Mutex lock put in around - global data accesses. - (ptw32_find_thread_entry): Ditto - (ptw32_delete_thread_entry): Ditto - -Thu Jul 23 23:25:30 1998 Ross Johnson - - * global.c: New. Global data objects declared here. These moved from - pthread.h. - - * pthread.h: Move implementation hidden definitions into - implement.h. - - * implement.h: Move implementation hidden definitions from - pthread.h. Add constants to index into the different handler stacks. - - * cleanup.c (ptw32_handler_push): Simplify args. Restructure. - (ptw32_handler_pop): Simplify args. Restructure. - (ptw32_handler_pop_all): Simplify args. Restructure. - -Wed Jul 22 00:16:22 1998 Ross Johnson - - * attr.c, implement.h, pthread.h, ChangeLog: Resolve CVS merge - conflicts. - - * private.c (ptw32_find_thread_entry): Changes to return type - to support leaner ptw32_threads_table[] which now only stores - ptw32_thread_thread_t *. - (ptw32_new_thread_entry): Internal changes. - (ptw32_delete_thread_entry): Internal changes to avoid contention. - Calling routines changed accordingly. - - * pthread.h: Modified cleanup macros to use new generic push and pop. - Added destructor and atfork stacks to ptw32_threads_thread_t. - - * cleanup.c (ptw32_handler_push, ptw32_handler_pop, - ptw32_handler_pop_all): Renamed cleanup push and pop routines - and made generic to handle destructors and atfork handlers as - well. - - * create.c (ptw32_start_call): New function is a wrapper for - all new threads. It allows us to do some cleanup when the thread - returns, ie. that is otherwise only done if the thread is cancelled. - - * exit.c (ptw32_vacuum): New function contains code from - pthread_exit() that we need in the new ptw32_start_call() - as well. - - * implement.h: Various additions and minor changes. - - * pthread.h: Various additions and minor changes. - Change cleanup handler macros to use generic handler push and pop - functions. - - * attr.c: Minor mods to all functions. - (is_attr): Implemented missing function. - - * create.c (pthread_create): More clean up. - - * private.c (ptw32_find_thread_entry): Implement. - (ptw32_delete_thread_entry): Implement. - (ptw32_new_thread_entry): Implement. - These functions manipulate the implementations internal thread - table and are part of general code cleanup and modularisation. - They replace ptw32_getthreadindex() which was removed. - - * exit.c (pthread_exit): Changed to use the new code above. - - * pthread.h: Add cancelability constants. Update comments. - -1998-07-22 Ben Elliston - - * attr.c (pthread_setstacksize): Update test of attr argument. - (pthread_getstacksize): Likewise. - (pthread_setstackaddr): Likewise. - (pthread_getstackaddr): Likewise. - (pthread_attr_init): No need to allocate any storage. - (pthread_attr_destroy): No need to free any storage. - - * mutex.c (is_attr): Not likely to be needed; remove. - (remove_attr): Likewise. - (insert_attr): Likewise. - - * implement.h (ptw32_mutexattr_t): Moved to a public definition - in pthread.h. There was little gain in hiding these details. - (ptw32_condattr_t): Likewise. - (ptw32_attr_t): Likewise. - - * pthread.h (pthread_atfork): Add function prototype. - (pthread_attr_t): Moved here from implement.h. - - * fork.c (pthread_atfork): Preliminary implementation. - (ptw32_fork): Likewise. - -Wed Jul 22 00:16:22 1998 Ross Johnson - - * cleanup.c (ptw32_cleanup_push): Implement. - (ptw32_cleanup_pop): Implement. - (ptw32_do_cancellation): Implement. - These are private to the implementation. The real cleanup functions - are macros. See below. - - * pthread.h (pthread_cleanup_push): Implement as a macro. - (pthread_cleanup_pop): Implement as a macro. - Because these are macros which start and end a block, the POSIX scoping - requirement is observed. See the comment in the file. - - * exit.c (pthread_exit): Refine the code. - - * create.c (pthread_create): Code cleanup. - - * implement.h (RND_SIZEOF): Add RND_SIZEOF(T) to round sizeof(T) - up to multiple of DWORD. - Add function prototypes. - - * private.c (ptw32_getthreadindex): "*thread" should have been - "thread". Detect empty slot fail condition. - -1998-07-20 Ben Elliston - - * misc.c (pthread_once): Implement. Don't use a per-application - flag and mutex--make `pthread_once_t' contain these elements in - their structure. The earlier version had incorrect semantics. - - * pthread.h (ptw32_once_flag): Add new variable. Remove. - (ptw32_once_lock): Add new mutex lock to ensure integrity of - access to ptw32_once_flag. Remove. - (pthread_once): Add function prototype. - (pthread_once_t): Define this type. - -Mon Jul 20 02:31:05 1998 Ross Johnson - - * private.c (ptw32_getthreadindex): Implement. - - * pthread.h: Add application static data dependent on - _PTHREADS_BUILD_DLL define. This is needed to avoid allocating - non-sharable static data within the pthread DLL. - - * implement.h: Add ptw32_cleanup_stack_t, ptw32_cleanup_node_t - and PTW32_HASH_INDEX. - - * exit.c (pthread_exit): Begin work on cleanup and de-allocate - thread-private storage. - - * create.c (pthread_create): Add thread to thread table. - Keep a thread-private copy of the attributes with default values - filled in when necessary. Same for the cleanup stack. Make - pthread_create C run-time library friendly by using _beginthreadex() - instead of CreateThread(). Fix error returns. - -Sun Jul 19 16:26:23 1998 Ross Johnson - - * implement.h: Rename pthreads_thread_count to ptw32_threads_count. - Create ptw32_threads_thread_t struct to keep thread specific data. - - * create.c: Rename pthreads_thread_count to ptw32_threads_count. - (pthread_create): Handle errors from CreateThread(). - -1998-07-19 Ben Elliston - - * condvar.c (pthread_cond_wait): Generalise. Moved from here .. - (cond_wait): To here. - (pthread_cond_timedwait): Implement; use generalised cond_wait(). - - * pthread.h (pthread_key_t): Define this type. - (pthread_key_create): Add function prototype. - (pthread_setspecific): Likewise. - (pthread_getspecific): Likwise. - (pthread_key_delete): Likewise. - - * tsd.c (pthread_key_create): Implement. - (pthread_setspecific): Likewise. - (pthread_getspecific): Likewise. - (pthread_key_delete): Likewise. - - * mutex.c (pthread_mutex_trylock): Return ENOSYS if this function - is called on a Win32 platform which is not Windows NT. - -1998-07-18 Ben Elliston - - * condvar.c (pthread_condattr_init): Do not attempt to malloc any - storage; none is needed now that condattr_t is an empty struct. - (pthread_condattr_destory): Likewise; do not free storage. - (pthread_condattr_setpshared): No longer supported; return ENOSYS. - (pthread_condattr_getpshared): Likewise. - (pthread_cond_init): Implement with help from Douglas Schmidt. - Remember to initialise the cv's internal mutex. - (pthread_cond_wait): Likewise. - (pthread_cond_signal): Likewise. - (pthread_cond_broadcast): Likewise. - (pthread_cond_timedwait): Preliminary implementation, but I need - to see some API documentation for `WaitForMultipleObject'. - (pthread_destory): Implement. - - * pthread.h (pthread_cond_init): Add function protoype. - (pthread_cond_broadcast): Likewise. - (pthread_cond_signal): Likewise. - (pthread_cond_timedwait): Likewise. - (pthread_cond_wait): Likewise. - (pthread_cond_destroy): Likewise. - (pthread_cond_t): Define this type. Fix for u_int. Do not assume - that the mutex contained withing the pthread_cond_t structure will - be a critical section. Use our new POSIX type! - - * implement.h (ptw32_condattr_t): Remove shared attribute. - -1998-07-17 Ben Elliston - - * pthread.h (PTHREADS_PROCESS_PRIVATE): Remove. - (PTHREAD_PROCESS_SHARED): Likewise. No support for mutexes shared - across processes for now. - (pthread_mutex_t): Use a Win32 CRITICAL_SECTION type for better - performance. - - * implement.h (ptw32_mutexattr_t): Remove shared attribute. - - * mutex.c (pthread_mutexattr_setpshared): This optional function - is no longer supported, since we want to implement POSIX mutex - variables using the much more efficient Win32 critical section - primitives. Critical section objects in Win32 cannot be shared - between processes. - (pthread_mutexattr_getpshared): Likewise. - (pthread_mutexattr_init): No need to malloc any storage; the - attributes structure is now empty. - (pthread_mutexattr_destroy): This is now a nop. - (pthread_mutex_init): Use InitializeCriticalSection(). - (pthread_mutex_destroy): Use DeleteCriticalSection(). - (pthread_mutex_lock): Use EnterCriticalSection(). - (pthread_mutex_trylock): Use TryEnterCriticalSection(). This is - not supported by Windows 9x, but trylock is a hack anyway, IMHO. - (pthread_mutex_unlock): Use LeaveCriticalSection(). - -1998-07-14 Ben Elliston - - * attr.c (pthread_attr_setstacksize): Implement. - (pthread_attr_getstacksize): Likewise. - (pthread_attr_setstackaddr): Likewise. - (pthread_attr_getstackaddr): Likewise. - (pthread_attr_init): Likewise. - (pthread_attr_destroy): Likewise. - - * condvar.c (pthread_condattr_init): Add `_cond' to function name. - - * mutex.c (pthread_mutex_lock): Add `_mutex' to function name. - (pthread_mutex_trylock): Likewise. - (pthread_mutex_unlock): Likewise. - - * pthread.h (pthread_condattr_setpshared): Fix typo. - (pthread_attr_init): Add function prototype. - (pthread_attr_destroy): Likewise. - (pthread_attr_setstacksize): Likewise. - (pthread_attr_getstacksize): Likewise. - (pthread_attr_setstackaddr): Likewise. - (pthread_attr_getstackaddr): Likewise. - -Mon Jul 13 01:09:55 1998 Ross Johnson - - * implement.h: Wrap in #ifndef _IMPLEMENT_H - - * create.c (pthread_create): Map stacksize attr to Win32. - - * mutex.c: Include implement.h - -1998-07-13 Ben Elliston - - * condvar.c (pthread_condattr_init): Implement. - (pthread_condattr_destroy): Likewise. - (pthread_condattr_setpshared): Likewise. - (pthread_condattr_getpshared): Likewise. - - * implement.h (PTHREAD_THREADS_MAX): Remove trailing semicolon. - (PTHREAD_STACK_MIN): Specify; needs confirming. - (ptw32_attr_t): Define this type. - (ptw32_condattr_t): Likewise. - - * pthread.h (pthread_mutex_t): Define this type. - (pthread_condattr_t): Likewise. - (pthread_mutex_destroy): Add function prototype. - (pthread_lock): Likewise. - (pthread_trylock): Likewise. - (pthread_unlock): Likewise. - (pthread_condattr_init): Likewise. - (pthread_condattr_destroy): Likewise. - (pthread_condattr_setpshared): Likewise. - (pthread_condattr_getpshared): Likewise. - - * mutex.c (pthread_mutex_init): Implement. - (pthread_mutex_destroy): Likewise. - (pthread_lock): Likewise. - (pthread_trylock): Likewise. - (pthread_unlock): Likewise. - -1998-07-12 Ben Elliston - - * implement.h (ptw32_mutexattr_t): Define this implementation - internal type. Application programmers only see a mutex attribute - object as a void pointer. - - * pthread.h (pthread_mutexattr_t): Define this type. - (pthread_mutexattr_init): Add function prototype. - (pthread_mutexattr_destroy): Likewise. - (pthread_mutexattr_setpshared): Likewise. - (pthread_mutexattr_getpshared): Likewise. - (pthread_mutexattr_setprotocol): Likewise. - (pthread_mutexattr_getprotocol): Likewise. - (pthread_mutexattr_setprioceiling): Likewise. - (pthread_mutexattr_getprioceiling): Likewise. - (PTHREAD_PROCESS_PRIVATE): Define. - (PTHREAD_PROCESS_SHARED): Define. - - * mutex.c (pthread_mutexattr_init): Implement. - (pthread_mutexattr_destroy): Implement. - (pthread_mutexattr_setprotocol): Implement. - (pthread_mutexattr_getprotocol): Likewise. - (pthread_mutexattr_setprioceiling): Likewise. - (pthread_mutexattr_getprioceiling): Likewise. - (pthread_mutexattr_setpshared): Likewise. - (pthread_mutexattr_getpshared): Likewise. - (insert_attr): New function; very preliminary implementation! - (is_attr): Likewise. - (remove_attr): Likewise. - -Sat Jul 11 14:48:54 1998 Ross Johnson - - * implement.h: Preliminary implementation specific defines. - - * create.c (pthread_create): Preliminary implementation. - -1998-07-11 Ben Elliston - - * sync.c (pthread_join): Implement. - - * misc.c (pthread_equal): Likewise. - - * pthread.h (pthread_join): Add function prototype. - (pthread_equal): Likewise. - -1998-07-10 Ben Elliston - - * misc.c (pthread_self): Implement. - - * exit.c (pthread_exit): Implement. - - * pthread.h (pthread_exit): Add function prototype. - (pthread_self): Likewise. - (pthread_t): Define this type. - -1998-07-09 Ben Elliston - - * create.c (pthread_create): A dummy stub right now. - - * pthread.h (pthread_create): Add function prototype. +2018-08-08 Ross Johnson + + * Makefile: "nmake realclean VC VC-static" and similar wasn't remaking pthread.obj. + * common.mk: changes to accommodate the above. + * GNUmakefile: use changes in common.mk but still has problem with + "make realclean GC GC-static" and similar. + * configure.ac (AC_INIT): package name change. + +2018-08-08 Mark Pizzolato + + * config.h (NEED_FTIME): Removed + * _ptw32.h (NEED_FTIME): Removed. + * ptw32_timespec.c (NEED_FTIME): Removed conditional. + * ptw32_relmillisecs: Fix long-standing bug in NEED_FTIME code; remove NEED_FTIME + and all !NEED_FTIME code; compare nanoseconds and convert to milliseconds + at the end. + * implement.h (NEED_FTIME): remove conditionals. + * pthread.h: Remove Borland compiler time types no longer needed. + * configure.ac (NEED_FTIME): Removed check. + +2018-08-07 Ross Johnson + + * GNUmakefile.in (DLL_VER): rename as PTW32_VER. + * Makefile (DLL_VER): Likewise. + * Bmakefile (DLL_VER): Likewise; does anyone use this anymore? + * pthread.h: Move internal library stuff from pthread.h to _pthw32.h + * _ptw32.h: As above. + * ANNOUNCE: Update. + * NEWS: Update. + * Makefile: Static libraries renamed to libpthreadV* + +2018-07-22 Mark Pizzolato + + * _ptw32.h: Restore support for compiling as static (with /MT or /MTd); + define int64_t and uint64_t as typedefs rather than #defines. + * dll.c: Likewise. + * implement.h: Likewise. + * need_errno.h: Likewise. + * pthread_detach.c: Likewise. + +2018-07-22 Carlo Bramini + + * context.h (ARM): Additional macros checked for ARM processors. + +2018-07-22 Ross Johnson + + * Makefile (all-tests-md): New; run the /MD build and tests from + all-tests-cflags. + * Makefile (all-tests-mt): New; run the /MT build and tests from + all-tests-cflags. + * Makefile (all-tests-cflags): retain; require all-tests-md and + all-tests-mt. + +2016-12-25 Ross Johnson + + * Change all license notices to the Apache License 2.0 + * LICENCE: New Apache License file + * NOTICE: New file. + * COPYING: Removed. + * COPYING.GPL: Removed. + +2016-12-20 Ross Johnson + + * implement.h (PThreadStateReuse): this thread state enum value + must be less than PThreadStateRunning to reflect an invalid thread + handle. + * pthread_kill.c: changed conditions for return of ESRCH. + * ptw32_destroy.c: copy HANDLEs rather than whole thread struct; + edit comment. + * pthread_self.c: set implicit thread handle state to PThreadStateRunning. + * pthread_create.c: set thread state to PThreadStateSuspended + regardless because it must have state >= PThreadStateRunning on return. + +2016-12-20 Ross Johnson + + * all (PTW32_*): rename to __PTW32_*. + (ptw32_*): rename to __ptw32_*. + (PtW32*): rename to __PtW32*. + * pthread.h (__PTW32_VERSION_MAJOR): = 3 + (__PTW32_VERSION_MINOR): = 0 + * GNUmakefile: removed; must now configure from GNUmakefile.in. + I.e. For either MinGW or MinGW-w64: + # autoheader + # autoconf + # ./configure + * pthread.h (PTHREAD_ONCE_INIT): for __PTW32_VERSION_MAJOR > 2, + reverse element values to conform to new pthread_once_t. + +2016-12-18 Ross Johnson + + * implement.h (__PTW32_TEST_SNEAK_PEEK): Defined in tests/test.h + to control what some tests see when sneaking a peek inside this + header. + * GNUMakefile.in: call tests "make realclean" + +2016-12-17 Ross Johnson + + * _ptw32.h: MINGW(all) include stdint.h to define all specific + size integers (int64_t etc). + +2016-12-17 Kyle Schwarz + + * _ptw32.h: MINGW6464 define pid_t as __int64. + +2016-04-01 Ross Johnson + + * _ptw32.h: Move more header stuff into here. + * pthread.h: Move stuff from here into _ptw32.h. + * implement.h: Likewise. + * sched.h (struct timespec): Wrap with extra condition check. + * pthread_win32_attach_detach.c: Source stdlib.h to define + _countof et. al. + +2016-03-31 Keith Marshall + + * aclocal.m4: New from MinGW32 patches for autoconf. + * configure.ac: Likewise. + * GNUmakefile.in: Likewise. + * install-sh: Likewise. + * _ptw32.h: Likewise. + * implement.h: Patched. + * pthread.h: Patched. + * sched.h: Patched. + * sem_open.c: Patched. + * semaphore.h: Patched. + * pthread_self.c: Patched. + +2016-03-28 Ross Johnson + + * ptw32_relmillisecs.c (pthread_win32_getabstime_np): New + platform-aware function to return the current time plus optional + offset. + * pthread.h (pthread_win32_getabstime_np): New exported function. + * ptw32_timespec.c: Conditionally compile only if NEED_FTIME config + flagged. + * sched.h: Update platform config flags for applications. + * semaphore.h: Likewise. + * pthread.h: Likewise. + +2016-03-25 Bill Parker + + * pthread_mutex_init.c: Memory allocation of robust mutex element + was not being checked. + +2016-02-29 Ross Johnson + + * GNUmakefile (MINGW_HAVE_SECURE_API): Moved to config.h. Undefined + for __MINGW32__; remove (make optional) forcing a specific C std. + * implement.h (uint64_t): Define for Visual Studio. + +2016-02-29 Keith Marshall + + * ptw32_timespec.c: Fix C90 warnings from GCC; int64_t -> uint64_t + +2016-02-18 Carey Gister + + * dll.c (DllMain): Should not be defined for static library builds. + Doing so prevents static linking with a dll library. + +2015-11-01 Anurag Sharma + + * ptw32_MCS_lock.c: Fix a race condition causing crashes. + This race condition was also analysed and reported with a slightly + different fix independently by Jonathan Brown at VMware. + +2015-11-01 Mark Smith + + * ptw32_relnillisecs.c: Fix erroneous 0-time waits, symptomizing as + busy-spinning eating CPU. When the time to wait is specified to be less + than 1 millisecond were erroneously rounded down to 0; Modify WinCE + dependency. + * ptw32_timespec.c: Remove NEED_FTIME conditionality. + +2015-06-31 Dimitry <> + + * sem_init.c: Remove double free() when NEED_SEM defined (for + early versions of WinCE). + +2014-05-29 Ross Johnson + + * autostatic.c: Move content to dll.c so autostatic no longer required. + * dll.c: Include content from autostatic.c. + * pthread.c (autostatic.c): Remove #include. + * common.mk (autostatic.*): remove from builds. + * Makefile (realclean): delete make.log.txt if present. + * GNUMakefile (realclean): Likewise. + +2014-05-28 Jaeeun Choi + + * pthread_mutex_init.c: Check and free malloced robustNode element if + init is returning an ENOSPC error. + +2013-12-10 Ross Johnson + + * Makefile (*-small-static): Removed all small-static targets in the MS + toolchain builds due to failures of TLS in apps linked with these + library builds, specifically fails tests/semaphore3.c. The other static + builds pass this test. + * dll.c: Remove unused MinGW static linking hooks; See autostatic.c. + Hope to incorporate a working set of hooks here for gcc that supports + PIMAGE_TLS_CALLBACK later at which point autostatic.c will be required + only for older compilers. + +2013-12-09 Ross Johnson + + * Makefile (.rc.res): Add logic to extract target CPU from different + environments. + +2013-07-23 Keith Clanton + + * create.c: Don't apply cpu affinity from thread attributes for WINCE; + bug fix. + +2013-07-23 Ross Johnson + + * config.h (HAVE_CPU_AFFINITY): Defined. + * several (WINCE): Substitute HAVE_CPU_AFFINITY where appropriate. + +2013-07-17 Ross Johnson + + * pthread_getname_np.c: Replace strncpy_s with strncpy to support older + MSVCRT.DLLs. + * pthread_attr_getname_np.c: Likewise. + +2013-06-19 Ross Johnson + + * pthread_attr_init.c: Initialise thread name element. + * create.c: Initialise thread name from attributes. + +2013-06-13 Ross Johnson + + * pthread_setname_np.c: Initial version. + * pthread_getname_np.c: Initial version. + * pthread_attr_setname_np.c: Initial version. + * pthread_attr_getname_np.c: Initial version. + * pthread.h: Add new prototypes. + * implement.h (pthread_attr_t_): Add "thrname" element. + * (__ptw32_thread_t): Add "name" element. + +2013-06-06 Ross Johnson + + * pthread.h (_POSIX_THREAD_ATTR_STACKADDR): Now set to -1. The API + prototypes are defined but return ENOSYS; previously the addr value was + stored in the attribute struct and retreivable but unused. + * pthread_attr_setstackaddr.c: Should return ENOSYS rather than silently + ignore the setting. + * pthread_attr_getstackaddr.c: Likewise. + * pthread_attr_getaffinity_np.c: Initial version. + * pthread_attr_setaffinity_np.c: Initial version. + +2013-05-01 Andrew Chernow + + * dll.c: Add invocation of thread detach logic for static linked + applications for MSVC8.0 or later builds. + +2012-12-19 Jason Baker + + * pthread_win32_attach_detach_np.c (pthread_win32_process_attach_np): + Fix function calls involving TCHAR. + +2012-10-29 Ross Johnson + + * sem_destroy.c: Remove NULL argument checks. These are only useful + to guard against some uninitialised arguments, not an invalid sem_t. + * sem_wait.c: Likewise. + * sem_post.c: Likewise. + * sem_post_multiple.c: Likewise. + * sem_timedwait.c: Likewise. + * sem_trywait.c: Likewise. + * ptw32_semwait.c: Likewise. + +2012-10-28 Ross Johnson + + * implement.h: sem_t_ replace internal state mutex with MCS lock. + * sem_init.c: Rewrite to use MCS lock rather than mutex. + * sem_destroy.c: Likewise. + * sem_wait.c: Likewise. + * sem_post.c: Likewise. + * sem_post_multiple.c: Likewise. + * sem_timedwait.c: Likewise. + * sem_trywait.c: Likewise. + * ptw32_semwait.c: Likewise. + +2012-10-26 sicaf-- at hanmail dot net + + * error.c: For WinCE use a more specific cast. + * implement.h: For WinCE don't include process.h. + * pthread_win32_attach_detach_np.c: For WinCE don't restrict QUserEx.dll + search to system path. + +2012-10-24 Stephane Clairet + + * pthread_key_delete.c: Bug fix - move keylock release to after the + while loop. (This bug first was introduced at release 2.9.1) + +2012-10-16 Ross Johnson + + * 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 + + * 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 + + * 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 + + * 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 + + * 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 + + * all: #include; 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 + + * GNUmakefile: Modify "all-tests" to use new targets in tests + GNUmakefile. + * Makefile: Similarly. + +2012-09-22 Daniel Richard. G + + * 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 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 + + * 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 + + * 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 + + * 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 + + * implement.h: whitespace adjustment. + * dll.c: Facilitate __PTW32_STATIC_LIB being defined in a header file. + +2012-09-04 Ross Johnson + + * 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 + + * 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 + + * All: correct spelling to 'cancellation'. + +2012-08-31 Ross Johnson + + * 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 + + * 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 + + * 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 + + * 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 + + * 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 + + * 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 + + * 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 + + * 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 + + * implement.h: Fix interlocked pointer casting under VC++ x64. + +2012-03-19 Ross Johnson + + * implement.h (__ptw32_spinlock_check_need_init): added missing + forward declaration. + +2012-07-19 Daniel Richard. G + + * 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 + + * 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 + + * pthread_cond_wait.c (pragma inline_depth): this is almost redundant + now nevertheless fixed thei controlling MSC_VER from "< 800" to + "< 1400" (i.e. any prior to VC++ 8.0). + * pthread_once.ci (pragma inline_depth): Likewise. + * pthread_rwlock_timedwrlock.ci (pragma inline_depth): Likewise. + * pthread_rwlock_wrlock.ci (pragma inline_depth): Likewise. + * sem_timedwait.ci (pragma inline_depth): Likewise. + * sem_wait.ci (pragma inline_depth): Likewise. + +2011-07-05 Ross Johnson + + * pthread_win32_attach_detach_np.c: Use strncat_s if available + to removei a compile warning; MingW supports this routine but we + continue to use strncat anyway there because it is secure if + given the correct parameters; fix strncat param 3 to avoid + buffer overrun exploitation potential. + +2011-07-03 Ross Johnson + + * pthread_spin_unlock.c (EPERM): Return success if unlocking a lock + that is not locked, because single CPU machines wrap a + PTHREAD_MUTEX_NORMAL mutex, which returns success in this case. + * pthread_win32_attach_detach_np.c (QUSEREX.DLL): Load from an + absolute path only which must be the Windows System folder. + +2011-07-03 Daniel Richard G. + + * Makefile (_WIN32_WINNT): Removed; duplicate definition in + implement.h; more cleanup and enhancements. + +2011-07-02 Daniel Richard G. + + * Makefile: Cleanups and implovements. + * ptw32_MCS_locks.c: Casting fixes. + * implement.h: Interlocked call and argument casting macro fixes + to support older and newer build environments. + +2011-07-01 Ross Johnson + + * *.[ch] (__PTW32_INTERLOCKED_*): Redo 23 and 64 bit versions of these + macros and re-apply in code to undo the incorrect changes from + 2011-06-29; remove some size_t casts which should not be required + and may be problematic.a + There are now two sets of macros: + PTW32_INTERLOCKED_*_LONG which work only on 32 bit integer variables; + PTW32_INTERLOCKED_*_SIZE which work on size_t integer variables, i.e. + LONG for 32 bit systems and LONGLONG for 64 bit systems. + * implement.h (MCS locks): nextFlag and waitFlag are now HANDLE type. + * ptw32_MCS_locks.c: Likewise. + * pthread.h (#include ): Removed. + * ptw32_throw.c (#include ): Added. + * ptw32_threadStart.c (#include ): Added. + * implement.h (#include ): Added. + +2011-06-30 Ross Johnson + + * pthread_once.c: Tighten 'if' statement casting; fix interlocked + pointer cast for 64 bit compatibility (missed yesterday); remove + the superfluous static cleanup routine and call the release routine + directly if popped. + * create.c (stackSize): Now type size_t. + * pthread.h (struct __ptw32_thread_t_): Rearrange to fix element alignments. + +2011-06-29 Daniel Richard G. + + * ptw32_relmillisecs.c (ftime): + _ftime64_s() is only available in MSVC 2005 or later; + _ftime64() is available in MinGW or MSVC 2002 or later; + _ftime() is always available. + * pthread.h (long long): Not defined in older MSVC 6. + * implement.h (long long): Likewise. + * pthread_getunique_np.c (long long): Likewise. + +2011-06-29 Ross Johnson + + * *.[ch] (__PTW32_INTERLOCKED_*): These macros should now work for + both 32 and 64 bit builds. The MingW versions are all inlined asm + while the MSVC versions expand to their Interlocked* or Interlocked*64 + counterparts appropriately. The argument type have also been changed + to cast to the appropriate value or pointer size for the architecture. + +2011-05-29 Ross Johnson + + * *.[ch] (#ifdef): Extended cleanup to whole project. + +2011-05-29 Daniel Richard G. + + * Makefile (CC): Define CC to allow use of other compatible + compilers such as the Intel compilter icl. + * implement.h (#if): Fix forms like #if HAVE_SOMETHING. + * pthread.h: Likewise. + * sched.h: Likewise; __PTW32_LEVEL_* becomes __PTW32_SCHED_LEVEL_*. + * semaphore.h: Likewise. + +2011-05-11 Ross Johnson + + * ptw32_callUserDestroyRoutines.c (terminate): Altered includes + to match ptw32_threadStart.c. + * GNUmakefile (GCE-inlined-debug, DOPT): Fixed. + +2011-04-31 Ross Johnson + + * (robust mutexes): Added this API. The API is not + mandatory for implementations that don't support PROCESS_SHARED + mutexes, nevertheless it was considered useful both functionally + and for source-level compatibility. + +2011-03-26 Ross Johnson + + * pthread_getunique_np.c: New non-POSIX interface for compatibility + with some other implementations; returns a 64 bit sequence number + that is unique to each thread in the process. + * pthread.h (pthread_getunique_np): Added. + * global.c: Add global sequence counter for above. + * implement.h: Likewise. + +2011-03-25 Ross Johnson + + * (cancelLock): Convert to an MCS lock and rename to stateLock. + * (threadLock): Likewise. + * (keyLock): Likewise. + * pthread_mutex*.c: First working robust mutexes. + +2011-03-11 Ross Johnson + + * implement.h (__PTW32_INTERLOCKED_*CREMENT macros): increment/decrement + using ++/-- instead of add/subtract 1. + * ptw32_MCS_lock.c: Make casts consistent. + +2011-03-09 Ross Johnson + + * implement.h (__ptw32_thread_t_): Add process unique sequence number. + * global.c: Replace global Critical Section objects with MCS + queue locks. + * implement.h: Likewise. + * pthread_cond_destroy.c: Likewise. + * pthread_cond_init.c: Likewise. + * pthread_detach.c: Likewise. + * pthread_join.c: Likewise. + * pthread_kill.c: Likewise. + * pthread_mutex_destroy.c: Likewise. + * pthread_rwlock_destroy.c: Likewise. + * pthread_spin_destroy.c: Likewise. + * pthread_timechange_handler_np.c: Likewise. + * ptw32_cond_check_need_init.c: Likewise. + * ptw32_mutex_check_need_init.c: Likewise. + * ptw32_processInitialize.c: Likewise. + * ptw32_processTerminate.c: Likewise. + * ptw32_reuse.c: Likewise. + * ptw32_rwlock_check_need_init.c: Likewise. + * ptw32_spinlock_check_need_init.c: Likewise. + +2011-03-06 Ross Johnson + + * several (MINGW64): Cast and call fixups for 64 bit compatibility; + clean build via x86_64-w64-mingw32 cross toolchain on Linux i686 + targeting x86_64 win64. + * ptw32_threadStart.c (__ptw32_threadStart): Routine no longer attempts + to pass [unexpected C++] exceptions out of scope but ends the thread + normally setting EINTR as the exit status. + * ptw32_throw.c: Fix C++ exception throwing warnings; ignore + informational warning. + * implement.h: Likewise with the corresponding header definition. + +2011-03-04 Ross Johnson + + * implement.h (__PTW32_INTERLOCKED_*): Mingw32 does not provide + the __sync_* intrinsics so implemented them here as macro + assembler routines. MSVS Interlocked* are emmitted as intrinsics + wherever possible, so we want mingw to match it; Extended to + include all interlocked routines used by the library; implemented + x86_64 versions also. + * ptw32_InterlockedCompareExchange.c: No code remaining here. + * ptw32_MCS_lock.c: Converted interlocked calls to use new macros. + * pthread_barrier_wait.c: Likewise. + * pthread_once.c: Likewise. + * ptw32_MCS_lock.c (__ptw32_mcs_node_substitute): Name changed to + __ptw32_mcs_node_transfer. + +2011-02-28 Ross Johnson + + * ptw32_relmillisecs.c: If possible, use _ftime64_s or _ftime64 + before resorting to _ftime. + +2011-02-27 Ross Johnson + + * sched_setscheduler.c: Ensure the handle is closed after use. + * sched_getscheduler.c: Likewise. + * pthread.h: Remove POSIX compatibility macros; don't define + timespec if already defined. + * context.h: Changes for 64 bit. + * pthread_cancel.c: Likewise. + * pthread_exit.c: Likewise. + * pthread_spin_destroy.c: Likewise. + * pthread_timechange_handler_np.c: Likewise. + * ptw32_MCS_lock.c: Likewise; some of these changes may + not be compatible with pre Windows 2000 systems; reverse the order of + the includes. + * ptw32_threadStart.c: Likewise. + * ptw32_throw.c: Likewise. + +2011-02-13 Ross Johnson + + * pthread_self: Add comment re returning 'nil' value to + indicate failure only to win32 threads that call us. + * pthread_attr_setstackaddr: Fix comments; note this + function and it's compliment are now removed from SUSv4. + +2011-02-12 Ross Johnson + + README.NONPORTABLE: Record a description of an obvious + method for nulling/comparing/hashing pthread_t using a + union; plus and investigation of a change of type for + pthread_t (to a union) to neutralise any padding bits and + bytes if they occur in pthread_t (the current pthread_t struct + does not contain padding AFAIK, but porting the library to a + future architecture may introduce them). Padding affects + byte-by-byte copies and compare operations. + +2010-11-16 Ross Johnson + + * ChangeLog: Add this entry ;-) + Restore entries from 2007 through 2009 that went missing + at the last update. + +2010-06-19 Ross Johnson + + * ptw32_MCS_lock.c (__ptw32_mcs_node_substitute): Fix variable + names to avoid using C++ keyword ("new"). + * implement.h (__ptw32_mcs_node_substitute): Likewise. + * pthread_barrier_wait.c: Fix signed/unsigned comparison warning. + +2010-06-18 Ramiro Polla + + * autostatic.c: New file; call pthread_win32_process_*() + libary init/cleanup routines automatically on application start + when statically linked. + * pthread.c (autostatic.c): Included. + * pthread.h (declspec): Remove import/export defines if compiler + is MINGW. + * sched.h (declspec): Likewise. + * semaphore.h (declspec): Likewise. + * need_errno.h (declspec): Likewise. + * Makefile (autostatic.obj): Add for small static builds. + * GNUmakefile (autostatic.o): Likewise. + * NEWS (Version 2.9.0): Add changes. + * README.NONPORTABLE (pthread_win32_process_*): Update + description. + +2010-06-15 Ramiro Polla + + * Makefile: Remove linkage with the winsock library by default. + * GNUmakefile: Likewise. + * pthread_getspecific.c: Likewise by removing calls to WSA + functions. + * config.h (RETAIN_WSALASTERROR): Can be defined if necessary. + +2010-01-26 Ross Johnson + + * ptw32_MCS_lock.c (__ptw32_mcs_node_substitute): New routine + to allow relocating the lock owners thread-local node to somewhere + else, e.g. to global space so that another thread can release the + lock. Used in pthread_barrier_wait. + (__ptw32_mcs_lock_try_acquire): New routine. + * pthread_barrier_init: Only one semaphore is used now. + * pthread_barrier_wait: Added an MCS guard lock with the last thread + to leave the barrier releasing the lock. This removes a deadlock bug + observed when there are greater than barrier-count threads + attempting to cross. + * pthread_barrier_destroy: Added an MCS guard lock. + +2009-03-03 Stephan O'Farrill + + * pthread_attr_getschedpolicy.c: Add "const" to function parameter + in accordance with SUSv3 (POSIX). + * pthread_attr_getinheritsched.c: Likewise. + * pthread_mutexattr_gettype.c: Likewise. + +2008-06-06 Robert Kindred + + * ptw32_throw.c (__ptw32_throw): Remove possible reference to NULL + pointer. (At the same time made the switch block conditionally + included only if exitCode is needed - RPJ.) + * pthread_testcancel.c (pthread_testcancel): Remove duplicate and + misplaced pthread_mutex_unlock(). + +2008-02-21 Sebastian Gottschalk + + * pthread_attr_getdetachstate.c (pthread_attr_getdetachstate): + Remove potential and superfluous null pointer assignment. + +2007-11-22 Ivan Pizhenko + + * pthread.h (gmtime_r): gmtime returns 0 if tm represents a time + prior to 1/1/1970. Notice this to prevent raising an exception. + * pthread.h (localtime_r): Likewise for localtime. + +2007-07-14 Marcel Ruff + + * errno.c (_errno): Fix test for pthread_self() success. + * need_errno.h: Remove unintentional line wrap from #if line. + +2007-07-14 Mike Romanchuk + + * pthread.h (timespec): Fix tv_sec type. + +2007-01-07 Sinan Kaya + + * need_errno.h: Fix declaration of _errno - the local version of + _errno() is used, e.g. by WinCE. + +2007-01-06 Ross Johnson + + * ptw32_semwait.c: Add check for invalid sem_t after acquiring the + sem_t state guard mutex and before affecting changes to sema state. + +2007-01-06 Marcel Ruff + + * error.c: Fix reference to pthread handle exitStatus member for + builds that use NEED_ERRNO (i.e. WINCE). + * context.h: Add support for ARM processor (WinCE). + * mutex.c (process.h): Exclude for WINCE. + * create.c: Likewise. + * exit.c: Likewise. + * implement.h: Likewise. + * pthread_detach.c (signal.h): Exclude for WINCE. + * pthread_join.c: Likewise. + * pthread_kill.c: Likewise. + * pthread_rwlock_init.c (errno.h): Remove - included by pthread.h. + * pthread_rwlock_destroy.c: Likewise. + * pthread_rwlock_rdlock.c: Likewise. + * pthread_rwlock_timedrdlock.c: Likewise. + * pthread_rwlock_timedwrlock.c: Likewise. + * pthread_rwlock_tryrdlock.c: Likewise. + * pthread_rwlock_trywrlock.c: likewise. + * pthread_rwlock_unlock.c: Likewise. + * pthread_rwlock_wrlock.c: Likewise. + * pthread_rwlockattr_destroy.c: Likewise. + * pthread_rwlockattr_getpshared.c: Likewise. + * pthread_rwlockattr_init.c: Likewise. + * pthread_rwlockattr_setpshared.c: Likewise. + +2007-01-06 Romano Paolo Tenca + + * pthread_cond_destroy.c: Replace sem_wait() with non-cancelable + __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. + +2007-01-06 Eric Berge + + * pthread_cond_destroy.c: Add LeaveCriticalSection before returning + after errors. + +2007-01-04 Ross Johnson + + * ptw32_InterlockedCompareExchange.c: Conditionally skip for + Win64 as not required. + * pthread_win32_attach_detach_np.c (pthread_win32_process_attach_np): + Test for InterlockedCompareExchange is not required for Win64. + * context.h: New file. Included by pthread_cancel.h and any tests + that need it (e.g. context1.c). + * pthread_cancel.c: Architecture-dependent context macros moved + to context.h. + +2007-01-04 Kip Streithorst + + * implement.h (__PTW32_INTERLOCKED_COMPARE_EXCHANGE): Add Win64 + support. + +2006-12-20 Ross Johnson + + * sem_destroy.c: Fix the race involving invalidation of the sema; + fix incorrect return of EBUSY resulting from the mutex trylock + on the private mutex guard. + * sem_wait.c: Add check for invalid sem_t after acquiring the + sem_t state guard mutex and before affecting changes to sema state. + * sem_trywait.c: Likewise. + * sem_timedwait.c: Likewise. + * sem_getvalue.c: Likewise. + * sem_post.c: Similar. + * sem_post_multiple.c: Likewise. + * sem_init.c: Set max Win32 semaphore count to SEM_VALUE_MAX (was + _POSIX_SEM_VALUE_MAX, which is a lower value - the minimum). + + * pthread_win32_attach_detach_np.c (pthread_win32_process_attach_np): + Load COREDLL.DLL under WINCE to check existence of + InterlockedCompareExchange() routine. This used to be done to test + for TryEnterCriticalSection() but was removed when this was no + longer needed. + +2006-01-25 Prashant Thakre + + * pthread_cancel.c: Added _M_IA64 register context support. + +2005-05-13 Ross Johnson + + * pthread_kill.c (pthread_kill): Remove check for Win32 thread + priority (to confirm HANDLE validity). Useless since thread HANDLEs + a not recycle-unique. + +2005-05-30 Vladimir Kliatchko + + * pthread_once.c: Re-implement using an MCS queue-based lock. The form + of pthread_once is as proposed by Alexander Terekhov (see entry of + 2005-03-13). The MCS lock implementation does not require a unique + 'name' to identify the lock between threads. Attempts to get the Event + or Semaphore based versions of pthread_once to a satisfactory level + of robustness have thus far failed. The last problem (avoiding races + involving non recycle-unique Win32 HANDLEs) was giving everyone + grey hair trying to solve it. + + * ptw32_MCS_lock.c: New MCS queue-based lock implementation. These + locks are efficient: they have very low overhead in the uncontended case; + are efficient in contention and minimise cache-coherence updates in + managing the user level FIFO queue; do not require an ABI change in the + library. + +2005-05-27 Alexander Gottwald + + * pthread.h: Some things, like HANDLE, were only defined if + PTW32_LEVEL was >= 3. They should always be defined. + +2005-05-25 Vladimir Kliatchko + + * pthread_once.c: Eliminate all priority operations and other + complexity by replacing the event with a semaphore. The advantage + of the change is the ability to release just one waiter if the + init_routine thread is cancelled yet still release all waiters when + done. Simplify once_control state checks to improve efficiency + further. + +2005-05-24 Mikael Magnusson + + * GNUmakefile: Patched to allow cross-compile with mingw32 on Linux. + It uses macros instead of referencing dlltool, gcc and g++ directly; + added a call to ranlib. For example the GC static library can be + built with: + make CC=i586-mingw32msvc-gcc RC=i586-mingw32msvc-windres \ + RANLIB=i586-mingw32msvc-ranlib clean GC-static + +2005-05-13 Ross Johnson + + * pthread_win32_attach_detach_np.c (pthread_win32_thread_detach_np): + Move on-exit-only stuff from __ptw32_threadDestroy() to here. + * ptw32_threadDestroy.c: It's purpose is now only to reclaim thread + resources for detached threads, or via pthread_join() or + pthread_detach() on joinable threads. + * ptw32_threadStart.c: Calling user destruct routines has moved to + pthread_win32_thread_detach_np(); call pthread_win32_thread_detach_np() + directly if statically linking, otherwise do so via dllMain; store + thread return value in thread struct for all cases, including + cancellation and exception exits; thread abnormal exits go via + pthread_win32_thread_detach_np. + * pthread_join.c (pthread_join): Don't try to get return code from + Win32 thread - always get it from he thread struct. + * pthread_detach.c (pthread_detach): reduce extent of the thread + existence check since we now don't care if the Win32 thread HANDLE has + been closed; reclaim thread resources if the thread has exited already. + * ptw32_throw.c (__ptw32_throw): For Win32 threads that are not implicit, + only Call thread cleanup if statically linking, otherwise leave it to + dllMain. + * sem_post.c (_POSIX_SEM_VALUE_MAX): Change to SEM_VALUE_MAX. + * sem_post_multiple.c: Likewise. + * sem_init.c: Likewise. + +2005-05-10 Ross Johnson + + * pthread_join.c (pthread_join): Add missing check for thread ID + reference count in thread existence test; reduce extent of the + existence test since we don't care if the Win32 thread HANDLE has + been closed. + +2005-05-09 Ross Johnson + + * ptw32_callUserDestroyRoutines.c: Run destructor process (i.e. + loop over all keys calling destructors) up to + PTHREAD_DESTRUCTOR_ITERATIONS times if TSD value isn't NULL yet; + modify assoc management. + * pthread_key_delete.c: Modify assoc management. + * ptw32_tkAssocDestroy.c: Fix error in assoc removal from chains. + * pthread.h + (_POSIX_THREAD_DESTRUCTOR_ITERATIONS): Define to value specified by + POSIX. + (_POSIX_THREAD_KEYS_MAX): Define to value specified by POSIX. + (PTHREAD_KEYS_MAX): Redefine [upward] to minimum required by POSIX. + (SEM_NSEMS_MAX): Define to implementation value. + (SEM_VALUE_MAX): Define to implementation value. + (_POSIX_SEM_NSEMS_MAX): Redefine to value specified by POSIX. + (_POSIX_SEM_VALUE_MAX): Redefine to value specified by POSIX. + +2005-05-06 Ross Johnson + + * signal.c (sigwait): Add a cancellation point to this otherwise + no-op. + * sem_init.c (sem_init): Check for and return ERANGE error. + * sem_post.c (sem_post): Likewise. + * sem_post_multiple.c (sem_post_multiple): Likewise. + * manual (directory): Added; see ChangeLog inside. + +2005-05-02 Ross Johnson + + * implement.h (struct pthread_key_t_): Change threadsLock to keyLock + so as not to be confused with the per thread lock 'threadlock'; + change all references to it. + * implement.h (struct ThreadKeyAssoc): Remove lock; add prevKey + and prevThread pointers; re-implemented all routines that use this + struct. The effect of this is to save one handle per association, + which could potentially equal the number of keys multiplied by the + number of threads, accumulating over time - and to free the + association memory as soon as it is no longer referenced by either + the key or the thread. Previously, the handle and memory were + released only after BOTH key and thread no longer referenced the + association. That is, often no association resources were released + until the process itself exited. In addition, at least one race + condition has been removed - where two threads could attempt to + release the association resources simultaneously - one via + __ptw32_callUserDestroyRoutines and the other via + pthread_key_delete. + - thanks to Richard Hughes at Aculab for discovering the problem. + * pthread_key_create.c: See above. + * pthread_key_delete.c: See above. + * pthread_setspecific.c: See above. + * ptw32_callUserDestroyRoutines.c: See above. + * ptw32_tkAssocCreate.c: See above. + * ptw32_tkAssocDestroy.c: See above. + +2005-04-27 Ross Johnson + + * sem_wait.c (__ptw32_sem_wait_cleanup): after cancellation re-attempt + to acquire the semaphore to avoid a race with a late sem_post. + * sem_timedwait.c: Modify comments. + +2005-04-25 Ross Johnson + + * ptw32_relmillisecs.c: New module; converts future abstime to + milliseconds relative to 'now'. + * pthread_mutex_timedlock.c: Use new __ptw32_relmillisecs routine in + place of internal code; remove the NEED_SEM code - this routine is now + implemented for builds that define NEED_SEM (WinCE etc) + * sem_timedwait.c: Likewise; after timeout or cancellation, + re-attempt to acquire the semaphore in case one has been posted since + the timeout/cancel occurred. Thanks to Stefan Mueller. + * Makefile: Add ptw32_relmillisecs.c module; remove + __ptw32_{in,de}crease_semaphore.c modules. + * GNUmakefile: Likewise. + * Bmakefile: Likewise. + + * sem_init.c: Re-write the NEED_SEM code to be consistent with the + non-NEED_SEM code, but retaining use of an event in place of the w32 sema + for w32 systems that don't include semaphores (WinCE); + the NEED_SEM versions of semaphores has been broken for a long time but is + now fixed and supports all of the same routines as the non-NEED_SEM case. + * sem_destroy.c: Likewise. + * sem_wait.c: Likewise. + * sem_post.c: Likewise. + * sem_post_multple.c: Likewise. + * implement.h: Likewise. + * sem_timedwait.c: Likewise; this routine is now + implemented for builds that define NEED_SEM (WinCE etc). + * sem_trywait.c: Likewise. + * sem_getvalue.c: Likewise. + + * pthread_once.c: Yet more changes, reverting closer to Gottlob Frege's + first design, but retaining cancellation, priority boosting, and adding + preservation of W32 error codes to make pthread_once transparent to + GetLastError. + +2005-04-11 Ross Johnson + + * pthread_once.c (pthread_once): Added priority boosting to + solve starvation problem after once_routine cancellation. + See notes in file. + +2005-04-06 Kevin Lussier + + * Makefile: Added debug targets for all versions of the library. + +2005-04-01 Ross Johnson + + * GNUmakefile: Add target to build libpthreadGC1.a as a static link + library. + * Makefile: Likewise for pthreadGC1.lib. + +2005-04-01 Kevin Lussier + + * sem_timedwait.c (sem_timedwait): Increase size of temp variables to + avoid int overflows for large timeout values. + * implement.h (int64_t): Include or define. + +2005-03-31 Dimitar Panayotov ^M + + * pthread.h: Fix conditional defines for static linking. + * sched.h: Liekwise. + * semaphore.h: Likewise. + * dll.c (__PTW32_STATIC_LIB): Module is conditionally included + in the build. + +2005-03-16 Ross Johnson ^M + + * pthread_setcancelstate.c: Undo the last change. + +2005-03-16 Ross Johnson ^M + + * pthread_setcancelstate.c: Don't check for an async cancel event + if the library is using alertable async cancel.. + +2005-03-14 Ross Johnson + + * pthread_once.c (pthread_once): Downgrade interlocked operations to simple + memory operations where these are protected by the critical section; edit + comments. + +2005-03-13 Ross Johnson + + * pthread_once.c (pthread_once): Completely redesigned; a change was + required to the ABI (pthread_once_t_), and resulting in a version + compatibility index increment. + + NOTES: + The design (based on pseudo code contributed by Gottlob Frege) avoids + creating a kernel object if there is no contention. See URL for details:- + http://sources.redhat.com/ml/pthreads-win32/2005/msg00029.html + This uses late initialisation similar to the technique already used for + pthreads-win32 mutexes and semaphores (from Alexander Terekhov). + + 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 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 + in speed. So, in the final design with cancelability, an uncontested + once_control operation involves a minimum of five interlocked operations + (including the LeaveCS operation). + + ALTERNATIVES: + An alternative design from Alexander Terekhov proposed using a named mutex, + as sketched below:- + + if (!once_control) { // May be in TLS + named_mutex::guard guard(&once_control2); + if (!once_control2) { + + once_control2 = true; + } + once_control = true; + } + + A more detailed description of this can be found here:- + http://groups.yahoo.com/group/boost/message/15442 + + [Although the definition of a suitable PTHREAD_ONCE_INIT precludes use of the + TLS located flag, this is not critical.] + + There are three primary concerns though:- + 1) The [named] mutex is 'created' even in the uncontended case. + 2) A system wide unique name must be generated. + 3) Win32 mutexes are VERY slow even in the uncontended case. An uncontested + Win32 mutex lock operation can be 50 (or more) times slower than an + uncontested EnterCS operation. + + Ultimately, the named mutex trick is making use of the global locks maintained + by the kernel. + + * pthread.h (pthread_once_t_): One flag and an event HANDLE added. + (PTHREAD_ONCE_INIT): Additional values included. + +2005-03-08 Ross Johnson + + * pthread_once.c (pthread_once): Redesigned to elliminate potential + starvation problem. + - reported by Gottlob Frege + + * ptw32_threadDestroy.c (__ptw32_threadDestroy): Implicit threads were + not closing their Win32 thread duplicate handle. + - reported by Dmitrii Semii + +2005-01-25 Ralf Kubis + + * Attempted acquisition of recursive mutex was causing waiting + threads to not be woken when the mutex is released. + + * GNUmakefile (GCE): Generate correct version resource comments. + +2005-01-01 Konstantin Voronkov + + * pthread_mutex_lock.c (pthread_mutex_lock): The new atomic exchange + mutex algorithm is known to allow a thread to steal the lock off + FIFO waiting threads. The next waiting FIFO thread gets a spurious + wake-up and must attempt to re-acquire the lock. The woken thread + was setting itself as the mutex's owner before the re-acquisition. + +2004-11-22 Ross Johnson + + * pthread_cond_wait.c (__ptw32_cond_wait_cleanup): Undo change + from 2004-11-02. + * Makefile (DLL_VER): Added for DLL naming suffix - see README. + * GNUmakefile (DLL_VER): Likewise. + * Wmakefile (DLL_VER): Likewise. + * Bmakefile (DLL_VER): Likewise. + * pthread.dsw (version.rc): Added to MSVS workspace. + +2004-11-20 Boudewijn Dekker + + * pthread_getspecific.c (pthread_getspecific): Check for + invalid (NULL) key argument. + +2004-11-19 Ross Johnson + + * config.h (__PTW32_THREAD_ID_REUSE_INCREMENT): Added to allow + building the library for either unique thread IDs like Solaris + or non-unique thread IDs like Linux; allows application developers + to override the library's default insensitivity to some apps + that may not be strictly POSIX compliant. + * version.rc: New resource module to encode version information + within the DLL. + * pthread.h: Added __PTW32_VERSION* defines and grouped sections + required by resource compiler together; bulk of file is skipped + if RC_INVOKED. Defined some error numbers and other names for + Borland compiler. + +2004-11-02 Ross Johnson + + * pthread_cond_wait.c (__ptw32_cond_wait_cleanup): Lock CV mutex at + start of cleanup handler rather than at the end. + * implement.h (__PTW32_THREAD_REUSE_EMPTY): Renamed from *_BOTTOM. + (__ptw32_threadReuseBottom): New global variable. + * global.c (__ptw32_threadReuseBottom): Declare new variable. + * ptw32_reuse.c (__ptw32_reuse): Change reuse LIFO stack to LILO queue + to more evenly distribute use of reusable thread IDs; use renamed + PTW32_THREAD_REUSE_EMPTY. + * ptw32_processTerminate.c (ptw2_processTerminate): Use renamed + PTW32_THREAD_REUSE_EMPTY. + +2004-10-31 Ross Johnson + + * implement.h (PThreadState): Add new state value + 'PThreadStateCancelPending'. + * pthread_testcancel.c (pthread_testcancel): Use new thread + '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 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 + 'PThreadStateCancelPending' state. + +2004-10-29 Ross Johnson + + * implement.h (pthread_t): Renamed to __ptw32_thread_t; struct contains + all thread state. + * pthread.h (__ptw32_handle_t): New general purpose struct to serve + as a handle for various reusable object IDs - currently only used + by pthread_t; contains a pointer to __ptw32_thread_t (thread state) + and a general purpose uint for use as a reuse counter or flags etc. + (pthread_t): typedef'ed to __ptw32_handle_t; the uint is the reuse + counter that allows the library to maintain unique POSIX thread IDs. + When the pthread struct reuse stack was introduced, threads would + often acquire an identical ID to a previously destroyed thread. The + same was true for the pre-reuse stack library, by virtue of pthread_t + 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 + cancellation cleanup. + * sem_timedwait.c (__ptw32_sem_timedwait_cleanup): Likewise. + +2004-10-22 Ross Johnson + + * sem_init.c (sem_init): Introduce a 'lock' element in order to + replace the interlocked operations with conventional serialisation. + This is needed in order to be able to atomically modify the sema + value and perform Win32 sema release operations. Win32 semaphores are + used instead of events in order to support efficient multiple posting. + If the whole modify/release isn't atomic, a race between + sem_timedwait() and sem_post() could result in a release when there is + no waiting semaphore, which would cause too many threads to proceed. + * sem_wait.c (sem_wait): Use new 'lock'element. + * sem_timedwait.c (sem_timedwait): Likewise. + * sem_trywait.c (sem_trywait): Likewise. + * sem_post.c (sem_post): Likewise. + * sem_post_multiple.c (sem_post_multiple): Likewise. + * sem_getvalue.c (sem_getvalue): Likewise. + * ptw32_semwait.c (__ptw32_semwait): Likewise. + * sem_destroy.c (sem_destroy): Likewise; also tightened the conditions + for semaphore destruction; in particular, a semaphore will not be + destroyed if it has waiters. + * sem_timedwait.c (sem_timedwait): Added cancel cleanup handler to + restore sema value when cancelled. + * sem_wait.c (sem_wait): Likewise. + +2004-10-21 Ross Johnson + + * pthread_mutex_unlock.c (pthread_mutex_unlock): Must use PulseEvent() + rather than SetEvent() to reset the event if there are no waiters. + +2004-10-19 Ross Johnson + + * sem_init.c (sem_init): New semaphore model based on the same idea + as mutexes, i.e. user space interlocked check to avoid + unnecessarily entering kernel space. Wraps the Win32 semaphore and + 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 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 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. + * sem_post.c (sem_post): Likewise. + * sem_trywait.c (sem_trywait): Likewise. + * sem_timedwait.c (sem_timedwait): Likewise. + * sem_post_multiple.c (sem_post_multiple): Likewise. + * sem_getvalue.c (sem_getvalue): Likewise. + * ptw32_semwait.c (__ptw32_semwait): Likewise. + * implement.h (sem_t_): Add counter element. + +2004-10-15 Ross Johnson + + * implement.h (pthread_mutex_t_): Use an event in place of + the POSIX semaphore. + * pthread_mutex_init.c: Create the event; remove semaphore init. + * pthread_mutex_destroy.c: Delete the event. + * pthread_mutex_lock.c: Replace the semaphore wait with the event wait. + * pthread_mutex_trylock.c: Likewise. + * pthread_mutex_timedlock.c: Likewise. + * pthread_mutex_unlock.c: Set the event. + +2004-10-14 Ross Johnson + + * pthread_mutex_lock.c (pthread_mutex_lock): New algorithm using + Terekhov's xchg based variation of Drepper's cmpxchg model. + Theoretically, xchg uses fewer clock cycles than cmpxchg (using IA-32 + as a reference), however, in my opinion bus locking dominates the + equation on smp systems, so the model with the least number of bus + lock operations in the execution path should win, which is Terekhov's + variant. On IA-32 uni-processor systems, it's faster to use the + CMPXCHG instruction without locking the bus than to use the XCHG + instruction, which always locks the bus. This makes the two variants + equal for the non-contended lock (fast lane) execution path on up + IA-32. Testing shows that the xchg variant is faster on up IA-32 as + well if the test forces higher lock contention frequency, even though + kernel calls should be dominating the times (on up IA-32, both + variants used CMPXCHG instructions and neither locked the bus). + * pthread_mutex_timedlock.c pthread_mutex_timedlock(): Similarly. + * pthread_mutex_trylock.c (pthread_mutex_trylock): Similarly. + * pthread_mutex_unlock.c (pthread_mutex_unlock): Similarly. + * ptw32_InterlockedCompareExchange.c (__ptw32_InterlockExchange): New + function. + (__PTW32_INTERLOCKED_EXCHANGE): Sets up macro to use inlined + __ptw32_InterlockedExchange. + * implement.h (__PTW32_INTERLOCKED_EXCHANGE): Set default to + InterlockedExchange(). + * Makefile: Building using /Ob2 so that asm sections within inline + functions are inlined. + +2004-10-08 Ross Johnson + + * pthread_mutex_destroy.c (pthread_mutex_destroy): Critical Section + element is no longer required. + * pthread_mutex_init.c (pthread_mutex_init): Likewise. + * pthread_mutex_lock.c (pthread_mutex_lock): New algorithm following + Drepper's paper at http://people.redhat.com/drepper/futex.pdf, but + using the existing semaphore in place of the futex described in the + paper. Idea suggested by Alexander Terekhov - see: + http://sources.redhat.com/ml/pthreads-win32/2003/msg00108.html + * pthread_mutex_timedlock.c pthread_mutex_timedlock(): Similarly. + * pthread_mutex_trylock.c (pthread_mutex_trylock): Similarly. + * pthread_mutex_unlock.c (pthread_mutex_unlock): Similarly. + * pthread_barrier_wait.c (pthread_barrier_wait): Use inlined version + of InterlockedCompareExchange() if possible - determined at + build-time. + * pthread_spin_destroy.c pthread_spin_destroy(): Likewise. + * pthread_spin_lock.c pthread_spin_lock():Likewise. + * pthread_spin_trylock.c (pthread_spin_trylock):Likewise. + * pthread_spin_unlock.c (pthread_spin_unlock):Likewise. + * ptw32_InterlockedCompareExchange.c: Sets up macro for inlined use. + * implement.h (pthread_mutex_t_): Remove Critical Section element. + (__PTW32_INTERLOCKED_COMPARE_EXCHANGE): Set to default non-inlined + version of InterlockedCompareExchange(). + * private.c: Include ptw32_InterlockedCompareExchange.c first for + inlining. + * GNUmakefile: Add commandline option to use inlined + InterlockedCompareExchange(). + * Makefile: Likewise. + +2004-09-27 Ross Johnson + + * pthread_mutex_lock.c (pthread_mutex_lock): Separate + PTHREAD_MUTEX_NORMAL logic since we do not need to keep or check some + state required by other mutex types; do not check mutex pointer arg + for validity - leave this to the system since we are only checking + for NULL pointers. This should improve speed of NORMAL mutexes and + marginally improve speed of other type. + * pthread_mutex_trylock.c (pthread_mutex_trylock): Likewise. + * pthread_mutex_unlock.c (pthread_mutex_unlock): Likewise; also avoid + entering the critical section for the no-waiters case, with approx. + 30% reduction in lock/unlock overhead for this case. + * pthread_mutex_timedlock.c (pthread_mutex_timedlock): Likewise; also + no longer keeps mutex if post-timeout second attempt succeeds - this + will assist applications that wish to impose strict lock deadlines, + rather than simply to escape from frozen locks. + +2004-09-09 Tristan Savatier + * pthread.h (struct pthread_once_t_): Qualify the 'done' element + as 'volatile'. + * pthread_once.c: Concerned about possible race condition, + specifically on MPU systems re concurrent access to multibyte types. + [Maintainer's note: the race condition is harmless on SPU systems + and only a problem on MPU systems if concurrent access results in an + exception (presumably generated by a hardware interrupt). There are + other instances of similar harmless race conditions that have not + been identified as issues.] + +2004-09-09 Ross Johnson + + * pthread.h: Declare additional types as volatile. + +2004-08-27 Ross Johnson + + * pthread_barrier_wait.c (pthread_barrier_wait): Remove excessive code + by substituting the internal non-cancelable version of sem_wait + (__ptw32_semwait). + +2004-08-25 Ross Johnson + + * pthread_join.c (pthread_join): Rewrite and re-order the conditional + tests in an attempt to improve efficiency and remove a race + condition. + +2004-08-23 Ross Johnson + + * create.c (pthread_create): Don't create a thread if the thread + id pointer location (first arg) is inaccessible. A memory + protection fault will result if the thread id arg isn't an accessible + location. This is consistent with GNU/Linux but different to + Solaris or MKS (and possibly others), which accept NULL as meaning + 'don't return the created thread's ID'. Applications that run + using pthreads-win32 will run on all other POSIX threads + implementations, at least w.r.t. this feature. + + It was decided not to copy the Solaris et al behaviour because, + although it would have simplified some application porting (but only + from Solaris to Windows), the feature is not technically necessary, + and the alternative segfault behaviour helps avoid buggy application + code. + +2004-07-01 Anuj Goyal + + * builddmc.bat: New; Windows bat file to build the library. + * config.h (__DMC__): Support for Digital Mars compiler. + * create.c (__DMC__): Likewise. + * pthread_exit.c (__DMC__): Likewise. + * pthread_join.c (__DMC__): Likewise. + * ptw32_threadDestroy.c (__DMC__): Likewise. + * ptw32_threadStart.c (__DMC__): Likewise. + * ptw32_throw.c (__DMC__): Likewise. + +2004-06-29 Anuj Goyal + + * pthread.h (__DMC__): Initial support for Digital Mars compiler. + +2004-06-29 Will Bryant + + * README.Borland: New; description of Borland changes. + * Bmakefile: New makefile for the Borland make utility. + * ptw32_InterlockedCompareExchange.c: + Add Borland compatible asm code. + +2004-06-26 Jason Bard + + * pthread.h (HAVE_STRUCT_TIMESPEC): If undefined, define it + to avoid timespec struct redefined errors elsewhere in an + application. + +2004-06-21 Ross Johnson + + * pthread.h (PTHREAD_RECURSIVE_MUTEX_INITIALIZER): Mutex + initialiser added for compatibility with Linux threads and + others; currently not included in SUSV3. + * pthread.h (PTHREAD_ERRORCHECK_MUTEX_INITIALIZER): Likewise. + * pthread.h (PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP): Likewise. + * pthread.h (PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP): Likewise. + + * ptw32_mutex_check_need_init.c (__ptw32_mutex_check_need_init): + Add new initialisers. + + * pthread_mutex_lock.c (pthread_mutex_lock): Check for new + initialisers. + * pthread_mutex_trylock.c (pthread_mutex_trylock): Likewise. + * pthread_mutex_timedlock.c (pthread_mutex_timedlock): Likewise. + * pthread_mutex_unlock.c (pthread_mutex_unlock): Likewise. + * pthread_mutex_destroy.c (pthread_mutex_destroy): Likewise. + +2004-05-20 Ross Johnson + + * README.NONPORTABLE: Document pthread_win32_test_features_np(). + * FAQ: Update various answers. + +2004-05-19 Ross Johnson + + * Makefile: Don't define _WIN32_WINNT on compiler command line. + * GNUmakefile: Likewise. + +2004-05-16 Ross Johnson + + * pthread_cancel.c (pthread_cancel): Adapted to use auto-detected + QueueUserAPCEx features at run-time. + (__ptw32_Registercancellation): Drop in replacement for QueueUserAPCEx() + if it can't be used. Provides older style non-preemptive async + 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_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. + +2004-05-16 Panagiotis E. Hadjidoukas + + * QueueUserAPCEx (separate contributed package): Provides preemptive + APC feature. + * pthread_cancel.c (pthread_cancel): Initial integration of + QueueUserAPCEx into pthreads-win32 to provide true pre-emptive + async cancellation of threads, including blocked threads. + +2004-05-06 Makoto Kato + + * pthread.h (DWORD_PTR): Define typedef for older MSVC. + * pthread_cancel.c (AMD64): Add architecture specific Context register. + * ptw32_getprocessors.c: Use correct types (DWORD_PTR) for mask + variables. + +2004-04-06 P. van Bruggen + + * ptw32_threadDestroy.c: Destroy threadLock mutex to + close a memory leak. + +2004-02-13 Gustav Hallberg + + * pthread_equal.c: Remove redundant equality logic. + +2003-12-10 Philippe Di Cristo + + * sem_timedwait.c (sem_timedwait): Fix timeout calculations. + +2003-10-20 Alexander Terekhov + + * pthread_mutex_timedlock.c (__ptw32_semwait): Move to individual module. + * ptw32_semwait.c: New module. + * pthread_cond_wait.c (__ptw32_cond_wait_cleanup): Replace cancelable + sem_wait() call with non-cancelable __ptw32_semwait() call. + * pthread.c (private.c): Re-order for inlining. GNU C warned that + function __ptw32_semwait() was defined 'inline' after it was called. + * pthread_cond_signal.c (__ptw32_cond_unblock): Likewise. + * pthread_delay_np.c: Disable Watcom warning with comment. + * *.c (process.h): Remove include from .c files. This is conditionally + included by the common project include files. + +2003-10-20 James Ewing + + * ptw32_getprocessors.c: Some Win32 environments don't have + GetProcessAffinityMask(), so always return CPU count = 1 for them. + * config.h (NEED_PROCESSOR_AFFINITY_MASK): Define for WinCE. + +2003-10-15 Ross Johnson + + * Re-indented all .c files using default GNU style to remove assorted + editor ugliness (used GNU indent utility in default style). + +2003-10-15 Alex Blanco + + * sem_init.c (sem_init): Would call CreateSemaphore even if the sema + struct calloc failed; was not freeing calloced memory if either + CreateSemaphore or CreateEvent failed. + +2003-10-14 Ross Johnson + + * pthread.h: Add Watcom compiler compatibility. Esssentially just add + the cdecl attribute to all exposed function prototypes so that Watcom + generates function call code compatible with non-Watcom built libraries. + By default, Watcom uses registers to pass function args if possible rather + than pushing to stack. + * semaphore.h: Likewise. + * sched.h: Likewise. + * pthread_cond_wait.c (__ptw32_cond_wait_cleanup): Define with cdecl attribute + for Watcom compatibility. This routine is called via pthread_cleanup_push so + it had to match function arg definition. + * Wmakefile: New makefile for Watcom builds. + +2003-09-14 Ross Johnson + + * pthread_setschedparam.c (pthread_setschedparam): Attempt to map + all priority levels between max and min (as returned by + sched_get_priority_min/max) to reasonable Win32 priority levels - i.e. + levels between THREAD_PRIORITY_LOWEST/IDLE to THREAD_PRIORITY_LOWEST and + between THREAD_PRIORITY_HIGHEST/TIME_CRITICAL to THREAD_PRIORITY_HIGHEST + while others remain unchanged; record specified thread priority level + for return by pthread_getschedparam. + + Note that, previously, specified levels not matching Win32 priority levels + would silently leave the current thread priority unaltered. + + * pthread_getschedparam.c (pthread_getschedparam): Return the priority + level specified by the latest pthread_setschedparam or pthread_create rather + than the actual running thread priority as returned by GetThreadPriority - as + required by POSIX. I.e. temporary or adjusted actual priority levels are not + returned by this routine. + + * pthread_create.c (pthread_create): For priority levels specified via + pthread attributes, attempt to map all priority levels between max and + min (as returned by sched_get_priority_min/max) to reasonable Win32 + priority levels; record priority level given via attributes, or + inherited from parent thread, for later return by pthread_getschedparam. + + * ptw32_new.c (__ptw32_new): Initialise pthread_t_ sched_priority element. + + * pthread_self.c (pthread_self): Set newly created implicit POSIX thread + sched_priority to Win32 thread's current actual priority. Temporarily + altered priorities can't be avoided in this case. + + * implement.h (struct pthread_t_): Add new sched_priority element. + +2003-09-12 Ross Johnson + + * sched_get_priority_min.c (sched_get_priority_min): On error should return -1 + with errno set. + * sched_get_priority_max.c (sched_get_priority_max): Likewise. + +2003-09-03 Ross Johnson + + * w32_cancelableWait.c (__ptw32_cancelable_wait): Allow cancellation + of implicit POSIX threads as well. + +2003-09-02 Ross Johnson + + * pthread_win32_attach_detach_np.c (pthread_win32_thread_detach_np): + Add comment. + + * pthread_exit.c (pthread_exit): Fix to recycle the POSIX thread handle in + addition to calling user TSD destructors. Move the implicit POSIX thread exit + handling to __ptw32_throw to centralise the logic. + + * ptw32_throw.c (__ptw32_throw): Implicit POSIX threads have no point + to jump or throw to, so cleanup and exit the thread here in this case. For + processes using the C runtime, the exit code will be set to the POSIX + reason for the throw (i.e. PTHREAD_CANCEL or the value given to pthread_exit). + Note that pthread_exit() already had similar logic, which has been moved to + here. + + * ptw32_threadDestroy.c (__ptw32_threadDestroy): Don't close the Win32 handle + of implicit POSIX threads - expect this to be done by Win32? + +2003-09-01 Ross Johnson + + * pthread_self.c (pthread_self): The newly aquired pthread_t must be + assigned to the reuse stack, not freed, if the routine fails somehow. + +2003-08-13 Ross Johnson + + * pthread_getschedparam.c (pthread_getschedparam): An invalid thread ID + parameter was returning an incorrect error value; now uses a more exhaustive + check for validity. + + * pthread_setschedparam.c (pthread_setschedparam): Likewise. + + * pthread_join.c (pthread_join): Now uses a more exhaustive + check for validity. + + * pthread_detach.c (pthread_detach): Likewise. + + * pthread_cancel.c (pthread_cancel): Likewise. + + * ptw32_threadDestroy.c (__ptw32_threadDestroy): pthread_t structs are + never freed - push them onto a stack for reuse. + + * ptw32_new.c (__ptw32_new): Check for reusable pthread_t before dynamically + allocating new memory for the struct. + + * pthread_kill.c (pthread_kill): New file; new routine; takes only a zero + signal arg so that applications can check the thread arg for validity; checks + that the underlying Win32 thread HANDLE is valid. + + * pthread.h (pthread_kill): Add prototype. + + * ptw32_reuse.c (__ptw32_threadReusePop): New file; new routine; pop a + pthread_t off the reuse stack. pthread_t_ structs that have been destroyed, i.e. + have exited detached or have been joined, are cleaned up and put onto a reuse + stack. Consequently, thread IDs are no longer freed once calloced. The library + will attempt to get a struct off this stack before asking the system to alloc + new memory when creating threads. The stack is guarded by a global mutex. + (__ptw32_threadReusePush): New routine; push a pthread_t onto the reuse stack. + + * implement.h (__ptw32_threadReusePush): Add new prototype. + (__ptw32_threadReusePop): Likewise. + (pthread_t): Add new element. + + * ptw32_processTerminate.c (__ptw32_processTerminate): Delete the thread + reuse lock; free all thread ID structs on the thread reuse stack. + + * ptw32_processInitialize.c (__ptw32_processInitialize): Initialise the + thread reuse lock. + +2003-07-19 Ross Johnson + + * GNUmakefile: modified to work under MsysDTK environment. + * pthread_spin_lock.c (pthread_spin_lock): Check for NULL arg. + * pthread_spin_unlock.c (pthread_spin_unlock): Likewise. + * pthread_spin_trylock.c (pthread_spin_trylock): Likewise; + fix incorrect pointer value if lock is dynamically initialised by + this function. + * sem_init.c (sem_init): Initialise sem_t value to quell compiler warning. + * sem_destroy.c (sem_destroy): Likewise. + * ptw32_threadStart.c (non-MSVC code sections): Include rather + than old-style ; fix all std:: namespace entities such as + std::terminate_handler instances and associated methods. + * ptw32_callUserDestroyRoutines.c (non-MSVC code sections): Likewise. + +2003-06-24 Piet van Bruggen + + * pthread_spin_destroy.c (pthread_spin_destroy): Was not freeing the + spinlock struct. + +2003-06-22 Nicolas Barry + + * pthread_mutex_destroy.c (pthread_mutex_destroy): When called + with a recursive mutex that was locked by the current thread, the + function was failing with a success return code. + +2003-05-15 Steven Reddie + + * pthread_win32_attach_detach_np.c (pthread_win32_process_detach_np): + NULLify __ptw32_selfThreadKey after the thread is destroyed, otherwise + destructors calling pthreads routines might resurrect it again, creating + memory leaks. Call the underlying Win32 Tls routine directly rather than + pthread_setspecific(). + (pthread_win32_thread_detach_np): Likewise. + +2003-05-14 Viv + + * pthread.dsp: Change /MT compile flag to /MD. + +2003-03-04 Alexander Terekhov + + * pthread_mutex_timedlock.c (pthread_mutex_timedlock): Fix failure to + set ownership of mutex on second grab after abstime timeout. + - bug reported by Robert Strycek + +2002-12-17 Thomas Pfaff + + * pthread_mutex_lock.c (__ptw32_semwait): New static routine to provide + a non-cancelable sem_wait() function. This is consistent with the + way that pthread_mutex_timedlock.c does it. + (pthread_mutex_lock): Use __ptw32_semwait() instead of sem_wait(). + +2002-12-11 Thomas Pfaff + + * pthread_mutex_trylock.c: Should return EBUSY rather than EDEADLK. + * pthread_mutex_destroy.c: Remove redundant ownership test (the + trylock call does this for us); do not destroy a recursively locked + mutex. + +2002-09-20 Michael Johnson + + * pthread_cond_destroy.c (pthread_cond_destroy): + When two different threads exist, and one is attempting to + destroy a condition variable while the other is attempting to + initialize a condition variable that was created with + PTHREAD_COND_INITIALIZER, a deadlock can occur. Shrink + the __ptw32_cond_list_lock critical section to fix it. + +2002-07-31 Ross Johnson + + * ptw32_threadStart.c (__ptw32_threadStart): Thread cancelLock + destruction moved to __ptw32_threadDestroy(). + + * ptw32_threadDestroy.c (__ptw32_threadDestroy): Destroy + the thread's cancelLock. Moved here from ptw32_threadStart.c + to cleanup implicit threads as well. + +2002-07-30 Alexander Terekhov + + * pthread_cond_wait.c (__ptw32_cond_wait_cleanup): + Remove code designed to avoid/prevent spurious wakeup + problems. It is believed that the sem_timedwait() call + is consuming a CV signal that it shouldn't and this is + breaking the avoidance logic. + +2002-07-30 Ross Johnson + + * sem_timedwait.c (sem_timedwait): Tighten checks for + unreasonable abstime values - that would result in + unexpected timeout values. + + * w32_CancelableWait.c (__ptw32_cancelable_wait): + Tighten up return value checking and add comments. + + +2002-06-08 Ross Johnson + + * sem_getvalue.c (sem_getvalue): Now returns a value for the + NEED_SEM version (i.e. earlier versions of WinCE). + + +2002-06-04 Rob Fanner + + * sem_getvalue.c (sem_getvalue): The Johnson M. Hart + approach didn't work - we are forced to take an + intrusive approach. We try to decrement the sema + and then immediately release it again to get the + value. There is a small probability that this may + block other threads, but only momentarily. + +2002-06-03 Ross Johnson + + * sem_init.c (sem_init): Initialise Win32 semaphores + to _POSIX_SEM_VALUE_MAX (which this implementation + defines in pthread.h) so that sem_getvalue() can use + the trick described in the comments in sem_getvalue(). + * pthread.h (_POSIX_SEM_VALUE_MAX): Defined. + (_POSIX_SEM_NSEMS_MAX): Defined - not used but may be + useful for source code portability. + +2002-06-03 Rob Fanner + + * sem_getvalue.c (sem_getvalue): Did not work on NT. + Use approach suggested by Johnson M. Hart in his book + "Win32 System Programming". + +2002-02-28 Ross Johnson + + * errno.c: Compiler directive was incorrectly including code. + * pthread.h: Conditionally added some #defines from config.h + needed when not building the library. e.g. NEED_ERRNO, NEED_SEM. + (__PTW32_DLLPORT): Now only defined if _DLL defined. + (_errno): Compiler directive was incorrectly including prototype. + * sched.h: Conditionally added some #defines from config.h + needed when not building the library. + * semaphore.h: Replace an instance of NEED_SEM that should + have been NEED_ERRNO. This change currently has nil effect. + + * GNUmakefile: Correct some recent changes. + + * Makefile: Add rule to generate pre-processor output. + +2002-02-23 Ross Johnson + + * pthread_rwlock_timedrdlock.c: New - untested. + * pthread_rwlock_timedwrlock.c: New - untested. + + * Testsuite passed (except known MSVC++ problems) + + * pthread_cond_destroy.c: Expand the time change + critical section to solve deadlock problem. + + * pthread.c: Add all remaining C modules. + * pthread.h: Use dllexport/dllimport attributes on functions + to avoid using pthread.def. + * sched.h: Likewise. + * semaphore.h: Likewise. + * GNUmakefile: Add new targets for single translation + unit build to maximise inlining potential; generate + pthread.def automatically. + * Makefile: Likewise, but no longer uses pthread.def. + +2002-02-20 Ross Johnson + + * pthread_cond_destroy.c (pthread_cond_destroy): + Enter the time change critical section earlier. + +2002-02-17 Ross Johnson + + * nonportable.c (pthread_delay_np): Make a true + cancellation point. Deferred cancels will interrupt the + wait. + +2002-02-07 Ross Johnson + + Reduced name space pollution. + ----------------------------- + When the appropriate symbols are defined, the headers + will restrict the definitions of new names. In particular, + it must be possible to NOT include the + header and related definitions with some combination + of symbol definitions. Secondly, it should be possible + that additional definitions should be limited to POSIX + compliant symbols by the definition of appropriate symbols. + + * pthread.h: POSIX conditionals. + * sched.h: POSIX conditionals. + * semaphore.h: POSIX conditionals. + + * semaphore.c: Included . + (sem_init): Changed magic 0x7FFFFFFFL to INT_MAX. + (sem_getvalue): Trial version. + + Reduce executable size. + ----------------------- + When linking with the static library, only those + routines actually called, either directly or indirectly + should be included. + + [Gcc has the -ffunction-segments option to do this but MSVC + doesn't have this feature as far as I can determine. Other + compilers are undetermined as well. - rpj] + + * semaphore.c: All routines are now in separate compilation units; + This file is used to congregate the separate modules for + potential inline optimisation and backward build compatibility. + * sem_close.c: Separated routine from semaphore.c. + * ptw32_decrease_semaphore.c: Likewise. + * sem_destroy.c: Likewise. + * sem_getvalue.c: Likewise. + * ptw32_increase_semaphore.c: Likewise. + * sem_init.c: Likewise. + * sem_open.c: Likewise. + * sem_post.c: Likewise. + * sem_post_multiple.c: Likewise. + * sem_timedwait.c: Likewise. + * sem_trywait.c: Likewise. + * sem_unlink.c: Likewise. + * sem_wait.c: Likewise. + +2002-02-04 Ross Johnson + + The following extends the idea above to the rest of pthreads-win32 - rpj + + * attr.c: All routines are now in separate compilation units; + This file is used to congregate the separate modules for + potential inline optimisation and backward build compatibility. + * pthread_attr_destroy.c: Separated routine from attr.c. + * pthread_attr_getdetachstate.c: Likewise. + * pthread_attr_getscope.c: Likewise. + * pthread_attr_getstackaddr.c: Likewise. + * pthread_attr_getstacksize.c: Likewise. + * pthread_attr_init.c: Likewise. + * pthread_attr_is_attr.c: Likewise. + * pthread_attr_setdetachstate.c: Likewise. + * pthread_attr_setscope.c: Likewise. + * pthread_attr_setstackaddr.c: Likewise. + * pthread_attr_setstacksize.c: Likewise. + + * pthread.c: Agregation of agregate modules for super-inlineability. + +2002-02-02 Ross Johnson + + * cancel.c: Rearranged some code and introduced checks + 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. + * condvar.c: Place pragmas around cleanup_push/pop to turn + off inline optimisation (/Obn where n>0 - MSVC only). Various + optimisation switches in MSVC turn this on, which interferes with + the way that cleanup handlers are run in C++ EH and SEH + code. Application code compiled with inline optimisation must + also wrap cleanup_push/pop blocks with the pragmas, e.g. + #pragma inline_depth(0) + pthread_cleanup_push(...) + ... + pthread_cleanup_pop(...) + #pragma inline_depth(8) + * rwlock.c: Likewise. + * mutex.c: Remove attempts to inline some functions. + * signal.c: Modify misleading comment. + +2002-02-01 Ross Johnson + + * semaphore.c (sem_trywait): Fix missing errno return + for systems that define NEED_SEM (e.g. early WinCE). + * mutex.c (pthread_mutex_timedlock): Return ENOTSUP + for systems that define NEED_SEM since they don't + have sem_trywait(). + +2002-01-27 Ross Johnson + + * mutex.c (pthread_mutex_timedlock): New function suggested by + Alexander Terekhov. The logic required to implement this + properly came from Alexander, with some collaboration + with Thomas Pfaff. + (pthread_mutex_unlock): Wrap the waiters check and sema + post in a critical section to prevent a race with + pthread_mutex_timedlock. + (__ptw32_timed_semwait): New function; + returns a special result if the absolute timeout parameter + represents a time already passed when called; used by + pthread_mutex_timedwait(). Have deliberately not reused + the name "__ptw32_sem_timedwait" because they are not the same + routine. + * condvar.c (__ptw32_cond_timedwait): Use the new sem_timedwait() + instead of __ptw32_sem_timedwait(), which now has a different + function. See previous. + * implement.h: Remove prototype for __ptw32_sem_timedwait. + See next. + (pthread_mutex_t_): Add critical section element for access + to lock_idx during mutex post-timeout processing. + * semaphore.h (sem_timedwait): See next. + * semaphore.c (sem_timedwait): See next. + * private.c (__ptw32_sem_timedwait): Move to semaphore.c + and rename as sem_timedwait(). + +2002-01-18 Ross Johnson + + * sync.c (pthread_join): Was getting the exit code from the + calling thread rather than the joined thread if + defined(__MINGW32__) && !defined(__MSVCRT__). + +2002-01-15 Ross Johnson + + * pthread.h: Unless the build explicitly defines __PTW32_CLEANUP_SEH, + __PTW32_CLEANUP_CXX, or __PTW32_CLEANUP_C, then the build defaults to + __PTW32_CLEANUP_C style cleanup. This style uses setjmp/longjmp + 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. + + * spin.c (pthread_spin_init): Edit renamed function call. + * nonportable.c (pthread_num_processors_np): New. + (pthread_getprocessors_np): Renamed to __ptw32_getprocessors + and moved to private.c. + * private.c (pthread_getprocessors): Moved here from + nonportable.c. + * pthread.def (pthread_getprocessors_np): Removed + from export list. + + * rwlock.c (pthread_rwlockattr_init): New. + (pthread_rwlockattr_destroy): New. + (pthread_rwlockattr_getpshared): New. + (pthread_rwlockattr_setpshared): New. + +2002-01-14 Ross Johnson + + * attr.c (pthread_attr_setscope): Fix struct pointer + indirection error introduced 2002-01-04. + (pthread_attr_getscope): Likewise. + +2002-01-12 Ross Johnson + + * pthread.dsp (SOURCE): Add missing source files. + +2002-01-08 Ross Johnson + + * mutex.c (pthread_mutex_trylock): use + __ptw32_interlocked_compare_exchange function pointer + rather than __ptw32_InterlockedCompareExchange() directly + to retain portability to non-iX86 processors, + e.g. WinCE etc. The pointer will point to the native + OS version of InterlockedCompareExchange() if the + OS supports it (see ChangeLog entry of 2001-10-17). + +2002-01-07 Thomas Pfaff , Alexander Terekhov + + * mutex.c (pthread_mutex_init): Remove critical + section calls. + (pthread_mutex_destroy): Likewise. + (pthread_mutex_unlock): Likewise. + (pthread_mutex_trylock): Likewise; uses + __ptw32_InterlockedCompareExchange() to avoid need for + critical section; library is no longer i386 compatible; + recursive mutexes now increment the lock count rather + than return EBUSY; errorcheck mutexes return EDEADLCK + rather than EBUSY. This behaviour is consistent with the + Solaris pthreads implementation. + * implement.h (pthread_mutex_t_): Remove critical + section element - no longer needed. + + +2002-01-04 Ross Johnson + + * attr.c (pthread_attr_setscope): Add more error + checking and actually store the scope value even + though it's not really necessary. + (pthread_attr_getscope): Return stored value. + * implement.h (pthread_attr_t_): Add new scope element. + * ANNOUNCE: Fix out of date comment next to + pthread_attr_setscope in conformance section. + +2001-12-21 Alexander Terekhov + + * mutex.c (pthread_mutex_lock): Decrementing lock_idx was + not thread-safe. + (pthread_mutex_trylock): Likewise. + +2001-10-26 prionx@juno.com + + * semaphore.c (sem_init): Fix typo and missing bracket + in conditionally compiled code. Only older versions of + WinCE require this code, hence it doesn't normally get + tested; somehow when sem_t reverted to an opaque struct + the calloc NULL check was left in the conditionally included + section. + (sem_destroy): Likewise, the calloced sem_t wasn't being freed. + +2001-10-25 Ross Johnson + + * GNUmakefile (libwsock32): Add to linker flags for + WSAGetLastError() and WSASetLastError(). + * Makefile (wsock32.lib): Likewise. + * create.c: Minor mostly inert changes. + * implement.h (__PTW32_MAX): Move into here and renamed + from sched.h. + (__PTW32_MIN): Likewise. + * GNUmakefile (TEST_ICE): Define if testing internal + implementation of InterlockedCompareExchange. + * Makefile (TEST_ICE): Likewise. + * private.c (TEST_ICE): Likewise. + +2001-10-24 Ross Johnson + + * attr.c (pthread_attr_setstacksize): Quell warning + from LCC by conditionally compiling the stacksize + validity check. LCC correctly warns that the condition + (stacksize < PTHREAD_STACK_MIN) is suspicious + because STACK_MIN is 0 and stacksize is of type + size_t (or unsigned int). + +2001-10-17 Ross Johnson + + * barrier.c: Move _LONG and _LPLONG defines into + implement.h; rename to __PTW32_INTERLOCKED_LONG and + PTW32_INTERLOCKED_LPLONG respectively. + * spin.c: Likewise; __ptw32_interlocked_compare_exchange used + in place of InterlockedCompareExchange directly. + * global.c (__ptw32_interlocked_compare_exchange): Add + prototype for this new routine pointer to be used when + InterlockedCompareExchange isn't supported by Windows. + * nonportable.c (pthread_win32_process_attach_np): Check for + support of InterlockedCompareExchange in kernel32 and assign its + address to __ptw32_interlocked_compare_exchange if it exists, or + our own ix86 specific implementation __ptw32_InterlockedCompareExchange. + *private.c (__ptw32_InterlockedCompareExchange): An + implementation of InterlockedCompareExchange() which is + specific to ix86; written directly in assembler for either + MSVC or GNU C; needed because Windows 95 doesn't support + InterlockedCompareExchange(). + + * sched.c (sched_get_priority_min): Extend to return + THREAD_PRIORITY_IDLE. + (sched_get_priority_max): Extend to return + THREAD_PRIORITY_CRITICAL. + +2001-10-15 Ross Johnson + + * spin.c (pthread_spin_lock): PTHREAD_SPINLOCK_INITIALIZER + was causing a program fault. + (pthread_spin_init): Could have alloced memory + without freeing under some error conditions. + + * mutex.c (pthread_mutex_init): Move memory + allocation of mutex struct after checking for + PROCESS_SHARED. + +2001-10-12 Ross Johnson + + * spin.c (pthread_spin_unlock): Was not returning + EPERM if the spinlock was not locked, for multi CPU + machines. + +2001-10-08 Ross Johnson + + * spin.c (pthread_spin_trylock): Was not returning + EBUSY for multi CPU machines. + +2001-08-24 Ross Johnson + + * condvar.c (pthread_cond_destroy): Remove cv element + that is no longer used. + * implement.h: Likewise. + +2001-08-23 Alexander Terekhov + + * condvar.c (pthread_cond_destroy): fix bug with + respect to deadlock in the case of concurrent + _destroy/_unblock; a condition variable can be destroyed + immediately after all the threads that are blocked on + it are awakened. + +2001-08-23 Phil Frisbie, Jr. + + * tsd.c (pthread_getspecific): Preserve the last + winsock error [from WSAGetLastError()]. + +2001-07-18 Scott McCaskill + + * mutex.c (pthread_mutexattr_init): Return ENOMEM + immediately and don't dereference the NULL pointer + if calloc fails. + (pthread_mutexattr_getpshared): Don't dereference + a pointer that is possibly NULL. + * barrier.c (pthread_barrierattr_init): Likewise + (pthread_barrierattr_getpshared): Don't dereference + a pointer that is possibly NULL. + * condvar.c (pthread_condattr_getpshared): Don't dereference + a pointer that is possibly NULL. + +2001-07-15 Ross Johnson + + * rwlock.c (pthread_rwlock_wrlock): Is allowed to be + a cancellation point; re-enable deferred cancelability + around the CV call. + +2001-07-10 Ross Johnson + + * barrier.c: Still more revamping. The exclusive access + mutex isn't really needed so it has been removed and replaced + by an InterlockedDecrement(). nSerial has been removed. + iStep is now dual-purpose. The process shared attribute + is now stored in the barrier struct. + * implement.h (pthread_barrier_t_): Lost some/gained one + elements. + * private.c (__ptw32_threadStart): Removed some comments. + +2001-07-10 Ross Johnson + + * barrier.c: Revamped to fix the race condition. Two alternating + semaphores are used instead of the PulseEvent. Also improved + overall throughput by returning PTHREAD_BARRIER_SERIAL_THREAD + to the first waking thread. + * implement.h (pthread_barrier_t_): Revamped. + +2001-07-09 Ross Johnson + + * barrier.c: Fix several bugs in all routines. Now passes + tests/barrier5.c which is fairly rigorous. There is still + a non-optimal work-around for a race condition between + the barrier breeched event signal and event wait. Basically + the last (signalling) thread to hit the barrier yields + to allow any other threads, which may have lost the race, + to complete. + +2001-07-07 Ross Johnson + + * barrier.c: Changed synchronisation mechanism to a + Win32 manual reset Event and use PulseEvent to signal + waiting threads. If the implementation continued to use + a semaphore it would require a second semaphore and + some management to use them alternately as barriers. A + single semaphore allows threads to cascade from one barrier + through the next, leaving some threads blocked at the first. + * implement.h (pthread_barrier_t_): As per above. + * general: Made a number of other routines inlinable. + +2001-07-07 Ross Johnson + + * spin.c: Revamped and working; included static initialiser. + Now beta level. + * barrier.c: Likewise. + * condvar.c: Macro constant change; inline auto init routine. + * mutex.c: Likewise. + * rwlock.c: Likewise. + * private.c: Add support for spinlock initialiser. + * global.c: Likewise. + * implement.h: Likewise. + * pthread.h (PTHREAD_SPINLOCK_INITIALIZER): Fix typo. + +2001-07-05 Ross Johnson + + * barrier.c: Remove static initialisation - irrelevent + for this object. + * pthread.h (PTHREAD_BARRIER_INITIALIZER): Removed. + * rwlock.c (pthread_rwlock_wrlock): This routine is + not a cancellation point - disable deferred + cancellation around call to pthread_cond_wait(). + +2001-07-05 Ross Johnson + + * spin.c: New module implementing spin locks. + * barrier.c: New module implementing barriers. + * pthread.h (_POSIX_SPIN_LOCKS): defined. + (_POSIX_BARRIERS): Defined. + (pthread_spin_*): Defined. + (pthread_barrier*): Defined. + (PTHREAD_BARRIER_SERIAL_THREAD): Defined. + * implement.h (pthread_spinlock_t_): Defined. + (pthread_barrier_t_): Defined. + (pthread_barrierattr_t_): Defined. + + * mutex.c (pthread_mutex_lock): Return with the error + if an auto-initialiser initialisation fails. + + * nonportable.c (pthread_getprocessors_np): New; gets the + number of available processors for the current process. + +2001-07-03 Ross Johnson + + * pthread.h (_POSIX_READER_WRITER_LOCKS): Define it + if not already defined. + +2001-07-01 Alexander Terekhov + + * condvar.c: Fixed lost signal bug reported by Timur Aydin + (taydin@snet.net). + [RPJ (me) didn't translate the original algorithm + correctly.] + * semaphore.c: Added sem_post_multiple; this is a useful + routine, but it doesn't appear to be standard. For now it's + not an exported function. + +2001-06-25 Ross Johnson + + * create.c (pthread_create): Add priority inheritance + attributes. + * mutex.c (pthread_mutex_lock): Remove some overhead for + PTHREAD_MUTEX_NORMAL mutex types. Specifically, avoid + calling pthread_self() and pthread_equal() to check/set + the mutex owner. Introduce a new pseudo owner for this + type. Test results suggest increases in speed of up to + 90% for non-blocking locks. + This is the default type of mutex used internally by other + synchronising objects, ie. condition variables and + read-write locks. The test rwlock7.c shows about a + 30-35% speed increase over snapshot 2001-06-06. The + price of this is that the application developer + must ensure correct behaviour, or explicitly set the + mutex to a safer type such as PTHREAD_MUTEX_ERRORCHECK. + For example, PTHREAD_MUTEX_NORMAL (or PTHREAD_MUTEX_DEFAULT) + type mutexes will not return an error if a thread which is not + the owner calls pthread_mutex_unlock. The call will succeed + in unlocking the mutex if it is currently locked, but a + subsequent unlock by the true owner will then fail with EPERM. + This is however consistent with some other implementations. + (pthread_mutex_unlock): Likewise. + (pthread_mutex_trylock): Likewise. + (pthread_mutex_destroy): Likewise. + * attr.c (pthread_attr_init): PTHREAD_EXPLICIT_SCHED is the + default inheritance attribute; THREAD_PRIORITY_NORMAL is + the default priority for new threads. + * sched.c (pthread_attr_setschedpolicy): Added routine. + (pthread_attr_getschedpolicy): Added routine. + (pthread_attr_setinheritsched): Added routine. + (pthread_attr_getinheritsched): Added routine. + * pthread.h (sched_rr_set_interval): Added as a macro; + returns -1 with errno set to ENOSYS. + +2001-06-23 Ross Johnson + + *sched.c (pthread_attr_setschedparam): Add priority range + check. + (sched_setscheduler): New function; checks for a valid + pid and policy; checks for permission to set information + in the target process; expects pid to be a Win32 process ID, + not a process handle; the only scheduler policy allowed is + SCHED_OTHER. + (sched_getscheduler): Likewise, but checks for permission + to query. + * pthread.h (SCHED_*): Moved to sched.h as defined in the + POSIX standard. + * sched.h (SCHED_*): Moved from pthread.h. + (pid_t): Defined if necessary. + (sched_setscheduler): Defined. + (sched_getscheduler): Defined. + * pthread.def (sched_setscheduler): Exported. + (sched_getscheduler): Likewise. + +2001-06-23 Ralf Brese + + * create.c (pthread_create): Set thread priority from + thread attributes. + +2001-06-18 Ross Johnson + + * Made organisational-only changes to UWIN additions. + * dll.c (dllMain): Moved UWIN process attach code + to pthread_win32_process_attach_np(); moved + instance of pthread_count to global.c. + * global.c (pthread_count): Moved from dll.c. + * nonportable.c (pthread_win32_process_attach_np): + Moved _UWIN code to here from dll.c. + * implement.h (pthread_count): Define extern int. + * create.c (pthread_count): Remove extern int. + * private.c (pthread_count): Likewise. + * exit.c (pthread_count): Likewise. + +2001-06-18 David Korn + + * dll.c: Added changes necessary to work with UWIN. + * create.c: Likewise. + * pthread.h: Likewise. + * misc.c: Likewise. + * exit.c: Likewise. + * private.c: Likewise. + * implement.h: Likewise. + There is some room at the start of struct pthread_t_ + to implement the signal semantics in UWIN's posix.dll + although this is not yet complete. + * Nmakefile: Compatible with UWIN's Nmake utility. + * Nmakefile.tests: Likewise - for running the tests. + +2001-06-08 Ross Johnson + + * semaphore.h (sem_t): Fixed for compile and test. + * implement.h (sem_t_): Likewise. + * semaphore.c: Likewise. + * private.c (__ptw32_sem_timedwait): Updated to use new + opaque sem_t. + +2001-06-06 Ross Johnson + + * semaphore.h (sem_t): Is now an opaque pointer; + moved actual definition to implement.h. + * implement.h (sem_t_): Move here from semaphore.h; + was the definition of sem_t. + * semaphore.c: Wherever necessary, changed use of sem + from that of a pointer to a pointer-pointer; added + extra checks for a valid sem_t; NULL sem_t when + it is destroyed; added extra checks when creating + and destroying sem_t elements in the NEED_SEM + code branches; changed from using a pthread_mutex_t + ((*sem)->mutex) to CRITICAL_SECTION ((*sem)->sem_lock_cs) + in NEED_SEM branches for access serialisation. + +2001-06-06 Ross Johnson + + * mutex.c (pthread_mutexattr_init): Remove + __ptw32_mutex_default_kind. + +2001-06-05 Ross Johnson + + * nonportable.c (pthread_mutex_setdefaultkind_np): + Remove - should not have been included in the first place. + (pthread_mutex_getdefaultkind_np): Likewise. + * global.c (__ptw32_mutex_default_kind): Likewise. + * mutex.c (pthread_mutex_init): Remove use of + __ptw32_mutex_default_kind. + * pthread.h (pthread_mutex_setdefaultkind_np): Likewise. + (pthread_mutex_getdefaultkind_np): Likewise. + * pthread.def (pthread_mutexattr_setkind_np): Added. + (pthread_mutexattr_getkind_np): Likewise. + + * README: Many changes that should have gone in before + the last snapshot. + * README.NONPORTABLE: New - referred to by ANNOUNCE + but never created; documents the non-portable routines + included in the library - moved from README with new + routines added. + * ANNOUNCE (pthread_mutexattr_setkind_np): Added to + compliance list. + (pthread_mutexattr_getkind_np): Likewise. + +2001-06-04 Ross Johnson + + * condvar.c: Add original description of the algorithm as + developed by Terekhov and Thomas, plus reference to + README.CV. + +2001-06-03 Alexander Terekhov , Louis Thomas + + * condvar.c (pthread_cond_init): Completely revamped. + (pthread_cond_destroy): Likewise. + (__ptw32_cond_wait_cleanup): Likewise. + (__ptw32_cond_timedwait): Likewise. + (__ptw32_cond_unblock): New general signaling routine. + (pthread_cond_signal): Now calls __ptw32_cond_unblock. + (pthread_cond_broadcast): Likewise. + * implement.h (pthread_cond_t_): Revamped. + * README.CV: New; explanation of the above changes. + +2001-05-30 Ross Johnson + + * pthread.h (rand_r): Fake using _seed argument to quell + compiler warning (compiler should optimise this away later). + + * GNUmakefile (OPT): Leave symbolic information out of the library + and increase optimisation level - for smaller faster prebuilt + dlls. + +2001-05-29 Milan Gardian + + * Makefile: fix typo. + * pthreads.h: Fix problems with stdcall/cdecl conventions, in particular + remove the need for PT_STDCALL everywhere; remove warning supression. + * (errno): Fix the longstanding "inconsistent dll linkage" problem + with errno; now also works with /MD debugging libs - + warnings emerged when compiling pthreads library with /MD (or /MDd) + compiler switch, instead of /MT (or /MTd) (i.e. when compiling pthreads + using Multithreaded DLL CRT instead of Multithreaded statically linked + CRT). + * create.c (pthread_create): Likewise; fix typo. + * private.c (__ptw32_threadStart): Eliminate use of terminate() which doesn't + throw exceptions. + * Remove unnecessary #includes from a number of modules - + [I had to #include malloc.h in implement.h for gcc - rpj]. + +2001-05-29 Thomas Pfaff + + * pthread.h (PTHREAD_MUTEX_DEFAULT): New; equivalent to + PTHREAD_MUTEX_DEFAULT_NP. + * (PTHREAD_MUTEX_NORMAL): Similarly. + * (PTHREAD_MUTEX_ERRORCHECK): Similarly. + * (PTHREAD_MUTEX_RECURSIVE): Similarly. + * (pthread_mutex_setdefaultkind_np): New; Linux compatibility stub + for pthread_mutexattr_settype. + * (pthread_mutexattr_getkind_np): New; Linux compatibility stub + for pthread_mutexattr_gettype. + * mutex.c (pthread_mutexattr_settype): New; allow + the following types of mutex: + PTHREAD_MUTEX_DEFAULT_NP + PTHREAD_MUTEX_NORMAL_NP + PTHREAD_MUTEX_ERRORCHECK_NP + PTHREAD_MUTEX_RECURSIVE_NP + * Note that PTHREAD_MUTEX_DEFAULT is equivalent to + PTHREAD_MUTEX_NORMAL - ie. mutexes should no longer + be recursive by default, and a thread will deadlock if it + tries to relock a mutex it already owns. This is inline with + other pthreads implementations. + * (pthread_mutex_lock): Process the lock request + according to the mutex type. + * (pthread_mutex_init): Eliminate use of Win32 mutexes as the + basis of POSIX mutexes - instead, a combination of one critical section + and one semaphore are used in conjunction with Win32 Interlocked* routines. + * (pthread_mutex_destroy): Likewise. + * (pthread_mutex_lock): Likewise. + * (pthread_mutex_trylock): Likewise. + * (pthread_mutex_unlock): Likewise. + * 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 + Milan Gardian's patches above. + +2001-02-07 Alexander Terekhov + + * rwlock.c: Revamped. + * implement.h (pthread_rwlock_t_): Redefined. + This implementation does not have reader/writer starvation problem. + Rwlock attempts to behave more like a normal mutex with + races and scheduling policy determining who is more important; + It also supports recursive locking, + has less synchronization overhead (no broadcasts at all, + readers are not blocked on any condition variable) and seem to + be faster than the current implementation [W98 appears to be + approximately 15 percent faster at least - on top of speed increase + from Thomas Pfaff's changes to mutex.c - rpj]. + +2000-12-29 Ross Johnson + + * Makefile: Back-out "for" loops which don't work. + + * GNUmakefile: Remove the fake.a target; add the "realclean" + target; don't remove built libs under the "clean" target. + + * config.h: Add a guard against multiple inclusion. + + * semaphore.h: Add some defines from config.h to make + semaphore.h independent of config.h when building apps. + + * pthread.h (_errno): Back-out previous fix until we know how to + fix it properly. + + * implement.h (lockCount): Add missing element to pthread_mutex_t_. + + * sync.c (pthread_join): Spelling fix in comment. + + * private.c (__ptw32_threadStart): Reset original termination + function (C++). + (__ptw32_threadStart): Cleanup detached threads early in case + the library is statically linked. + (__ptw32_callUserDestroyRoutines): Remove [SEH] __try block from + destructor call so that unhandled exceptions will be passed through + to the system; call terminate() from [C++] try block for the same + reason. + + * tsd.c (pthread_getspecific): Add comment. + + * mutex.c (pthread_mutex_init): Initialise new elements in + pthread_mutex_t. + (pthread_mutex_unlock): Invert "pthread_equal()" test. + +2000-12-28 Ross Johnson + + * semaphore.c (mode_t): Use ifndef HAVE_MODE_T to include definition. + + * config.h.in (HAVE_MODE_T): Added. + (_UWIN): Start adding defines for the UWIN package. + + * private.c (__ptw32_threadStart): Unhandled exceptions are + now passed through to the system to deal with. This is consistent + with normal Windows behaviour. C++ applications may use + set_terminate() to override the default behaviour which is + to call __ptw32_terminate(). Ptw32_terminate() cleans up some + POSIX thread stuff before calling the system default function + which calls abort(). The users termination function should conform + to standard C++ semantics which is to not return. It should + exit the thread (call pthread_exit()) or exit the application. + * private.c (__ptw32_terminate): Added as the default set_terminate() + function. It calls the system default function after cleaning up + some POSIX thread stuff. + + * implement.h (__ptw32_try_enter_critical_section): Move + declaration. + * global.c (__ptw32_try_enter_critical_section): Moved + from dll.c. + * dll.c: Move process and thread attach/detach code into + functions in nonportable.c. + * nonportable.c (pthread_win32_process_attach_np): Process + attach code from dll.c is now available to static linked + applications. + * nonportable.c (pthread_win32_process_detach_np): Likewise. + * nonportable.c (pthread_win32_thread_attach_np): Likewise. + * nonportable.c (pthread_win32_thread_detach_np): Likewise. + + * pthread.h: Add new non-portable prototypes for static + linked applications. + + * GNUmakefile (OPT): Increase optimisation flag and remove + debug info flag. + + * pthread.def: Add new non-portable exports for static + linked applications. + +2000-12-11 Ross Johnson + + * FAQ: Update Answer 6 re getting a fully working + Mingw32 built library. + +2000-10-10 Steven Reddie + + * misc.c (pthread_self): Restore Win32 "last error" + cleared by TlsGetValue() call in + pthread_getspecific() + +2000-09-20 Arthur Kantor + + * mutex.c (pthread_mutex_lock): Record the owner + of the mutex. This requires also keeping count of + recursive locks ourselves rather than leaving it + to Win32 since we need to know when to NULL the + thread owner when the mutex is unlocked. + (pthread_mutex_trylock): Likewise. + (pthread_mutex_unlock): Check that the calling + thread owns the mutex, decrement the recursive + lock count, and NULL the owner if zero. Return + EPERM if the mutex is owned by another thread. + * implement.h (pthread_mutex_t_): Add ownerThread + and lockCount members. + +2000-09-13 Jef Gearhart + + * mutex.c (pthread_mutex_init): Call + TryEnterCriticalSection through the pointer + rather than directly so that the dll can load + on Windows versions that can't resolve the + function, eg. Windows 95 + +2000-09-09 Ross Johnson + + * pthread.h (ctime_r): Fix arg. + +2000-09-08 Ross Johnson + + * GNUmakefile(_WIN32_WINNT=0x400): Define in CFLAGS; + doesn't seem to be needed though. + + * cancel.c (pthread_cancel): Must get "self" through + calling pthread_self() which will ensure a POSIX thread + struct is built for non-POSIX threads; return an error + if this fails + - Ollie Leahy + (pthread_setcancelstate): Likewise. + (pthread_setcanceltype): Likewise. + * misc.c (__ptw32_cancelable_wait): Likewise. + + * private.c (__ptw32_tkAssocCreate): Remove unused #if 0 + wrapped code. + + * pthread.h (__ptw32_get_exception_services_code): + Needed to be forward declared unconditionally. + +2000-09-06 Ross Johnson + + * cancel.c (pthread_cancel): If called from the main + thread "self" would be NULL; get "self" via pthread_self() + instead of directly from TLS so that an implicit + pthread object is created. + + * misc.c (pthread_equal): Strengthen test for NULLs. + +2000-09-02 Ross Johnson + + * condvar.c (__ptw32_cond_wait_cleanup): Ensure that all + waking threads check if they are the last, and notify + the broadcaster if so - even if an error occurs in the + waiter. + + * semaphore.c (_decrease_semaphore): Should be + a call to __ptw32_decrease_semaphore. + (_increase_semaphore): Should be a call to + __ptw32_increase_semaphore. + + * misc.c (__ptw32_cancelable_wait): Renamed from + CancelableWait. + * rwlock.c (_rwlock_check*): Renamed to + __ptw32_rwlock_check*. + * mutex.c (_mutex_check*): Renamed to __ptw32_mutex_check*. + * condvar.c (cond_timed*): Renamed to __ptw32_cond_timed*. + (_cond_check*): Renamed to __ptw32_cond_check*. + (cond_wait_cleanup*): Rename to __ptw32_cond_wait_cleanup*. + (__ptw32_cond_timedwait): Add comments. + +2000-08-22 Ross Johnson + + * private.c (__ptw32_throw): Fix exception test; + move exceptionInformation declaration. + + * tsd.c (pthread_key_create): newkey wrongly declared. + + * pthread.h: Fix comment block. + +2000-08-18 Ross Johnson + + * mutex.c (pthread_mutex_destroy): Check that the mutex isn't + held; invalidate the mutex as early as possible to avoid + contention; not perfect - FIXME! + + * rwlock.c (pthread_rwlock_init): Remove redundant assignment + to "rw". + (pthread_rwlock_destroy): Invalidate the rwlock before + freeing up any of it's resources - to avoid contention. + + * private.c (__ptw32_tkAssocCreate): Change assoc->lock + to use a dynamically initialised mutex - only consumes + a W32 mutex or critical section when first used, + not before. + + * mutex.c (pthread_mutex_init): Remove redundant assignment + to "mx". + (pthread_mutexattr_destroy): Set attribute to NULL + before freeing it's memory - to avoid contention. + + * implement.h (__PTW32_EPS_CANCEL/PTW32_EPS_EXIT): + Must be defined for all compilers - used as generic + exception selectors by __ptw32_throw(). + + * Several: Fix typos from scripted edit session + yesterday. + + * nonportable.c (pthread_mutexattr_setforcecs_np): + Moved this function from mutex.c. + (pthread_getw32threadhandle_np): New function to + return the win32 thread handle that the POSIX + thread is using. + * mutex.c (pthread_mutexattr_setforcecs_np): + Moved to new file "nonportable.c". + + * pthread.h (__PTW32_BUILD): Only redefine __except + and catch compiler keywords if we aren't building + the library (ie. __PTW32_BUILD is not defined) - + this is safer than defining and then undefining + if not building the library. + * implement.h: Remove __except and catch undefines. + * Makefile (CFLAGS): Define __PTW32_BUILD. + * GNUmakefile (CFLAGS): Define __PTW32_BUILD. + + * All appropriate: Change Pthread_exception* to + __ptw32_exception* to be consistent with internal + identifier naming. + + * private.c (__ptw32_throw): New function to provide + a generic exception throw for all internal + exceptions and EH schemes. + (__ptw32_threadStart): pthread_exit() value is now + returned via the thread structure exitStatus + element. + * exit.c (pthread_exit): pthread_exit() value is now + returned via the thread structure exitStatus + element. + * cancel.c (__ptw32_cancel_self): Now uses __ptw32_throw. + (pthread_setcancelstate): Ditto. + (pthread_setcanceltype): Ditto. + (pthread_testcancel): Ditto. + (pthread_cancel): Ditto. + * misc.c (CancelableWait): Ditto. + * exit.c (pthread_exit): Ditto. + * All applicable: Change __PTW32_ prefix to + PTW32_ prefix to remove leading underscores + from private library identifiers. + +2000-08-17 Ross Johnson + + * All applicable: Change _pthread_ prefix to + __ptw32_ prefix to remove leading underscores + from private library identifiers (single + and double leading underscores are reserved in the + ANSI C standard for compiler implementations). + + * tsd.c (pthread_create_key): Initialise temporary + key before returning it's address to avoid race + conditions. + +2000-08-13 Ross Johnson + + * errno.c: Add _MD precompile condition; thus far + had no effect when using /MD compile option but I + thnk it should be there. + + * exit.c: Add __cplusplus to various #if lines; + was compiling SEH code even when VC++ had + C++ compile options. + + * private.c: ditto. + + * create.c (pthread_create): Add PT_STDCALL macro to + function pointer arg in _beginthread(). + + * pthread.h: PT_STDCALL really does need to be defined + in both this and impliment.h; don't set it to __cdecl + - this macro is only used to extend function pointer + casting for functions that will be passed as parameters. + (~PThreadCleanup): add cast and group expression. + (_errno): Add _MD compile conditional. + (__PtW32NoCatchWarn): Change pragma message. + + * implement.h: Move and change PT_STDCALL define. + + * need_errno.h: Add _MD to compilation conditional. + + * GNUmakefile: Substantial rewrite for new naming + convention; set for nil optimisation (turn it up + when we have a working library build; add target + "fake.a" to build a libpthreadw32.a from the VC++ + built DLL pthreadVCE.dll. + + * pthread.def (LIBRARY): Don't specify in the .def + file - it is specified on the linker command line + since we now use the same .def file for variously + named .dlls. + + * Makefile: Substantial rewrite for new naming + convention; default nmake target only issues a + help message; run nmake with specific target + corresponding to the EH scheme being used. + + * README: Update information; add naming convention + explanation. + + * ANNOUNCE: Update information. + +2000-08-12 Ross Johnson + + * 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 cancellation and pthread_exit to work. + + * implement.h: Remove #include ; we + use our own local semaphore.h. + +2000-08-10 Ross Johnson + + * cleanup.c (pthread_pop_cleanup): Remove _pthread + prefix from __except and catch keywords; implement.h + now simply undefines __ptw32__except and + __ptw32_catch if defined; VC++ was not textually + substituting __ptw32_catch etc back to catch as + it was redefined; the reason for using the prefixed + version was to make it clear that it was not using + the pthread.h redefined catch keyword. + + * private.c (__ptw32_threadStart): Ditto. + (__ptw32_callUserDestroyRoutines): Ditto. + + * implement.h (__ptw32__except): Remove #define. + (__ptw32_catch): Remove #define. + + * GNUmakefile (pthread.a): New target to build + libpthread32.a from pthread.dll using dlltool. + + * buildlib.bat: Duplicate cl commands with args to + build C++ EH version of pthread.dll; use of .bat + files is redundant now that nmake compatible + Makefile is included; used as a kludge only now. + + * Makefile: Localise some macros and fix up the clean: + target to extend it and work properly. + + * CONTRIBUTORS: Add contributors. + + * ANNOUNCE: Updated. + + * README: Updated. + +2000-08-06 Ross Johnson + + * pthread.h: Remove #warning - VC++ doesn't accept it. + +2000-08-05 Ross Johnson + + * 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 cancellation or + pthread_exit() to work. + +2000-08-03 Ross Johnson + + * pthread.h: Add a base class __ptw32_exception for + library internal exceptions and change the "catch" + re-define macro to use it. + +2000-08-02 Ross Johnson + + * GNUmakefile (CFLAGS): Add -mthreads. + Add new targets to generate cpp and asm output. + + * sync.c (pthread_join): Remove dead code. + +2000-07-25 Tristan Savatier + + * sched.c (sched_get_priority_max): Handle different WinCE and + Win32 priority values together. + (sched_get_priority_min): Ditto. + +2000-07-25 Ross Johnson + + * create.c (pthread_create): Force new threads to wait until + pthread_create has the new thread's handle; we also retain + a local copy of the handle for internal use until + pthread_create returns. + + * private.c (__ptw32_threadStart): Initialise ei[]. + (__ptw32_threadStart): When beginthread is used to start the + thread, force waiting until the creator thread had the + thread handle. + + * cancel.c (__ptw32_cancel_thread): Include context switch + code for defined(_X86_) environments in addition to _M_IX86. + + * rwlock.c (pthread_rwlock_destroy): Assignment changed + to avoid compiler warning. + + * private.c (__ptw32_get_exception_services_code): Cast + NULL return value to avoid compiler warning. + + * cleanup.c (pthread_pop_cleanup): Initialise "cleanup" variable + to avoid compiler warnings. + + * misc.c (__ptw32_new): Change "new" variable to "t" to avoid + confusion with the C++ keyword of the same name. + + * condvar.c (cond_wait_cleanup): Initialise lastWaiter variable. + (cond_timedwait): Remove unused local variables. to avoid + compiler warnings. + + * dll.c (dllMain): Remove 2000-07-21 change - problem + appears to be in pthread_create(). + +2000-07-22 Ross Johnson + + * tsd.c (pthread_key_create): If a destructor was given + and the pthread_mutex_init failed, then would try to + reference a NULL pointer (*key); eliminate this section of + code by using a dynamically initialised mutex + (PTHREAD_MUTEX_INITIALIZER). + + * tsd.c (pthread_setspecific): Return an error if + unable to set the value; simplify cryptic conditional. + + * tsd.c (pthread_key_delete): Locking threadsLock relied + on mutex_lock returning an error if the key has no destructor. + ThreadsLock is only initialised if the key has a destructor. + Making this mutex a static could reduce the number of mutexes + used by an application since it is actually created only at + first use and it's often destroyed soon after. + +2000-07-22 Ross Johnson + + * FAQ: Added Q5 and Q6. + +2000-07-21 David Baggett + + * dll.c: Include resource leakage work-around. This is a + partial FIXME which doesn't stop all leakage. The real + problem needs to be found and fixed. + +2000-07-21 Ross Johnson + + * create.c (pthread_create): Set threadH to 0 (zero) + everywhere. Some assignments were using NULL. Maybe + it should be NULL everywhere - need to check. (I know + they are nearly always the same thing - but not by + definition.) + + * misc.c (pthread_self): Try to catch NULL thread handles + at the point where they might be generated, even though + they should always be valid at this point. + + * tsd.c (pthread_setspecific): return an error value if + pthread_self() returns NULL. + + * sync.c (pthread_join): return an error value if + pthread_self() returns NULL. + + * signal.c (pthread_sigmask): return an error value if + pthread_self() returns NULL. + +2000-03-02 Ross Johnson + + * attr.c (pthread_attr_init): Set default stacksize to zero (0) + rather than PTHREAD_STACK_MIN even though these are now the same. + + * pthread.h (PTHREAD_STACK_MIN): Lowered to 0. + +2000-01-28 Ross Johnson + + * mutex.c (pthread_mutex_init): Free mutex if it has been alloced; + if critical sections can be used instead of Win32 mutexes, test + that the critical section works and return an error if not. + +2000-01-07 Ross Johnson + + * cleanup.c (pthread_pop_cleanup): Include SEH code only if MSC is not + compiling as C++. + (pthread_push_cleanup): Include SEH code only if MSC is not + compiling as C++. + + * pthread.h: Include SEH code only if MSC is not + compiling as C++. + + * implement.h: Include SEH code only if MSC is not + compiling as C++. + + * cancel.c (__ptw32_cancel_thread): Add _M_IX86 check. + (pthread_testcancel): Include SEH code only if MSC is not + compiling as C++. + (__ptw32_cancel_self): Include SEH code only if MSC is not + compiling as C++. + +2000-01-06 Erik Hensema + + * Makefile: Remove inconsistencies in 'cl' args + +2000-01-04 Ross Johnson + + * private.c (__ptw32_get_exception_services_code): New; returns + value of EXCEPTION_PTW32_SERVICES. + (__ptw32_processInitialize): Remove initialisation of + __ptw32_exception_services which is no longer needed. + + * pthread.h (__ptw32_exception_services): Remove extern. + (__ptw32_get_exception_services_code): Add function prototype; + use this to return EXCEPTION_PTW32_SERVICES value instead of + using the __ptw32_exception_services variable which I had + trouble exporting through pthread.def. + + * global.c (__ptw32_exception_services): Remove declaration. + +1999-11-22 Ross Johnson + + * implement.h: Forward declare __ptw32_new(); + + * misc.c (__ptw32_new): New; alloc and initialise a new pthread_t. + (pthread_self): New thread struct is generated by new routine + __ptw32_new(). + + * create.c (pthread_create): New thread struct is generated + by new routine __ptw32_new(). + +1999-11-21 Ross Johnson + + * global.c (__ptw32_exception_services): Declare new variable. + + * private.c (__ptw32_threadStart): Destroy thread's + cancelLock mutex; make 'catch' and '__except' usageimmune to + redfinitions in pthread.h. + (__ptw32_processInitialize): Init new constant __ptw32_exception_services. + + * create.c (pthread_create): Initialise thread's cancelLock + mutex. + + * cleanup.c (pthread_pop_cleanup): Make 'catch' and '__except' + usage immune to redfinition s in pthread.h. + + * private.c: Ditto. + + * pthread.h (catch): Redefine 'catch' so that C++ applications + won't catch our internal exceptions. + (__except): ditto for __except. + + * implement.h (__ptw32_catch): Define internal version + of 'catch' because 'catch' is redefined by pthread.h. + (__except): ditto for __except. + (struct pthread_t_): Add cancelLock mutex for async cancel + safety. + +1999-11-21 Jason Nye , Erik Hensema + + * cancel.c (__ptw32_cancel_self): New; part of the async + cancellation implementation. + (__ptw32_cancel_thread): Ditto; this function is X86 + processor specific. + (pthread_setcancelstate): Add check for pending async + cancel request and cancel the calling thread if + required; add async-cancel safety lock. + (pthread_setcanceltype): Ditto. + +1999-11-13 Erik Hensema + + * configure.in (AC_OUTPUT): Put generated output into GNUmakefile + rather than Makefile. Makefile will become the MSC nmake compatible + version + +1999-11-13 John Bossom (John.Bossom@gmail.com> + + * misc.c (pthread_self): Add a note about GetCurrentThread + returning a pseudo-handle + +1999-11-10 Todd Owen + + * dll.c (dllMain): Free kernel32 ASAP. + If TryEnterCriticalSection is not being used, then free + the kernel32.dll handle now, rather than leaving it until + DLL_PROCESS_DETACH. + + Note: this is not a pedantic exercise in freeing unused + resources! It is a work-around for a bug in Windows 95 + (see microsoft knowledge base article, Q187684) which + does Bad Things when FreeLibrary is called within + the DLL_PROCESS_DETACH code, in certain situations. + Since w95 just happens to be a platform which does not + provide TryEnterCriticalSection, the bug will be + effortlessly avoided. + +1999-11-10 Ross Johnson + + * sync.c (pthread_join): Make it a deferred cancellation point. + + * misc.c (pthread_self): Explicitly initialise implicitly + created thread state to default values. + +1999-11-05 Tristan Savatier + + * pthread.h (winsock.h): Include unconditionally. + (ETIMEDOUT): Change fallback value to that defined by winsock.h. + + * general: Patched for portability to WinCE. The details are + described in the file WinCE-PORT. Follow the instructions + in README.WinCE to make the appropriate changes in config.h. + +1999-10-30 Erik Hensema + + * create.c (pthread_create): Explicitly initialise thread state to + default values. + + * cancel.c (pthread_setcancelstate): Check for NULL 'oldstate' + for compatibility with Solaris pthreads; + (pthread_setcanceltype): ditto: + +1999-10-23 Erik Hensema + + * pthread.h (ctime_r): Fix incorrect argument "_tm" + +1999-10-21 Aurelio Medina + + * pthread.h (_POSIX_THREADS): Only define it if it isn't + already defined. Projects may need to define this on + the CC command line under Win32 as it doesn't have unistd.h + +1999-10-17 Ross Johnson + + * rwlock.c (pthread_rwlock_destroy): Add cast to remove compile + warning. + + * condvar.c (pthread_cond_broadcast): Only release semaphores + if there are waiting threads. + +1999-10-15 Lorin Hochstein , Peter Slacik + + * condvar.c (cond_wait_cleanup): New static cleanup handler for + cond_timedwait; + (cond_timedwait): pthread_cleanup_push args changed; + canceling a thread while it's in pthread_cond_wait + will now decrement the waiters count and cleanup if it's the + last waiter. + +1999-10-15 Graham Dumpleton + + * condvar.c (cond_wait_cleanup): the last waiter will now reset the CV's + wasBroadcast flag + +Thu Sep 16 1999 Ross Johnson + + * rwlock.c (pthread_rwlock_destroy): Add serialisation. + (_rwlock_check_need_init): Check for detroyed rwlock. + * rwlock.c: Check return codes from _rwlock_check_need_init(); + modify comments; serialise access to rwlock objects during + operations; rename rw_mutex to rw_lock. + * implement.h: Rename rw_mutex to rw_lock. + * mutex.c (pthread_mutex_destroy): Add serialisation. + (_mutex_check_need_init): Check for detroyed mutex. + * condvar.c (pthread_cond_destroy): Add serialisation. + (_cond_check_need_init): Check for detroyed condvar. + * mutex.c: Modify comments. + * condvar.c: Modify comments. + +1999-08-10 Aurelio Medina + + * implement.h (pthread_rwlock_t_): Add. + * pthread.h (pthread_rwlock_t): Add. + (PTHREAD_RWLOCK_INITIALIZER): Add. + Add rwlock function prototypes. + * rwlock.c: New module. + * pthread.def: Add new rwlock functions. + * private.c (__ptw32_processInitialize): initialise + __ptw32_rwlock_test_init_lock critical section. + * global.c (__ptw32_rwlock_test_init_lock): Add. + + * mutex.c (pthread_mutex_destroy): Don't free mutex memory + if mutex is PTHREAD_MUTEX_INITIALIZER and has not been + initialised yet. + +1999-08-08 Milan Gardian + + * mutex.c (pthread_mutex_destroy): Free mutex memory. + +1999-08-22 Ross Johnson + + * exit.c (pthread_exit): Fix reference to potentially + uninitialised pointer. + +1999-08-21 Ross Johnson + + * private.c (__ptw32_threadStart): Apply fix of 1999-08-19 + this time to C++ and non-trapped C versions. Ommitted to + do this the first time through. + +1999-08-19 Ross Johnson + + * private.c (__ptw32_threadStart): Return exit status from + the application thread startup routine. + - Milan Gardian + +1999-08-18 John Bossom + + * exit.c (pthread_exit): Put status into pthread_t->exitStatus + * private.c (__ptw32_threadStart): Set pthread->exitStatus + on exit of try{} block. + * sync.c (pthread_join): use pthread_exitStatus value if the + thread exit doesn't return a value (for Mingw32 CRTDLL + which uses endthread instead of _endthreadex). + +Tue Aug 17 20:17:58 CDT 1999 Mumit Khan + + * create.c (pthread_create): Add CRTDLL suppport. + * exit.c (pthread_exit): Likewise. + * private.c (__ptw32_threadStart): Likewise. + (__ptw32_threadDestroy): Likewise. + * sync.c (pthread_join): Likewise. + * tests/join1.c (main): Warn about partial support for CRTDLL. + +Tue Aug 17 20:00:08 1999 Mumit Khan + + * Makefile.in (LD): Delete entry point. + * acconfig.h (STDCALL): Delete unused macro. + * configure.in: Remove test for STDCALL. + * config.h.in: Regenerate. + * errno.c (_errno): Fix self type. + * pthread.h (PT_STDCALL): Move from here to + * implement.h (PT_STDCALL): here. + (__ptw32_threadStart): Fix prototype. + * private.c (__ptw32_threadStart): Likewise. + +1999-08-14 Ross Johnson + + * exit.c (pthread_exit): Don't call pthread_self() but + get thread handle directly from TSD for efficiency. + +1999-08-12 Ross Johnson + + * private.c (__ptw32_threadStart): ei[] only declared if _MSC_VER. + + * exit.c (pthread_exit): Check for implicitly created threads + to avoid raising an unhandled exception. + +1999-07-12 Peter Slacik + + * condvar.c (pthread_cond_destroy): Add critical section. + (cond_timedwait): Add critical section; check for timeout + waiting on semaphore. + (pthread_cond_broadcast): Add critical section. + +1999-07-09 Lorin Hochstein , John Bossom + + The problem was that cleanup handlers were not executed when + pthread_exit() was called. + + * implement.h (pthread_t_): Add exceptionInformation element for + C++ per-thread exception information. + (general): Define and rename exceptions. + +1999-07-09 Ross Johnson + + * misc.c (CancelableWait): __PTW32_EPS_CANCEL (SEH) and + __ptw32_exception_cancel (C++) used to identify the exception. + + * cancel.c (pthread_testcancel): __PTW32_EPS_CANCEL (SEH) and + __ptw32_exception_cancel (C++) used to identify the exception. + + * exit.c (pthread_exit): throw/raise an exception to return to + __ptw32_threadStart() to exit the thread. __PTW32_EPS_EXIT (SEH) + and __ptw32_exception_exit (C++) used to identify the exception. + + * private.c (__ptw32_threadStart): Add pthread_exit exception trap; + clean up and exit the thread directly rather than via pthread_exit(). + +Sun May 30 00:25:02 1999 Ross Johnson + + * semaphore.h (mode_t): Conditionally typedef it. + +Fri May 28 13:33:05 1999 Mark E. Armstrong + + * condvar.c (pthread_cond_broadcast): Fix possible memory fault + +Thu May 27 13:08:46 1999 Peter Slacik + + * condvar.c (pthread_cond_broadcast): Fix logic bug + +Thu May 27 13:08:46 1999 Bossom, John + + * condvar.c (pthread_cond_broadcast): optimise sem_post loop + +Fri May 14 12:13:18 1999 Mike Russo + + * attr.c (pthread_attr_setdetachstate): Fix logic bug + +Sat May 8 09:42:30 1999 Ross Johnson + + * pthread.def (sem_open): Add. + (sem_close): Add. + (sem_unlink): Add. + (sem_getvalue): Add. + + * FAQ (Question 3): Add. + +Thu Apr 8 01:16:23 1999 Ross Johnson + + * semaphore.c (sem_open): New function; returns an error (ENOSYS). + (sem_close): ditto. + (sem_unlink): ditto. + (sem_getvalue): ditto. + + * semaphore.h (_POSIX_SEMAPHORES): define. + +Wed Apr 7 14:09:52 1999 Ross Johnson + + * errno.c (_REENTRANT || _MT): Invert condition. + + * pthread.h (_errno): Conditionally include prototype. + +Wed Apr 7 09:37:00 1999 Ross Johnson + + * *.c (comments): Remove individual attributions - these are + documented sufficiently elsewhere. + + * implement.h (pthread.h): Remove extraneous include. + +Sun Apr 4 11:05:57 1999 Ross Johnson + + * sched.c (sched.h): Include. + + * sched.h: New file for POSIX 1b scheduling. + + * pthread.h: Move opaque structures to implement.h; move sched_* + prototypes out and into sched.h. + + * implement.h: Add opaque structures from pthread.h. + + * sched.c (sched_yield): New function. + + * condvar.c (__ptw32_sem_*): Rename to sem_*; except for + __ptw32_sem_timedwait which is an private function. + +Sat Apr 3 23:28:00 1999 Ross Johnson + + * Makefile.in (OBJS): Add errno.o. + +Fri Apr 2 11:08:50 1999 Ross Johnson + + * implement.h (__ptw32_sem_*): Remove prototypes now defined in + semaphore.h. + + * pthread.h (sempahore.h): Include. + + * semaphore.h: New file for POSIX 1b semaphores. + + * semaphore.c (__ptw32_sem_timedwait): Moved to private.c. + + * pthread.h (__ptw32_sem_t): Change to sem_t. + + * private.c (__ptw32_sem_timedwait): Moved from semaphore.c; + set errno on error. + + * pthread.h (pthread_t_): Add per-thread errno element. + +Fri Apr 2 11:08:50 1999 John Bossom + + * semaphore.c (__ptw32_sem_*): Change to sem_*; these functions + will be exported from the library; set errno on error. + + * errno.c (_errno): New file. New function. + +Fri Mar 26 14:11:45 1999 Tor Lillqvist + + * semaphore.c (__ptw32_sem_timedwait): Check for negative + milliseconds. + +Wed Mar 24 11:32:07 1999 John Bossom + + * misc.c (CancelableWait): Initialise exceptionInformation[2]. + (pthread_self): Get a real Win32 thread handle for implicit threads. + + * cancel.c (pthread_testcancel): Initialise exceptionInformation[2]. + + * implement.h (SE_INFORMATION): Fix values. + + * private.c (__ptw32_threadDestroy): Close the thread handle. + +Fri Mar 19 12:57:27 1999 Ross Johnson + + * cancel.c (comments): Update and cleanup. + +Fri Mar 19 09:12:59 1999 Ross Johnson + + * private.c (__ptw32_threadStart): status returns PTHREAD_CANCELED. + + * pthread.h (PTHREAD_CANCELED): defined. + +Tue Mar 16 1999 Ross Johnson + + * all: Add GNU LGPL and Copyright and Warranty. + +Mon Mar 15 00:20:13 1999 Ross Johnson + + * condvar.c (pthread_cond_init): fix possible uninitialised use + of cv. + +Sun Mar 14 21:01:59 1999 Ross Johnson + + * condvar.c (pthread_cond_destroy): don't do full cleanup if + static initialised cv has never been used. + (cond_timedwait): check result of auto-initialisation. + +Thu Mar 11 09:01:48 1999 Ross Johnson + + * pthread.h (pthread_mutex_t): revert to (pthread_mutex_t *); + define a value to serve as PTHREAD_MUTEX_INITIALIZER. + (pthread_mutex_t_): remove staticinit and valid elements. + (pthread_cond_t): revert to (pthread_cond_t_ *); + define a value to serve as PTHREAD_COND_INITIALIZER. + (pthread_cond_t_): remove staticinit and valid elements. + + * mutex.c (pthread_mutex_t args): adjust indirection of references. + (all functions): check for PTHREAD_MUTEX_INITIALIZER value; + check for NULL (invalid). + + * condvar.c (pthread_cond_t args): adjust indirection of references. + (all functions): check for PTHREAD_COND_INITIALIZER value; + check for NULL (invalid). + +Wed Mar 10 17:18:12 1999 Ross Johnson + + * misc.c (CancelableWait): Undo changes from Mar 8 and 7. + +Mon Mar 8 11:18:59 1999 Ross Johnson + + * misc.c (CancelableWait): Ensure cancelEvent handle is the lowest + indexed element in the handles array. Enhance test for abandoned + objects. + + * pthread.h (PTHREAD_MUTEX_INITIALIZER): Trailing elements not + initialised are set to zero by the compiler. This avoids the + problem of initialising the opaque critical section element in it. + (PTHREAD_COND_INITIALIZER): Ditto. + + * semaphore.c (__ptw32_sem_timedwait): Check sem == NULL earlier. + +Sun Mar 7 12:31:14 1999 Ross Johnson + + * condvar.c (pthread_cond_init): set semaphore initial value + to 0, not 1. cond_timedwait was returning signaled immediately. + + * misc.c (CancelableWait): Place the cancel event handle first + in the handle table for WaitForMultipleObjects. This ensures that + the cancel event is recognised and acted apon if both objects + happen to be signaled together. + + * private.c (__ptw32_cond_test_init_lock): Initialise and destroy. + + * implement.h (__ptw32_cond_test_init_lock): Add extern. + + * global.c (__ptw32_cond_test_init_lock): Add declaration. + + * condvar.c (pthread_cond_destroy): check for valid initialised CV; + flag destroyed CVs as invalid. + (pthread_cond_init): pthread_cond_t is no longer just a pointer. + This is because PTHREAD_COND_INITIALIZER needs state info to reside + in pthread_cond_t so that it can initialise on first use. Will work on + making pthread_cond_t (and other objects like it) opaque again, if + possible, later. + (cond_timedwait): add check for statically initialisation of + CV; initialise on first use. + (pthread_cond_signal): check for valid CV. + (pthread_cond_broadcast): check for valid CV. + (_cond_check_need_init): Add. + + * pthread.h (PTHREAD_COND_INITIALIZER): Fix. + (pthread_cond_t): no longer a pointer to pthread_cond_t_. + (pthread_cond_t_): add 'staticinit' and 'valid' elements. + +Sat Mar 6 1999 Ross Johnson + + * implement.h: Undate comments. + +Sun Feb 21 1999 Ross Johnson + + * pthread.h (PTHREAD_MUTEX_INITIALIZER): missing braces around + cs element initialiser. + +1999-02-21 Ben Elliston + + * pthread.h (pthread_exit): The return type of this function is + void, not int. + + * exit.c (pthread_exit): Do not return 0. + +Sat Feb 20 16:03:30 1999 Ross Johnson + + * dll.c (DLLMain): Expand TryEnterCriticalSection support test. + + * mutex.c (pthread_mutex_trylock): The check for + __ptw32_try_enter_critical_section == NULL should have been + removed long ago. + +Fri Feb 19 16:03:30 1999 Ross Johnson + + * sync.c (pthread_join): Fix pthread_equal() test. + + * mutex.c (pthread_mutex_trylock): Check mutex != NULL before + using it. + +Thu Feb 18 16:17:30 1999 Ross Johnson + + * misc.c (pthread_equal): Fix inverted result. + + * Makefile.in: Use libpthread32.a as the name of the DLL export + library instead of pthread.lib. + + * condvar.c (pthread_cond_init): cv could have been used unitialised; + initialise. + + * create.c (pthread_create): parms could have been used unitialised; + initialise. + + * pthread.h (struct pthread_once_t_): Remove redefinition. + +Sat Feb 13 03:03:30 1999 Ross Johnson + + * pthread.h (struct pthread_once_t_): Replaced. + + * misc.c (pthread_once): Replace with John Bossom's version; + has lighter weight serialisation; fixes problem of not holding + competing threads until after the init_routine completes. + +Thu Feb 11 13:34:14 1999 Ross Johnson + + * misc.c (CancelableWait): Change C++ exception throw. + + * sync.c (pthread_join): Change FIXME comment - issue resolved. + +Wed Feb 10 12:49:11 1999 Ross Johnson + + * configure: Various temporary changes. + - Kevin Ruland + + * README: Update. + + * pthread.def (pthread_attr_getstackaddr): uncomment + (pthread_attr_setstackaddr): uncomment + +Fri Feb 5 13:42:30 1999 Ross Johnson + + * semaphore.c: Comment format changes. + +Thu Feb 4 10:07:28 1999 Ross Johnson + + * global.c: Remove __ptw32_exception instantiation. + + * cancel.c (pthread_testcancel): Change C++ exception throw. + + * implement.h: Remove extern declaration. + +Wed Feb 3 13:04:44 1999 Ross Johnson + + * cleanup.c: Rename __ptw32_*_cleanup() to pthread_*_cleanup(). + + * pthread.def: Ditto. + + * pthread.h: Ditto. + + * pthread.def (pthread_cleanup_push): Remove from export list; + the function is defined as a macro under all compilers. + (pthread_cleanup_pop): Ditto. + + * pthread.h: Remove #if defined(). + +Wed Feb 3 10:13:48 1999 Ross Johnson + + * sync.c (pthread_join): Check for NULL value_ptr arg; + check for detached threads. + +Tue Feb 2 18:07:43 1999 Ross Johnson + + * implement.h: Add #include . + Change sem_t to __ptw32_sem_t. + +Tue Feb 2 18:07:43 1999 Kevin Ruland + + * signal.c (pthread_sigmask): Add and modify casts. + Reverse LHS/RHS bitwise assignments. + + * pthread.h: Remove #include . + (__PTW32_ATTR_VALID): Add cast. + (struct pthread_t_): Add sigmask element. + + * dll.c: Add "extern C" for DLLMain. + (DllMain): Add cast. + + * create.c (pthread_create): Set sigmask in thread. + + * condvar.c: Remove #include. Change sem_* to __ptw32_sem_*. + + * attr.c: Changed #include. + + * Makefile.in: Additional targets and changes to build the library + as a DLL. + +Fri Jan 29 11:56:28 1999 Ross Johnson + + * Makefile.in (OBJS): Add semaphore.o to list. + + * semaphore.c (__ptw32_sem_timedwait): Move from private.c. + Rename sem_* to __ptw32_sem_*. + + * pthread.h (pthread_cond_t): Change type of sem_t. + _POSIX_SEMAPHORES no longer defined. + + * semaphore.h: Contents moved to implement.h. + Removed from source tree. + + * implement.h: Add semaphore function prototypes and rename all + functions to prepend '__ptw32_'. They are + now private to the pthreads-win32 implementation. + + * private.c: Change #warning. + Move __ptw32_sem_timedwait() to semaphore.c. + + * cleanup.c: Change #warning. + + * misc.c: Remove #include + + * pthread.def: Cleanup CVS merge conflicts. + + * global.c: Ditto. + + * ChangeLog: Ditto. + + * cleanup.c: Ditto. + +Sun Jan 24 01:34:52 1999 Ross Johnson + + * semaphore.c (sem_wait): Remove second arg to + pthreadCancelableWait() call. + +Sat Jan 23 17:36:40 1999 Ross Johnson + + * pthread.def: Add new functions to export list. + + * pthread.h (PTHREAD_MUTEX_AUTO_CS_NP): New. + (PTHREAD_MUTEX_FORCE_CS_NP): New. + + * README: Updated. + +Fri Jan 22 14:31:59 1999 Ross Johnson + + * Makefile.in (CFLAGS): Remove -fhandle-exceptions. Not needed + with egcs. Add -g for debugging. + + * create.c (pthread_create): Replace __stdcall with PT_STDCALL + macro. This is a hack and must be fixed. + + * misc.c (CancelableWait): Remove redundant statement. + + * mutex.c (pthread_mutexattr_init): Cast calloc return value. + + * misc.c (CancelableWait): Add cast. + (pthread_self): Add cast. + + * exit.c (pthread_exit): Add cast. + + * condvar.c (pthread_condattr_init): Cast calloc return value. + + * cleanup.c: Reorganise conditional compilation. + + * attr.c (pthread_attr_init): Remove unused 'result'. + Cast malloc return value. + + * private.c (__ptw32_callUserDestroyRoutines): Redo conditional + compilation. + + * misc.c (CancelableWait): C++ version uses 'throw'. + + * cancel.c (pthread_testcancel): Ditto. + + * implement.h (class __ptw32_exception): Define for C++. + + * pthread.h: Fix C, C++, and Win32 SEH condition compilation + mayhem around pthread_cleanup_* defines. C++ version now uses John + Bossom's cleanup handlers. + (pthread_attr_t): Make 'valid' unsigned. + Define '_timeb' as 'timeb' for Ming32. + Define PT_STDCALL as nothing for Mingw32. May be temporary. + + * cancel.c (pthread_testcancel): Cast return value. + +Wed Jan 20 09:31:28 1999 Ross Johnson + + * pthread.h (pthread_mutexattr_t): Changed to a pointer. + + * mutex.c (pthread_mutex_init): Conditionally create Win32 mutex + - from John Bossom's implementation. + (pthread_mutex_destroy): Conditionally close Win32 mutex + - from John Bossom's implementation. + (pthread_mutexattr_init): Replaced by John Bossom's version. + (pthread_mutexattr_destroy): Ditto. + (pthread_mutexattr_getpshared): New function from John Bossom's + implementation. + (pthread_mutexattr_setpshared): New function from John Bossom's + implementation. + +Tue Jan 19 18:27:42 1999 Ross Johnson + + * pthread.h (pthreadCancelableTimedWait): New prototype. + (pthreadCancelableWait): Remove second argument. + + * misc.c (CancelableWait): New static function is + pthreadCancelableWait() renamed. + (pthreadCancelableWait): Now just calls CancelableWait() with + INFINITE timeout. + (pthreadCancelableTimedWait): Just calls CancelableWait() + with passed in timeout. + +Tue Jan 19 18:27:42 1999 Scott Lightner + + * private.c (__ptw32_sem_timedwait): 'abstime' arg really is + absolute time. Calculate relative time to wait from current + time before passing timeout to new routine + pthreadCancelableTimedWait(). + +Tue Jan 19 10:27:39 1999 Ross Johnson + + * pthread.h (pthread_mutexattr_setforcecs_np): New prototype. + + * mutex.c (pthread_mutexattr_init): Init 'pshared' and 'forcecs' + attributes to 0. + (pthread_mutexattr_setforcecs_np): New function (not portable). + + * pthread.h (pthread_mutex_t): + Add 'mutex' element. Set to NULL in PTHREAD_MUTEX_INITIALIZER. + The pthread_mutex_*() routines will try to optimise performance + by choosing either mutexes or critical sections as the basis + for pthread mutexes for each indevidual mutex. + (pthread_mutexattr_t_): Add 'forcecs' element. + Some applications may choose to force use of critical sections + if they know that:- + the mutex is PROCESS_PRIVATE and, + either the OS supports TryEnterCriticalSection() or + pthread_mutex_trylock() will never be called on the mutex. + This attribute will be setable via a non-portable routine. + + Note: We don't yet support PROCESS_SHARED mutexes, so the + implementation as it stands will default to Win32 mutexes only if + the OS doesn't support TryEnterCriticalSection. On Win9x, and early + versions of NT 'forcecs' will need to be set in order to get + critical section based mutexes. + +Sun Jan 17 12:01:26 1999 Ross Johnson + + * pthread.h (PTHREAD_MUTEX_INITIALIZER): Init new 'staticinit' + value to '1' and existing 'valid' value to '1'. + + * global.c (__ptw32_mutex_test_init_lock): Add. + + * implement.h (__ptw32_mutex_test_init_lock.): Add extern. + + * private.c (__ptw32_processInitialize): Init critical section for + global lock used by _mutex_check_need_init(). + (__ptw32_processTerminate): Ditto (:s/Init/Destroy/). + + * dll.c (dllMain): Move call to FreeLibrary() so that it is only + called once when the process detaches. + + * mutex.c (_mutex_check_need_init): New static function to test + and init PTHREAD_MUTEX_INITIALIZER mutexes. Provides serialised + access to the internal state of the uninitialised static mutex. + Called from pthread_mutex_trylock() and pthread_mutex_lock() which + do a quick unguarded test to check if _mutex_check_need_init() + needs to be called. This is safe as the test is conservative + and is repeated inside the guarded section of + _mutex_check_need_init(). Thus in all calls except the first + calls to lock static mutexes, the additional overhead to lock any + mutex is a single memory fetch and test for zero. + + * pthread.h (pthread_mutex_t_): Add 'staticinit' member. Mutexes + initialised by PTHREAD_MUTEX_INITIALIZER aren't really initialised + until the first attempt to lock it. Using the 'valid' + flag (which flags the mutex as destroyed or not) to record this + information would be messy. It is possible for a statically + initialised mutex such as this to be destroyed before ever being + used. + + * mutex.c (pthread_mutex_trylock): Call _mutex_check_need_init() + to test/init PTHREAD_MUTEX_INITIALIZER mutexes. + (pthread_mutex_lock): Ditto. + (pthread_mutex_unlock): Add check to ensure we don't try to unlock + an unitialised static mutex. + (pthread_mutex_destroy): Add check to ensure we don't try to delete + a critical section that we never created. Allows us to destroy + a static mutex that has never been locked (and hence initialised). + (pthread_mutex_init): Set 'staticinit' flag to 0 for the new mutex. + +Sun Jan 17 12:01:26 1999 Ross Johnson + + * private.c (__ptw32_sem_timedwait): Move from semaphore.c. + + * semaphore.c : Remove redundant #includes. + (__ptw32_sem_timedwait): Move to private.c. + (sem_wait): Add missing abstime arg to pthreadCancelableWait() call. + +Fri Jan 15 23:38:05 1999 Ross Johnson + + * condvar.c (cond_timedwait): Remove comment. + +Fri Jan 15 15:41:28 1999 Ross Johnson + + * pthread.h: Add new 'abstime' arg to pthreadCancelableWait() + prototype. + + * condvar.c (cond_timedwait): New generalised function called by + both pthread_cond_wait() and pthread_cond_timedwait(). This is + essentially pthread_cond_wait() renamed and modified to add the + 'abstime' arg and call the new __ptw32_sem_timedwait() instead of + sem_wait(). + (pthread_cond_wait): Now just calls the internal static + function cond_timedwait() with an INFINITE wait. + (pthread_cond_timedwait): Now implemented. Calls the internal + static function cond_timedwait(). + + * implement.h (__ptw32_sem_timedwait): New internal function + prototype. + + * misc.c (pthreadCancelableWait): Added new 'abstime' argument + to allow shorter than INFINITE wait. + + * semaphore.c (__ptw32_sem_timedwait): New function for internal + use. This is essentially sem_wait() modified to add the + 'abstime' arg and call the modified (see above) + pthreadCancelableWait(). + +Thu Jan 14 14:27:13 1999 Ross Johnson + + * cleanup.c: Correct _cplusplus to __cplusplus wherever used. + + * Makefile.in: Add CC=g++ and add -fhandle-exceptions to CFLAGS. + The derived Makefile will compile all units of the package as C++ + so that those which include try/catch exception handling should work + properly. The package should compile ok if CC=gcc, however, exception + handling will not be included and thus thread cancellation, for + example, will not work. + + * cleanup.c (__ptw32_pop_cleanup): Add #warning to compile this + file as C++ if using a cygwin32 environment. Perhaps the whole package + should be compiled using g++ under cygwin. + + * private.c (__ptw32_threadStart): Change #error directive + into #warning and bracket for __CYGWIN__ and derivative compilers. + +Wed Jan 13 09:34:52 1999 Ross Johnson + + * build.bat: Delete old binaries before compiling/linking. + +Tue Jan 12 09:58:38 1999 Tor Lillqvist + + * dll.c: The Microsoft compiler pragmas probably are more + appropriately protected by _MSC_VER than by _WIN32. + + * pthread.h: Define ETIMEDOUT. This should be returned by + pthread_cond_timedwait which is not implemented yet as of + snapshot-1999-01-04-1305. It was implemented in the older version. + The Microsoft compiler pragmas probably are more appropriately + protected by _MSC_VER than by _WIN32. + + * pthread.def: pthread_mutex_destroy was missing from the def file + + * condvar.c (pthread_cond_broadcast): Ensure we only wait on threads + if there were any waiting on the condition. + I think pthread_cond_broadcast should do the WaitForSingleObject + only if cv->waiters > 0? Otherwise it seems to hang, at least in the + testg thread program from glib. + +Tue Jan 12 09:58:38 1999 Ross Johnson + + * condvar.c (pthread_cond_timedwait): Fix function description + comments. + + * semaphore.c (sem_post): Correct typo in comment. + +Mon Jan 11 20:33:19 1999 Ross Johnson + + * pthread.h: Re-arrange conditional compile of pthread_cleanup-* + macros. + + * cleanup.c (__ptw32_push_cleanup): Provide conditional + compile of cleanup->prev. + +1999-01-11 Tor Lillqvist + + * condvar.c (pthread_cond_init): Invert logic when testing the + return value from calloc(). + +Sat Jan 9 14:32:08 1999 Ross Johnson + + * implement.h: Compile-time switch for CYGWIN derived environments + to use CreateThread instead of _beginthreadex. Ditto for ExitThread. + Patch provided by Anders Norlander . + +Tue Jan 5 16:33:04 1999 Ross Johnson + + * cleanup.c (__ptw32_pop_cleanup): Add C++ version of __try/__except + block. Move trailing "}" out of #ifdef _WIN32 block left there by + (rpj's) mistake. + + * private.c: Remove #include which is included by pthread.h. + +1998-12-11 Ben Elliston + + * README: Update info about subscribing to the mailing list. + +Mon Jan 4 11:23:40 1999 Ross Johnson + + * all: No code changes, just cleanup. + - remove #if 0 /* Pre Bossom */ enclosed code. + - Remove some redundant #includes. + * pthread.h: Update implemented/unimplemented routines list. + * Tag the bossom merge branch getting ready to merge back to main + trunk. + +Tue Dec 29 13:11:16 1998 Ross Johnson + + * implement.h: Move the following struct definitions to pthread.h: + pthread_t_, pthread_attr_t_, pthread_mutex_t_, pthread_mutex_t_, + pthread_mutexattr_t_, pthread_key_t_, pthread_cond_t_, + pthread_condattr_t_, pthread_once_t_. + + * pthread.h: Add "_" prefix to pthread_push_cleanup and + pthread_pop_cleanup internal routines, and associated struct and + typedefs. + + * buildlib.bat: Add compile command for semaphore.c + + * pthread.def: Comment out pthread_atfork routine name. + Now unimplemented. + + * tsd.c (pthread_setspecific): Rename tkAssocCreate to + __ptw32_tkAssocCreate. + (pthread_key_delete): Rename tkAssocDestroy to + __ptw32_tkAssocDestroy. + + * sync.c (pthread_join): Rename threadDestroy to __ptw32_threadDestroy + + * sched.c (is_attr): attr is now **attr (was *attr), so add extra + NULL pointer test. + (pthread_attr_setschedparam): Increase redirection for attr which is + now a **. + (pthread_attr_getschedparam): Ditto. + (pthread_setschedparam): Change thread validation and rename "thread" + Win32 thread Handle element name to match John Bossom's version. + (pthread_getschedparam): Ditto. + + * private.c (__ptw32_threadDestroy): Rename call to + callUserDestroyRoutines() as __ptw32_callUserDestroyRoutines() + + * misc.c: Add #include "implement.h". + + * dll.c: Remove defined(KLUDGE) wrapped code. + + * fork.c: Remove redefinition of ENOMEM. + Remove pthread_atfork() and fork() with #if 0/#endif. + + * create.c (pthread_create): Rename threadStart and threadDestroy calls + to __ptw32_threadStart and __ptw32_threadDestroy. + + * implement.h: Rename "detachedstate" to "detachstate". + + * attr.c: Rename "detachedstate" to "detachstate". + +Mon Dec 28 09:54:39 1998 John Bossom + + * semaphore.c: Initial version. + * semaphore.h: Initial version. + +Mon Dec 28 09:54:39 1998 Ross Johnson + + * pthread.h (pthread_attr_t_): Change to *pthread_attr_t. + +Mon Dec 28 09:54:39 1998 John Bossom, Ben Elliston + + * attr.c (pthread_attr_setstacksize): Merge with John's version. + (pthread_attr_getstacksize): Merge with John's version. + (pthread_attr_setstackaddr): Merge with John's version. + (pthread_attr_getstackaddr): Merge with John's version. + (pthread_attr_init): Merge with John's version. + (pthread_attr_destroy): Merge with John's version. + (pthread_attr_getdetachstate): Merge with John's version. + (pthread_attr_setdetachstate): Merge with John's version. + (is_attr): attr is now **attr (was *attr), so add extra NULL pointer + test. + +Mon Dec 28 09:54:39 1998 Ross Johnson + + * implement.h (pthread_attr_t_): Add and rename elements in JEB's + version to correspond to original, so that it can be used with + original attr routines. + + * pthread.h: Add #endif at end which was truncated in merging. + +Sun Dec 20 14:51:58 1998 Ross Johnson + + * misc.c (pthreadCancelableWait): New function by John Bossom. Non-standard + but provides a hook that can be used to implement cancellation points in + applications that use this library. + + * pthread.h (pthread_cleanup_pop): C++ (non-WIN32) version uses + try/catch to emulate John Bossom's WIN32 __try/__finally behaviour. + In the WIN32 version __finally block, add a test for AbnormalTermination otherwise + cleanup is only run if the cleanup_pop execute arg is non-zero. Cancellation + should cause the cleanup to run irrespective of the execute arg. + + * condvar.c (pthread_condattr_init): Replaced by John Bossom's version. + (pthread_condattr_destroy): Replaced by John Bossom's version. + (pthread_condattr_getpshared): Replaced by John Bossom's version. + (pthread_condattr_setpshared): Replaced by John Bossom's version. + (pthread_cond_init): Replaced by John Bossom's version. + Fix comment (refered to mutex rather than condition variable). + (pthread_cond_destroy): Replaced by John Bossom's version. + (pthread_cond_wait): Replaced by John Bossom's version. + (pthread_cond_timedwait): Replaced by John Bossom's version. + (pthread_cond_signal): Replaced by John Bossom's version. + (pthread_cond_broadcast): Replaced by John Bossom's version. + +Thu Dec 17 19:10:46 1998 Ross Johnson + + * tsd.c (pthread_key_create): Replaced by John Bossom's version. + (pthread_key_delete): Replaced by John Bossom's version. + (pthread_setspecific): Replaced by John Bossom's version. + (pthread_getspecific): Replaced by John Bossom's version. + +Mon Dec 7 09:44:40 1998 John Bossom + + * cancel.c (pthread_setcancelstate): Replaced. + (pthread_setcanceltype): Replaced. + (pthread_testcancel): Replaced. + (pthread_cancel): Replaced. + + * exit.c (pthread_exit): Replaced. + + * misc.c (pthread_self): Replaced. + (pthread_equal): Replaced. + + * sync.c (pthread_detach): Replaced. + (pthread_join): Replaced. + + * create.c (pthread_create): Replaced. + + * private.c (__ptw32_processInitialize): New. + (__ptw32_processTerminate): New. + (__ptw32_threadStart): New. + (__ptw32_threadDestroy): New. + (__ptw32_cleanupStack): New. + (__ptw32_tkAssocCreate): New. + (__ptw32_tkAssocDestroy): New. + (__ptw32_callUserDestroyRoutines): New. + + * implement.h: Added non-API structures and declarations. + + * dll.c (PthreadsEntryPoint): Cast return value of GetProcAddress + to resolve compile warning from MSVC. + + * dll.c (DLLmain): Replaced. + * dll.c (PthreadsEntryPoint): + Re-applied Anders Norlander's patch:- + Initialize __ptw32_try_enter_critical_section at startup + and release kernel32 handle when DLL is being unloaded. + +Sun Dec 6 21:54:35 1998 Ross Johnson + + * buildlib.bat: Fix args to CL when building the .DLL + + * cleanup.c (__ptw32_destructor_run_all): Fix TSD key management. + This is a tidy-up before TSD and Thread management is completely + replaced by John Bossom's code. + + * tsd.c (pthread_key_create): Fix TSD key management. + + * global.c (__ptw32_key_virgin_next): Initialise. + + * build.bat: New DOS script to compile and link a pthreads app + using Microsoft's CL compiler linker. + * buildlib.bat: New DOS script to compile all the object files + and create pthread.lib and pthread.dll using Microsoft's CL + compiler linker. + +1998-12-05 Anders Norlander + + * implement.h (__ptw32_try_enter_critical_section): New extern + * dll.c (__ptw32_try_enter_critical_section): New pointer to + TryEnterCriticalSection if it exists; otherwise NULL. + * dll.c (PthreadsEntryPoint): + Initialize __ptw32_try_enter_critical_section at startup + and release kernel32 handle when DLL is being unloaded. + * mutex.c (pthread_mutex_trylock): Replaced check for NT with + a check if __ptw32_try_enter_critical_section is valid + pointer to a function. Call __ptw32_try_enter_critical_section + instead of TryEnterCriticalSection to avoid errors on Win95. + +Thu Dec 3 13:32:00 1998 Ross Johnson + + * README: Correct cygwin32 compatibility statement. + +Sun Nov 15 21:24:06 1998 Ross Johnson + + * cleanup.c (__ptw32_destructor_run_all): Declare missing void * arg. + Fixup CVS merge conflicts. + +1998-10-30 Ben Elliston + + * condvar.c (cond_wait): Fix semantic error. Test for equality + instead of making an assignment. + +Fri Oct 30 15:15:50 1998 Ross Johnson + + * cleanup.c (__ptw32_handler_push): Fixed bug appending new + handler to list reported by Peter Slacik + . + (new_thread): Rename poorly named local variable to + "new_handler". + +Sat Oct 24 18:34:59 1998 Ross Johnson + + * global.c: Add TSD key management array and index declarations. + + * implement.h: Ditto for externs. + +Fri Oct 23 00:08:09 1998 Ross Johnson + + * implement.h (__PTW32_TSD_KEY_REUSE): Add enum. + + * private.c (__ptw32_delete_thread): Add call to + __ptw32_destructor_run_all() to clean up the threads keys. + + * cleanup.c (__ptw32_destructor_run_all): Check for no more dirty + keys to run destructors on. Assume that the destructor call always + succeeds and set the key value to NULL. + +Thu Oct 22 21:44:44 1998 Ross Johnson + + * tsd.c (pthread_setspecific): Add key management code. + (pthread_key_create): Ditto. + (pthread_key_delete): Ditto. + + * implement.h (struct __ptw32_tsd_key): Add status member. + + * tsd.c: Add description of pthread_key_delete() from the + standard as a comment. + +Fri Oct 16 17:38:47 1998 Ross Johnson + + * cleanup.c (__ptw32_destructor_run_all): Fix and improve + stepping through the key table. + +Thu Oct 15 14:05:01 1998 Ross Johnson + + * private.c (__ptw32_new_thread): Remove init of destructorstack. + No longer an element of pthread_t. + + * tsd.c (pthread_setspecific): Fix type declaration and cast. + (pthread_getspecific): Ditto. + (pthread_getspecific): Change error return value to NULL if key + is not in use. + +Thu Oct 15 11:53:21 1998 Ross Johnson + + * global.c (__ptw32_tsd_key_table): Fix declaration. + + * implement.h(__ptw32_TSD_keys_TlsIndex): Add missing extern. + (__ptw32_tsd_mutex): Ditto. + + * create.c (__ptw32_start_call): Fix "keys" array declaration. + Add comment. + + * tsd.c (pthread_setspecific): Fix type declaration and cast. + (pthread_getspecific): Ditto. + + * cleanup.c (__ptw32_destructor_run_all): Declare missing loop + counter. + +Wed Oct 14 21:09:24 1998 Ross Johnson + + * private.c (__ptw32_new_thread): Increment __ptw32_threads_count. + (__ptw32_delete_thread): Decrement __ptw32_threads_count. + Remove some comments. + + * exit.c (__ptw32_exit): : Fix two pthread_mutex_lock() calls that + should have been pthread_mutex_unlock() calls. + (__ptw32_vacuum): Remove call to __ptw32_destructor_pop_all(). + + * create.c (pthread_create): Fix two pthread_mutex_lock() calls that + should have been pthread_mutex_unlock() calls. + + * global.c (__ptw32_tsd_mutex): Add mutex for TSD operations. + + * tsd.c (pthread_key_create): Add critical section. + (pthread_setspecific): Ditto. + (pthread_getspecific): Ditto. + (pthread_key_delete): Ditto. + + * sync.c (pthread_join): Fix two pthread_mutex_lock() calls that + should have been pthread_mutex_unlock() calls. + +Mon Oct 12 00:00:44 1998 Ross Johnson + + * implement.h (__ptw32_tsd_key_table): New. + + * create.c (__ptw32_start_call): Initialise per-thread TSD keys + to NULL. + + * misc.c (pthread_once): Correct typo in comment. + + * implement.h (__ptw32_destructor_push): Remove. + (__ptw32_destructor_pop): Remove. + (__ptw32_destructor_run_all): Rename from __ptw32_destructor_pop_all. + (__PTW32_TSD_KEY_DELETED): Add enum. + (__PTW32_TSD_KEY_INUSE): Add enum. + + * cleanup.c (__ptw32_destructor_push): Remove. + (__ptw32_destructor_pop): Remove. + (__ptw32_destructor_run_all): Totally revamped TSD. + + * dll.c (__ptw32_TSD_keys_TlsIndex): Initialise. + + * tsd.c (pthread_setspecific): Totally revamped TSD. + (pthread_getspecific): Ditto. + (pthread_create): Ditto. + (pthread_delete): Ditto. + +Sun Oct 11 22:44:55 1998 Ross Johnson + + * global.c (__ptw32_tsd_key_table): Add new global. + + * implement.h (__ptw32_tsd_key_t and struct __ptw32_tsd_key): + Add. + (struct _pthread): Remove destructorstack. + + * cleanup.c (__ptw32_destructor_run_all): Rename from + __ptw32_destructor_pop_all. The key destructor stack was made + global rather than per-thread. No longer removes destructor nodes + from the stack. Comments updated. + +1998-10-06 Ben Elliston + + * condvar.c (cond_wait): Use POSIX, not Win32 mutex calls. + (pthread_cond_broadcast): Likewise. + (pthread_cond_signal): Likewise. + +1998-10-05 Ben Elliston + + * pthread.def: Update. Some functions aren't available yet, others + are macros in . + + * tests/join.c: Remove; useless. + +Mon Oct 5 14:25:08 1998 Ross Johnson + + * pthread.def: New file for building the DLL. + +1998-10-05 Ben Elliston + + * misc.c (pthread_equal): Correct inverted logic bug. + (pthread_once): Use the POSIX mutex primitives, not Win32. Remove + irrelevant FIXME comment. + + * global.c (PTHREAD_MUTEX_INITIALIZER): Move to pthread.h. + + * pthread.h (PTHREAD_MUTEX_INITIALIZER): Define. + (pthread_mutex_t): Reimplement as a struct containing a valid + flag. If the flag is ever down upon entry to a mutex operation, + we call pthread_mutex_create() to initialise the object. This + fixes the problem of how to handle statically initialised objects + that can't call InitializeCriticalSection() due to their context. + (PTHREAD_ONCE_INIT): Define. + + * mutex.c (pthread_mutex_init): Set valid flag. + (pthread_mutex_destroy): Clear valid flag. + (pthread_mutex_lock): Check and handle the valid flag. + (pthread_mutex_unlock): Likewise. + (pthread_mutex_trylock): Likewise. + + * tests/mutex3.c: New file; test for the static initialisation + macro. Passes. + + * tests/create1.c: New file; test pthread_create(). Passes. + + * tests/equal.c: Poor test; remove. + + * tests/equal1.c New file; test pthread_equal(). Passes. + + * tests/once1.c: New file; test for pthread_once(). Passes. + + * tests/self.c: Remove; rename to self1.c. + + * tests/self1.c: This is the old self.c. + + * tests/self2.c: New file. Test pthread_self() with a single + thread. Passes. + + * tests/self3.c: New file. Test pthread_self() with a couple of + threads to ensure their thread IDs differ. Passes. + +1998-10-04 Ben Elliston + + * tests/mutex2.c: Test pthread_mutex_trylock(). Passes. + + * tests/mutex1.c: New basic test for mutex functions (it passes). + (main): Eliminate warning. + + * configure.in: Test for __stdcall, not _stdcall. Typo. + + * configure: Regenerate. + + * attr.c (pthread_attr_setstackaddr): Remove FIXME comment. Win32 + does know about ENOSYS after all. + (pthread_attr_setstackaddr): Likewise. + +1998-10-03 Ben Elliston + + * configure.in: Test for the `_stdcall' keyword. Define `STDCALL' + to `_stdcall' if we have it, null otherwise. + + * configure: Regenerate. + + * acconfig.h (STDCALL): New define. + + * config.h.in: Regenerate. + + * create.c (__ptw32_start_call): Add STDCALL prefix. + + * mutex.c (pthread_mutex_init): Correct function signature. + + * attr.c (pthread_attr_init): Only zero out the `sigmask' member + if we have the sigset_t type. + + * pthread.h: No need to include . It doesn't even exist + on Win32! Again, an artifact of cross-compilation. + (pthread_sigmask): Only provide if we have the sigset_t type. + + * process.h: Remove. This was a stand-in before we started doing + native compilation under Win32. + + * pthread.h (pthread_mutex_init): Make `attr' argument const. + +1998-10-02 Ben Elliston + + * COPYING: Remove. + + * COPYING.LIB: Add. This library is under the LGPL. + +1998-09-13 Ben Elliston + + * configure.in: Test for required system features. + + * configure: Generate. + + * acconfig.h: New file. + + * config.h.in: Generate. + + * Makefile.in: Renamed from Makefile. + + * COPYING: Import from a recent GNU package. + + * config.guess: Likewise. + + * config.sub: Likewise. + + * install-sh: Likewise. + + * config.h: Remove. + + * Makefile: Likewise. + +1998-09-12 Ben Elliston + + * windows.h: No longer needed; remove. + + * windows.c: Likewise. + +Sat Sep 12 20:09:24 1998 Ross Johnson + + * windows.h: Remove error number definitions. These are in + + * tsd.c: Add comment explaining rationale for not building + POSIX TSD on top of Win32 TLS. + +1998-09-12 Ben Elliston + + * {most}.c: Include to get POSIX error values. + + * signal.c (pthread_sigmask): Only provide if HAVE_SIGSET_T is + defined. + + * config.h: #undef features, don't #define them. This will be + generated by autoconf very soon. + +1998-08-11 Ben Elliston + + * Makefile (LIB): Define. + (clean): Define target. + (all): Build a library not just the object files. + + * pthread.h: Provide a definition for struct timespec if we don't + already have one. + + * windows.c (TlsGetValue): Bug fix. + +Thu Aug 6 15:19:22 1998 Ross Johnson + + * misc.c (pthread_once): Fix arg 1 of EnterCriticalSection() + and LeaveCriticalSection() calls to pass address-of lock. + + * fork.c (pthread_atfork): Typecast (void (*)(void *)) funcptr + in each __ptw32_handler_push() call. + + * exit.c (__ptw32_exit): Fix attr arg in + pthread_attr_getdetachstate() call. + + * private.c (__ptw32_new_thread): Typecast (HANDLE) NULL. + (__ptw32_delete_thread): Ditto. + + * implement.h: (__PTW32_MAX_THREADS): Add define. This keeps + changing in an attempt to make thread administration data types + opaque and cleanup DLL startup. + + * dll.c (PthreadsEntryPoint): + (__ptw32_virgins): Remove malloc() and free() calls. + (__ptw32_reuse): Ditto. + (__ptw32_win32handle_map): Ditto. + (__ptw32_threads_mutex_table): Ditto. + + * global.c (_POSIX_THREAD_THREADS_MAX): Initialise with + PTW32_MAX_THREADS. + (__ptw32_virgins): Ditto. + (__ptw32_reuse): Ditto. + (__ptw32_win32handle_map): Ditto. + (__ptw32_threads_mutex_table): Ditto. + + * create.c (pthread_create): Typecast (HANDLE) NULL. + Typecast (unsigned (*)(void *)) start_routine. + + * condvar.c (pthread_cond_init): Add address-of operator & to + arg 1 of pthread_mutex_init() call. + (pthread_cond_destroy): Add address-of operator & to + arg 1 of pthread_mutex_destroy() call. + + * cleanup.c (__ptw32_destructor_pop_all): Add (int) cast to + pthread_getspecific() arg. + (__ptw32_destructor_pop): Add (void *) cast to "if" conditional. + (__ptw32_destructor_push): Add (void *) cast to + __ptw32_handler_push() "key" arg. + (malloc.h): Add include. + + * implement.h (__ptw32_destructor_pop): Add prototype. + + * tsd.c (implement.h): Add include. + + * sync.c (pthread_join): Remove target_thread_mutex and it's + initialisation. Rename getdetachedstate to getdetachstate. + Remove unused variable "exitcode". + (pthread_detach): Remove target_thread_mutex and it's + initialisation. Rename getdetachedstate to getdetachstate. + Rename setdetachedstate to setdetachstate. + + * signal.c (pthread_sigmask): Rename SIG_SET to SIG_SETMASK. + Cast "set" to (long *) in assignment to passify compiler warning. + Add address-of operator & to thread->attr.sigmask in memcpy() call + and assignment. + (pthread_sigmask): Add address-of operator & to thread->attr.sigmask + in memcpy() call and assignment. + + * windows.h (THREAD_PRIORITY_ERROR_RETURN): Add. + (THREAD_PRIORITY_LOWEST): Add. + (THREAD_PRIORITY_HIGHEST): Add. + + * sched.c (is_attr): Add function. + (implement.h): Add include. + (pthread_setschedparam): Rename all instances of "sched_policy" + to "sched_priority". + (pthread_getschedparam): Ditto. + +Tue Aug 4 16:57:58 1998 Ross Johnson + + * private.c (__ptw32_delete_thread): Fix typo. Add missing ';'. + + * global.c (__ptw32_virgins): Change types from pointer to + array pointer. + (__ptw32_reuse): Ditto. + (__ptw32_win32handle_map): Ditto. + (__ptw32_threads_mutex_table): Ditto. + + * implement.h(__ptw32_virgins): Change types from pointer to + array pointer. + (__ptw32_reuse): Ditto. + (__ptw32_win32handle_map): Ditto. + (__ptw32_threads_mutex_table): Ditto. + + * private.c (__ptw32_delete_thread): Fix "entry" should be "thread". + + * misc.c (pthread_self): Add extern for __ptw32_threadID_TlsIndex. + + * global.c: Add comment. + + * misc.c (pthread_once): Fix member -> dereferences. + Change __ptw32_once_flag to once_control->flag in "if" test. + +Tue Aug 4 00:09:30 1998 Ross Johnson + + * implement.h(__ptw32_virgins): Add extern. + (__ptw32_virgin_next): Ditto. + (__ptw32_reuse): Ditto. + (__ptw32_reuse_top): Ditto. + (__ptw32_win32handle_map): Ditto. + (__ptw32_threads_mutex_table): Ditto. + + * global.c (__ptw32_virgins): Changed from array to pointer. + Storage allocation for the array moved into dll.c. + (__ptw32_reuse): Ditto. + (__ptw32_win32handle_map): Ditto. + (__ptw32_threads_mutex_table): Ditto. + + * dll.c (PthreadsEntryPoint): Set up thread admin storage when + DLL is loaded. + + * fork.c (pthread_atfork): Fix function pointer arg to all + __ptw32_handler_push() calls. Change "arg" arg to NULL in child push. + + * exit.c: Add windows.h and process.h includes. + (__ptw32_exit): Add local detachstate declaration. + (__ptw32_exit): Fix incorrect name for pthread_attr_getdetachstate(). + + * pthread.h (_POSIX_THREAD_ATTR_STACKSIZE): Move from global.c + (_POSIX_THREAD_ATTR_STACKADDR): Ditto. + + * create.c (pthread_create): Fix #if should be #ifdef. + (__ptw32_start_call): Remove usused variables. + + * process.h: Create. + + * windows.h: Move _beginthreadex and _endthreadex into + process.h + +Mon Aug 3 21:19:57 1998 Ross Johnson + + * condvar.c (pthread_cond_init): Add NULL attr to + pthread_mutex_init() call - default attributes will be used. + (cond_wait): Fix typo. + (cond_wait): Fix typo - cv was ev. + (pthread_cond_broadcast): Fix two identical typos. + + * cleanup.c (__ptw32_destructor_pop_all): Remove _ prefix from + PTHREAD_DESTRUCTOR_ITERATIONS. + + * pthread.h: Move _POSIX_* values into posix.h + + * pthread.h: Fix typo in pthread_mutex_init() prototype. + + * attr.c (pthread_attr_init): Fix error in priority member init. + + * windows.h (THREAD_PRIORITY_NORMAL): Add. + + * pthread.h (sched_param): Add missing ';' to struct definition. + + * attr.c (pthread_attr_init): Remove obsolete pthread_attr_t + member initialisation - cancelstate, canceltype, cancel_pending. + (is_attr): Make arg "attr" a const. + + * implement.h (__PTW32_HANDLER_POP_LIFO): Remove definition. + (__PTW32_HANDLER_POP_FIFO): Ditto. + (__PTW32_VALID): Add missing newline escape (\). + (__ptw32_handler_node): Make element "next" a pointer. + +1998-08-02 Ben Elliston + + * windows.h: Remove duplicate TlsSetValue() prototype. Add + TlsGetValue() prototype. + (FALSE): Define. + (TRUE): Likewise. + Add forgotten errno values. Guard against multiple #includes. + + * windows.c: New file. Implement stubs for Win32 functions. + + * Makefile (SRCS): Remove. Not explicitly needed. + (CFLAGS): Add -Wall for all warnings with GCC. + +Sun Aug 2 19:03:42 1998 Ross Johnson + + * config.h: Create. This is a temporary stand-in for autoconf yet + to be done. + (HAVE_SIGNAL_H): Add. + + * pthread.h: Minor rearrangement for temporary config.h. + +Fri Jul 31 14:00:29 1998 Ross Johnson + + * cleanup.c (__ptw32_destructor_pop): Implement. Removes + destructors associated with a key without executing them. + (__ptw32_destructor_pop_all): Add FIXME comment. + + * tsd.c (pthread_key_delete): Add call to __ptw32_destructor_pop(). + +Fri Jul 31 00:05:45 1998 Ross Johnson + + * tsd.c (pthread_key_create): Update to properly associate + the destructor routine with the key. + (pthread_key_delete): Add FIXME comment. + + * exit.c (__ptw32_vacuum): Add call to + __ptw32_destructor_pop_all(). + + * implement.h (__ptw32_handler_pop_all): Add prototype. + (__ptw32_destructor_pop_all): Ditto. + + * cleanup.c (__ptw32_destructor_push): Implement. This is just a + call to __ptw32_handler_push(). + (__ptw32_destructor_pop_all): Implement. This is significantly + different to __ptw32_handler_pop_all(). + + * Makefile (SRCS): Create. Preliminary. + + * windows.h: Create. Contains Win32 definitions for compile + testing. This is just a standin for the real one. + + * pthread.h (SIG_UNBLOCK): Fix typo. Was SIG_BLOCK. + (windows.h): Add include. Required for CRITICAL_SECTION. + (pthread_cond_t): Move enum declaration outside of struct + definition. + (unistd.h): Add include - may be temporary. + + * condvar.c (windows.h): Add include. + + * implement.h (__PTW32_THIS): Remove - no longer required. + (__PTW32_STACK): Use pthread_self() instead of __PTW32_THIS. + +Thu Jul 30 23:12:45 1998 Ross Johnson + + * implement.h: Remove __ptw32_find_entry() prototype. + + * private.c: Extend comments. + Remove __ptw32_find_entry() - no longer needed. + + * create.c (__ptw32_start_call): Add call to TlsSetValue() to + store the thread ID. + + * dll.c (PthreadsEntryPoint): Implement. This is called + whenever a process loads the DLL. Used to initialise thread + local storage. + + * implement.h: Add __ptw32_threadID_TlsIndex. + Add ()s around __PTW32_VALID expression. + + * misc.c (pthread_self): Re-implement using Win32 TLS to store + the threads own ID. + +Wed Jul 29 11:39:03 1998 Ross Johnson + + * private.c: Corrections in comments. + (__ptw32_new_thread): Alter "if" flow to be more natural. + + * cleanup.c (__ptw32_handler_push): Same as below. + + * create.c (pthread_create): Same as below. + + * private.c (__ptw32_new_thread): Rename "new" to "new_thread". + Since when has a C programmer been required to know C++? + +Tue Jul 28 14:04:29 1998 Ross Johnson + + * implement.h: Add __PTW32_VALID macro. + + * sync.c (pthread_join): Modify to use the new thread + type and __ptw32_delete_thread(). Rename "target" to "thread". + Remove extra local variable "target". + (pthread_detach): Ditto. + + * signal.c (pthread_sigmask): Move init of "us" out of inner block. + Fix instance of "this" should have been "us". Rename "us" to "thread". + + * sched.c (pthread_setschedparam): Modify to use the new thread + type. + (pthread_getschedparam): Ditto. + + * private.c (__ptw32_find_thread): Fix return type and arg. + + * implement.h: Remove __PTW32_YES and __PTW32_NO. + (__ptw32_new_thread): Add prototype. + (__ptw32_find_thread): Ditto. + (__ptw32_delete_thread): Ditto. + (__ptw32_new_thread_entry): Remove prototype. + (__ptw32_find_thread_entry): Ditto. + (__ptw32_delete_thread_entry): Ditto. + ( __PTW32_NEW, __PTW32_INUSE, __PTW32_EXITED, __PTW32_REUSE): + Add. + + + * create.c (pthread_create): Minor rename "us" to "new" (I need + these cues but it doesn't stop me coming out with some major bugs + at times). + Load start_routine and arg into the thread so the wrapper can + call it. + + * exit.c (pthread_exit): Fix pthread_this should be pthread_self. + + * cancel.c (pthread_setcancelstate): Change + __ptw32_threads_thread_t * to pthread_t and init with + pthread_this(). + (pthread_setcanceltype): Ditto. + + * exit.c (__ptw32_exit): Add new pthread_t arg. + Rename __ptw32_delete_thread_entry to __ptw32_delete_thread. + Rename "us" to "thread". + (pthread_exit): Call __ptw32_exit with added thread arg. + + * create.c (__ptw32_start_call): Insert missing ")". + Add "us" arg to __ptw32_exit() call. + (pthread_create): Modify to use new thread allocation scheme. + + * private.c: Added detailed explanation of the new thread + allocation scheme. + (__ptw32_new_thread): Totally rewritten to use + new thread allocation scheme. + (__ptw32_delete_thread): Ditto. + (__ptw32_find_thread): Obsolete. + +Mon Jul 27 17:46:37 1998 Ross Johnson + + * create.c (pthread_create): Start of rewrite. Not completed yet. + + * private.c (__ptw32_new_thread_entry): Start of rewrite. Not + complete. + + * implement.h (__ptw32_threads_thread): Rename, remove thread + member, add win32handle and ptstatus members. + (__ptw32_t): Add. + + * pthread.h: pthread_t is no longer mapped directly to a Win32 + HANDLE type. This is so we can let the Win32 thread terminate and + reuse the HANDLE while pthreads holds it's own thread ID until + the last waiting join exits. + +Mon Jul 27 00:20:37 1998 Ross Johnson + + * private.c (__ptw32_delete_thread_entry): Destroy the thread + entry attribute object before deleting the thread entry itself. + + * attr.c (pthread_attr_init): Initialise cancel_pending = FALSE. + (pthread_attr_setdetachstate): Rename "detached" to "detachedstate". + (pthread_attr_getdetachstate): Ditto. + + * exit.c (__ptw32_exit): Fix incorrect check for detachedstate. + + * implement.h (__ptw32_call_t): Remove env member. + +Sun Jul 26 13:06:12 1998 Ross Johnson + + * implement.h (__ptw32_new_thread_entry): Fix prototype. + (__ptw32_find_thread_entry): Ditto. + (__ptw32_delete_thread_entry): Ditto. + (__ptw32_exit): Add prototype. + + * exit.c (__ptw32_exit): New function. Called from pthread_exit() + and __ptw32_start_call() to exit the thread. It allows an extra + argument which is the return code passed to _endthreadex(). + (__ptw32_exit): Move thread entry delete call from __ptw32_vacuum() + into here. Add more explanation of thread entry deletion. + (__ptw32_exit): Clarify comment. + + * create.c (__ptw32_start_call): Change pthread_exit() call to + __ptw32_exit() call. + + * exit.c (__ptw32_vacuum): Add thread entry deletion code + moved from __ptw32_start_call(). See next item. + (pthread_exit): Remove longjmp(). Add mutex lock around thread table + manipulation code. This routine now calls _enthreadex(). + + * create.c (__ptw32_start_call): Remove setjmp() call and move + cleanup code out. Call pthread_exit(NULL) to terminate the thread. + +1998-07-26 Ben Elliston + + * tsd.c (pthread_getspecific): Update comments. + + * mutex.c (pthread_mutexattr_setpshared): Not supported; remove. + (pthread_mutexattr_getpshared): Likewise. + + * pthread.h (pthread_mutexattr_setpshared): Remove prototype. + (pthread_mutexattr_getpshared): Likewise. + +Sun Jul 26 00:09:59 1998 Ross Johnson + + * sync.c: Rename all instances of __ptw32_count_mutex to + __ptw32_table_mutex. + + * implement.h: Rename __ptw32_count_mutex to + __ptw32_table_mutex. + + * global.c: Rename __ptw32_count_mutex to + __ptw32_table_mutex. + + * create.c (pthread_create): Add critical sections. + (__ptw32_start_call): Rename __ptw32_count_mutex to + __ptw32_table_mutex. + + * cancel.c (pthread_setcancelstate): Fix indirection bug and rename + "this" to "us". + + * signal.c (pthread_sigmask): Rename "this" to "us" and fix some + minor syntax errors. Declare "us" and initialise it. + + * sync.c (pthread_detach): Rename "this" to "target". + + * pthread.h: Converting PTHREAD_* defines to alias the (const int) + values in global.c. + + * global.c: Started converting PTHREAD_* defines to (const int) as + a part of making the eventual pthreads DLL binary compatible + through version changes. + + * 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". + + * implement.h: Add comment. + + * sync.c (pthread_join): I've satisfied myself that pthread_detach() + does set the detached attribute in the thread entry attributes + to PTHREAD_CREATE_DETACHED. "if" conditions were changed to test + that attribute instead of a separate flag. + + * create.c (pthread_create): Rename "this" to "us". + (pthread_create): cancelstate and canceltype are not attributes + so the copy to thread entry attribute storage was removed. + Only the thread itself can change it's cancelstate or canceltype, + ie. the thread must exist already. + + * private.c (__ptw32_delete_thread_entry): Mutex locks removed. + Mutexes must be applied at the caller level. + (__ptw32_new_thread_entry): Ditto. + (__ptw32_new_thread_entry): Init cancelstate, canceltype, and + cancel_pending to default values. + (__ptw32_new_thread_entry): Rename "this" to "new". + (__ptw32_find_thread_entry): Rename "this" to "entry". + (__ptw32_delete_thread_entry): Rename "thread_entry" to "entry". + + * create.c (__ptw32_start_call): Mutexes changed to + __ptw32_count_mutex. All access to the threads table entries is + under the one mutex. Otherwise chaos reigns. + +Sat Jul 25 23:16:51 1998 Ross Johnson + + * implement.h (__ptw32_threads_thread): Move cancelstate and + canceltype members out of pthread_attr_t into here. + + * fork.c (fork): Add comment. + +1998-07-25 Ben Elliston + + * fork.c (fork): Autoconfiscate. + +Sat Jul 25 00:00:13 1998 Ross Johnson + + * create.c (__ptw32_start_call): Set thread priority. Ensure our + thread entry is removed from the thread table but only if + pthread_detach() was called and there are no waiting joins. + (pthread_create): Set detach flag in thread entry if the + thread is created PTHREAD_CREATE_DETACHED. + + * pthread.h (pthread_attr_t): Rename member "detachedstate". + + * attr.c (pthread_attr_init): Rename attr members. + + * exit.c (pthread_exit): Fix indirection mistake. + + * implement.h (__PTW32_THREADS_TABLE_INDEX): Add. + + * exit.c (__ptw32_vacuum): Fix incorrect args to + __ptw32_handler_pop_all() calls. + Make thread entry removal conditional. + + * sync.c (pthread_join): Add multiple join and async detach handling. + + * implement.h (__PTW32_THREADS_TABLE_INDEX): Add. + + * global.c (__ptw32_threads_mutex_table): Add. + + * implement.h (__ptw32_once_flag): Remove. + (__ptw32_once_lock): Ditto. + (__ptw32_threads_mutex_table): Add. + + * global.c (__ptw32_once_flag): Remove. + (__ptw32_once_lock): Ditto. + + * sync.c (pthread_join): Fix tests involving new return value + from __ptw32_find_thread_entry(). + (pthread_detach): Ditto. + + * private.c (__ptw32_find_thread_entry): Failure return code + changed from -1 to NULL. + +Fri Jul 24 23:09:33 1998 Ross Johnson + + * create.c (pthread_create): Change . to -> in sigmask memcpy() args. + + * pthread.h: (pthread_cancel): Add function prototype. + (pthread_testcancel): Ditto. + +1998-07-24 Ben Elliston + + * pthread.h (pthread_condattr_t): Rename dummy structure member. + (pthread_mutexattr_t): Likewise. + +Fri Jul 24 21:13:55 1998 Ross Johnson + + * cancel.c (pthread_cancel): Implement. + (pthread_testcancel): Implement. + + * exit.c (pthread_exit): Add comment explaining the longjmp(). + + * implement.h (__ptw32_threads_thread_t): New member cancelthread. + (__PTW32_YES): Define. + (__PTW32_NO): Define. + (RND_SIZEOF): Remove. + + * create.c (pthread_create): Rename cancelability to cancelstate. + + * pthread.h (pthread_attr_t): Rename cancelability to cancelstate. + (PTHREAD_CANCELED): Define. + +1998-07-24 Ben Elliston + + * pthread.h (SIG_BLOCK): Define if not already defined. + (SIG_UNBLOCK): Likewise. + (SIG_SETMASK): Likewise. + (pthread_attr_t): Add signal mask member. + (pthread_sigmask): Add function prototype. + + * signal.c (pthread_sigmask): Implement. + + * create.c: #include to get a prototype for memcpy(). + (pthread_create): New threads inherit their creator's signal + mask. Copy the signal mask to the new thread structure if we know + about signals. + +Fri Jul 24 16:33:17 1998 Ross Johnson + + * fork.c (pthread_atfork): Add all the necessary push calls. + Local implementation semantics: + If we get an ENOMEM at any time then ALL handlers + (including those from previous pthread_atfork() calls) will be + popped off each of the three atfork stacks before we return. + (fork): Add all the necessary pop calls. Add the thread cancellation + and join calls to the child fork. + Add #includes. + + * implement.h: (__ptw32_handler_push): Fix return type and stack arg + type in prototype. + (__ptw32_handler_pop): Fix stack arg type in prototype. + (__ptw32_handler_pop_all): Fix stack arg type in prototype. + + * cleanup.c (__ptw32_handler_push): Change return type to int and + return ENOMEM if malloc() fails. + + * sync.c (pthread_detach): Use equality test, not assignment. + + * create.c (__ptw32_start_call): Add call to Win32 CloseHandle() + if thread is detached. + +1998-07-24 Ben Elliston + + * sync.c (pthread_detach): Close the Win32 thread handle to + emulate detached (or daemon) threads. + +Fri Jul 24 03:00:25 1998 Ross Johnson + + * sync.c (pthread_join): Save valueptr arg in joinvalueptr for + pthread_exit() to use. + + * private.c (__ptw32_new_thread_entry): Initialise joinvalueptr to + NULL. + + * create.c (__ptw32_start_call): Rewrite to facilitate joins. + pthread_exit() will do a longjmp() back to here. Does appropriate + cleanup and exit/return from the thread. + (pthread_create): _beginthreadex() now passes a pointer to our + thread table entry instead of just the call member of that entry. + + * implement.h (__ptw32_threads_thread): New member + void ** joinvalueptr. + (__ptw32_call_t): New member jmpbuf env. + + * exit.c (pthread_exit): Major rewrite to handle joins and handing + value pointer to joining thread. Uses longjmp() back to + __ptw32_start_call(). + + * create.c (pthread_create): Ensure values of new attribute members + are copied to the thread attribute object. + + * attr.c (pthread_attr_destroy): Fix merge conflicts. + (pthread_attr_getdetachstate): Fix merge conflicts. + (pthread_attr_setdetachstate): Fix merge conflicts. + + * pthread.h: Fix merge conflicts. + + * sync.c (pthread_join): Fix merge conflicts. + +Fri Jul 24 00:21:21 1998 Ross Johnson + + * sync.c (pthread_join): Add check for valid and joinable + thread. + (pthread_detach): Implement. After checking for a valid and joinable + thread, it's still a no-op. + + * private.c (__ptw32_find_thread_entry): Bug prevented returning + an error value in some cases. + + * attr.c (pthread_attr_setdetachedstate): Implement. + (pthread_attr_getdetachedstate): Implement. + + * implement.h: Move more hidden definitions into here from + pthread.h. + +1998-07-24 Ben Elliston + + * pthread.h (PTHREAD_CREATE_JOINABLE): Define. + (PTHREAD_CREATE_DETACHED): Likewise. + (pthread_attr_t): Add new structure member `detached'. + (pthread_attr_getdetachstate): Add function prototype. + (pthread_attr_setdetachstate): Likewise. + + * sync.c (pthread_join): Return if the target thread is detached. + + * attr.c (pthread_attr_init): Initialise cancelability and + canceltype structure members. + (pthread_attr_getdetachstate): Implement. + (pthread_attr_setdetachstate): Likewise. + + * implement.h (__PTW32_CANCEL_DEFAULTS): Remove. Bit fields + proved to be too cumbersome. Set the defaults in attr.c using the + public PTHREAD_CANCEL_* constants. + + * cancel.c: New file. + + * pthread.h (sched_param): Define this type. + (pthread_attr_getschedparam): Add function prototype. + (pthread_attr_setschedparam): Likewise. + (pthread_setcancelstate): Likewise. + (pthread_setcanceltype): Likewise. + (sched_get_priority_min): Likewise. + (sched_get_priority_max): Likewise. + (pthread_mutexattr_setprotocol): Remove; not supported. + (pthread_mutexattr_getprotocol): Likewise. + (pthread_mutexattr_setprioceiling): Likewise. + (pthread_mutexattr_getprioceiling): Likewise. + (pthread_attr_t): Add canceltype member. Update comments. + (SCHED_OTHER): Define this scheduling policy constant. + (SCHED_FIFO): Likewise. + (SCHED_RR): Likewise. + (SCHED_MIN): Define the lowest possible value for this constant. + (SCHED_MAX): Likewise, the maximum possible value. + (PTHREAD_CANCEL_ASYNCHRONOUS): Redefine. + (PTHREAD_CANCEL_DEFERRED): Likewise. + + * sched.c: New file. + (pthread_setschedparam): Implement. + (pthread_getschedparam): Implement. + (sched_get_priority_max): Validate policy argument. + (sched_get_priority_min): Likewise. + + * mutex.c (pthread_mutexattr_setprotocol): Remove; not supported. + (pthread_mutexattr_getprotocol): Likewise. + (pthread_mutexattr_setprioceiling): Likewise. + (pthread_mutexattr_getprioceiling): Likewise. + +Fri Jul 24 00:21:21 1998 Ross Johnson + + * create.c (pthread_create): Arg to __ptw32_new_thread_entry() + changed. See next entry. Move mutex locks out. Changes made yesterday + and today allow us to start the new thread running rather than + temporarily suspended. + + * private.c (__ptw32_new_thread_entry): __ptw32_thread_table + was changed back to a table of thread structures rather than pointers. + As such we're trading storage for increaded speed. This routine + was modified to work with the new table. Mutex lock put in around + global data accesses. + (__ptw32_find_thread_entry): Ditto + (__ptw32_delete_thread_entry): Ditto + +Thu Jul 23 23:25:30 1998 Ross Johnson + + * global.c: New. Global data objects declared here. These moved from + pthread.h. + + * pthread.h: Move implementation hidden definitions into + implement.h. + + * implement.h: Move implementation hidden definitions from + pthread.h. Add constants to index into the different handler stacks. + + * cleanup.c (__ptw32_handler_push): Simplify args. Restructure. + (__ptw32_handler_pop): Simplify args. Restructure. + (__ptw32_handler_pop_all): Simplify args. Restructure. + +Wed Jul 22 00:16:22 1998 Ross Johnson + + * attr.c, implement.h, pthread.h, ChangeLog: Resolve CVS merge + conflicts. + + * private.c (__ptw32_find_thread_entry): Changes to return type + to support leaner __ptw32_threads_table[] which now only stores + __ptw32_thread_thread_t *. + (__ptw32_new_thread_entry): Internal changes. + (__ptw32_delete_thread_entry): Internal changes to avoid contention. + Calling routines changed accordingly. + + * pthread.h: Modified cleanup macros to use new generic push and pop. + Added destructor and atfork stacks to __ptw32_threads_thread_t. + + * cleanup.c (__ptw32_handler_push, __ptw32_handler_pop, + __ptw32_handler_pop_all): Renamed cleanup push and pop routines + and made generic to handle destructors and atfork handlers as + well. + + * create.c (__ptw32_start_call): New function is a wrapper for + all new threads. It allows us to do some cleanup when the thread + returns, ie. that is otherwise only done if the thread is cancelled. + + * exit.c (__ptw32_vacuum): New function contains code from + pthread_exit() that we need in the new __ptw32_start_call() + as well. + + * implement.h: Various additions and minor changes. + + * pthread.h: Various additions and minor changes. + Change cleanup handler macros to use generic handler push and pop + functions. + + * attr.c: Minor mods to all functions. + (is_attr): Implemented missing function. + + * create.c (pthread_create): More clean up. + + * private.c (__ptw32_find_thread_entry): Implement. + (__ptw32_delete_thread_entry): Implement. + (__ptw32_new_thread_entry): Implement. + These functions manipulate the implementations internal thread + table and are part of general code cleanup and modularisation. + They replace __ptw32_getthreadindex() which was removed. + + * exit.c (pthread_exit): Changed to use the new code above. + + * pthread.h: Add cancelability constants. Update comments. + +1998-07-22 Ben Elliston + + * attr.c (pthread_setstacksize): Update test of attr argument. + (pthread_getstacksize): Likewise. + (pthread_setstackaddr): Likewise. + (pthread_getstackaddr): Likewise. + (pthread_attr_init): No need to allocate any storage. + (pthread_attr_destroy): No need to free any storage. + + * mutex.c (is_attr): Not likely to be needed; remove. + (remove_attr): Likewise. + (insert_attr): Likewise. + + * implement.h (__ptw32_mutexattr_t): Moved to a public definition + in pthread.h. There was little gain in hiding these details. + (__ptw32_condattr_t): Likewise. + (__ptw32_attr_t): Likewise. + + * pthread.h (pthread_atfork): Add function prototype. + (pthread_attr_t): Moved here from implement.h. + + * fork.c (pthread_atfork): Preliminary implementation. + (__ptw32_fork): Likewise. + +Wed Jul 22 00:16:22 1998 Ross Johnson + + * cleanup.c (__ptw32_cleanup_push): Implement. + (__ptw32_cleanup_pop): Implement. + (__ptw32_do_cancellation): Implement. + These are private to the implementation. The real cleanup functions + are macros. See below. + + * pthread.h (pthread_cleanup_push): Implement as a macro. + (pthread_cleanup_pop): Implement as a macro. + Because these are macros which start and end a block, the POSIX scoping + requirement is observed. See the comment in the file. + + * exit.c (pthread_exit): Refine the code. + + * create.c (pthread_create): Code cleanup. + + * implement.h (RND_SIZEOF): Add RND_SIZEOF(T) to round sizeof(T) + up to multiple of DWORD. + Add function prototypes. + + * private.c (__ptw32_getthreadindex): "*thread" should have been + "thread". Detect empty slot fail condition. + +1998-07-20 Ben Elliston + + * misc.c (pthread_once): Implement. Don't use a per-application + flag and mutex--make `pthread_once_t' contain these elements in + their structure. The earlier version had incorrect semantics. + + * pthread.h (__ptw32_once_flag): Add new variable. Remove. + (__ptw32_once_lock): Add new mutex lock to ensure integrity of + access to __ptw32_once_flag. Remove. + (pthread_once): Add function prototype. + (pthread_once_t): Define this type. + +Mon Jul 20 02:31:05 1998 Ross Johnson + + * private.c (__ptw32_getthreadindex): Implement. + + * pthread.h: Add application static data dependent on + _PTHREADS_BUILD_DLL define. This is needed to avoid allocating + non-sharable static data within the pthread DLL. + + * implement.h: Add __ptw32_cleanup_stack_t, __ptw32_cleanup_node_t + and __PTW32_HASH_INDEX. + + * exit.c (pthread_exit): Begin work on cleanup and de-allocate + thread-private storage. + + * create.c (pthread_create): Add thread to thread table. + Keep a thread-private copy of the attributes with default values + filled in when necessary. Same for the cleanup stack. Make + pthread_create C run-time library friendly by using _beginthreadex() + instead of CreateThread(). Fix error returns. + +Sun Jul 19 16:26:23 1998 Ross Johnson + + * implement.h: Rename pthreads_thread_count to __ptw32_threads_count. + Create __ptw32_threads_thread_t struct to keep thread specific data. + + * create.c: Rename pthreads_thread_count to __ptw32_threads_count. + (pthread_create): Handle errors from CreateThread(). + +1998-07-19 Ben Elliston + + * condvar.c (pthread_cond_wait): Generalise. Moved from here .. + (cond_wait): To here. + (pthread_cond_timedwait): Implement; use generalised cond_wait(). + + * pthread.h (pthread_key_t): Define this type. + (pthread_key_create): Add function prototype. + (pthread_setspecific): Likewise. + (pthread_getspecific): Likwise. + (pthread_key_delete): Likewise. + + * tsd.c (pthread_key_create): Implement. + (pthread_setspecific): Likewise. + (pthread_getspecific): Likewise. + (pthread_key_delete): Likewise. + + * mutex.c (pthread_mutex_trylock): Return ENOSYS if this function + is called on a Win32 platform which is not Windows NT. + +1998-07-18 Ben Elliston + + * condvar.c (pthread_condattr_init): Do not attempt to malloc any + storage; none is needed now that condattr_t is an empty struct. + (pthread_condattr_destory): Likewise; do not free storage. + (pthread_condattr_setpshared): No longer supported; return ENOSYS. + (pthread_condattr_getpshared): Likewise. + (pthread_cond_init): Implement with help from Douglas Schmidt. + Remember to initialise the cv's internal mutex. + (pthread_cond_wait): Likewise. + (pthread_cond_signal): Likewise. + (pthread_cond_broadcast): Likewise. + (pthread_cond_timedwait): Preliminary implementation, but I need + to see some API documentation for `WaitForMultipleObject'. + (pthread_destory): Implement. + + * pthread.h (pthread_cond_init): Add function protoype. + (pthread_cond_broadcast): Likewise. + (pthread_cond_signal): Likewise. + (pthread_cond_timedwait): Likewise. + (pthread_cond_wait): Likewise. + (pthread_cond_destroy): Likewise. + (pthread_cond_t): Define this type. Fix for u_int. Do not assume + that the mutex contained withing the pthread_cond_t structure will + be a critical section. Use our new POSIX type! + + * implement.h (__ptw32_condattr_t): Remove shared attribute. + +1998-07-17 Ben Elliston + + * pthread.h (PTHREADS_PROCESS_PRIVATE): Remove. + (PTHREAD_PROCESS_SHARED): Likewise. No support for mutexes shared + across processes for now. + (pthread_mutex_t): Use a Win32 CRITICAL_SECTION type for better + performance. + + * implement.h (__ptw32_mutexattr_t): Remove shared attribute. + + * mutex.c (pthread_mutexattr_setpshared): This optional function + is no longer supported, since we want to implement POSIX mutex + variables using the much more efficient Win32 critical section + primitives. Critical section objects in Win32 cannot be shared + between processes. + (pthread_mutexattr_getpshared): Likewise. + (pthread_mutexattr_init): No need to malloc any storage; the + attributes structure is now empty. + (pthread_mutexattr_destroy): This is now a nop. + (pthread_mutex_init): Use InitializeCriticalSection(). + (pthread_mutex_destroy): Use DeleteCriticalSection(). + (pthread_mutex_lock): Use EnterCriticalSection(). + (pthread_mutex_trylock): Use TryEnterCriticalSection(). This is + not supported by Windows 9x, but trylock is a hack anyway, IMHO. + (pthread_mutex_unlock): Use LeaveCriticalSection(). + +1998-07-14 Ben Elliston + + * attr.c (pthread_attr_setstacksize): Implement. + (pthread_attr_getstacksize): Likewise. + (pthread_attr_setstackaddr): Likewise. + (pthread_attr_getstackaddr): Likewise. + (pthread_attr_init): Likewise. + (pthread_attr_destroy): Likewise. + + * condvar.c (pthread_condattr_init): Add `_cond' to function name. + + * mutex.c (pthread_mutex_lock): Add `_mutex' to function name. + (pthread_mutex_trylock): Likewise. + (pthread_mutex_unlock): Likewise. + + * pthread.h (pthread_condattr_setpshared): Fix typo. + (pthread_attr_init): Add function prototype. + (pthread_attr_destroy): Likewise. + (pthread_attr_setstacksize): Likewise. + (pthread_attr_getstacksize): Likewise. + (pthread_attr_setstackaddr): Likewise. + (pthread_attr_getstackaddr): Likewise. + +Mon Jul 13 01:09:55 1998 Ross Johnson + + * implement.h: Wrap in #ifndef _IMPLEMENT_H + + * create.c (pthread_create): Map stacksize attr to Win32. + + * mutex.c: Include implement.h + +1998-07-13 Ben Elliston + + * condvar.c (pthread_condattr_init): Implement. + (pthread_condattr_destroy): Likewise. + (pthread_condattr_setpshared): Likewise. + (pthread_condattr_getpshared): Likewise. + + * implement.h (PTHREAD_THREADS_MAX): Remove trailing semicolon. + (PTHREAD_STACK_MIN): Specify; needs confirming. + (__ptw32_attr_t): Define this type. + (__ptw32_condattr_t): Likewise. + + * pthread.h (pthread_mutex_t): Define this type. + (pthread_condattr_t): Likewise. + (pthread_mutex_destroy): Add function prototype. + (pthread_lock): Likewise. + (pthread_trylock): Likewise. + (pthread_unlock): Likewise. + (pthread_condattr_init): Likewise. + (pthread_condattr_destroy): Likewise. + (pthread_condattr_setpshared): Likewise. + (pthread_condattr_getpshared): Likewise. + + * mutex.c (pthread_mutex_init): Implement. + (pthread_mutex_destroy): Likewise. + (pthread_lock): Likewise. + (pthread_trylock): Likewise. + (pthread_unlock): Likewise. + +1998-07-12 Ben Elliston + + * implement.h (__ptw32_mutexattr_t): Define this implementation + internal type. Application programmers only see a mutex attribute + object as a void pointer. + + * pthread.h (pthread_mutexattr_t): Define this type. + (pthread_mutexattr_init): Add function prototype. + (pthread_mutexattr_destroy): Likewise. + (pthread_mutexattr_setpshared): Likewise. + (pthread_mutexattr_getpshared): Likewise. + (pthread_mutexattr_setprotocol): Likewise. + (pthread_mutexattr_getprotocol): Likewise. + (pthread_mutexattr_setprioceiling): Likewise. + (pthread_mutexattr_getprioceiling): Likewise. + (PTHREAD_PROCESS_PRIVATE): Define. + (PTHREAD_PROCESS_SHARED): Define. + + * mutex.c (pthread_mutexattr_init): Implement. + (pthread_mutexattr_destroy): Implement. + (pthread_mutexattr_setprotocol): Implement. + (pthread_mutexattr_getprotocol): Likewise. + (pthread_mutexattr_setprioceiling): Likewise. + (pthread_mutexattr_getprioceiling): Likewise. + (pthread_mutexattr_setpshared): Likewise. + (pthread_mutexattr_getpshared): Likewise. + (insert_attr): New function; very preliminary implementation! + (is_attr): Likewise. + (remove_attr): Likewise. + +Sat Jul 11 14:48:54 1998 Ross Johnson + + * implement.h: Preliminary implementation specific defines. + + * create.c (pthread_create): Preliminary implementation. + +1998-07-11 Ben Elliston + + * sync.c (pthread_join): Implement. + + * misc.c (pthread_equal): Likewise. + + * pthread.h (pthread_join): Add function prototype. + (pthread_equal): Likewise. + +1998-07-10 Ben Elliston + + * misc.c (pthread_self): Implement. + + * exit.c (pthread_exit): Implement. + + * pthread.h (pthread_exit): Add function prototype. + (pthread_self): Likewise. + (pthread_t): Define this type. + +1998-07-09 Ben Elliston + + * create.c (pthread_create): A dummy stub right now. + + * pthread.h (pthread_create): Add function prototype. diff --git a/vendor/pthreads/include/FAQ b/vendor/pthreads/include/FAQ deleted file mode 100644 index cb1786c5ae..0000000000 --- a/vendor/pthreads/include/FAQ +++ /dev/null @@ -1,451 +0,0 @@ - ========================================= - 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. - diff --git a/vendor/pthreads/include/GNUmakefile b/vendor/pthreads/include/GNUmakefile deleted file mode 100644 index e489f002ec..0000000000 --- a/vendor/pthreads/include/GNUmakefile +++ /dev/null @@ -1,593 +0,0 @@ -# -# -------------------------------------------------------------------------- -# -# Pthreads-win32 - POSIX 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 -# - -DLL_VER = 2 -DLL_VERD= $(DLL_VER)d - -DEVROOT = C:\PTHREADS - -DLLDEST = $(DEVROOT)\DLL -LIBDEST = $(DEVROOT)\DLL - -# If Running MsysDTK -RM = rm -f -MV = mv -f -CP = cp -f - -# If not. -#RM = erase -#MV = rename -#CP = copy - -# For cross compiling use e.g. -# make CROSS=x86_64-w64-mingw32- clean GC-inlined -CROSS = - -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=. -# Uncomment this if config.h defines RETAIN_WSALASTERROR -#LFLAGS = -lws2_32 - -# ---------------------------------------------------------------------- -# The library can be built with some alternative behaviour to -# facilitate development of applications on Win32 that will be ported -# to other POSIX systems. Nothing definable here will make the library -# non-compliant, but applications that make assumptions that POSIX -# does not garrantee may fail or misbehave under some settings. -# -# PTW32_THREAD_ID_REUSE_INCREMENT -# Purpose: -# POSIX says that applications should assume that thread IDs can be -# recycled. However, Solaris and some other systems use a [very large] -# sequence number as the thread ID, which provides virtual uniqueness. -# Pthreads-win32 provides pseudo-unique IDs when the default increment -# (1) is used, but pthread_t is not a scalar type like Solaris's. -# -# Usage: -# Set to any value in the range: 0 <= value <= 2^wordsize -# -# Examples: -# Set to 0 to emulate non recycle-unique behaviour like Linux or *BSD. -# Set to 1 for recycle-unique thread IDs (this is the default). -# Set to some other +ve value to emulate smaller word size types -# (i.e. will wrap sooner). -# -#PTW32_FLAGS = "-DPTW32_THREAD_ID_REUSE_INCREMENT=0" -# -# ---------------------------------------------------------------------- - -GC_CFLAGS = $(PTW32_FLAGS) -GCE_CFLAGS = $(PTW32_FLAGS) -mthreads - -## Mingw -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 - - -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 - -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)" - -all: - @ $(MAKE) clean GCE - @ $(MAKE) clean GC - -GC: - $(MAKE) 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) - -GCE: - $(MAKE) 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) - -GC-inlined: - $(MAKE) XOPT="-DPTW32_BUILD_INLINED" CLEANUP=-D__CLEANUP_C XC_FLAGS="$(GC_CFLAGS)" OBJ="$(DLL_INLINED_OBJS)" $(GC_INLINED_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) - -GCE-inlined: - $(MAKE) CC=$(CXX) XOPT="-DPTW32_BUILD_INLINED" CLEANUP=-D__CLEANUP_CXX XC_FLAGS="$(GCE_CFLAGS)" OBJ="$(DLL_INLINED_OBJS)" $(GCE_INLINED_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) - -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) - -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) - -tests: - @ cd tests - @ $(MAKE) auto - -%.pre: %.c - $(CC) -E -o $@ $(CFLAGS) $^ - -%.s: %.c - $(CC) -c $(CFLAGS) -DPTW32_BUILD_INLINED -Wa,-ahl $^ > $@ - -%.o: %.rc - $(RC) $(RCFLAGS) $(CLEANUP) -o $@ -i $< - -.SUFFIXES: .dll .rc .c .o - -.c.o:; $(CC) -c -o $@ $(CFLAGS) $(XC_FLAGS) $< - - -$(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) - -clean: - -$(RM) *~ - -$(RM) *.i - -$(RM) *.s - -$(RM) *.o - -$(RM) *.obj - -$(RM) *.exe - -$(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) diff --git a/vendor/pthreads/include/LICENSE b/vendor/pthreads/include/LICENSE new file mode 100644 index 0000000000..7a4a3ea242 --- /dev/null +++ b/vendor/pthreads/include/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/vendor/pthreads/include/MAINTAINERS b/vendor/pthreads/include/MAINTAINERS deleted file mode 100644 index d253c1f69e..0000000000 --- a/vendor/pthreads/include/MAINTAINERS +++ /dev/null @@ -1,4 +0,0 @@ -CVS Repository maintainers - -Ross Johnson rpj@ise.canberra.edu.au -Ben Elliston bje@cygnus.com diff --git a/vendor/pthreads/include/Makefile b/vendor/pthreads/include/Makefile deleted file mode 100644 index 472969cf9b..0000000000 --- a/vendor/pthreads/include/Makefile +++ /dev/null @@ -1,514 +0,0 @@ -# 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). -# -# 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 -DLL_VERD= $(DLL_VER)d - -DEVROOT = C:\pthreads - -DLLDEST = $(DEVROOT)\dll -LIBDEST = $(DEVROOT)\lib -HDRDEST = $(DEVROOT)\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 - -CC = cl -CPPFLAGS = /I. /DHAVE_PTW32_CONFIG_H -XCFLAGS = /W3 /MD /nologo -CFLAGS = /O2 /Ob2 $(XCFLAGS) -CFLAGSD = /Z7 $(XCFLAGS) - -# Uncomment this if config.h defines RETAIN_WSALASTERROR -#XLIBS = wsock32.lib - -# Default cleanup style -CLEANUP = __CLEANUP_C - -# C++ Exceptions -VCEFLAGS = /EHsc /TP $(CPPFLAGS) $(CFLAGS) -VCEFLAGSD = /EHsc /TP $(CPPFLAGS) $(CFLAGSD) -#Structured Exceptions -VSEFLAGS = $(CPPFLAGS) $(CFLAGS) -VSEFLAGSD = $(CPPFLAGS) $(CFLAGSD) -#C cleanup code -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 - - -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) - -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 - -VCE: - @ $(MAKE) /E /nologo EHFLAGS="$(VCEFLAGS)" CLEANUP=__CLEANUP_CXX pthreadVCE$(DLL_VER).dll - -VCE-debug: - @ $(MAKE) /E /nologo EHFLAGS="$(VCEFLAGSD)" CLEANUP=__CLEANUP_CXX pthreadVCE$(DLL_VERD).dll - -VSE: - @ $(MAKE) /E /nologo EHFLAGS="$(VSEFLAGS)" CLEANUP=__CLEANUP_SEH pthreadVSE$(DLL_VER).dll - -VSE-debug: - @ $(MAKE) /E /nologo EHFLAGS="$(VSEFLAGSD)" CLEANUP=__CLEANUP_SEH pthreadVSE$(DLL_VERD).dll - -VC: - @ $(MAKE) /E /nologo EHFLAGS="$(VCFLAGS)" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VER).dll - -VC-debug: - @ $(MAKE) /E /nologo EHFLAGS="$(VCFLAGSD)" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VERD).dll - -# -# The so-called inlined DLL is just a single translation unit with -# inlining optimisation turned on. -# -VCE-inlined: - @ $(MAKE) /E /nologo EHFLAGS="$(VCEFLAGS) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_CXX pthreadVCE$(DLL_VER).stamp - -VCE-inlined-debug: - @ $(MAKE) /E /nologo EHFLAGS="$(VCEFLAGSD) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_CXX pthreadVCE$(DLL_VERD).stamp - -VSE-inlined: - @ $(MAKE) /E /nologo EHFLAGS="$(VSEFLAGS) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_SEH pthreadVSE$(DLL_VER).stamp - -VSE-inlined-debug: - @ $(MAKE) /E /nologo EHFLAGS="$(VSEFLAGSD) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_SEH pthreadVSE$(DLL_VERD).stamp - -VC-inlined: - @ $(MAKE) /E /nologo EHFLAGS="$(VCFLAGS) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VER).stamp - -VC-inlined-debug: - @ $(MAKE) /E /nologo EHFLAGS="$(VCFLAGSD) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VERD).stamp - -VC-static: - @ $(MAKE) /E /nologo EHFLAGS="$(VCFLAGS) /DPTW32_BUILD_INLINED /DPTW32_STATIC_LIB" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VER).static - -VC-static-debug: - @ $(MAKE) /E /nologo EHFLAGS="$(VCFLAGSD) /DPTW32_BUILD_INLINED /DPTW32_STATIC_LIB" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VERD).static - -realclean: clean - if exist pthread*.dll del pthread*.dll - if exist pthread*.lib del pthread*.lib - if exist *.manifest del *.manifest - if exist *.stamp del *.stamp - -clean: - if exist *.obj del *.obj - if exist *.def del *.def - if exist *.ilk del *.ilk - if exist *.pdb del *.pdb - if exist *.exp del *.exp - if exist *.map del *.map - if exist *.o del *.o - if exist *.i del *.i - if exist *.res del *.res - - -install: - copy pthread*.dll $(DLLDEST) - copy pthread*.lib $(LIBDEST) - copy pthread.h $(HDRDEST) - copy sched.h $(HDRDEST) - copy semaphore.h $(HDRDEST) - -$(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 - -$(STATIC_STAMPS): $(DLL_INLINED_OBJS) - if exist $*.lib del $*.lib - lib $(DLL_INLINED_OBJS) /out:$*.lib - -.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_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/vendor/pthreads/include/NEWS b/vendor/pthreads/include/NEWS deleted file mode 100644 index d1b789635f..0000000000 --- a/vendor/pthreads/include/NEWS +++ /dev/null @@ -1,1241 +0,0 @@ -RELEASE 2.9.0 -------------- -(2012-05-25) - -General -------- -New bug fixes in this release since 2.8.0 have NOT been applied to the -1.x.x series. - -Some changes post 2011-02-26 in CVS may not be compatible with pre -Windows 2000 systems. - -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 ------------------------- -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 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. -See README.NONPORTABLE for descriptions of these routines. -- Ramiro Polla - -Robust mutexes are implemented within the PROCESS_PRIVATE scope. NOTE that -pthread_mutex_* functions may return different error codes for robust -mutexes than they otherwise do in normal usage, e.g. pthread_mutex_unlock -is required to check ownership for all mutex types when the mutex is -robust, whereas this does not occur for the "normal" non-robust mutex type. -- Ross Johnson - -pthread_getunique_np is implemented for source level compatibility -with some other implementations. This routine returns a 64 bit -sequence number that is uniquely associated with a thread. It can be -used by applications to order or hash POSIX thread handles. -- Ross Johnson - -Bug fixes ---------- -Many more changes for 64 bit systems. -- Kai Tietz - -Various modifications and fixes to build and test for WinCE. -- Marcel Ruff, Sinan Kaya - -Fix pthread_cond_destroy() - should not be a cancellation point. Other -minor build problems fixed. -- Romano Paolo Tenca - -Remove potential deadlock condition from pthread_cond_destroy(). -- Eric Berge - -Various modifications to build and test for Win64. -- Kip Streithorst - -Various fixes to the QueueUserAPCEx async cancellation helper DLL -(this is a separate download) and pthreads code cleanups. -- Sebastian Gottschalk - -Removed potential NULL pointer reference. -- Robert Kindred - -Removed the requirement that applications restrict the number of threads -calling pthread_barrier_wait to just the barrier count. Also reduced the -contention between barrier_wait and barrier_destroy. This change will have -slowed barriers down slightly but halves the number of semaphores consumed -per barrier to one. -- Ross Johnson - -Fixed a handle leak in sched_[gs]etscheduler. -- Mark Pizzolato - -Removed all of the POSIX re-entrant function compatibility macros from pthread.h. -Some were simply not semanticly correct. -- Igor Lubashev - -Threads no longer attempt to pass uncaught exceptions out of thread scope (C++ -and SEH builds only). Uncaught exceptions now cause the thread to exit with -the return code PTHREAD_CANCELED. -- Ross Johnson - -Lots of casting fixes particularly for x64, Interlocked fixes and reworking -for x64. -- Daniel Richard G., John Kamp - -Other changes -------------- -Dependence on the winsock library is now discretionary via -#define RETAIN_WSALASTERROR in config.h. It is undefined by default unless -WINCE is defined (because RJ is unsure of the dependency there). -- Ramiro Polla - -Several static POSIX mutexes used for internal management were replaced by -MCS queue-based locks to reduce resource consumption, in particular use of Win32 -objects. -- Ross Johnson - -For security, the QuserEx.dll if used must now be installed in the Windows System -folder. -- Ross Johnson - -New tests ---------- -robust[1-5].c - Robust mutexes -sequence1.c - per-thread unique sequence numbers - -Modified tests and benchtests ------------------------------ -All mutex*.c tests wherever appropriate have been modified to also test -robust mutexes under the same conditions. -Added robust mutex benchtests to benchtest*.c wherever appropriate. - - -RELEASE 2.8.0 -------------- -(2006-12-22) - -General -------- -New bug fixes in this release since 2.7.0 have not been applied to the -version 1.x.x series. It is probably time to drop version 1. - -Testing and verification ------------------------- -This release has not yet been tested on SMP architechtures. All tests pass -on a uni-processor system. - -Bug fixes ---------- -Sem_destroy could return EBUSY even though no threads were waiting on the -semaphore. Other races around invalidating semaphore structs (internally) -have been removed as well. - -New tests ---------- -semaphore5.c - tests the bug fix referred to above. - - -RELEASE 2.7.0 -------------- -(2005-06-04) - -General -------- -All new features in this release have been back-ported in release 1.11.0, -including the incorporation of MCS locks in pthread_once, however, versions -1 and 2 remain incompatible even though they are now identical in -performance and functionality. - -Testing and verification ------------------------- -This release has been tested (passed the test suite) on both uni-processor -and multi-processor systems. -- Tim Theisen - -Bug fixes ---------- -Pthread_once has been re-implemented to remove priority boosting and other -complexity to improve robustness. Races for Win32 handles that are not -recycle-unique have been removed. The general form of pthread_once is now -the same as that suggested earlier by Alexander Terekhov, but instead of the -'named mutex', a queue-based lock has been implemented which has the required -properties of dynamic self initialisation and destruction. This lock is also -efficient. The ABI is unaffected in as much as the size of pthread_once_t has -not changed and PTHREAD_ONCE_INIT has not changed, however, applications that -peek inside pthread_once_t, which is supposed to be opaque, will break. -- Vladimir Kliatchko - -New features ------------- -* Support for Mingw cross development tools added to GNUmakefile. -Mingw cross tools allow building the libraries on Linux. -- Mikael Magnusson - - -RELEASE 2.6.0 -------------- -(2005-05-19) - -General -------- -All of the bug fixes and new features in this release have been -back-ported in release 1.10.0. - -Testing and verification ------------------------- -This release has been tested (passed the test suite) on both uni-processor -and multi-processor systems. Thanks to Tim Theisen at TomoTherapy for -exhaustively running the MP tests and for providing crutial observations -and data when faults are detected. - -Bugs fixed ----------- - -* pthread_detach() now reclaims remaining thread resources if called after -the target thread has terminated. Previously, this routine did nothing in -this case. - -New tests ---------- - -* detach1.c - tests that pthread_detach properly invalidates the target -thread, which indicates that the thread resources have been reclaimed. - - -RELEASE 2.5.0 -------------- -(2005-05-09) - -General -------- - -The package now includes a reference documentation set consisting of -HTML formatted Unix-style manual pages that have been edited for -consistency with Pthreads-w32. The set can also be read online at: -http://sources.redhat.com/pthreads-win32/manual/index.html - -Thanks again to Tim Theisen for running the test suite pre-release -on an MP system. - -All of the bug fixes and new features in this release have been -back-ported in release 1.9.0. - -Bugs fixed ----------- - -* Thread Specific Data (TSD) key management has been ammended to -eliminate a source of (what was effectively) resource leakage (a HANDLE -plus memory for each key destruct routine/thread association). This was -not a true leak because these resources were eventually reclaimed when -pthread_key_delete was run AND each thread referencing the key had exited. -The problem was that these two conditions are often not met until very -late, and often not until the process is about to exit. - -The ammended implementation avoids the need for the problematic HANDLE -and reclaims the memory as soon as either the key is deleted OR the -thread exits, whichever is first. - -Thanks to Richard Hughes at Aculab for identifying and locating the leak. - -* TSD key destructors are now processed up to PTHREAD_DESTRUCTOR_ITERATIONS -times instead of just once. PTHREAD_DESTRUCTOR_ITERATIONS has been -defined in pthread.h for some time but not used. - -* Fix a semaphore accounting race between sem_post/sem_post_multiple -and sem_wait cancellation. This is the same issue as with -sem_timedwait that was fixed in the last release. - -* sem_init, sem_post, and sem_post_multiple now check that the -semaphore count never exceeds _POSIX_SEM_VALUE_MAX. - -* Although sigwait() is nothing more than a no-op, it should at least -be a cancellation point to be consistent with the standard. - -New tests ---------- - -* stress1.c - attempts to expose problems in condition variable -and semaphore timed wait logic. This test was inspired by Stephan -Mueller's sample test code used to identify the sem_timedwait bug -from the last release. It's not a part of the regular test suite -because it can take awhile to run. To run it: -nmake clean VC-stress - -* tsd2.c - tests that key destructors are re-run if the tsd key value is -not NULL after the destructor routine has run. Also tests that -pthread_setspecific() and pthread_getspecific() are callable from -destructors. - - -RELEASE 2.4.0 -------------- -(2005-04-26) - -General -------- - -There is now no plan to release a version 3.0.0 to fix problems in -pthread_once(). Other possible implementations of pthread_once -will still be investigated for a possible future release in an attempt -to reduce the current implementation's complexity. - -All of the bug fixes and new features in this release have been -back-ported for release 1.8.0. - -Bugs fixed ----------- - -* Fixed pthread_once race (failures on an MP system). Thanks to -Tim Theisen for running exhaustive pre-release testing on his MP system -using a range of compilers: - VC++ 6 - VC++ 7.1 - Intel C++ version 8.0 -All tests passed. -Some minor speed improvements were also done. - -* Fix integer overrun error in pthread_mutex_timedlock() - missed when -sem_timedwait() was fixed in release 2.2.0. This routine no longer returns -ENOTSUP when NEED_SEM is defined - it is supported (NEED_SEM is only -required for WinCE versions prior to 3.0). - -* Fix timeout bug in sem_timedwait(). -- Thanks to Stephan Mueller for reporting, providing diagnostic output -and test code. - -* Fix several problems in the NEED_SEM conditionally included code. -NEED_SEM included code is provided for systems that don't implement W32 -semaphores, such as WinCE prior to version 3.0. An alternate implementation -of POSIX semaphores is built using W32 events for these systems when -NEED_SEM is defined. This code has been completely rewritten in this -release to reuse most of the default POSIX semaphore code, and particularly, -to implement all of the sem_* routines supported by pthreads-win32. Tim -Theisen also run the test suite over the NEED_SEM code on his MP system. All -tests passed. - -* The library now builds without errors for the Borland Builder 5.5 compiler. - -New features ------------- - -* pthread_mutex_timedlock() and all sem_* routines provided by -pthreads-win32 are now implemented for WinCE versions prior to 3.0. Those -versions did not implement W32 semaphores. Define NEED_SEM in config.h when -building the library for these systems. - -Known issues in this release ----------------------------- - -* pthread_once is too complicated - but it works as far as testing can -determine.. - -* The Borland version of the dll fails some of the tests with a memory read -exception. The cause is not yet known but a compiler bug has not been ruled -out. - - -RELEASE 2.3.0 -------------- -(2005-04-12) - -General -------- - -Release 1.7.0 is a backport of features and bug fixes new in -this release. See earlier notes under Release 2.0.0/General. - -Bugs fixed ----------- - -* Fixed pthread_once potential for post once_routine cancellation -hanging due to starvation. See comments in pthread_once.c. -Momentary priority boosting is used to ensure that, after a -once_routine is cancelled, the thread that will run the -once_routine is not starved by higher priority waiting threads at -critical times. Priority boosting occurs only AFTER a once_routine -cancellation, and is applied only to that once_control. The -once_routine is run at the thread's normal base priority. - -New tests ---------- - -* once4.c: Aggressively tests pthread_once() under realtime -conditions using threads with varying priorities. Windows' -random priority boosting does not occur for threads with realtime -priority levels. - - -RELEASE 2.2.0 -------------- -(2005-04-04) - -General -------- - -* Added makefile targets to build static link versions of the library. -Both MinGW and MSVC. Please note that this does not imply any change -to the LGPL licensing, which still imposes psecific conditions on -distributing software that has been statically linked with this library. - -* There is a known bug in pthread_once(). Cancellation of the init_routine -exposes a potential starvation (i.e. deadlock) problem if a waiting thread -has a higher priority than the initting thread. This problem will be fixed -in version 3.0.0 of the library. - -Bugs fixed ----------- - -* Fix integer overrun error in sem_timedwait(). -Kevin Lussier - -* Fix preprocessor directives for static linking. -Dimitar Panayotov - - -RELEASE 2.1.0 -------------- -(2005-03-16) - -Bugs fixed ----------- - -* Reverse change to pthread_setcancelstate() in 2.0.0. - - -RELEASE 2.0.0 -------------- -(2005-03-16) - -General -------- - -This release represents an ABI change and the DLL version naming has -incremented from 1 to 2, e.g. pthreadVC2.dll. - -Version 1.4.0 back-ports the new functionality included in this -release. Please distribute DLLs built from that version with updates -to applications built on pthreads-win32 version 1.x.x. - -The package naming has changed, replacing the snapshot date with -the version number + descriptive information. E.g. this -release is "pthreads-w32-2-0-0-release". - -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. - -New features ------------- - -* pthread_once() now supports init_routine cancellability. - -New tests ---------- - -* Agressively test pthread_once() init_routine cancellability. - - -SNAPSHOT 2005-03-08 -------------------- -Version 1.3.0 - -Bug reports (fixed) -------------------- - -* Implicitly created threads leave Win32 handles behind after exiting. -- Dmitrii Semii - -* pthread_once() starvation problem. -- Gottlob Frege - -New tests ---------- - -* More intense testing of pthread_once(). - - -SNAPSHOT 2005-01-25 -------------------- -Version 1.2.0 - -Bug fixes ---------- - -* Attempted acquisition of a recursive mutex could cause waiting threads -to not be woken when the mutex was released. -- Ralf Kubis - -* Various package omissions have been fixed. - - -SNAPSHOT 2005-01-03 -------------------- -Version 1.1.0 - -Bug fixes ---------- - -* Unlocking recursive or errorcheck mutexes would sometimes -unexpectedly return an EPERM error (bug introduced in -snapshot-2004-11-03). -- Konstantin Voronkov - - -SNAPSHOT 2004-11-22 -------------------- -Version 1.0.0 - -This snapshot primarily fixes the condvar bug introduced in -snapshot-2004-11-03. DLL versioning has also been included to allow -applications to runtime check the Microsoft compatible DLL version -information, and to extend the DLL naming system for ABI and major -(non-backward compatible) API changes. See the README file for details. - -Bug fixes ---------- - -* Condition variables no longer deadlock (bug introduced in -snapshot-2004-11-03). -- Alexander Kotliarov and Nicolas at saintmac - -* DLL naming extended to avoid 'DLL hell' in the future, and to -accommodate the ABI change introduced in snapshot-2004-11-03. Snapshot -2004-11-03 will be removed from FTP sites. - -New features ------------- - -* A Microsoft-style version resource has been added to the DLL for -applications that wish to check DLL compatibility at runtime. - -* Pthreads-win32 DLL naming has been extended to allow incompatible DLL -versions to co-exist in the same filesystem. See the README file for details, -but briefly: while the version information inside the DLL will change with -each release from now on, the DLL version names will only change if the new -DLL is not backward compatible with older applications. - -The versioning scheme has been borrowed from GNU Libtool, and the DLL -naming scheme is from Cygwin. Provided the Libtool-style numbering rules are -honoured, the Cygwin DLL naming scheme automatcally ensures that DLL name -changes are minimal and that applications will not load an incompatible -pthreads-win32 DLL. - -Those who use the pre-built DLLs will find that the DLL/LIB names have a new -suffix (1) in this snapshot. E.g. pthreadVC1.dll etc. - -* The POSIX thread ID reuse uniqueness feature introduced in the last snapshot -has been kept as default, but the behaviour can now be controlled when the DLL -is built to effectively switch it off. This makes the library much more -sensitive to applications that assume that POSIX thread IDs are unique, i.e. -are not strictly compliant with POSIX. See the PTW32_THREAD_ID_REUSE_INCREMENT -macro comments in config.h for details. - -Other changes -------------- -Certain POSIX macros have changed. - -These changes are intended to conform to the Single Unix Specification version 3, -which states that, if set to 0 (zero) or not defined, then applications may use -sysconf() to determine their values at runtime. Pthreads-win32 does not -implement sysconf(). - -The following macros are no longer undefined, but defined and set to -1 -(not implemented): - - _POSIX_THREAD_ATTR_STACKADDR - _POSIX_THREAD_PRIO_INHERIT - _POSIX_THREAD_PRIO_PROTECT - _POSIX_THREAD_PROCESS_SHARED - -The following macros are defined and set to 200112L (implemented): - - _POSIX_THREADS - _POSIX_THREAD_SAFE_FUNCTIONS - _POSIX_THREAD_ATTR_STACKSIZE - _POSIX_THREAD_PRIORITY_SCHEDULING - _POSIX_SEMAPHORES - _POSIX_READER_WRITER_LOCKS - _POSIX_SPIN_LOCKS - _POSIX_BARRIERS - -The following macros are defined and set to appropriate values: - - _POSIX_THREAD_THREADS_MAX - _POSIX_SEM_VALUE_MAX - _POSIX_SEM_NSEMS_MAX - PTHREAD_DESTRUCTOR_ITERATIONS - PTHREAD_KEYS_MAX - PTHREAD_STACK_MIN - PTHREAD_THREADS_MAX - - -SNAPSHOT 2004-11-03 -------------------- - -DLLs produced from this snapshot cannot be used with older applications without -recompiling the application, due to a change to pthread_t to provide unique POSIX -thread IDs. - -Although this snapshot passes the extended test suite, many of the changes are -fairly major, and some applications may show different behaviour than previously, -so adopt with care. Hopefully, any changed behaviour will be due to the library -being better at it's job, not worse. - -Bug fixes ---------- - -* pthread_create() no longer accepts NULL as the thread reference arg. -A segfault (memory access fault) will result, and no thread will be -created. - -* pthread_barrier_wait() no longer acts as a cancelation point. - -* Fix potential race condition in pthread_once() -- Tristan Savatier - -* Changes to pthread_cond_destroy() exposed some coding weaknesses in several -test suite mini-apps because pthread_cond_destroy() now returns EBUSY if the CV -is still in use. - -New features ------------- - -* Added for compatibility: -PTHREAD_RECURSIVE_MUTEX_INITIALIZER, -PTHREAD_ERRORCHECK_MUTEX_INITIALIZER, -PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, -PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP - -* Initial support for Digital Mars compiler -- Anuj Goyal - -* Faster Mutexes. These have been been rewritten following a model provided by -Alexander Terekhov that reduces kernel space checks, and eliminates some additional -critical sections used to manage a race between timedlock expiration and unlock. -Please be aware that the new mutexes do not enforce strict absolute FIFO scheduling -of mutexes, however any out-of-order lock acquisition should be very rare. - -* Faster semaphores. Following a similar model to mutexes above, these have been -rewritten to use preliminary users space checks. - -* sem_getvalue() now returns the number of waiters. - -* The POSIX thread ID now has much stronger uniqueness characteristics. The library -garrantees not to reuse the same thread ID for at least 2^(wordsize) thread -destruction/creation cycles. - -New tests ---------- - -* semaphore4.c: Tests cancelation of the new sem_wait(). - -* semaphore4t.c: Likewise for sem_timedwait(). - -* rwlock8.c: Tests and times the slow execution paths of r/w locks, and the CVs, -mutexes, and semaphores that they're built on. - - -SNAPSHOT 2004-05-16 -------------------- - -Attempt to add Watcom to the list of compilers that can build the library. -This failed in the end due to it's non-thread-aware errno. The library -builds but the test suite fails. See README.Watcom for more details. - -Bug fixes ---------- -* Bug and memory leak in sem_init() -- Alex Blanco - -* ptw32_getprocessors() now returns CPU count of 1 for WinCE. -- James Ewing - -* pthread_cond_wait() could be canceled at a point where it should not -be cancelable. Fixed. -- Alexander Terekhov - -* sem_timedwait() had an incorrect timeout calculation. -- Philippe Di Cristo - -* Fix a memory leak left behind after threads are destroyed. -- P. van Bruggen - -New features ------------- -* Ported to AMD64. -- Makoto Kato - -* True pre-emptive asynchronous cancelation 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 -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. -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 -feature is a welcome addition with respect to the library's conformance to -the POSIX standard. - -SNAPSHOT 2003-09-18 -------------------- - -Cleanup of thread priority management. In particular, setting of thread -priority now attempts to map invalid Win32 values within the range returned -by sched_get_priority_min/max() to useful values. See README.NONPORTABLE -under "Thread priority". - -Bug fixes ---------- -* pthread_getschedparam() now returns the priority given by the most recent -call to pthread_setschedparam() or established by pthread_create(), as -required by the standard. Previously, pthread_getschedparam() incorrectly -returned the running thread priority at the time of the call, which may have -been adjusted or temporarily promoted/demoted. - -* sched_get_priority_min() and sched_get_priority_max() now return -1 on error -and set errno. Previously, they incorrectly returned the error value directly. - - -SNAPSHOT 2003-09-04 -------------------- - -Bug fixes ---------- -* ptw32_cancelableWait() now allows cancelation of waiting implicit POSIX -threads. - -New test --------- -* cancel8.c tests cancelation of Win32 threads waiting at a POSIX cancelation -point. - - -SNAPSHOT 2003-09-03 -------------------- - -Bug fixes ---------- -* pthread_self() would free the newly created implicit POSIX thread handle if -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 ---------------------------------------------------------- -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 -deferred). Now it does. - -Any thread can be canceled by any other thread (Win32 or POSIX) if the former -thread's POSIX pthread_t value is known. It's TSD destructors and POSIX -cleanup handlers will be run before the thread exits with an exit code of -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). - -By adding cancelation, 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. - -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 -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 -necessary and return the pthread_t value. - -New tests ---------- -Test the above new feature. - - -SNAPSHOT 2003-08-19 -------------------- - -This snapshot fixes some accidental corruption to new test case sources. -There are no changes to the library source code. - - -SNAPSHOT 2003-08-15 -------------------- - -Bug fixes ---------- - -* pthread.dsp now uses correct compile flags (/MD). -- Viv - -* pthread_win32_process_detach_np() fixed memory leak. -- Steven Reddie - -* pthread_mutex_destroy() fixed incorrect return code. -- Nicolas Barry - -* pthread_spin_destroy() fixed memory leak. -- Piet van Bruggen - -* Various changes to tighten arg checking, and to work with later versions of -MinGW32 and MsysDTK. - -* pthread_getschedparam() etc, fixed dangerous thread validity checking. -- Nicolas Barry - -* POSIX thread handles are now reused and their memory is not freed on thread exit. -This allows for stronger thread validity checking. - -New standard routine --------------------- - -* pthread_kill() added to provide thread validity checking to applications. -It does not accept any non zero values for the signal arg. - -New test cases --------------- - -* New test cases to confirm validity checking, pthread_kill(), and thread reuse. - - -SNAPSHOT 2003-05-10 -------------------- - -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. -- Thomas Pfaff - -* pthread_mutex_timedlock() no longer occasionally sets incorrect mutex -ownership, causing deadlocks in some applications. -- Robert Strycek and Alexander Terekhov - - -SNAPSHOT 2002-11-04 -------------------- - -Bug fixes ---------- - -* sem_getvalue() now returns the correct value under Win NT and WinCE. -- Rob Fanner - -* sem_timedwait() now uses tighter checks for unreasonable -abstime values - that would result in unexpected timeout values. - -* ptw32_cond_wait_cleanup() no longer mysteriously consumes -CV signals but may produce more spurious wakeups. It is believed -that the sem_timedwait() call is consuming a CV signal that it -shouldn't. -- Alexander Terekhov - -* Fixed a memory leak in ptw32_threadDestroy() for implicit threads. - -* Fixed potential for deadlock in pthread_cond_destroy(). -A deadlock could occur for statically declared CVs (PTHREAD_COND_INITIALIZER), -when one thread is attempting to destroy the condition variable while another -is attempting to dynamically initialize it. -- Michael Johnson - - -SNAPSHOT 2002-03-02 -------------------- - -Cleanup code default style. (IMPORTANT) ----------------------------------------------------------------------- -Previously, if not defined, the cleanup style was determined automatically -from the compiler/language, 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(). - -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, -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 -may be an exception (no pun intended) and possible future trend. - -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 - -E.g. regardless of whether your app is C or C++, if you link with -pthreadVC.lib or libpthreadGC.a, then you must define __CLEANUP_C. - - -THE POINT OF ALL THIS IS: if you have not been defining one of these -explicitly, then the defaults as described at the top of this -section were being used. - -THIS NOW CHANGES, as has been explained above, but to try to make this -clearer here's an example: - -If you were building your application with MSVC++ i.e. using C++ -exceptions and not explicitly defining one of __CLEANUP_*, then -__CLEANUP_C++ was automatically 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 -automatically 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, or 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 locally -instantiated 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. - - -WHY ARE WE MAKING THE DEFAULT STYLE LESS EXCEPTION-FRIENDLY? -Because no commercial Unix POSIX threads implementation allows you to -choose to have stack unwinding. Therefore, providing it in pthread-win32 -as a default is dangerous. We still provide the choice but unless -you consciously choose to do otherwise, your pthreads applications will -now run or crash in similar ways irrespective of the threads platform -you use. Or at least this is the hope. - - -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, for unconditional conformity to other implementations.) -- 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. - - -Source module splitting ------------------------ -In order to enable smaller image sizes to be generated -for applications that link statically with the library, -most routines have been separated out into individual -source code files. - -This is being done in such a way as to be backward compatible. -The old source files are reused to congregate the individual -routine files into larger translation units (via a bunch of -# includes) so that the compiler can still optimise wherever -possible, e.g. through inlining, which can only be done -within the same translation unit. - -It is also possible to build the entire library by compiling -the single file named "pthread.c", which just #includes all -the secondary congregation source files. The compiler -may be able to use this to do more inlining of routines. - -Although the GNU compiler is able to produce libraries with -the necessary separation (the -ffunction-segments switch), -AFAIK, the MSVC and other compilers don't have this feature. - -Finally, since I use makefiles and command-line compilation, -I don't know what havoc this reorganisation may wreak amongst -IDE project file users. You should be able to continue -using your existing project files without modification. - - -New non-portable functions --------------------------- -pthread_num_processors_np(): - Returns the number of processors in the system that are - available to the process, as determined from the processor - affinity mask. - -pthread_timechange_handler_np(): - To improve tolerance against operator or time service initiated - system clock changes. - - This routine can be called by an application when it - receives a WM_TIMECHANGE message from the system. At present - it broadcasts all condition variables so that waiting threads - can wake up and re-evaluate their conditions and restart - their timed waits if required. - - Suggested by Alexander Terekhov - - -Platform dependence -------------------- -As Win95 doesn't provide one, the library now contains -it's own InterlockedCompareExchange() routine, which is used -whenever Windows doesn't provide it. InterlockedCompareExchange() -is used to implement spinlocks and barriers, and also in mutexes. -This routine relies on the CMPXCHG machine instruction which -is not available on i386 CPUs. This library (from snapshot -20010712 onwards) is therefore no longer supported on i386 -processor platforms. - - -New standard routines ---------------------- -For source code portability only - rwlocks cannot be process shared yet. - - pthread_rwlockattr_init() - pthread_rwlockattr_destroy() - pthread_rwlockattr_setpshared() - pthread_rwlockattr_getpshared() - -As defined in the new POSIX standard, and the Single Unix Spec version 3: - - sem_timedwait() - pthread_mutex_timedlock() - Alexander Terekhov and Thomas Pfaff - pthread_rwlock_timedrdlock() - adapted from pthread_rwlock_rdlock() - pthread_rwlock_timedwrlock() - adapted from pthread_rwlock_wrlock() - - -pthread.h no longer includes windows.h --------------------------------------- -[Not yet for G++] - -This was done to prevent conflicts. - -HANDLE, DWORD, and NULL are temporarily defined within pthread.h if -they are not already. - - -pthread.h, sched.h and semaphore.h now use dllexport/dllimport --------------------------------------------------------------- -Not only to avoid the need for the pthread.def file, but to -improve performance. Apparently, declaring functions with dllimport -generates a direct call to the function and avoids the overhead -of a stub function call. - -Bug fixes ---------- -* Fixed potential NULL pointer dereferences in pthread_mutexattr_init, -pthread_mutexattr_getpshared, pthread_barrierattr_init, -pthread_barrierattr_getpshared, and pthread_condattr_getpshared. -- Scott McCaskill - -* Removed potential race condition in pthread_mutex_trylock and -pthread_mutex_lock; -- Alexander Terekhov - -* The behaviour of pthread_mutex_trylock in relation to -recursive mutexes was inconsistent with commercial implementations. -Trylock would return EBUSY if the lock was owned already by the -calling thread regardless of mutex type. Trylock now increments the -recursion count and returns 0 for RECURSIVE mutexes, and will -return EDEADLK rather than EBUSY for ERRORCHECK mutexes. This is -consistent with Solaris. -- Thomas Pfaff - -* Found a fix for the library and workaround for applications for -the known bug #2, i.e. where __CLEANUP_CXX or __CLEANUP_SEH is defined. -See the "Known Bugs in this snapshot" section below. - -This could be made transparent to applications by replacing the macros that -define the current C++ and SEH versions of pthread_cleanup_push/pop -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 -return an error (ESRCH). - -* errno: An incorrect compiler directive caused a local version -of errno to be used instead of the Win32 errno. Both instances are -thread-safe but applications checking errno after a pthreads-win32 -call would be wrong. Fixing this also fixed a bad compiler -option in the testsuite (/MT should have been /MD) which is -needed to link with the correct library MSVCRT.LIB. - - -SNAPSHOT 2001-07-12 -------------------- - -To be added - - -SNAPSHOT 2001-07-03 -------------------- - -To be added - - -SNAPSHOT 2000-08-13 -------------------- - -New: -- Renamed DLL and LIB files: - pthreadVSE.dll (MS VC++/Structured EH) - pthreadVSE.lib - pthreadVCE.dll (MS VC++/C++ EH) - pthreadVCE.lib - pthreadGCE.dll (GNU G++/C++ EH) - libpthreadw32.a - - Both your application and the pthread dll should use the - same exception handling scheme. - -Bugs fixed: -- MSVC++ C++ exception handling. - -Some new tests have been added. - - -SNAPSHOT 2000-08-10 -------------------- - -New: -- asynchronous cancelation on X86 (Jason Nye) -- Makefile compatible with MS nmake to replace - buildlib.bat -- GNUmakefile for Mingw32 -- tests/Makefile for MS nmake replaces runall.bat -- tests/GNUmakefile for Mingw32 - -Bugs fixed: -- kernel32 load/free problem -- attempt to hide internel exceptions from application - exception handlers (__try/__except and try/catch blocks) -- Win32 thread handle leakage bug - (David Baggett/Paul Redondo/Eyal Lebedinsky) - -Some new tests have been added. - - -SNAPSHOT 1999-11-02 -------------------- - -Bugs fixed: -- ctime_r macro had an incorrect argument (Erik Hensema), -- threads were not being created - PTHREAD_CANCEL_DEFERRED. This should have - had little effect as deferred is the only - supported type. (Ross Johnson). - -Some compatibility improvements added, eg. -- pthread_setcancelstate accepts NULL pointer - for the previous value argument. Ditto for - pthread_setcanceltype. This is compatible - with Solaris but should not affect - standard applications (Erik Hensema) - -Some new tests have been added. - - -SNAPSHOT 1999-10-17 -------------------- - -Bug fix - Cancelation of threads waiting on condition variables -now works properly (Lorin Hochstein and Peter Slacik) - - -SNAPSHOT 1999-08-12 -------------------- - -Fixed exception stack cleanup if calling pthread_exit() -- (Lorin Hochstein and John Bossom). - -Fixed bugs in condition variables - (Peter Slacik): - - additional contention checks - - properly adjust number of waiting threads after timed - condvar timeout. - - -SNAPSHOT 1999-05-30 -------------------- - -Some minor bugs have been fixed. See the ChangeLog file for details. - -Some more POSIX 1b functions are now included but ony return an -error (ENOSYS) if called. They are: - - sem_open - sem_close - sem_unlink - sem_getvalue - - -SNAPSHOT 1999-04-07 -------------------- - -Some POSIX 1b functions which were internally supported are now -available as exported functions: - - sem_init - sem_destroy - sem_wait - sem_trywait - sem_post - sched_yield - sched_get_priority_min - sched_get_priority_max - -Some minor bugs have been fixed. See the ChangeLog file for details. - - -SNAPSHOT 1999-03-16 -------------------- - -Initial release. - diff --git a/vendor/pthreads/include/Nmakefile b/vendor/pthreads/include/Nmakefile deleted file mode 100644 index d9e5bf1bc7..0000000000 --- a/vendor/pthreads/include/Nmakefile +++ /dev/null @@ -1,24 +0,0 @@ -/* - * nmake file for uwin pthread library - */ - -VERSION = - -CCFLAGS = -V -g $(CC.DLL) -HAVE_PTW32_CONFIG_H == 1 -_MT == 1 -_timeb == timeb -_ftime == ftime -_errno == _ast_errno - -$(INCLUDEDIR) :INSTALLDIR: pthread.h sched.h - -pthread $(VERSION) :LIBRARY: attr.c barrier.c cancel.c cleanup.c condvar.c \ - create.c dll.c exit.c fork.c global.c misc.c mutex.c private.c \ - rwlock.c sched.c semaphore.c spin.c sync.c tsd.c nonportable.c - -:: ANNOUNCE CONTRIBUTORS COPYING.LIB ChangeLog FAQ GNUmakefile MAINTAINERS \ - Makefile Makefile.in Makefile.vc NEWS PROGRESS README README.WinCE \ - TODO WinCE-PORT install-sh errno.c tests tests.mk acconfig.h \ - config.guess config.h.in config.sub configure configure.in signal.c \ - README.CV README.NONPORTABLE pthread.dsp pthread.dsw - diff --git a/vendor/pthreads/include/Nmakefile.tests b/vendor/pthreads/include/Nmakefile.tests deleted file mode 100644 index 203560b6cb..0000000000 --- a/vendor/pthreads/include/Nmakefile.tests +++ /dev/null @@ -1,260 +0,0 @@ -/* for running tests */ -CCFLAGS = -g -_MT == 1 -_timeb == timeb -_ftime == ftime - -.SOURCE: tests -/* -:PACKAGE: pthread -*/ - -set keepgoing - -":test:" : .MAKE .OPERATOR - local I - $(<:D:B:S=.pass) : .IMPLICIT $(>:D:B:S=.pass) - for I $(<) $(>) - $(I:D:B:S=.pass) : .VIRTUAL .FORCE $(I) - $(>) - end -sizes:: sizes.c -loadfree:: loadfree.c -mutex1:: mutex1.c -mutex1e:: mutex1e.c -mutex1n:: mutex1n.c -mutex1r:: mutex1r.c -mutex2:: mutex2.c -mutex2r:: mutex2r.c -mutex2e:: mutex2e.c -exit1:: exit1.c -condvar1:: condvar1.c -condvar1_1:: condvar1_1.c -condvar1_2:: condvar1_2.c -self1:: self1.c -condvar2:: condvar2.c -condvar2_1:: condvar2_1.c -condvar3_1:: condvar3_1.c -condvar3_2:: condvar3_2.c -condvar3_3:: condvar3_3.c -create1.:: create1.c -create2.:: create2.c -cancel1:: cancel1.c -cancel2:: cancel2.c -mutex3:: mutex3.c -mutex3r:: mutex3r.c -mutex3e:: mutex3e.c -mutex4:: mutex4.c -mutex5:: mutex5.c -mutex6:: mutex6.c -mutex6e:: mutex6e.c -mutex6n:: mutex6n.c -mutex6r:: mutex6r.c -mutex7:: mutex7.c -mutex6s:: mutex6s.c -mutex6rs:: mutex6rs.c -mutex6es:: mutex6es.c -mutex7e:: mutex7e.c -mutex7n:: mutex7n.c -mutex7r:: mutex7r.c -mutex8:: mutex8.c -mutex8e:: mutex8e.c -mutex8n:: mutex8n.c -mutex8r:: mutex8r.c -equal1:: equal1.c -exit2:: exit2.c -exit3:: exit3.c -exit4:: exit4.c -exit5:: exit5.c -join0:: join0.c -join1:: join1.c -join2:: join2.c -join3:: join3.c -kill1:: kill1.c -count1:: count1.c -once1:: once1.c -tsd1:: tsd1.c -self2:: self2.c -eyal1:: eyal1.c -condvar3:: condvar3.c -condvar4:: condvar4.c -condvar5:: condvar5.c -condvar6:: condvar6.c -condvar7:: condvar7.c -condvar8:: condvar8.c -condvar9:: condvar9.c -errno1:: errno1.c -reuse1.:: reuse1.c -reuse2.:: reuse2.c -rwlock1:: rwlock1.c -rwlock2:: rwlock2.c -rwlock3:: rwlock3.c -rwlock4:: rwlock4.c -rwlock5:: rwlock5.c -rwlock6:: rwlock6.c -rwlock7:: rwlock7.c -rwlock8:: rwlock8.c -rwlock2_t:: rwlock2_t.c -rwlock3_t:: rwlock3_t.c -rwlock4_t:: rwlock4_t.c -rwlock5_t:: rwlock5_t.c -rwlock6_t:: rwlock6_t.c -rwlock6_t2:: rwlock6_t2.c -semaphore1:: semaphore1.c -semaphore2:: semaphore2.c -semaphore3:: semaphore3.c -context1:: context1.c -cancel3:: cancel3.c -cancel4:: cancel4.c -cancel5:: cancel5.c -cancel6a:: cancel6a.c -cancel6d:: cancel6d.c -cancel7:: cancel7.c -cleanup0:: cleanup0.c -cleanup1:: cleanup1.c -cleanup2:: cleanup2.c -cleanup3:: cleanup3.c -priority1:: priority1.c -priority2:: priority2.c -inherit1:: inherit1.c -spin1:: spin1.c -spin2:: spin2.c -spin3:: spin3.c -spin4:: spin4.c -barrier1:: barrier1.c -barrier2:: barrier2.c -barrier3:: barrier3.c -barrier4:: barrier4.c -barrier5:: barrier5.c -exception1:: exception1.c -exception2:: exception2.c -exception3:: exception3.c -benchtest1:: benchtest1.c -benchtest2:: benchtest2.c -benchtest3:: benchtest3.c -benchtest4:: benchtest4.c -benchtest5:: benchtest5.c -valid1:: valid1.c -valid2:: valid2.c -cancel9:: cancel9.c - -sizes: :test: sizes -loadfree: :test: -mutex5 :test: loadfree -mutex1 :test: loadfree -mutex1n :test: loadfree -mutex1r :test: loadfree -mutex1e :test: loadfree -semaphore1 :test: loadfree -semaphore2 :test: loadfree -semaphore3 :test: loadfree -mutex2 :test: loadfree -mutex2r :test: loadfree -mutex2e :test: loadfree -exit1 :test: loadfree -condvar1 :test: loadfree -kill1 :test: loadfree -condvar1_1 :test: condvar1 -condvar1_2 :test: join2 -self1 :test: loadfree -condvar2 :test: condvar1 -condvar2_1 :test: condvar2 -create1 :test: mutex2 -create2 :test: create1 -reuse1 :test: create2 -reuse2 :test: reuse1 -cancel1 :test: create1 -cancel2 :test: cancel1 -mutex3 :test: create1 -mutex3r :test: create1 -mutex3e :test: create1 -mutex4 :test: mutex3 -mutex6 :test: mutex4 -mutex6n :test: mutex4 -mutex6e :test: mutex4 -mutex6r :test: mutex4 -mutex6s :test: mutex6 -mutex6rs :test: mutex6r -mutex6es :test: mutex6e -mutex7 :test: mutex6 -mutex7n :test: mutex6n -mutex7e :test: mutex6e -mutex7r :test: mutex6r -mutex8 :test: mutex7 -mutex8n :test: mutex7n -mutex8e :test: mutex7e -mutex8r :test: mutex7r -equal1 :test: create1 -exit2 :test: create1 -exit3 :test: create1 -exit4 :test: kill1 -exit5 :test: exit4 -join0 :test: create1 -join1 :test: create1 -join2 :test: create1 -join3 :test: join2 -count1 :test: join1 -once1 :test: create1 -tsd1 :test: join1 -self2 :test: create1 -eyal1 :test: tsd1 -condvar3 :test: create1 -condvar3_1 :test: condvar3 -condvar3_2 :test: condvar3_1 -condvar3_3 :test: condvar3_2 -condvar4 :test: create1 -condvar5 :test: condvar4 -condvar6 :test: condvar5 -condvar7 :test: condvar6 cleanup1 -condvar8 :test: condvar7 -condvar9 :test: condvar8 -errno1 :test: mutex3 -rwlock1 :test: condvar6 -rwlock2 :test: rwlock1 -rwlock3 :test: rwlock2 -rwlock4 :test: rwlock3 -rwlock5 :test: rwlock4 -rwlock6 :test: rwlock5 -rwlock7 :test: rwlock6 -rwlock8 :test: rwlock7 -rwlock2_t :test: rwlock2 -rwlock3_t :test: rwlock2_t -rwlock4_t :test: rwlock3_t -rwlock5_t :test: rwlock4_t -rwlock6_t :test: rwlock5_t -rwlock6_t2 :test: rwlock6_t -context1 :test: cancel2 -cancel3 :test: context1 -cancel4 :test: cancel3 -cancel5 :test: cancel3 -cancel6a :test: cancel3 -cancel6d :test: cancel3 -cancel7 :test: kill1 -cleanup0 :test: cancel5 -cleanup1 :test: cleanup0 -cleanup2 :test: cleanup1 -cleanup3 :test: cleanup2 -priority1 :test: join1 -priority2 :test: priority1 -inherit1 :test: join1 -spin1 :test: -spin2 :test: spin1.c -spin3 :test: spin2.c -spin4 :test: spin3.c -barrier1 :test: -barrier2 :test: barrier1.c -barrier3 :test: barrier2.c -barrier4 :test: barrier3.c -barrier5 :test: barrier4.c -benchtest1 :test: mutex3 -benchtest2 :test: benchtest1 -benchtest3 :test: benchtest2 -benchtest4 :test: benchtest3 -benchtest5 :test: benchtest4 -exception1 :test: cancel4 -exception2 :test: exception1 -exception3 :test: exception2 -exit4 :test: exit3 -valid1 :test: join1 -valid2 :test: valid1 -cancel9 :test: cancel8 diff --git a/vendor/pthreads/include/PROGRESS b/vendor/pthreads/include/PROGRESS deleted file mode 100644 index 9abf0bca47..0000000000 --- a/vendor/pthreads/include/PROGRESS +++ /dev/null @@ -1,4 +0,0 @@ -Please see the ANNOUNCE file "Level of Standards Conformance" -or the web page: - -http://sources.redhat.com/pthreads-win32/conformance.html diff --git a/vendor/pthreads/include/README b/vendor/pthreads/include/README deleted file mode 100644 index 545360bfa7..0000000000 --- a/vendor/pthreads/include/README +++ /dev/null @@ -1,601 +0,0 @@ -PTHREADS-WIN32 -============== - -Pthreads-win32 is free software, distributed under the GNU Lesser -General Public License (LGPL). See the file 'COPYING.LIB' for terms -and conditions. Also see the file 'COPYING' for information -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 -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). - -See the file "ANNOUNCE" for more information including standards -conformance details and the list of supported and unsupported -routines. - - -Prerequisites -------------- -MSVC or GNU C (MinGW32 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. - This library is not required otherwise. - - For true async cancelation 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 - self-unpacking ZIP, and on the pthreads-win32 FTP site (in source - and pre-built forms). Currently this is a separate LGPL package to - pthreads-win32. See the README in the QueueUserAPCEx folder for - installation instructions. - - 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 - are runnable. The simulated async cancellation cannot cancel blocked - threads. - - [FOR SECURITY] To be found Quserex.dll MUST be installed in the - Windows System Folder. This is not an unreasonable constraint given a - driver must also be installed and loaded at system startup. - - -Library naming --------------- - -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 was to also name either the VC or GC -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. - -In general: - pthread[VG]{SE,CE,C}[c].dll - pthread[VG]{SE,CE,C}[c].lib - -where: - [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 - - c - DLL compatibility number indicating ABI and API - compatibility with applications built against - a snapshot with the same compatibility number. - See 'Version numbering' below. - -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). - -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) - -The GNU library archive file names have correspondingly changed to: - - libpthreadGCEc.a - libpthreadGCc.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. - -See 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. -The fourth is commonly used for the build number, but will be reserved -for future use. - - current.revision.age.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. - - -DLL compatibility numbering is an attempt to ensure that applications -always load a compatible pthreads-win32 DLL by using a DLL naming system -that is consistent with the version numbering system. It also allows -older and newer DLLs to coexist in the same filesystem so that older -applications can continue to be used. For pre .NET Windows systems, -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.) - -Using this method, 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. - - -Which of the several dll versions to use? ------------------------------------------ -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. - -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 -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] - -1. [See also the discussion in the FAQ file - Q2, Q4, and Q5] - -If your application contains catch(...) blocks in your POSIX -threads then you will need to replace the "catch(...)" with the macro -"PtW32Catch", eg. - - #ifdef PtW32Catch - PtW32Catch { - ... - } - #else - catch(...) { - ... - } - #endif - -Otherwise neither pthreads cancelation 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. - - -Other name changes ------------------- - -All snapshots prior to and including snapshot 2000-08-13 -used "_pthread_" as the prefix to library internal -functions, and "_PTHREAD_" to many library internal -macros. These have now been changed to "ptw32_" and "PTW32_" -respectively so as to not conflict with the ANSI standard's -reservation of identifiers beginning with "_" and "__" for -use by compiler implementations only. - -If you have written any applications and you are linking -statically with the pthreads-win32 library then you may have -included a call to _pthread_processInitialize. You will -now have to change that to ptw32_processInitialize. - - -Cleanup code default style --------------------------- - -Previously, 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 short, the exceptions versions of the library throw an exception -when a thread is canceled, or exits via pthread_exit(). This exception 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(). - -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, -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 - -It is recommended that you let pthread.h use it's default __CLEANUP_C -for both library and application builds. That is, don't define any of -the above, and then link with pthreadVC.lib (MSVC or MSVC++) and -libpthreadGC.a (MinGW GCC or G++). The reason is explained below, but -another reason is that the prebuilt pthreadVCE.dll is currently broken. -Versions built with MSVC++ later than version 6 may not be broken, but I -can't verify this yet. - -WHY ARE WE MAKING THE DEFAULT STYLE LESS EXCEPTION-FRIENDLY? -Because no commercial Unix POSIX threads implementation allows you to -choose to have stack unwinding. Therefore, providing it in pthread-win32 -as a default is dangerous. We still provide the choice but unless -you consciously choose to do otherwise, your pthreads applications will -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 ----------------------------------------------------------- - -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. - -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) - - -The pre-built dlls are normally built using the *-inlined targets. - -You can run the testsuite by changing to the "tests" directory and -running nmake. E.g.: - -$ cd tests -$ nmake - -Microsoft (R) Program Maintenance Utility Version 6.00.8168.0 -Copyright (C) Microsoft Corp 1988-1998. All rights reserved. - -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) - - -Building under Mingw32 ----------------------- - -The dll can be built easily with recent versions of Mingw32. -(The distributed versions are built using Mingw32 and MsysDTK -from www.mingw32.org.) - -From the source directory, run make for help information. E.g.: - -$ 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) - - -The pre-built dlls are normally built using the *-inlined targets. - -You can run the testsuite by changing to the "tests" directory and -running make for help information. 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) - - -Building under Linux using the Mingw32 cross development tools --------------------------------------------------------------- - -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: - -make CROSS=i386-mingw32msvc- clean GC-inlined - -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 -at the URL above). - - -Building the library as a statically linkable library ------------------------------------------------------ - -General: PTW32_STATIC_LIB must be defined for both the library build and the -application build. The makefiles supplied and used by the following 'make' -command lines will define this for you. - -MSVC (creates pthreadVCn.lib as a static link lib): - -nmake clean VC-static - - -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. - - -Building the library under Cygwin ---------------------------------- - -Cygwin is implementing it's own POSIX threads routines and these -will be the ones to use if you develop using Cygwin. - - -Ready to run binaries ---------------------- - -For convenience, the following ready-to-run files can be downloaded -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. - - -Building applications with GNU compilers ----------------------------------------- - -If you're using pthreadGC.dll: - -With the three header files, pthreadGC.dll and libpthreadGC.a in the -same directory as your application myapp.c, you could compile, link -and run myapp.c under Mingw32 as follows: - - gcc -o myapp.exe myapp.c -I. -L. -lpthreadGC - myapp - -Or put pthreadGC.dll in an appropriate directory in your PATH, -put libpthreadGC.a in your system lib directory, and -put the three header files in your system include directory, -then use: - - gcc -o myapp.exe myapp.c -lpthreadGC - myapp - - -If you're using pthreadGCE.dll: - -With the three header files, pthreadGCE.dll, gcc.dll and libpthreadGCE.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 - myapp - -Or put pthreadGCE.dll and gcc.dll in an appropriate directory in -your PATH, put libpthreadGCE.a in your system lib directory, and -put the three header files in your system include directory, -then use: - - gcc -x c++ -o myapp.exe myapp.c -lpthreadGCE - myapp - - -Availability ------------- - -The complete source code in either unbundled, self-extracting -Zip file, or tar/gzipped format can be found at: - - ftp://sources.redhat.com/pub/pthreads-win32 - -The pre-built DLL, export libraries and matching pthread.h can -be found at: - - ftp://sources.redhat.com/pub/pthreads-win32/dll-latest - -Home page: - - http://sources.redhat.com/pthreads-win32/ - - -Mailing list ------------- - -There is a mailing list for discussing pthreads on Win32. -To join, send email to: - - pthreads-win32-subscribe@sources.redhat.com - -Unsubscribe by sending mail to: - - pthreads-win32-unsubscribe@sources.redhat.com - - -Acknowledgements ----------------- - -See the ANNOUNCE file for acknowledgements. -See the 'CONTRIBUTORS' file for the list of contributors. - -As much as possible, the ChangeLog file attributes -contributions and patches that have been incorporated -in the library to the individuals responsible. - -Finally, thanks to all those who work on and contribute to the -POSIX and Single Unix Specification standards. The maturity of an -industry can be measured by it's open standards. - ----- -Ross Johnson - - - - - - - - - diff --git a/vendor/pthreads/include/README.Borland b/vendor/pthreads/include/README.Borland deleted file mode 100644 index a130d2bd27..0000000000 --- a/vendor/pthreads/include/README.Borland +++ /dev/null @@ -1,57 +0,0 @@ -In ptw32_InterlockedCompareExchange.c, I've added a section for -Borland's compiler; it's identical to that for the MS compiler except -that it uses /* ... */ comments instead of ; comments. - -[RPJ: need to define HAVE_TASM32 in config.h to use the above.] - - -The other file is a makefile suitable for use with Borland's compiler -(run "make -fBmakefile" in the directory). It builds a single version -of the library, pthreadBC.dll and the corresponding pthreadBC.lib -import library, which is comparable to the pthreadVC version; I can't -personally see any demand for the versions that include structured or -C++ exception cancellation handling so I haven't attempted to build -those versions of the library. (I imagine a static version might be -of use to some, but we can't legally use that on my commercial -projects so I can't try that out, unfortunately.) - -[RPJ: Added tests\Bmakefile as well.] - -Borland C++ doesn't define the ENOSYS constant used by pthreads-win32; -rather than make more extensive patches to the pthreads-win32 source I -have a mostly-arbitrary constant for it in the makefile. However this -doesn't make it visible to the application using the library, so if -anyone actually wants to use this constant in their apps (why?) -someone might like to make a seperate NEED_BCC_something define to add -this stuff. - -The makefile also #defines EDEADLK as EDEADLOCK, _timeb as timeb, and -_ftime as ftime, to deal with the minor differences between the two -RTLs' naming conventions, and sets the compiler flags as required to -get a normal compile of the library. - -[RPJ: Moved errno values and _timeb etc to pthread.h, so apps will also -use them.] - -(While I'm on the subject, the reason Borland users should recompile -the library, rather than using the impdef/implib technique suggested -previously on the mailing list, is that a) the errno constants are -different, so the results returned by the pthread_* functions can be -meaningless, and b) the errno variable/pseudo-variable itself is -different in the MS & BCC runtimes, so you can't access the -pthreadVC's errno from a Borland C++-compiled host application -correctly - I imagine there are other potential problems from the RTL -mismatch too.) - -[RPJ: Make sure you use the same RTL in both dll and application builds. -The dll and tests Bmakefiles use cw32mti.lib. Having some trouble with -memory read exceptions running the test suite using BCC55.] - -Best regards, -Will - --- -Will Bryant -Systems Architect, eCOSM Limited -Cell +64 21 655 443, office +64 3 365 4176 -http://www.ecosm.com/ diff --git a/vendor/pthreads/include/README.CV b/vendor/pthreads/include/README.CV deleted file mode 100644 index 698728b95b..0000000000 --- a/vendor/pthreads/include/README.CV +++ /dev/null @@ -1,3036 +0,0 @@ -README.CV -- Condition Variables --------------------------------- - -The original implementation of condition variables in -pthreads-win32 was based on a discussion paper: - -"Strategies for Implementing POSIX Condition Variables -on Win32": http://www.cs.wustl.edu/~schmidt/win32-cv-1.html - -The changes suggested below were made on Feb 6 2001. This -file is included in the package for the benefit of anyone -interested in understanding the pthreads-win32 implementation -of condition variables and the (sometimes subtle) issues that -it attempts to resolve. - -Thanks go to the individuals whose names appear throughout -the following text. - -Ross Johnson - --------------------------------------------------------------------- - -fyi.. (more detailed problem description/demos + possible fix/patch) - -regards, -alexander. - - -Alexander Terekhov -31.01.2001 17:43 - -To: ace-bugs@cs.wustl.edu -cc: -From: Alexander Terekhov/Germany/IBM@IBMDE -Subject: Implementation of POSIX CVs: spur.wakeups/lost - signals/deadlocks/unfairness - - - - ACE VERSION: - - 5.1.12 (pthread-win32 snapshot 2000-12-29) - - HOST MACHINE and OPERATING SYSTEM: - - IBM IntelliStation Z Pro, 2 x XEON 1GHz, Win2K - - TARGET MACHINE and OPERATING SYSTEM, if different from HOST: - COMPILER NAME AND VERSION (AND PATCHLEVEL): - - Microsoft Visual C++ 6.0 - - AREA/CLASS/EXAMPLE AFFECTED: - - Implementation of POSIX condition variables - OS.cpp/.h - - DOES THE PROBLEM AFFECT: - - EXECUTION? YES! - - SYNOPSIS: - - a) spurious wakeups (minor problem) - b) lost signals - c) broadcast deadlock - d) unfairness (minor problem) - - DESCRIPTION: - - Please see attached copy of discussion thread - from comp.programming.threads for more details on - some reported problems. (i've also posted a "fyi" - message to ace-users a week or two ago but - unfortunately did not get any response so far). - - It seems that current implementation suffers from - two essential problems: - - 1) cond.waiters_count does not accurately reflect - number of waiters blocked on semaphore - w/o - proper synchronisation that could result (in the - time window when counter is not accurate) - in spurious wakeups organised by subsequent - _signals and _broadcasts. - - 2) Always having (with no e.g. copy_and_clear/..) - the same queue in use (semaphore+counter) - neither signal nor broadcast provide 'atomic' - behaviour with respect to other threads/subsequent - calls to signal/broadcast/wait. - - Each problem and combination of both could produce - various nasty things: - - a) spurious wakeups (minor problem) - - it is possible that waiter(s) which was already - unblocked even so is still counted as blocked - waiter. signal and broadcast will release - semaphore which will produce a spurious wakeup - for a 'real' waiter coming later. - - b) lost signals - - signalling thread ends up consuming its own - signal. please see demo/discussion below. - - c) broadcast deadlock - - last_waiter processing code does not correctly - handle the case with multiple threads - waiting for the end of broadcast. - please see demo/discussion below. - - d) unfairness (minor problem) - - without SignalObjectAndWait some waiter(s) - may end up consuming broadcasted signals - multiple times (spurious wakeups) because waiter - thread(s) can be preempted before they call - semaphore wait (but after count++ and mtx.unlock). - - REPEAT BY: - - See below... run problem demos programs (tennis.cpp and - tennisb.cpp) number of times concurrently (on multiprocessor) - and in multiple sessions or just add a couple of "Sleep"s - as described in the attached copy of discussion thread - from comp.programming.threads - - SAMPLE FIX/WORKAROUND: - - See attached patch to pthread-win32.. well, I can not - claim that it is completely bug free but at least my - test and tests provided by pthreads-win32 seem to work. - Perhaps that will help. - - regards, - alexander. - - ->> Forum: comp.programming.threads ->> Thread: pthread_cond_* implementation questions -. -. -. -David Schwartz wrote: - -> terekhov@my-deja.com wrote: -> ->> BTW, could you please also share your view on other perceived ->> "problems" such as nested broadcast deadlock, spurious wakeups ->> and (the latest one) lost signals?? -> ->I'm not sure what you mean. The standard allows an implementation ->to do almost whatever it likes. In fact, you could implement ->pthread_cond_wait by releasing the mutex, sleeping a random ->amount of time, and then reacquiring the mutex. Of course, ->this would be a pretty poor implementation, but any code that ->didn't work under that implementation wouldn't be strictly ->compliant. - -The implementation you suggested is indeed correct -one (yes, now I see it :). However it requires from -signal/broadcast nothing more than to "{ return 0; }" -That is not the case for pthread-win32 and ACE -implementations. I do think that these implementations -(basically the same implementation) have some serious -problems with wait/signal/broadcast calls. I am looking -for help to clarify whether these problems are real -or not. I think that I can demonstrate what I mean -using one or two small sample programs. -. -. -. -========== -tennis.cpp -========== - -#include "ace/Synch.h" -#include "ace/Thread.h" - -enum GAME_STATE { - - START_GAME, - PLAYER_A, // Player A playes the ball - PLAYER_B, // Player B playes the ball - GAME_OVER, - ONE_PLAYER_GONE, - BOTH_PLAYERS_GONE - -}; - -enum GAME_STATE eGameState; -ACE_Mutex* pmtxGameStateLock; -ACE_Condition< ACE_Mutex >* pcndGameStateChange; - -void* - playerA( - void* pParm - ) -{ - - // For access to game state variable - pmtxGameStateLock->acquire(); - - // Play loop - while ( eGameState < GAME_OVER ) { - - // Play the ball - cout << endl << "PLAYER-A" << endl; - - // Now its PLAYER-B's turn - eGameState = PLAYER_B; - - // Signal to PLAYER-B that now it is his turn - pcndGameStateChange->signal(); - - // Wait until PLAYER-B finishes playing the ball - do { - - pcndGameStateChange->wait(); - - if ( PLAYER_B == eGameState ) - cout << endl << "----PLAYER-A: SPURIOUS WAKEUP!!!" << endl; - - } while ( PLAYER_B == eGameState ); - - } - - // PLAYER-A gone - eGameState = (GAME_STATE)(eGameState+1); - cout << endl << "PLAYER-A GONE" << endl; - - // No more access to state variable needed - pmtxGameStateLock->release(); - - // Signal PLAYER-A gone event - pcndGameStateChange->broadcast(); - - return 0; - -} - -void* - playerB( - void* pParm - ) -{ - - // For access to game state variable - pmtxGameStateLock->acquire(); - - // Play loop - while ( eGameState < GAME_OVER ) { - - // Play the ball - cout << endl << "PLAYER-B" << endl; - - // Now its PLAYER-A's turn - eGameState = PLAYER_A; - - // Signal to PLAYER-A that now it is his turn - pcndGameStateChange->signal(); - - // Wait until PLAYER-A finishes playing the ball - do { - - pcndGameStateChange->wait(); - - if ( PLAYER_A == eGameState ) - cout << endl << "----PLAYER-B: SPURIOUS WAKEUP!!!" << endl; - - } while ( PLAYER_A == eGameState ); - - } - - // PLAYER-B gone - eGameState = (GAME_STATE)(eGameState+1); - cout << endl << "PLAYER-B GONE" << endl; - - // No more access to state variable needed - pmtxGameStateLock->release(); - - // Signal PLAYER-B gone event - pcndGameStateChange->broadcast(); - - return 0; - -} - - -int -main (int, ACE_TCHAR *[]) -{ - - pmtxGameStateLock = new ACE_Mutex(); - pcndGameStateChange = new ACE_Condition< ACE_Mutex >( *pmtxGameStateLock -); - - // Set initial state - eGameState = START_GAME; - - // Create players - ACE_Thread::spawn( playerA ); - ACE_Thread::spawn( playerB ); - - // Give them 5 sec. to play - Sleep( 5000 );//sleep( 5 ); - - // Set game over state - pmtxGameStateLock->acquire(); - eGameState = GAME_OVER; - - // Let them know - pcndGameStateChange->broadcast(); - - // Wait for players to stop - do { - - pcndGameStateChange->wait(); - - } while ( eGameState < BOTH_PLAYERS_GONE ); - - // Cleanup - cout << endl << "GAME OVER" << endl; - pmtxGameStateLock->release(); - delete pcndGameStateChange; - delete pmtxGameStateLock; - - return 0; - -} - -=========== -tennisb.cpp -=========== -#include "ace/Synch.h" -#include "ace/Thread.h" - -enum GAME_STATE { - - START_GAME, - PLAYER_A, // Player A playes the ball - PLAYER_B, // Player B playes the ball - GAME_OVER, - ONE_PLAYER_GONE, - BOTH_PLAYERS_GONE - -}; - -enum GAME_STATE eGameState; -ACE_Mutex* pmtxGameStateLock; -ACE_Condition< ACE_Mutex >* pcndGameStateChange; - -void* - playerA( - void* pParm - ) -{ - - // For access to game state variable - pmtxGameStateLock->acquire(); - - // Play loop - while ( eGameState < GAME_OVER ) { - - // Play the ball - cout << endl << "PLAYER-A" << endl; - - // Now its PLAYER-B's turn - eGameState = PLAYER_B; - - // Signal to PLAYER-B that now it is his turn - pcndGameStateChange->broadcast(); - - // Wait until PLAYER-B finishes playing the ball - do { - - pcndGameStateChange->wait(); - - if ( PLAYER_B == eGameState ) - cout << endl << "----PLAYER-A: SPURIOUS WAKEUP!!!" << endl; - - } while ( PLAYER_B == eGameState ); - - } - - // PLAYER-A gone - eGameState = (GAME_STATE)(eGameState+1); - cout << endl << "PLAYER-A GONE" << endl; - - // No more access to state variable needed - pmtxGameStateLock->release(); - - // Signal PLAYER-A gone event - pcndGameStateChange->broadcast(); - - return 0; - -} - -void* - playerB( - void* pParm - ) -{ - - // For access to game state variable - pmtxGameStateLock->acquire(); - - // Play loop - while ( eGameState < GAME_OVER ) { - - // Play the ball - cout << endl << "PLAYER-B" << endl; - - // Now its PLAYER-A's turn - eGameState = PLAYER_A; - - // Signal to PLAYER-A that now it is his turn - pcndGameStateChange->broadcast(); - - // Wait until PLAYER-A finishes playing the ball - do { - - pcndGameStateChange->wait(); - - if ( PLAYER_A == eGameState ) - cout << endl << "----PLAYER-B: SPURIOUS WAKEUP!!!" << endl; - - } while ( PLAYER_A == eGameState ); - - } - - // PLAYER-B gone - eGameState = (GAME_STATE)(eGameState+1); - cout << endl << "PLAYER-B GONE" << endl; - - // No more access to state variable needed - pmtxGameStateLock->release(); - - // Signal PLAYER-B gone event - pcndGameStateChange->broadcast(); - - return 0; - -} - - -int -main (int, ACE_TCHAR *[]) -{ - - pmtxGameStateLock = new ACE_Mutex(); - pcndGameStateChange = new ACE_Condition< ACE_Mutex >( *pmtxGameStateLock -); - - // Set initial state - eGameState = START_GAME; - - // Create players - ACE_Thread::spawn( playerA ); - ACE_Thread::spawn( playerB ); - - // Give them 5 sec. to play - Sleep( 5000 );//sleep( 5 ); - - // Make some noise - pmtxGameStateLock->acquire(); - cout << endl << "---Noise ON..." << endl; - pmtxGameStateLock->release(); - for ( int i = 0; i < 100000; i++ ) - pcndGameStateChange->broadcast(); - cout << endl << "---Noise OFF" << endl; - - // Set game over state - pmtxGameStateLock->acquire(); - eGameState = GAME_OVER; - cout << endl << "---Stopping the game..." << endl; - - // Let them know - pcndGameStateChange->broadcast(); - - // Wait for players to stop - do { - - pcndGameStateChange->wait(); - - } while ( eGameState < BOTH_PLAYERS_GONE ); - - // Cleanup - cout << endl << "GAME OVER" << endl; - pmtxGameStateLock->release(); - delete pcndGameStateChange; - delete pmtxGameStateLock; - - return 0; - -} -. -. -. -David Schwartz wrote: ->> > It's compliant ->> ->> That is really good. -> ->> Tomorrow (I have to go urgently now) I will try to ->> demonstrate the lost-signal "problem" of current ->> pthread-win32 and ACE-(variant w/o SingleObjectAndWait) ->> implementations: players start suddenly drop their balls :-) ->> (with no change in source code). -> ->Signals aren't lost, they're going to the main thread, ->which isn't coded correctly to handle them. Try this: -> -> // Wait for players to stop -> do { -> -> pthread_cond_wait( &cndGameStateChange,&mtxGameStateLock ); ->printf("Main thread stole a signal\n"); -> -> } while ( eGameState < BOTH_PLAYERS_GONE ); -> ->I bet everytime you thing a signal is lost, you'll see that printf. ->The signal isn't lost, it was stolen by another thread. - -well, you can probably loose your bet.. it was indeed stolen -by "another" thread but not the one you seem to think of. - -I think that what actually happens is the following: - -H:\SA\UXX\pt\PTHREADS\TESTS>tennis3.exe - -PLAYER-A - -PLAYER-B - -----PLAYER-B: SPURIOUS WAKEUP!!! - -PLAYER-A GONE - -PLAYER-B GONE - -GAME OVER - -H:\SA\UXX\pt\PTHREADS\TESTS> - -here you can see that PLAYER-B after playing his first -ball (which came via signal from PLAYER-A) just dropped -it down. What happened is that his signal to player A -was consumed as spurious wakeup by himself (player B). - -The implementation has a problem: - -================ -waiting threads: -================ - -{ /** Critical Section - - inc cond.waiters_count - -} - - /* - /* Atomic only if using Win32 SignalObjectAndWait - /* - cond.mtx.release - - /*** ^^-- A THREAD WHICH DID SIGNAL MAY ACQUIRE THE MUTEX, - /*** GO INTO WAIT ON THE SAME CONDITION AND OVERTAKE - /*** ORIGINAL WAITER(S) CONSUMING ITS OWN SIGNAL! - - cond.sem.wait - -Player-A after playing game's initial ball went into -wait (called _wait) but was pre-empted before reaching -wait semaphore. He was counted as waiter but was not -actually waiting/blocked yet. - -=============== -signal threads: -=============== - -{ /** Critical Section - - waiters_count = cond.waiters_count - -} - - if ( waiters_count != 0 ) - - sem.post 1 - - endif - -Player-B after he received signal/ball from Player A -called _signal. The _signal did see that there was -one waiter blocked on the condition (Player-A) and -released the semaphore.. (but it did not unblock -Player-A because he was not actually blocked). -Player-B thread continued its execution, called _wait, -was counted as second waiter BUT was allowed to slip -through opened semaphore gate (which was opened for -Player-B) and received his own signal. Player B remained -blocked followed by Player A. Deadlock happened which -lasted until main thread came in and said game over. - -It seems to me that the implementation fails to -correctly implement the following statement -from specification: - -http://www.opengroup.org/ -onlinepubs/007908799/xsh/pthread_cond_wait.html - -"These functions atomically release mutex and cause -the calling thread to block on the condition variable -cond; atomically here means "atomically with respect -to access by another thread to the mutex and then the -condition variable". That is, if another thread is -able to acquire the mutex after the about-to-block -thread has released it, then a subsequent call to -pthread_cond_signal() or pthread_cond_broadcast() -in that thread behaves as if it were issued after -the about-to-block thread has blocked." - -Question: Am I right? - -(I produced the program output above by simply -adding ?Sleep( 1 )?: - -================ -waiting threads: -================ - -{ /** Critical Section - - inc cond.waiters_count - -} - - /* - /* Atomic only if using Win32 SignalObjectAndWait - /* - cond.mtx.release - -Sleep( 1 ); // Win32 - - /*** ^^-- A THREAD WHICH DID SIGNAL MAY ACQUIRE THE MUTEX, - /*** GO INTO WAIT ON THE SAME CONDITION AND OVERTAKE - /*** ORIGINAL WAITER(S) CONSUMING ITS OWN SIGNAL! - - cond.sem.wait - -to the source code of pthread-win32 implementation: - -http://sources.redhat.com/cgi-bin/cvsweb.cgi/pthreads/ -condvar.c?rev=1.36&content-type=text/ -x-cvsweb-markup&cvsroot=pthreads-win32 - - - /* - * We keep the lock held just long enough to increment the count of - * waiters by one (above). - * Note that we can't keep it held across the - * call to sem_wait since that will deadlock other calls - * to pthread_cond_signal - */ - cleanup_args.mutexPtr = mutex; - cleanup_args.cv = cv; - cleanup_args.resultPtr = &result; - - pthread_cleanup_push (ptw32_cond_wait_cleanup, (void *) -&cleanup_args); - - if ((result = pthread_mutex_unlock (mutex)) == 0) - {((result -Sleep( 1 ); // @AT - - /* - * Wait to be awakened by - * pthread_cond_signal, or - * pthread_cond_broadcast, or - * a timeout - * - * Note: - * ptw32_sem_timedwait is a cancelation point, - * hence providing the - * mechanism for making pthread_cond_wait a cancelation - * 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; - } - } - - pthread_cleanup_pop (1); /* Always cleanup */ - - -BTW, on my system (2 CPUs) I can manage to get -signals lost even without any source code modification -if I run the tennis program many times in different -shell sessions. -. -. -. -David Schwartz wrote: ->terekhov@my-deja.com wrote: -> ->> well, it might be that the program is in fact buggy. ->> but you did not show me any bug. -> ->You're right. I was close but not dead on. I was correct, however, ->that the code is buggy because it uses 'pthread_cond_signal' even ->though not any thread waiting on the condition variable can do the ->job. I was wrong in which thread could be waiting on the cv but ->unable to do the job. - -Okay, lets change 'pthread_cond_signal' to 'pthread_cond_broadcast' -but also add some noise from main() right before declaring the game -to be over (I need it in order to demonstrate another problem of -pthread-win32/ACE implementations - broadcast deadlock)... -. -. -. -It is my understanding of POSIX conditions, -that on correct implementation added noise -in form of unnecessary broadcasts from main, -should not break the tennis program. The -only 'side effect' of added noise on correct -implementation would be 'spurious wakeups' of -players (in fact they are not spurious, -players just see them as spurious) unblocked, -not by another player but by main before -another player had a chance to acquire the -mutex and change the game state variable: -. -. -. - -PLAYER-B - -PLAYER-A - ----Noise ON... - -PLAYER-B - -PLAYER-A - -. -. -. - -PLAYER-B - -PLAYER-A - -----PLAYER-A: SPURIOUS WAKEUP!!! - -PLAYER-B - -PLAYER-A - ----Noise OFF - -PLAYER-B - ----Stopping the game... - -PLAYER-A GONE - -PLAYER-B GONE - -GAME OVER - -H:\SA\UXX\pt\PTHREADS\TESTS> - -On pthread-win32/ACE implementations the -program could stall: - -. -. -. - -PLAYER-A - -PLAYER-B - -PLAYER-A - -PLAYER-B - -PLAYER-A - -PLAYER-B - -PLAYER-A - -PLAYER-B - ----Noise ON... - -PLAYER-A - ----Noise OFF -^C -H:\SA\UXX\pt\PTHREADS\TESTS> - - -The implementation has problems: - -================ -waiting threads: -================ - -{ /** Critical Section - - inc cond.waiters_count - -} - - /* - /* Atomic only if using Win32 SignalObjectAndWait - /* - cond.mtx.release - cond.sem.wait - - /*** ^^-- WAITER CAN BE PREEMPTED AFTER BEING UNBLOCKED... - -{ /** Critical Section - - dec cond.waiters_count - - /*** ^^- ...AND BEFORE DECREMENTING THE COUNT (1) - - last_waiter = ( cond.was_broadcast && - cond.waiters_count == 0 ) - - if ( last_waiter ) - - cond.was_broadcast = FALSE - - endif - -} - - if ( last_waiter ) - - /* - /* Atomic only if using Win32 SignalObjectAndWait - /* - cond.auto_reset_event_or_sem.post /* Event for Win32 - cond.mtx.acquire - - /*** ^^-- ...AND BEFORE CALL TO mtx.acquire (2) - - /*** ^^-- NESTED BROADCASTS RESULT IN A DEADLOCK - - - else - - cond.mtx.acquire - - /*** ^^-- ...AND BEFORE CALL TO mtx.acquire (3) - - endif - - -================== -broadcast threads: -================== - -{ /** Critical Section - - waiters_count = cond.waiters_count - - if ( waiters_count != 0 ) - - cond.was_broadcast = TRUE - - endif - -} - -if ( waiters_count != 0 ) - - cond.sem.post waiters_count - - /*** ^^^^^--- SPURIOUS WAKEUPS DUE TO (1) - - cond.auto_reset_event_or_sem.wait /* Event for Win32 - - /*** ^^^^^--- DEADLOCK FOR FURTHER BROADCASTS IF THEY - HAPPEN TO GO INTO WAIT WHILE PREVIOUS - BROADCAST IS STILL IN PROGRESS/WAITING - -endif - -a) cond.waiters_count does not accurately reflect -number of waiters blocked on semaphore - that could -result (in the time window when counter is not accurate) -in spurios wakeups organised by subsequent _signals -and _broadcasts. From standard compliance point of view -that is OK but that could be a real problem from -performance/efficiency point of view. - -b) If subsequent broadcast happen to go into wait on -cond.auto_reset_event_or_sem before previous -broadcast was unblocked from cond.auto_reset_event_or_sem -by its last waiter, one of two blocked threads will -remain blocked because last_waiter processing code -fails to unblock both threads. - -In the situation with tennisb.c the Player-B was put -in a deadlock by noise (broadcast) coming from main -thread. And since Player-B holds the game state -mutex when it calls broadcast, the whole program -stalled: Player-A was deadlocked on mutex and -main thread after finishing with producing the noise -was deadlocked on mutex too (needed to declare the -game over) - -(I produced the program output above by simply -adding ?Sleep( 1 )?: - -================== -broadcast threads: -================== - -{ /** Critical Section - - waiters_count = cond.waiters_count - - if ( waiters_count != 0 ) - - cond.was_broadcast = TRUE - - endif - -} - -if ( waiters_count != 0 ) - -Sleep( 1 ); //Win32 - - cond.sem.post waiters_count - - /*** ^^^^^--- SPURIOUS WAKEUPS DUE TO (1) - - cond.auto_reset_event_or_sem.wait /* Event for Win32 - - /*** ^^^^^--- DEADLOCK FOR FURTHER BROADCASTS IF THEY - HAPPEN TO GO INTO WAIT WHILE PREVIOUS - BROADCAST IS STILL IN PROGRESS/WAITING - -endif - -to the source code of pthread-win32 implementation: - -http://sources.redhat.com/cgi-bin/cvsweb.cgi/pthreads/ -condvar.c?rev=1.36&content-type=text/ -x-cvsweb-markup&cvsroot=pthreads-win32 - - if (wereWaiters) - {(wereWaiters)sroot=pthreads-win32eb.cgi/pthreads/Yem...m - /* - * Wake up all waiters - */ - -Sleep( 1 ); //@AT - -#ifdef NEED_SEM - - result = (ptw32_increase_semaphore( &cv->sema, cv->waiters ) - ? 0 - : EINVAL); - -#else /* NEED_SEM */ - - result = (ReleaseSemaphore( cv->sema, cv->waiters, NULL ) - ? 0 - : EINVAL); - -#endif /* NEED_SEM */ - - } - - (void) pthread_mutex_unlock(&(cv->waitersLock)); - - if (wereWaiters && result == 0) - {(wereWaiters - /* - * Wait for all the awakened threads to acquire their part of - * the counting semaphore - */ - - if (WaitForSingleObject (cv->waitersDone, INFINITE) - == WAIT_OBJECT_0) - { - result = 0; - } - else - { - result = EINVAL; - } - - } - - return (result); - -} - -BTW, on my system (2 CPUs) I can manage to get -the program stalled even without any source code -modification if I run the tennisb program many -times in different shell sessions. - -=================== -pthread-win32 patch -=================== -struct pthread_cond_t_ { - long nWaitersBlocked; /* Number of threads blocked -*/ - long nWaitersUnblocked; /* Number of threads unblocked -*/ - long nWaitersToUnblock; /* Number of threads to unblock -*/ - sem_t semBlockQueue; /* Queue up threads waiting for the -*/ - /* condition to become signalled -*/ - sem_t semBlockLock; /* Semaphore that guards access to -*/ - /* | waiters blocked count/block queue -*/ - /* +-> Mandatory Sync.LEVEL-1 -*/ - pthread_mutex_t mtxUnblockLock; /* Mutex that guards access to -*/ - /* | waiters (to)unblock(ed) counts -*/ - /* +-> Optional* Sync.LEVEL-2 -*/ -}; /* Opt*) for _timedwait and -cancellation*/ - -int -pthread_cond_init (pthread_cond_t * cond, const pthread_condattr_t * attr) - int result = EAGAIN; - pthread_cond_t cv = NULL; - - if (cond == NULL) - {(cond - return EINVAL; - } - - if ((attr != NULL && *attr != NULL) && - ((*attr)->pshared == PTHREAD_PROCESS_SHARED)) - { - /* - * Creating condition variable that can be shared between - * processes. - */ - result = ENOSYS; - - goto FAIL0; - } - - cv = (pthread_cond_t) calloc (1, sizeof (*cv)); - - if (cv == NULL) - {(cv - result = ENOMEM; - goto FAIL0; - } - - cv->nWaitersBlocked = 0; - cv->nWaitersUnblocked = 0; - cv->nWaitersToUnblock = 0; - - if (sem_init (&(cv->semBlockLock), 0, 1) != 0) - {(sem_init - goto FAIL0; - } - - if (sem_init (&(cv->semBlockQueue), 0, 0) != 0) - {(sem_init - goto FAIL1; - } - - if (pthread_mutex_init (&(cv->mtxUnblockLock), 0) != 0) - {(pthread_mutex_init - goto FAIL2; - } - - - result = 0; - - goto DONE; - - /* - * ------------- - * Failed... - * ------------- - */ -FAIL2: - (void) sem_destroy (&(cv->semBlockQueue)); - -FAIL1: - (void) sem_destroy (&(cv->semBlockLock)); - -FAIL0: -DONE: - *cond = cv; - - return (result); - -} /* pthread_cond_init */ - -int -pthread_cond_destroy (pthread_cond_t * cond) -{ - int result = 0; - pthread_cond_t cv; - - /* - * Assuming any race condition here is harmless. - */ - if (cond == NULL - || *cond == NULL) - { - return EINVAL; - } - - if (*cond != (pthread_cond_t) PTW32_OBJECT_AUTO_INIT) - {(*cond - cv = *cond; - - /* - * Synchronize access to waiters blocked count (LEVEL-1) - */ - if (sem_wait(&(cv->semBlockLock)) != 0) - {(sem_wait(&(cv->semBlockLock)) - return errno; - } - - /* - * Synchronize access to waiters (to)unblock(ed) counts (LEVEL-2) - */ - if ((result = pthread_mutex_lock(&(cv->mtxUnblockLock))) != 0) - {((result - (void) sem_post(&(cv->semBlockLock)); - return result; - } - - /* - * Check whether cv is still busy (still has waiters blocked) - */ - if (cv->nWaitersBlocked - cv->nWaitersUnblocked > 0) - {(cv->nWaitersBlocked - (void) sem_post(&(cv->semBlockLock)); - (void) pthread_mutex_unlock(&(cv->mtxUnblockLock)); - return EBUSY; - } - - /* - * Now it is safe to destroy - */ - (void) sem_destroy (&(cv->semBlockLock)); - (void) sem_destroy (&(cv->semBlockQueue)); - (void) pthread_mutex_unlock (&(cv->mtxUnblockLock)); - (void) pthread_mutex_destroy (&(cv->mtxUnblockLock)); - - free(cv); - *cond = NULL; - } - else - { - /* - * See notes in ptw32_cond_check_need_init() above also. - */ - EnterCriticalSection(&ptw32_cond_test_init_lock); - - /* - * Check again. - */ - if (*cond == (pthread_cond_t) PTW32_OBJECT_AUTO_INIT) - {(*cond - /* - * This is all we need to do to destroy a statically - * initialised cond that has not yet been used (initialised). - * If we get to here, another thread - * waiting to initialise this cond will get an EINVAL. - */ - *cond = NULL; - } - else - { - /* - * The cv has been initialised while we were waiting - * so assume it's in use. - */ - result = EBUSY; - } - - LeaveCriticalSection(&ptw32_cond_test_init_lock); - } - - return (result); -} - -/* - * Arguments for cond_wait_cleanup, since we can only pass a - * single void * to it. - */ -typedef struct { - pthread_mutex_t * mutexPtr; - pthread_cond_t cv; - int * resultPtr; -} ptw32_cond_wait_cleanup_args_t; - -static void -ptw32_cond_wait_cleanup(void * args) -{ - ptw32_cond_wait_cleanup_args_t * cleanup_args = -(ptw32_cond_wait_cleanup_args_t *) args; - pthread_cond_t cv = cleanup_args->cv; - int * resultPtr = cleanup_args->resultPtr; - int eLastSignal; /* enum: 1=yes 0=no -1=cancelled/timedout w/o signal(s) -*/ - int result; - - /* - * Whether we got here as a result of signal/broadcast or because of - * timeout on wait or thread cancellation we indicate that we are no - * longer waiting. The waiter is responsible for adjusting waiters - * (to)unblock(ed) counts (protected by unblock lock). - * Unblock lock/Sync.LEVEL-2 supports _timedwait and cancellation. - */ - if ((result = pthread_mutex_lock(&(cv->mtxUnblockLock))) != 0) - {((result - *resultPtr = result; - return; - } - - cv->nWaitersUnblocked++; - - eLastSignal = (cv->nWaitersToUnblock == 0) ? - -1 : (--cv->nWaitersToUnblock == 0); - - /* - * No more LEVEL-2 access to waiters (to)unblock(ed) counts needed - */ - if ((result = pthread_mutex_unlock(&(cv->mtxUnblockLock))) != 0) - {((result - *resultPtr = result; - return; - } - - /* - * If last signal... - */ - if (eLastSignal == 1) - {(eLastSignal - /* - * ...it means that we have end of 'atomic' signal/broadcast - */ - if (sem_post(&(cv->semBlockLock)) != 0) - {(sem_post(&(cv->semBlockLock)) - *resultPtr = errno; - return; - } - } - /* - * If not last signal and not timed out/cancelled wait w/o signal... - */ - else if (eLastSignal == 0) - { - /* - * ...it means that next waiter can go through semaphore - */ - if (sem_post(&(cv->semBlockQueue)) != 0) - {(sem_post(&(cv->semBlockQueue)) - *resultPtr = errno; - return; - } - } - - /* - * XSH: Upon successful return, the mutex has been locked and is owned - * by the calling thread - */ - if ((result = pthread_mutex_lock(cleanup_args->mutexPtr)) != 0) - {((result - *resultPtr = result; - } - -} /* ptw32_cond_wait_cleanup */ - -static int -ptw32_cond_timedwait (pthread_cond_t * cond, - pthread_mutex_t * mutex, - const struct timespec *abstime) -{ - int result = 0; - pthread_cond_t cv; - ptw32_cond_wait_cleanup_args_t cleanup_args; - - if (cond == NULL || *cond == NULL) - {(cond - return EINVAL; - } - - /* - * We do a quick check to see if we need to do more work - * to initialise a static condition variable. We check - * again inside the guarded section of ptw32_cond_check_need_init() - * to avoid race conditions. - */ - if (*cond == (pthread_cond_t) PTW32_OBJECT_AUTO_INIT) - {(*cond - result = ptw32_cond_check_need_init(cond); - } - - if (result != 0 && result != EBUSY) - {(result - return result; - } - - cv = *cond; - - /* - * Synchronize access to waiters blocked count (LEVEL-1) - */ - if (sem_wait(&(cv->semBlockLock)) != 0) - {(sem_wait(&(cv->semBlockLock)) - return errno; - } - - cv->nWaitersBlocked++; - - /* - * Thats it. Counted means waiting, no more access needed - */ - if (sem_post(&(cv->semBlockLock)) != 0) - {(sem_post(&(cv->semBlockLock)) - return errno; - } - - /* - * Setup this waiter cleanup handler - */ - cleanup_args.mutexPtr = mutex; - cleanup_args.cv = cv; - cleanup_args.resultPtr = &result; - - pthread_cleanup_push (ptw32_cond_wait_cleanup, (void *) &cleanup_args); - - /* - * Now we can release 'mutex' and... - */ - if ((result = pthread_mutex_unlock (mutex)) == 0) - {((result - - /* - * ...wait to be awakened by - * pthread_cond_signal, or - * pthread_cond_broadcast, or - * timeout, or - * thread cancellation - * - * Note: - * - * ptw32_sem_timedwait is a cancellation point, - * hence providing the mechanism for making - * pthread_cond_wait a cancellation point. - * We use the cleanup mechanism to ensure we - * re-lock the mutex and adjust (to)unblock(ed) waiters - * counts if we are cancelled, timed out or signalled. - */ - if (ptw32_sem_timedwait (&(cv->semBlockQueue), abstime) != 0) - {(ptw32_sem_timedwait - result = errno; - } - } - - /* - * Always cleanup - */ - pthread_cleanup_pop (1); - - - /* - * "result" can be modified by the cleanup handler. - */ - return (result); - -} /* ptw32_cond_timedwait */ - - -static int -ptw32_cond_unblock (pthread_cond_t * cond, - int unblockAll) -{ - int result; - pthread_cond_t cv; - - if (cond == NULL || *cond == NULL) - {(cond - return EINVAL; - } - - cv = *cond; - - /* - * No-op if the CV is static and hasn't been initialised yet. - * Assuming that any race condition is harmless. - */ - if (cv == (pthread_cond_t) PTW32_OBJECT_AUTO_INIT) - {(cv - return 0; - } - - /* - * Synchronize access to waiters blocked count (LEVEL-1) - */ - if (sem_wait(&(cv->semBlockLock)) != 0) - {(sem_wait(&(cv->semBlockLock)) - return errno; - } - - /* - * Synchronize access to waiters (to)unblock(ed) counts (LEVEL-2) - * This sync.level supports _timedwait and cancellation - */ - if ((result = pthread_mutex_lock(&(cv->mtxUnblockLock))) != 0) - {((result - return result; - } - - /* - * Adjust waiters blocked and unblocked counts (collect garbage) - */ - if (cv->nWaitersUnblocked != 0) - {(cv->nWaitersUnblocked - cv->nWaitersBlocked -= cv->nWaitersUnblocked; - cv->nWaitersUnblocked = 0; - } - - /* - * If (after adjustment) there are still some waiters blocked counted... - */ - if ( cv->nWaitersBlocked > 0) - {( - /* - * We will unblock first waiter and leave semBlockLock/LEVEL-1 locked - * LEVEL-1 access is left disabled until last signal/unblock -completes - */ - cv->nWaitersToUnblock = (unblockAll) ? cv->nWaitersBlocked : 1; - - /* - * No more LEVEL-2 access to waiters (to)unblock(ed) counts needed - * This sync.level supports _timedwait and cancellation - */ - if ((result = pthread_mutex_unlock(&(cv->mtxUnblockLock))) != 0) - {((result - return result; - } - - - /* - * Now, with LEVEL-2 lock released let first waiter go through -semaphore - */ - if (sem_post(&(cv->semBlockQueue)) != 0) - {(sem_post(&(cv->semBlockQueue)) - return errno; - } - } - /* - * No waiter blocked - no more LEVEL-1 access to blocked count needed... - */ - else if (sem_post(&(cv->semBlockLock)) != 0) - { - return errno; - } - /* - * ...and no more LEVEL-2 access to waiters (to)unblock(ed) counts needed -too - * This sync.level supports _timedwait and cancellation - */ - else - { - result = pthread_mutex_unlock(&(cv->mtxUnblockLock)); - } - - return(result); - -} /* ptw32_cond_unblock */ - -int -pthread_cond_wait (pthread_cond_t * cond, - pthread_mutex_t * mutex) -{ - /* The NULL abstime arg means INFINITE waiting. */ - return(ptw32_cond_timedwait(cond, mutex, NULL)); -} /* pthread_cond_wait */ - - -int -pthread_cond_timedwait (pthread_cond_t * cond, - pthread_mutex_t * mutex, - const struct timespec *abstime) -{ - if (abstime == NULL) - {(abstime - return EINVAL; - } - - return(ptw32_cond_timedwait(cond, mutex, abstime)); -} /* pthread_cond_timedwait */ - - -int -pthread_cond_signal (pthread_cond_t * cond) -{ - /* The '0'(FALSE) unblockAll arg means unblock ONE waiter. */ - return(ptw32_cond_unblock(cond, 0)); -} /* pthread_cond_signal */ - -int -pthread_cond_broadcast (pthread_cond_t * cond) -{ - /* The '1'(TRUE) unblockAll arg means unblock ALL waiters. */ - return(ptw32_cond_unblock(cond, 1)); -} /* pthread_cond_broadcast */ - - - - -TEREKHOV@de.ibm.com on 17.01.2001 01:00:57 - -Please respond to TEREKHOV@de.ibm.com - -To: pthreads-win32@sourceware.cygnus.com -cc: schmidt@uci.edu -Subject: win32 conditions: sem+counter+event = broadcast_deadlock + - spur.wakeup/unfairness/incorrectness ?? - - - - - - - -Hi, - -Problem 1: broadcast_deadlock - -It seems that current implementation does not provide "atomic" -broadcasts. That may lead to "nested" broadcasts... and it seems -that nested case is not handled correctly -> producing a broadcast -DEADLOCK as a result. - -Scenario: - -N (>1) waiting threads W1..N are blocked (in _wait) on condition's -semaphore. - -Thread B1 calls pthread_cond_broadcast, which results in "releasing" N -W threads via incrementing semaphore counter by N (stored in -cv->waiters) BUT cv->waiters counter does not change!! The caller -thread B1 remains blocked on cv->waitersDone event (auto-reset!!) BUT -condition is not protected from starting another broadcast (when called -on another thread) while still waiting for the "old" broadcast to -complete on thread B1. - -M (>=0, waiters counter. - -L (N-M) "late" waiter W threads are a) still blocked/not returned from -their semaphore wait call or b) were preempted after sem_wait but before -lock( &cv->waitersLock ) or c) are blocked on cv->waitersLock. - -cv->waiters is still > 0 (= L). - -Another thread B2 (or some W thread from M group) calls -pthread_cond_broadcast and gains access to counter... neither a) nor b) -prevent thread B2 in pthread_cond_broadcast from gaining access to -counter and starting another broadcast ( for c) - it depends on -cv->waitersLock scheduling rules: FIFO=OK, PRTY=PROBLEM,... ) - -That call to pthread_cond_broadcast (on thread B2) will result in -incrementing semaphore by cv->waiters (=L) which is INCORRECT (all -W1..N were in fact already released by thread B1) and waiting on -_auto-reset_ event cv->waitersDone which is DEADLY WRONG (produces a -deadlock)... - -All late W1..L threads now have a chance to complete their _wait call. -Last W_L thread sets an auto-reselt event cv->waitersDone which will -release either B1 or B2 leaving one of B threads in a deadlock. - -Problem 2: spur.wakeup/unfairness/incorrectness - -It seems that: - -a) because of the same problem with counter which does not reflect the -actual number of NOT RELEASED waiters, the signal call may increment -a semaphore counter w/o having a waiter blocked on it. That will result -in (best case) spurious wake ups - performance degradation due to -unnecessary context switches and predicate re-checks and (in worth case) -unfairness/incorrectness problem - see b) - -b) neither signal nor broadcast prevent other threads - "new waiters" -(and in the case of signal, the caller thread as well) from going into -_wait and overtaking "old" waiters (already released but still not returned -from sem_wait on condition's semaphore). Win semaphore just [API DOC]: -"Maintains a count between zero and some maximum value, limiting the number -of threads that are simultaneously accessing a shared resource." Calling -ReleaseSemaphore does not imply (at least not documented) that on return -from ReleaseSemaphore all waiters will in fact become released (returned -from their Wait... call) and/or that new waiters calling Wait... afterwards -will become less importance. It is NOT documented to be an atomic release -of -waiters... And even if it would be there is still a problem with a thread -being preempted after Wait on semaphore and before Wait on cv->waitersLock -and scheduling rules for cv->waitersLock itself -(??WaitForMultipleObjects??) -That may result in unfairness/incorrectness problem as described -for SetEvent impl. in "Strategies for Implementing POSIX Condition -Variables -on Win32": http://www.cs.wustl.edu/~schmidt/win32-cv-1.html - -Unfairness -- The semantics of the POSIX pthread_cond_broadcast function is -to wake up all threads currently blocked in wait calls on the condition -variable. The awakened threads then compete for the external_mutex. To -ensure -fairness, all of these threads should be released from their -pthread_cond_wait calls and allowed to recheck their condition expressions -before other threads can successfully complete a wait on the condition -variable. - -Unfortunately, the SetEvent implementation above does not guarantee that -all -threads sleeping on the condition variable when cond_broadcast is called -will -acquire the external_mutex and check their condition expressions. Although -the Pthreads specification does not mandate this degree of fairness, the -lack of fairness can cause starvation. - -To illustrate the unfairness problem, imagine there are 2 threads, C1 and -C2, -that are blocked in pthread_cond_wait on condition variable not_empty_ that -is guarding a thread-safe message queue. Another thread, P1 then places two -messages onto the queue and calls pthread_cond_broadcast. If C1 returns -from -pthread_cond_wait, dequeues and processes the message, and immediately -waits -again then it and only it may end up acquiring both messages. Thus, C2 will -never get a chance to dequeue a message and run. - -The following illustrates the sequence of events: - -1. Thread C1 attempts to dequeue and waits on CV non_empty_ -2. Thread C2 attempts to dequeue and waits on CV non_empty_ -3. Thread P1 enqueues 2 messages and broadcasts to CV not_empty_ -4. Thread P1 exits -5. Thread C1 wakes up from CV not_empty_, dequeues a message and runs -6. Thread C1 waits again on CV not_empty_, immediately dequeues the 2nd - message and runs -7. Thread C1 exits -8. Thread C2 is the only thread left and blocks forever since - not_empty_ will never be signaled - -Depending on the algorithm being implemented, this lack of fairness may -yield -concurrent programs that have subtle bugs. Of course, application -developers -should not rely on the fairness semantics of pthread_cond_broadcast. -However, -there are many cases where fair implementations of condition variables can -simplify application code. - -Incorrectness -- A variation on the unfairness problem described above -occurs -when a third consumer thread, C3, is allowed to slip through even though it -was not waiting on condition variable not_empty_ when a broadcast occurred. - -To illustrate this, we will use the same scenario as above: 2 threads, C1 -and -C2, are blocked dequeuing messages from the message queue. Another thread, -P1 -then places two messages onto the queue and calls pthread_cond_broadcast. -C1 -returns from pthread_cond_wait, dequeues and processes the message. At this -time, C3 acquires the external_mutex, calls pthread_cond_wait and waits on -the events in WaitForMultipleObjects. Since C2 has not had a chance to run -yet, the BROADCAST event is still signaled. C3 then returns from -WaitForMultipleObjects, and dequeues and processes the message in the -queue. -Thus, C2 will never get a chance to dequeue a message and run. - -The following illustrates the sequence of events: - -1. Thread C1 attempts to dequeue and waits on CV non_empty_ -2. Thread C2 attempts to dequeue and waits on CV non_empty_ -3. Thread P1 enqueues 2 messages and broadcasts to CV not_empty_ -4. Thread P1 exits -5. Thread C1 wakes up from CV not_empty_, dequeues a message and runs -6. Thread C1 exits -7. Thread C3 waits on CV not_empty_, immediately dequeues the 2nd - message and runs -8. Thread C3 exits -9. Thread C2 is the only thread left and blocks forever since - not_empty_ will never be signaled - -In the above case, a thread that was not waiting on the condition variable -when a broadcast occurred was allowed to proceed. This leads to incorrect -semantics for a condition variable. - - -COMMENTS??? - -regards, -alexander. - ------------------------------------------------------------------------------ - -Subject: RE: FYI/comp.programming.threads/Re: pthread_cond_* - implementation questions -Date: Wed, 21 Feb 2001 11:54:47 +0100 -From: TEREKHOV@de.ibm.com -To: lthomas@arbitrade.com -CC: rpj@ise.canberra.edu.au, Thomas Pfaff , - Nanbor Wang - -Hi Louis, - -generation number 8.. - -had some time to revisit timeouts/spurious wakeup problem.. -found some bugs (in 7.b/c/d) and something to improve -(7a - using IPC semaphores but it should speedup Win32 -version as well). - -regards, -alexander. - ----------- Algorithm 8a / IMPL_SEM,UNBLOCK_STRATEGY == UNBLOCK_ALL ------ -given: -semBlockLock - bin.semaphore -semBlockQueue - semaphore -mtxExternal - mutex or CS -mtxUnblockLock - mutex or CS -nWaitersGone - int -nWaitersBlocked - int -nWaitersToUnblock - int - -wait( timeout ) { - - [auto: register int result ] // error checking omitted - [auto: register int nSignalsWasLeft ] - [auto: register int nWaitersWasGone ] - - sem_wait( semBlockLock ); - nWaitersBlocked++; - sem_post( semBlockLock ); - - unlock( mtxExternal ); - bTimedOut = sem_wait( semBlockQueue,timeout ); - - lock( mtxUnblockLock ); - if ( 0 != (nSignalsWasLeft = nWaitersToUnblock) ) { - if ( bTimeout ) { // timeout (or canceled) - if ( 0 != nWaitersBlocked ) { - nWaitersBlocked--; - } - else { - nWaitersGone++; // count spurious wakeups - } - } - if ( 0 == --nWaitersToUnblock ) { - if ( 0 != nWaitersBlocked ) { - sem_post( semBlockLock ); // open the gate - nSignalsWasLeft = 0; // do not open the gate below -again - } - else if ( 0 != (nWaitersWasGone = nWaitersGone) ) { - nWaitersGone = 0; - } - } - } - else if ( INT_MAX/2 == ++nWaitersGone ) { // timeout/canceled or spurious -semaphore :-) - sem_wait( semBlockLock ); - nWaitersBlocked -= nWaitersGone; // something is going on here - -test of timeouts? :-) - sem_post( semBlockLock ); - nWaitersGone = 0; - } - unlock( mtxUnblockLock ); - - if ( 1 == nSignalsWasLeft ) { - if ( 0 != nWaitersWasGone ) { - // sem_adjust( -nWaitersWasGone ); - while ( nWaitersWasGone-- ) { - sem_wait( semBlockLock ); // better now than spurious -later - } - } - sem_post( semBlockLock ); // open the gate - } - - lock( mtxExternal ); - - return ( bTimedOut ) ? ETIMEOUT : 0; -} - -signal(bAll) { - - [auto: register int result ] - [auto: register int nSignalsToIssue] - - lock( mtxUnblockLock ); - - if ( 0 != nWaitersToUnblock ) { // the gate is closed!!! - if ( 0 == nWaitersBlocked ) { // NO-OP - return unlock( mtxUnblockLock ); - } - if (bAll) { - nWaitersToUnblock += nSignalsToIssue=nWaitersBlocked; - nWaitersBlocked = 0; - } - else { - nSignalsToIssue = 1; - nWaitersToUnblock++; - nWaitersBlocked--; - } - } - else if ( nWaitersBlocked > nWaitersGone ) { // HARMLESS RACE CONDITION! - sem_wait( semBlockLock ); // close the gate - if ( 0 != nWaitersGone ) { - nWaitersBlocked -= nWaitersGone; - nWaitersGone = 0; - } - if (bAll) { - nSignalsToIssue = nWaitersToUnblock = nWaitersBlocked; - nWaitersBlocked = 0; - } - else { - nSignalsToIssue = nWaitersToUnblock = 1; - nWaitersBlocked--; - } - } - else { // NO-OP - return unlock( mtxUnblockLock ); - } - - unlock( mtxUnblockLock ); - sem_post( semBlockQueue,nSignalsToIssue ); - return result; -} - ----------- Algorithm 8b / IMPL_SEM,UNBLOCK_STRATEGY == UNBLOCK_ONEBYONE ------- -given: -semBlockLock - bin.semaphore -semBlockQueue - bin.semaphore -mtxExternal - mutex or CS -mtxUnblockLock - mutex or CS -nWaitersGone - int -nWaitersBlocked - int -nWaitersToUnblock - int - -wait( timeout ) { - - [auto: register int result ] // error checking omitted - [auto: register int nWaitersWasGone ] - [auto: register int nSignalsWasLeft ] - - sem_wait( semBlockLock ); - nWaitersBlocked++; - sem_post( semBlockLock ); - - unlock( mtxExternal ); - bTimedOut = sem_wait( semBlockQueue,timeout ); - - lock( mtxUnblockLock ); - if ( 0 != (nSignalsWasLeft = nWaitersToUnblock) ) { - if ( bTimeout ) { // timeout (or canceled) - if ( 0 != nWaitersBlocked ) { - nWaitersBlocked--; - nSignalsWasLeft = 0; // do not unblock next waiter -below (already unblocked) - } - else { - nWaitersGone = 1; // spurious wakeup pending!! - } - } - if ( 0 == --nWaitersToUnblock && - if ( 0 != nWaitersBlocked ) { - sem_post( semBlockLock ); // open the gate - nSignalsWasLeft = 0; // do not open the gate below -again - } - else if ( 0 != (nWaitersWasGone = nWaitersGone) ) { - nWaitersGone = 0; - } - } - } - else if ( INT_MAX/2 == ++nWaitersGone ) { // timeout/canceled or spurious -semaphore :-) - sem_wait( semBlockLock ); - nWaitersBlocked -= nWaitersGone; // something is going on here - -test of timeouts? :-) - sem_post( semBlockLock ); - nWaitersGone = 0; - } - unlock( mtxUnblockLock ); - - if ( 1 == nSignalsWasLeft ) { - if ( 0 != nWaitersWasGone ) { - // sem_adjust( -1 ); - sem_wait( semBlockQueue ); // better now than spurious -later - } - sem_post( semBlockLock ); // open the gate - } - else if ( 0 != nSignalsWasLeft ) { - sem_post( semBlockQueue ); // unblock next waiter - } - - lock( mtxExternal ); - - return ( bTimedOut ) ? ETIMEOUT : 0; -} - -signal(bAll) { - - [auto: register int result ] - - lock( mtxUnblockLock ); - - if ( 0 != nWaitersToUnblock ) { // the gate is closed!!! - if ( 0 == nWaitersBlocked ) { // NO-OP - return unlock( mtxUnblockLock ); - } - if (bAll) { - nWaitersToUnblock += nWaitersBlocked; - nWaitersBlocked = 0; - } - else { - nWaitersToUnblock++; - nWaitersBlocked--; - } - unlock( mtxUnblockLock ); - } - else if ( nWaitersBlocked > nWaitersGone ) { // HARMLESS RACE CONDITION! - sem_wait( semBlockLock ); // close the gate - if ( 0 != nWaitersGone ) { - nWaitersBlocked -= nWaitersGone; - nWaitersGone = 0; - } - if (bAll) { - nWaitersToUnblock = nWaitersBlocked; - nWaitersBlocked = 0; - } - else { - nWaitersToUnblock = 1; - nWaitersBlocked--; - } - unlock( mtxUnblockLock ); - sem_post( semBlockQueue ); - } - else { // NO-OP - unlock( mtxUnblockLock ); - } - - return result; -} - ----------- Algorithm 8c / IMPL_EVENT,UNBLOCK_STRATEGY == UNBLOCK_ONEBYONE ---------- -given: -hevBlockLock - auto-reset event -hevBlockQueue - auto-reset event -mtxExternal - mutex or CS -mtxUnblockLock - mutex or CS -nWaitersGone - int -nWaitersBlocked - int -nWaitersToUnblock - int - -wait( timeout ) { - - [auto: register int result ] // error checking omitted - [auto: register int nSignalsWasLeft ] - [auto: register int nWaitersWasGone ] - - wait( hevBlockLock,INFINITE ); - nWaitersBlocked++; - set_event( hevBlockLock ); - - unlock( mtxExternal ); - bTimedOut = wait( hevBlockQueue,timeout ); - - lock( mtxUnblockLock ); - if ( 0 != (SignalsWasLeft = nWaitersToUnblock) ) { - if ( bTimeout ) { // timeout (or canceled) - if ( 0 != nWaitersBlocked ) { - nWaitersBlocked--; - nSignalsWasLeft = 0; // do not unblock next waiter -below (already unblocked) - } - else { - nWaitersGone = 1; // spurious wakeup pending!! - } - } - if ( 0 == --nWaitersToUnblock ) - if ( 0 != nWaitersBlocked ) { - set_event( hevBlockLock ); // open the gate - nSignalsWasLeft = 0; // do not open the gate below -again - } - else if ( 0 != (nWaitersWasGone = nWaitersGone) ) { - nWaitersGone = 0; - } - } - } - else if ( INT_MAX/2 == ++nWaitersGone ) { // timeout/canceled or spurious -event :-) - wait( hevBlockLock,INFINITE ); - nWaitersBlocked -= nWaitersGone; // something is going on here - -test of timeouts? :-) - set_event( hevBlockLock ); - nWaitersGone = 0; - } - unlock( mtxUnblockLock ); - - if ( 1 == nSignalsWasLeft ) { - if ( 0 != nWaitersWasGone ) { - reset_event( hevBlockQueue ); // better now than spurious -later - } - set_event( hevBlockLock ); // open the gate - } - else if ( 0 != nSignalsWasLeft ) { - set_event( hevBlockQueue ); // unblock next waiter - } - - lock( mtxExternal ); - - return ( bTimedOut ) ? ETIMEOUT : 0; -} - -signal(bAll) { - - [auto: register int result ] - - lock( mtxUnblockLock ); - - if ( 0 != nWaitersToUnblock ) { // the gate is closed!!! - if ( 0 == nWaitersBlocked ) { // NO-OP - return unlock( mtxUnblockLock ); - } - if (bAll) { - nWaitersToUnblock += nWaitersBlocked; - nWaitersBlocked = 0; - } - else { - nWaitersToUnblock++; - nWaitersBlocked--; - } - unlock( mtxUnblockLock ); - } - else if ( nWaitersBlocked > nWaitersGone ) { // HARMLESS RACE CONDITION! - wait( hevBlockLock,INFINITE ); // close the gate - if ( 0 != nWaitersGone ) { - nWaitersBlocked -= nWaitersGone; - nWaitersGone = 0; - } - if (bAll) { - nWaitersToUnblock = nWaitersBlocked; - nWaitersBlocked = 0; - } - else { - nWaitersToUnblock = 1; - nWaitersBlocked--; - } - unlock( mtxUnblockLock ); - set_event( hevBlockQueue ); - } - else { // NO-OP - unlock( mtxUnblockLock ); - } - - return result; -} - ----------- Algorithm 8d / IMPL_EVENT,UNBLOCK_STRATEGY == UNBLOCK_ALL ------ -given: -hevBlockLock - auto-reset event -hevBlockQueueS - auto-reset event // for signals -hevBlockQueueB - manual-reset even // for broadcasts -mtxExternal - mutex or CS -mtxUnblockLock - mutex or CS -eBroadcast - int // 0: no broadcast, 1: broadcast, 2: -broadcast after signal(s) -nWaitersGone - int -nWaitersBlocked - int -nWaitersToUnblock - int - -wait( timeout ) { - - [auto: register int result ] // error checking omitted - [auto: register int eWasBroadcast ] - [auto: register int nSignalsWasLeft ] - [auto: register int nWaitersWasGone ] - - wait( hevBlockLock,INFINITE ); - nWaitersBlocked++; - set_event( hevBlockLock ); - - unlock( mtxExternal ); - bTimedOut = waitformultiple( hevBlockQueueS,hevBlockQueueB,timeout,ONE ); - - lock( mtxUnblockLock ); - if ( 0 != (SignalsWasLeft = nWaitersToUnblock) ) { - if ( bTimeout ) { // timeout (or canceled) - if ( 0 != nWaitersBlocked ) { - nWaitersBlocked--; - nSignalsWasLeft = 0; // do not unblock next waiter -below (already unblocked) - } - else if ( 1 != eBroadcast ) { - nWaitersGone = 1; - } - } - if ( 0 == --nWaitersToUnblock ) { - if ( 0 != nWaitersBlocked ) { - set_event( hevBlockLock ); // open the gate - nSignalsWasLeft = 0; // do not open the gate below -again - } - else { - if ( 0 != (eWasBroadcast = eBroadcast) ) { - eBroadcast = 0; - } - if ( 0 != (nWaitersWasGone = nWaitersGone ) { - nWaitersGone = 0; - } - } - } - else if ( 0 != eBroadcast ) { - nSignalsWasLeft = 0; // do not unblock next waiter -below (already unblocked) - } - } - else if ( INT_MAX/2 == ++nWaitersGone ) { // timeout/canceled or spurious -event :-) - wait( hevBlockLock,INFINITE ); - nWaitersBlocked -= nWaitersGone; // something is going on here - -test of timeouts? :-) - set_event( hevBlockLock ); - nWaitersGone = 0; - } - unlock( mtxUnblockLock ); - - if ( 1 == nSignalsWasLeft ) { - if ( 0 != eWasBroadcast ) { - reset_event( hevBlockQueueB ); - } - if ( 0 != nWaitersWasGone ) { - reset_event( hevBlockQueueS ); // better now than spurious -later - } - set_event( hevBlockLock ); // open the gate - } - else if ( 0 != nSignalsWasLeft ) { - set_event( hevBlockQueueS ); // unblock next waiter - } - - lock( mtxExternal ); - - return ( bTimedOut ) ? ETIMEOUT : 0; -} - -signal(bAll) { - - [auto: register int result ] - [auto: register HANDLE hevBlockQueue ] - - lock( mtxUnblockLock ); - - if ( 0 != nWaitersToUnblock ) { // the gate is closed!!! - if ( 0 == nWaitersBlocked ) { // NO-OP - return unlock( mtxUnblockLock ); - } - if (bAll) { - nWaitersToUnblock += nWaitersBlocked; - nWaitersBlocked = 0; - eBroadcast = 2; - hevBlockQueue = hevBlockQueueB; - } - else { - nWaitersToUnblock++; - nWaitersBlocked--; - return unlock( mtxUnblockLock ); - } - } - else if ( nWaitersBlocked > nWaitersGone ) { // HARMLESS RACE CONDITION! - wait( hevBlockLock,INFINITE ); // close the gate - if ( 0 != nWaitersGone ) { - nWaitersBlocked -= nWaitersGone; - nWaitersGone = 0; - } - if (bAll) { - nWaitersToUnblock = nWaitersBlocked; - nWaitersBlocked = 0; - eBroadcast = 1; - hevBlockQueue = hevBlockQueueB; - } - else { - nWaitersToUnblock = 1; - nWaitersBlocked--; - hevBlockQueue = hevBlockQueueS; - } - } - else { // NO-OP - return unlock( mtxUnblockLock ); - } - - unlock( mtxUnblockLock ); - set_event( hevBlockQueue ); - return result; -} ----------------------- Forwarded by Alexander Terekhov/Germany/IBM on -02/21/2001 09:13 AM --------------------------- - -Alexander Terekhov -02/20/2001 04:33 PM - -To: Louis Thomas -cc: - -From: Alexander Terekhov/Germany/IBM@IBMDE -Subject: RE: FYI/comp.programming.threads/Re: pthread_cond_* implementatio - n questions -Importance: Normal - ->Sorry, gotta take a break and work on something else for a while. ->Real work ->calls, unfortunately. I'll get back to you in two or three days. - -ok. no problem. here is some more stuff for pauses you might have -in between :) - ----------- Algorithm 7d / IMPL_EVENT,UNBLOCK_STRATEGY == UNBLOCK_ALL ------ -given: -hevBlockLock - auto-reset event -hevBlockQueueS - auto-reset event // for signals -hevBlockQueueB - manual-reset even // for broadcasts -mtxExternal - mutex or CS -mtxUnblockLock - mutex or CS -bBroadcast - int -nWaitersGone - int -nWaitersBlocked - int -nWaitersToUnblock - int - -wait( timeout ) { - - [auto: register int result ] // error checking omitted - [auto: register int bWasBroadcast ] - [auto: register int nSignalsWasLeft ] - - wait( hevBlockLock,INFINITE ); - nWaitersBlocked++; - set_event( hevBlockLock ); - - unlock( mtxExternal ); - bTimedOut = waitformultiple( hevBlockQueueS,hevBlockQueueB,timeout,ONE ); - - lock( mtxUnblockLock ); - if ( 0 != (SignalsWasLeft = nWaitersToUnblock) ) { - if ( bTimeout ) { // timeout (or canceled) - if ( 0 != nWaitersBlocked ) { - nWaitersBlocked--; - nSignalsWasLeft = 0; // do not unblock next waiter -below (already unblocked) - } - else if ( !bBroadcast ) { - wait( hevBlockQueueS,INFINITE ); // better now than spurious -later - } - } - if ( 0 == --nWaitersToUnblock ) { - if ( 0 != nWaitersBlocked ) { - if ( bBroadcast ) { - reset_event( hevBlockQueueB ); - bBroadcast = false; - } - set_event( hevBlockLock ); // open the gate - nSignalsWasLeft = 0; // do not open the gate below -again - } - else if ( false != (bWasBroadcast = bBroadcast) ) { - bBroadcast = false; - } - } - else { - bWasBroadcast = bBroadcast; - } - } - else if ( INT_MAX/2 == ++nWaitersGone ) { // timeout/canceled or spurious -event :-) - wait( hevBlockLock,INFINITE ); - nWaitersBlocked -= nWaitersGone; // something is going on here - -test of timeouts? :-) - set_event( hevBlockLock ); - nWaitersGone = 0; - } - unlock( mtxUnblockLock ); - - if ( 1 == nSignalsWasLeft ) { - if ( bWasBroadcast ) { - reset_event( hevBlockQueueB ); - } - set_event( hevBlockLock ); // open the gate - } - else if ( 0 != nSignalsWasLeft && !bWasBroadcast ) { - set_event( hevBlockQueueS ); // unblock next waiter - } - - lock( mtxExternal ); - - return ( bTimedOut ) ? ETIMEOUT : 0; -} - -signal(bAll) { - - [auto: register int result ] - [auto: register HANDLE hevBlockQueue ] - - lock( mtxUnblockLock ); - - if ( 0 != nWaitersToUnblock ) { // the gate is closed!!! - if ( 0 == nWaitersBlocked ) { // NO-OP - return unlock( mtxUnblockLock ); - } - if (bAll) { - nWaitersToUnblock += nWaitersBlocked; - nWaitersBlocked = 0; - bBroadcast = true; - hevBlockQueue = hevBlockQueueB; - } - else { - nWaitersToUnblock++; - nWaitersBlocked--; - return unlock( mtxUnblockLock ); - } - } - else if ( nWaitersBlocked > nWaitersGone ) { // HARMLESS RACE CONDITION! - wait( hevBlockLock,INFINITE ); // close the gate - if ( 0 != nWaitersGone ) { - nWaitersBlocked -= nWaitersGone; - nWaitersGone = 0; - } - if (bAll) { - nWaitersToUnblock = nWaitersBlocked; - nWaitersBlocked = 0; - bBroadcast = true; - hevBlockQueue = hevBlockQueueB; - } - else { - nWaitersToUnblock = 1; - nWaitersBlocked--; - hevBlockQueue = hevBlockQueueS; - } - } - else { // NO-OP - return unlock( mtxUnblockLock ); - } - - unlock( mtxUnblockLock ); - set_event( hevBlockQueue ); - return result; -} - - ----------------------------------------------------------------------------- - -Subject: RE: FYI/comp.programming.threads/Re: pthread_cond_* implementatio - n questions -Date: Mon, 26 Feb 2001 22:20:12 -0600 -From: Louis Thomas -To: "'TEREKHOV@de.ibm.com'" -CC: rpj@ise.canberra.edu.au, Thomas Pfaff , - Nanbor Wang - - -Sorry all. Busy week. - -> this insures the fairness -> which POSIX does not (e.g. two subsequent broadcasts - the gate does -insure -> that first wave waiters will start the race for the mutex before waiters -> from the second wave - Linux pthreads process/unblock both waves -> concurrently...) - -I'm not sure how we are any more fair about this than Linux. We certainly -don't guarantee that the threads released by the first broadcast will get -the external mutex before the threads of the second wave. In fact, it is -possible that those threads will never get the external mutex if there is -enough contention for it. - -> e.g. i was thinking about implementation with a pool of -> N semaphores/counters [...] - -I considered that too. The problem is as you mentioned in a). You really -need to assign threads to semaphores once you know how you want to wake them -up, not when they first begin waiting which is the only time you can assign -them. - -> well, i am not quite sure that i've fully understood your scenario, - -Hmm. Well, it think it's an important example, so I'll try again. First, we -have thread A which we KNOW is waiting on a condition. As soon as it becomes -unblocked for any reason, we will know because it will set a flag. Since the -flag is not set, we are 100% confident that thread A is waiting on the -condition. We have another thread, thread B, which has acquired the mutex -and is about to wait on the condition. Thus it is pretty clear that at any -point, either just A is waiting, or A and B are waiting. Now thread C comes -along. C is about to do a broadcast on the condition. A broadcast is -guaranteed to unblock all threads currently waiting on a condition, right? -Again, we said that either just A is waiting, or A and B are both waiting. -So, when C does its broadcast, depending upon whether B has started waiting -or not, thread C will unblock A or unblock A and B. Either way, C must -unblock A, right? - -Now, you said anything that happens is correct so long as a) "a signal is -not lost between unlocking the mutex and waiting on the condition" and b) "a -thread must not steal a signal it sent", correct? Requirement b) is easy to -satisfy: in this scenario, thread C will never wait on the condition, so it -won't steal any signals. Requirement a) is not hard either. The only way we -could fail to meet requirement a) in this scenario is if thread B was -started waiting but didn't wake up because a signal was lost. This will not -happen. - -Now, here is what happens. Assume thread C beats thread B. Thread C looks to -see how many threads are waiting on the condition. Thread C sees just one -thread, thread A, waiting. It does a broadcast waking up just one thread -because just one thread is waiting. Next, before A can become unblocked, -thread B begins waiting. Now there are two threads waiting, but only one -will be unblocked. Suppose B wins. B will become unblocked. A will not -become unblocked, because C only unblocked one thread (sema_post cond, 1). -So at the end, B finishes and A remains blocked. - -We have met both of your requirements, so by your rules, this is an -acceptable outcome. However, I think that the spec says this is an -unacceptable outcome! We know for certain that A was waiting and that C did -a broadcast, but A did not become unblocked! Yet, the spec says that a -broadcast wakes up all waiting threads. This did not happen. Do you agree -that this shows your rules are not strict enough? - -> and what about N2? :) this one does allow almost everything. - -Don't get me started about rule #2. I'll NEVER advocate an algorithm that -uses rule 2 as an excuse to suck! - -> but it is done (decrement)under mutex protection - this is not a subject -> of a race condition. - -You are correct. My mistake. - -> i would remove "_bTimedOut=false".. after all, it was a real timeout.. - -I disagree. A thread that can't successfully retract its waiter status can't -really have timed out. If a thread can't return without executing extra code -to deal with the fact that someone tried to unblock it, I think it is a poor -idea to pretend we -didn't realize someone was trying to signal us. After all, a signal is more -important than a time out. - -> when nSignaled != 0, it is possible to update nWaiters (--) and do not -> touch nGone - -I realize this, but I was thinking that writing it the other ways saves -another if statement. - -> adjust only if nGone != 0 and save one cache memory write - probably much -slower than 'if' - -Hmm. You are probably right. - -> well, in a strange (e.g. timeout test) program you may (theoretically) -> have an overflow of nWaiters/nGone counters (with waiters repeatedly -timing -> out and no signals at all). - -Also true. Not only that, but you also have the possibility that one could -overflow the number of waiters as well! However, considering the limit you -have chosen for nWaitersGone, I suppose it is unlikely that anyone would be -able to get INT_MAX/2 threads waiting on a single condition. :) - -Analysis of 8a: - -It looks correct to me. - -What are IPC semaphores? - -In the line where you state, "else if ( nWaitersBlocked > nWaitersGone ) { -// HARMLESS RACE CONDITION!" there is no race condition for nWaitersGone -because nWaitersGone is never modified without holding mtxUnblockLock. You -are correct that there is a harmless race on nWaitersBlocked, which can -increase and make the condition become true just after we check it. If this -happens, we interpret it as the wait starting after the signal. - -I like your optimization of this. You could improve Alg. 6 as follows: ----------- Algorithm 6b ---------- -signal(bAll) { - _nSig=0 - lock counters - // this is safe because nWaiting can only be decremented by a thread that - // owns counters and nGone can only be changed by a thread that owns -counters. - if (nWaiting>nGone) { - if (0==nSignaled) { - sema_wait gate // close gate if not already closed - } - if (nGone>0) { - nWaiting-=nGone - nGone=0 - } - _nSig=bAll?nWaiting:1 - nSignaled+=_nSig - nWaiting-=_nSig - } - unlock counters - if (0!=_nSig) { - sema_post queue, _nSig - } -} ----------- ---------- ---------- -I guess this wouldn't apply to Alg 8a because nWaitersGone changes meanings -depending upon whether the gate is open or closed. - -In the loop "while ( nWaitersWasGone-- ) {" you do a sema_wait on -semBlockLock. Perhaps waiting on semBlockQueue would be a better idea. - -What have you gained by making the last thread to be signaled do the waits -for all the timed out threads, besides added complexity? It took me a long -time to figure out what your objective was with this, to realize you were -using nWaitersGone to mean two different things, and to verify that you -hadn't introduced any bug by doing this. Even now I'm not 100% sure. - -What has all this playing about with nWaitersGone really gained us besides a -lot of complexity (it is much harder to verify that this solution is -correct), execution overhead (we now have a lot more if statements to -evaluate), and space overhead (more space for the extra code, and another -integer in our data)? We did manage to save a lock/unlock pair in an -uncommon case (when a time out occurs) at the above mentioned expenses in -the common cases. - -As for 8b, c, and d, they look ok though I haven't studied them thoroughly. -What would you use them for? - - Later, - -Louis! :) - ------------------------------------------------------------------------------ - -Subject: RE: FYI/comp.programming.threads/Re: pthread_cond_* implementatio - n questions -Date: Tue, 27 Feb 2001 15:51:28 +0100 -From: TEREKHOV@de.ibm.com -To: Louis Thomas -CC: rpj@ise.canberra.edu.au, Thomas Pfaff , - Nanbor Wang - -Hi Louis, - ->> that first wave waiters will start the race for the mutex before waiters ->> from the second wave - Linux pthreads process/unblock both waves ->> concurrently...) -> ->I'm not sure how we are any more fair about this than Linux. We certainly ->don't guarantee that the threads released by the first broadcast will get ->the external mutex before the threads of the second wave. In fact, it is ->possible that those threads will never get the external mutex if there is ->enough contention for it. - -correct. but gate is nevertheless more fair than Linux because of the -barrier it establishes between two races (1st and 2nd wave waiters) for -the mutex which under 'normal' circumstances (e.g. all threads of equal -priorities,..) will 'probably' result in fair behaviour with respect to -mutex ownership. - ->> well, i am not quite sure that i've fully understood your scenario, -> ->Hmm. Well, it think it's an important example, so I'll try again. ... - -ok. now i seem to understand this example. well, now it seems to me -that the only meaningful rule is just: - -a) "a signal is not lost between unlocking the mutex and waiting on the -condition" - -and that the rule - -b) "a thread must not steal a signal it sent" - -is not needed at all because a thread which violates b) also violates a). - -i'll try to explain.. - -i think that the most important thing is how POSIX defines waiter's -visibility: - -"if another thread is able to acquire the mutex after the about-to-block -thread -has released it, then a subsequent call to pthread_cond_signal() or -pthread_cond_broadcast() in that thread behaves as if it were issued after -the about-to-block thread has blocked. " - -my understanding is the following: - -1) there is no guarantees whatsoever with respect to whether -signal/broadcast -will actually unblock any 'waiter' if it is done w/o acquiring the mutex -first -(note that a thread may release it before signal/broadcast - it does not -matter). - -2) it is guaranteed that waiters become 'visible' - eligible for unblock as -soon -as signalling thread acquires the mutex (but not before!!) - -so.. - ->So, when C does its broadcast, depending upon whether B has started -waiting ->or not, thread C will unblock A or unblock A and B. Either way, C must ->unblock A, right? - -right. but only if C did acquire the mutex prior to broadcast (it may -release it before broadcast as well). - -implementation will violate waiters visibility rule (signal will become -lost) -if C will not unblock A. - ->Now, here is what happens. Assume thread C beats thread B. Thread C looks -to ->see how many threads are waiting on the condition. Thread C sees just one ->thread, thread A, waiting. It does a broadcast waking up just one thread ->because just one thread is waiting. Next, before A can become unblocked, ->thread B begins waiting. Now there are two threads waiting, but only one ->will be unblocked. Suppose B wins. B will become unblocked. A will not ->become unblocked, because C only unblocked one thread (sema_post cond, 1). ->So at the end, B finishes and A remains blocked. - -thread C did acquire the mutex ("Thread C sees just one thread, thread A, -waiting"). beginning from that moment it is guaranteed that subsequent -broadcast will unblock A. Otherwise we will have a lost signal with respect -to A. I do think that it does not matter whether the signal was physically -(completely) lost or was just stolen by another thread (B) - in both cases -it was simply lost with respect to A. - ->..Do you agree that this shows your rules are not strict enough? - -probably the opposite.. :-) i think that it shows that the only meaningful -rule is - -a) "a signal is not lost between unlocking the mutex and waiting on the -condition" - -with clarification of waiters visibility as defined by POSIX above. - ->> i would remove "_bTimedOut=false".. after all, it was a real timeout.. -> ->I disagree. A thread that can't successfully retract its waiter status -can't ->really have timed out. If a thread can't return without executing extra -code ->to deal with the fact that someone tried to unblock it, I think it is a -poor ->idea to pretend we ->didn't realize someone was trying to signal us. After all, a signal is -more ->important than a time out. - -a) POSIX does allow timed out thread to consume a signal (cancelled is -not). -b) ETIMEDOUT status just says that: "The time specified by abstime to -pthread_cond_timedwait() has passed." -c) it seem to me that hiding timeouts would violate "The -pthread_cond_timedwait() -function is the same as pthread_cond_wait() except that an error is -returned if -the absolute time specified by abstime passes (that is, system time equals -or -exceeds abstime) before the condition cond is signaled or broadcasted" -because -the abs. time did really pass before cond was signaled (waiter was -released via semaphore). however, if it really matters, i could imaging -that we -can save an abs. time of signal/broadcast and compare it with timeout after -unblock to find out whether it was a 'real' timeout or not. absent this -check -i do think that hiding timeouts would result in technical violation of -specification.. but i think that this check is not important and we can -simply -trust timeout error code provided by wait since we are not trying to make -'hard' realtime implementation. - ->What are IPC semaphores? - - -int semctl(int, int, int, ...); -int semget(key_t, int, int); -int semop(int, struct sembuf *, size_t); - -they support adjustment of semaphore counter (semvalue) -in one single call - imaging Win32 ReleaseSemaphore( hsem,-N ) - ->In the line where you state, "else if ( nWaitersBlocked > nWaitersGone ) { ->// HARMLESS RACE CONDITION!" there is no race condition for nWaitersGone ->because nWaitersGone is never modified without holding mtxUnblockLock. You ->are correct that there is a harmless race on nWaitersBlocked, which can ->increase and make the condition become true just after we check it. If -this ->happens, we interpret it as the wait starting after the signal. - -well, the reason why i've asked on comp.programming.threads whether this -race -condition is harmless or not is that in order to be harmless it should not -violate the waiters visibility rule (see above). Fortunately, we increment -the counter under protection of external mutex.. so that any (signalling) -thread which will acquire the mutex next, should see the updated counter -(in signal) according to POSIX memory visibility rules and mutexes -(memory barriers). But i am not so sure how it actually works on -Win32/INTEL -which does not explicitly define any memory visibility rules :( - ->I like your optimization of this. You could improve Alg. 6 as follows: ->---------- Algorithm 6b ---------- ->signal(bAll) { -> _nSig=0 -> lock counters -> // this is safe because nWaiting can only be decremented by a thread -that -> // owns counters and nGone can only be changed by a thread that owns ->counters. -> if (nWaiting>nGone) { -> if (0==nSignaled) { -> sema_wait gate // close gate if not already closed -> } -> if (nGone>0) { -> nWaiting-=nGone -> nGone=0 -> } -> _nSig=bAll?nWaiting:1 -> nSignaled+=_nSig -> nWaiting-=_nSig -> } -> unlock counters -> if (0!=_nSig) { -> sema_post queue, _nSig -> } ->} ->---------- ---------- ---------- ->I guess this wouldn't apply to Alg 8a because nWaitersGone changes -meanings ->depending upon whether the gate is open or closed. - -agree. - ->In the loop "while ( nWaitersWasGone-- ) {" you do a sema_wait on ->semBlockLock. Perhaps waiting on semBlockQueue would be a better idea. - -you are correct. my mistake. - ->What have you gained by making the last thread to be signaled do the waits ->for all the timed out threads, besides added complexity? It took me a long ->time to figure out what your objective was with this, to realize you were ->using nWaitersGone to mean two different things, and to verify that you ->hadn't introduced any bug by doing this. Even now I'm not 100% sure. -> ->What has all this playing about with nWaitersGone really gained us besides -a ->lot of complexity (it is much harder to verify that this solution is ->correct), execution overhead (we now have a lot more if statements to ->evaluate), and space overhead (more space for the extra code, and another ->integer in our data)? We did manage to save a lock/unlock pair in an ->uncommon case (when a time out occurs) at the above mentioned expenses in ->the common cases. - -well, please consider the following: - -1) with multiple waiters unblocked (but some timed out) the trick with -counter -seem to ensure potentially higher level of concurrency by not delaying -most of unblocked waiters for semaphore cleanup - only the last one -will be delayed but all others would already contend/acquire/release -the external mutex - the critical section protected by mtxUnblockLock is -made smaller (increment + couple of IFs is faster than system/kernel call) -which i think is good in general. however, you are right, this is done -at expense of 'normal' waiters.. - -2) some semaphore APIs (e.g. POSIX IPC sems) do allow to adjust the -semaphore counter in one call => less system/kernel calls.. imagine: - -if ( 1 == nSignalsWasLeft ) { - if ( 0 != nWaitersWasGone ) { - ReleaseSemaphore( semBlockQueue,-nWaitersWasGone ); // better now -than spurious later - } - sem_post( semBlockLock ); // open the gate - } - -3) even on win32 a single thread doing multiple cleanup calls (to wait) -will probably result in faster execution (because of processor caching) -than multiple threads each doing a single call to wait. - ->As for 8b, c, and d, they look ok though I haven't studied them -thoroughly. ->What would you use them for? - -8b) for semaphores which do not allow to unblock multiple waiters -in a single call to post/release (e.g. POSIX realtime semaphores - -) - -8c/8d) for WinCE prior to 3.0 (WinCE 3.0 does have semaphores) - -ok. so, which one is the 'final' algorithm(s) which we should use in -pthreads-win32?? - -regards, -alexander. - ----------------------------------------------------------------------------- - -Louis Thomas on 02/27/2001 05:20:12 AM - -Please respond to Louis Thomas - -To: Alexander Terekhov/Germany/IBM@IBMDE -cc: rpj@ise.canberra.edu.au, Thomas Pfaff , Nanbor Wang - -Subject: RE: FYI/comp.programming.threads/Re: pthread_cond_* implementatio - n questions - -Sorry all. Busy week. - -> this insures the fairness -> which POSIX does not (e.g. two subsequent broadcasts - the gate does -insure -> that first wave waiters will start the race for the mutex before waiters -> from the second wave - Linux pthreads process/unblock both waves -> concurrently...) - -I'm not sure how we are any more fair about this than Linux. We certainly -don't guarantee that the threads released by the first broadcast will get -the external mutex before the threads of the second wave. In fact, it is -possible that those threads will never get the external mutex if there is -enough contention for it. - -> e.g. i was thinking about implementation with a pool of -> N semaphores/counters [...] - -I considered that too. The problem is as you mentioned in a). You really -need to assign threads to semaphores once you know how you want to wake -them -up, not when they first begin waiting which is the only time you can assign -them. - -> well, i am not quite sure that i've fully understood your scenario, - -Hmm. Well, it think it's an important example, so I'll try again. First, we -have thread A which we KNOW is waiting on a condition. As soon as it -becomes -unblocked for any reason, we will know because it will set a flag. Since -the -flag is not set, we are 100% confident that thread A is waiting on the -condition. We have another thread, thread B, which has acquired the mutex -and is about to wait on the condition. Thus it is pretty clear that at any -point, either just A is waiting, or A and B are waiting. Now thread C comes -along. C is about to do a broadcast on the condition. A broadcast is -guaranteed to unblock all threads currently waiting on a condition, right? -Again, we said that either just A is waiting, or A and B are both waiting. -So, when C does its broadcast, depending upon whether B has started waiting -or not, thread C will unblock A or unblock A and B. Either way, C must -unblock A, right? - -Now, you said anything that happens is correct so long as a) "a signal is -not lost between unlocking the mutex and waiting on the condition" and b) -"a -thread must not steal a signal it sent", correct? Requirement b) is easy to -satisfy: in this scenario, thread C will never wait on the condition, so it -won't steal any signals. Requirement a) is not hard either. The only way -we -could fail to meet requirement a) in this scenario is if thread B was -started waiting but didn't wake up because a signal was lost. This will not -happen. - -Now, here is what happens. Assume thread C beats thread B. Thread C looks -to -see how many threads are waiting on the condition. Thread C sees just one -thread, thread A, waiting. It does a broadcast waking up just one thread -because just one thread is waiting. Next, before A can become unblocked, -thread B begins waiting. Now there are two threads waiting, but only one -will be unblocked. Suppose B wins. B will become unblocked. A will not -become unblocked, because C only unblocked one thread (sema_post cond, 1). -So at the end, B finishes and A remains blocked. - -We have met both of your requirements, so by your rules, this is an -acceptable outcome. However, I think that the spec says this is an -unacceptable outcome! We know for certain that A was waiting and that C did -a broadcast, but A did not become unblocked! Yet, the spec says that a -broadcast wakes up all waiting threads. This did not happen. Do you agree -that this shows your rules are not strict enough? - -> and what about N2? :) this one does allow almost everything. - -Don't get me started about rule #2. I'll NEVER advocate an algorithm that -uses rule 2 as an excuse to suck! - -> but it is done (decrement)under mutex protection - this is not a subject -> of a race condition. - -You are correct. My mistake. - -> i would remove "_bTimedOut=false".. after all, it was a real timeout.. - -I disagree. A thread that can't successfully retract its waiter status -can't -really have timed out. If a thread can't return without executing extra -code -to deal with the fact that someone tried to unblock it, I think it is a -poor -idea to pretend we -didn't realize someone was trying to signal us. After all, a signal is more -important than a time out. - -> when nSignaled != 0, it is possible to update nWaiters (--) and do not -> touch nGone - -I realize this, but I was thinking that writing it the other ways saves -another if statement. - -> adjust only if nGone != 0 and save one cache memory write - probably much -slower than 'if' - -Hmm. You are probably right. - -> well, in a strange (e.g. timeout test) program you may (theoretically) -> have an overflow of nWaiters/nGone counters (with waiters repeatedly -timing -> out and no signals at all). - -Also true. Not only that, but you also have the possibility that one could -overflow the number of waiters as well! However, considering the limit you -have chosen for nWaitersGone, I suppose it is unlikely that anyone would be -able to get INT_MAX/2 threads waiting on a single condition. :) - -Analysis of 8a: - -It looks correct to me. - -What are IPC semaphores? - -In the line where you state, "else if ( nWaitersBlocked > nWaitersGone ) { -// HARMLESS RACE CONDITION!" there is no race condition for nWaitersGone -because nWaitersGone is never modified without holding mtxUnblockLock. You -are correct that there is a harmless race on nWaitersBlocked, which can -increase and make the condition become true just after we check it. If this -happens, we interpret it as the wait starting after the signal. - -I like your optimization of this. You could improve Alg. 6 as follows: ----------- Algorithm 6b ---------- -signal(bAll) { - _nSig=0 - lock counters - // this is safe because nWaiting can only be decremented by a thread that - // owns counters and nGone can only be changed by a thread that owns -counters. - if (nWaiting>nGone) { - if (0==nSignaled) { - sema_wait gate // close gate if not already closed - } - if (nGone>0) { - nWaiting-=nGone - nGone=0 - } - _nSig=bAll?nWaiting:1 - nSignaled+=_nSig - nWaiting-=_nSig - } - unlock counters - if (0!=_nSig) { - sema_post queue, _nSig - } -} ----------- ---------- ---------- -I guess this wouldn't apply to Alg 8a because nWaitersGone changes meanings -depending upon whether the gate is open or closed. - -In the loop "while ( nWaitersWasGone-- ) {" you do a sema_wait on -semBlockLock. Perhaps waiting on semBlockQueue would be a better idea. - -What have you gained by making the last thread to be signaled do the waits -for all the timed out threads, besides added complexity? It took me a long -time to figure out what your objective was with this, to realize you were -using nWaitersGone to mean two different things, and to verify that you -hadn't introduced any bug by doing this. Even now I'm not 100% sure. - -What has all this playing about with nWaitersGone really gained us besides -a -lot of complexity (it is much harder to verify that this solution is -correct), execution overhead (we now have a lot more if statements to -evaluate), and space overhead (more space for the extra code, and another -integer in our data)? We did manage to save a lock/unlock pair in an -uncommon case (when a time out occurs) at the above mentioned expenses in -the common cases. - -As for 8b, c, and d, they look ok though I haven't studied them thoroughly. -What would you use them for? - - Later, - -Louis! :) - diff --git a/vendor/pthreads/include/README.NONPORTABLE b/vendor/pthreads/include/README.NONPORTABLE deleted file mode 100644 index 0821104d89..0000000000 --- a/vendor/pthreads/include/README.NONPORTABLE +++ /dev/null @@ -1,783 +0,0 @@ -This file documents non-portable functions and other issues. - -Non-portable functions included in pthreads-win32 -------------------------------------------------- - -BOOL -pthread_win32_test_features_np(int mask) - - This routine allows an application to check which - run-time auto-detected features are available within - the library. - - The possible features are: - - PTW32_SYSTEM_INTERLOCKED_COMPARE_EXCHANGE - Return TRUE if the native version of - InterlockedCompareExchange() is being used. - This feature is not meaningful in recent - library versions as MSVC builds only support - system implemented ICE. Note that all Mingw - builds use inlined asm versions of all the - Interlocked routines. - PTW32_ALERTABLE_ASYNC_CANCEL - Return TRUE is the QueueUserAPCEx package - 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 - then the default async cancel scheme is in - use, which cannot cancel blocked threads. - - Features may be Or'ed into the mask parameter, in which case - the routine returns TRUE if any of the Or'ed features would - return TRUE. At this stage it doesn't make sense to Or features - but it may some day. - - -void * -pthread_timechange_handler_np(void *) - - To improve tolerance against operator or time service - initiated system clock changes. - - This routine can be called by an application when it - receives a WM_TIMECHANGE message from the system. At - present it broadcasts all condition variables so that - waiting threads can wake up and re-evaluate their - conditions and restart their timed waits if required. - - It has the same return type and argument type as a - thread routine so that it may be called directly - through pthread_create(), i.e. as a separate thread. - - Parameters - - Although a parameter must be supplied, it is ignored. - The value NULL can be used. - - Return values - - It can return an error EAGAIN to indicate that not - all condition variables were broadcast for some reason. - Otherwise, 0 is returned. - - If run as a thread, the return value is returned - through pthread_join(). - - The return value should be cast to an integer. - - -HANDLE -pthread_getw32threadhandle_np(pthread_t thread); - - 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. - -DWORD -pthread_getw32threadid_np (pthread_t thread) - - Returns the Windows native thread ID that the POSIX - thread "thread" is running as. - - Only valid when the library is built where - ! (defined(__MINGW64__) || defined(__MINGW32__)) || defined (__MSVCRT__) || defined (__DMC__) - and otherwise returns 0. - - -int -pthread_mutexattr_setkind_np(pthread_mutexattr_t * attr, int kind) - -int -pthread_mutexattr_getkind_np(pthread_mutexattr_t * attr, int *kind) - - These two routines are included for Linux compatibility - and are direct equivalents to the standard routines - pthread_mutexattr_settype - pthread_mutexattr_gettype - - pthread_mutexattr_setkind_np accepts the following - mutex kinds: - PTHREAD_MUTEX_FAST_NP - PTHREAD_MUTEX_ERRORCHECK_NP - PTHREAD_MUTEX_RECURSIVE_NP - - These are really just equivalent to (respectively): - PTHREAD_MUTEX_NORMAL - PTHREAD_MUTEX_ERRORCHECK - PTHREAD_MUTEX_RECURSIVE - -int -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 - will not return before the end of the period is reached, but may return an - arbitrary amount of time after the period has gone by. This can be due to - system load, thread priorities, and system timer granularity. - - 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. - - This routine is a cancelation point. - - The timespec structure contains the following two fields: - - tv_sec is an integer number of seconds. - tv_nsec is an integer number of nanoseconds. - - Return Values - - If an error condition occurs, this routine returns an integer value - indicating the type of error. Possible return values are as follows: - - 0 Successful completion. - [EINVAL] The value specified by interval is invalid. - -int -pthread_num_processors_np (void) - - This routine (found on HPUX systems) returns the number of processors - in the system. This implementation actually returns the number of - processors available to the process, which can be a lower number - than the system's number, depending on the process's affinity mask. - -BOOL -pthread_win32_process_attach_np (void); - -BOOL -pthread_win32_process_detach_np (void); - -BOOL -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. - - 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(). - - These functions invariably return TRUE except for - pthread_win32_process_attach_np() which will return FALSE - if pthreads-win32 initialisation fails. - -int -pthreadCancelableWait (HANDLE waitHandle); - -int -pthreadCancelableTimedWait (HANDLE waitHandle, DWORD timeout); - - These two functions provide hooks into the pthread_cancel - mechanism that will allow you to wait on a Windows handle - and make it a cancellation point. Both functions block - until either the given w32 handle is signaled, or - pthread_cancel has been called. It is implemented using - WaitForMultipleObjects on 'waitHandle' and a manually - reset w32 event used to implement pthread_cancel. - - -Non-portable issues -------------------- - -Thread priority - - POSIX defines a single contiguous range of numbers that determine a - thread's priority. Win32 defines priority classes and priority - levels relative to these classes. Classes are simply priority base - levels that the defined priority levels are relative to such that, - changing a process's priority class will change the priority of all - of it's threads, while the threads retain the same relativity to each - other. - - A Win32 system defines a single contiguous monotonic range of values - that define system priority levels, just like POSIX. However, Win32 - restricts individual threads to a subset of this range on a - per-process basis. - - The following table shows the base priority levels for combinations - of priority class and priority value in Win32. - - Process Priority Class Thread Priority Level - ----------------------------------------------------------------- - 1 IDLE_PRIORITY_CLASS THREAD_PRIORITY_IDLE - 1 BELOW_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_IDLE - 1 NORMAL_PRIORITY_CLASS THREAD_PRIORITY_IDLE - 1 ABOVE_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_IDLE - 1 HIGH_PRIORITY_CLASS THREAD_PRIORITY_IDLE - 2 IDLE_PRIORITY_CLASS THREAD_PRIORITY_LOWEST - 3 IDLE_PRIORITY_CLASS THREAD_PRIORITY_BELOW_NORMAL - 4 IDLE_PRIORITY_CLASS THREAD_PRIORITY_NORMAL - 4 BELOW_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_LOWEST - 5 IDLE_PRIORITY_CLASS THREAD_PRIORITY_ABOVE_NORMAL - 5 BELOW_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_BELOW_NORMAL - 5 Background NORMAL_PRIORITY_CLASS THREAD_PRIORITY_LOWEST - 6 IDLE_PRIORITY_CLASS THREAD_PRIORITY_HIGHEST - 6 BELOW_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_NORMAL - 6 Background NORMAL_PRIORITY_CLASS THREAD_PRIORITY_BELOW_NORMAL - 7 BELOW_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_ABOVE_NORMAL - 7 Background NORMAL_PRIORITY_CLASS THREAD_PRIORITY_NORMAL - 7 Foreground NORMAL_PRIORITY_CLASS THREAD_PRIORITY_LOWEST - 8 BELOW_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_HIGHEST - 8 NORMAL_PRIORITY_CLASS THREAD_PRIORITY_ABOVE_NORMAL - 8 Foreground NORMAL_PRIORITY_CLASS THREAD_PRIORITY_BELOW_NORMAL - 8 ABOVE_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_LOWEST - 9 NORMAL_PRIORITY_CLASS THREAD_PRIORITY_HIGHEST - 9 Foreground NORMAL_PRIORITY_CLASS THREAD_PRIORITY_NORMAL - 9 ABOVE_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_BELOW_NORMAL - 10 Foreground NORMAL_PRIORITY_CLASS THREAD_PRIORITY_ABOVE_NORMAL - 10 ABOVE_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_NORMAL - 11 Foreground NORMAL_PRIORITY_CLASS THREAD_PRIORITY_HIGHEST - 11 ABOVE_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_ABOVE_NORMAL - 11 HIGH_PRIORITY_CLASS THREAD_PRIORITY_LOWEST - 12 ABOVE_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_HIGHEST - 12 HIGH_PRIORITY_CLASS THREAD_PRIORITY_BELOW_NORMAL - 13 HIGH_PRIORITY_CLASS THREAD_PRIORITY_NORMAL - 14 HIGH_PRIORITY_CLASS THREAD_PRIORITY_ABOVE_NORMAL - 15 HIGH_PRIORITY_CLASS THREAD_PRIORITY_HIGHEST - 15 HIGH_PRIORITY_CLASS THREAD_PRIORITY_TIME_CRITICAL - 15 IDLE_PRIORITY_CLASS THREAD_PRIORITY_TIME_CRITICAL - 15 BELOW_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_TIME_CRITICAL - 15 NORMAL_PRIORITY_CLASS THREAD_PRIORITY_TIME_CRITICAL - 15 ABOVE_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_TIME_CRITICAL - 16 REALTIME_PRIORITY_CLASS THREAD_PRIORITY_IDLE - 17 REALTIME_PRIORITY_CLASS -7 - 18 REALTIME_PRIORITY_CLASS -6 - 19 REALTIME_PRIORITY_CLASS -5 - 20 REALTIME_PRIORITY_CLASS -4 - 21 REALTIME_PRIORITY_CLASS -3 - 22 REALTIME_PRIORITY_CLASS THREAD_PRIORITY_LOWEST - 23 REALTIME_PRIORITY_CLASS THREAD_PRIORITY_BELOW_NORMAL - 24 REALTIME_PRIORITY_CLASS THREAD_PRIORITY_NORMAL - 25 REALTIME_PRIORITY_CLASS THREAD_PRIORITY_ABOVE_NORMAL - 26 REALTIME_PRIORITY_CLASS THREAD_PRIORITY_HIGHEST - 27 REALTIME_PRIORITY_CLASS 3 - 28 REALTIME_PRIORITY_CLASS 4 - 29 REALTIME_PRIORITY_CLASS 5 - 30 REALTIME_PRIORITY_CLASS 6 - 31 REALTIME_PRIORITY_CLASS THREAD_PRIORITY_TIME_CRITICAL - - Windows NT: Values -7, -6, -5, -4, -3, 3, 4, 5, and 6 are not supported. - - - As you can see, the real priority levels available to any individual - Win32 thread are non-contiguous. - - An application using pthreads-win32 should not make assumptions about - the numbers used to represent thread priority levels, except that they - are monotonic between the values returned by sched_get_priority_min() - and sched_get_priority_max(). E.g. Windows 95, 98, NT, 2000, XP make - available a non-contiguous range of numbers between -15 and 15, while - at least one version of WinCE (3.0) defines the minimum priority - (THREAD_PRIORITY_LOWEST) as 5, and the maximum priority - (THREAD_PRIORITY_HIGHEST) as 1. - - Internally, pthreads-win32 maps any priority levels between - THREAD_PRIORITY_IDLE and THREAD_PRIORITY_LOWEST to THREAD_PRIORITY_LOWEST, - or between THREAD_PRIORITY_TIME_CRITICAL and THREAD_PRIORITY_HIGHEST to - THREAD_PRIORITY_HIGHEST. Currently, this also applies to - REALTIME_PRIORITY_CLASSi even if levels -7, -6, -5, -4, -3, 3, 4, 5, and 6 - are supported. - - If it wishes, a Win32 application using pthreads-win32 can use the Win32 - defined priority macros THREAD_PRIORITY_IDLE through - THREAD_PRIORITY_TIME_CRITICAL. - - -The opacity of the pthread_t datatype -------------------------------------- -and possible solutions for portable null/compare/hash, etc ----------------------------------------------------------- - -Because pthread_t is an opague datatype an implementation is permitted to define -pthread_t in any way it wishes. That includes defining some bits, if it is -scalar, or members, if it is an aggregate, to store information that may be -extra to the unique identifying value of the ID. As a result, pthread_t values -may not be directly comparable. - -If you want your code to be portable you must adhere to the following contraints: - -1) Don't assume it is a scalar data type, e.g. an integer or pointer value. There -are several other implementations where pthread_t is also a struct. See our FAQ -Question 11 for our reasons for defining pthread_t as a struct. - -2) You must not compare them using relational or equality operators. You must use -the API function pthread_equal() to test for equality. - -3) Never attempt to reference individual members. - - -The problem - -Certain applications would like to be able to access only the 'pure' pthread_t -id values, primarily to use as keys into data structures to manage threads or -thread-related data, but this is not possible in a maximally portable and -standards compliant way for current POSIX threads implementations. - -For implementations that define pthread_t as a scalar, programmers often employ -direct relational and equality operators on pthread_t. This code will break when -ported to an implementation that defines pthread_t as an aggregate type. - -For implementations that define pthread_t as an aggregate, e.g. a struct, -programmers can use memcmp etc., but then face the prospect that the struct may -include alignment padding bytes or bits as well as extra implementation-specific -members that are not part of the unique identifying value. - -[While this is not currently the case for pthreads-win32, opacity also -means that an implementation is free to change the definition, which should -generally only require that applications be recompiled and relinked, not -rewritten.] - - -Doesn't the compiler take care of padding? - -The C89 and later standards only effectively guarrantee element-by-element -equivalence following an assignment or pass by value of a struct or union, -therefore undefined areas of any two otherwise equivalent pthread_t instances -can still compare differently, e.g. attempting to compare two such pthread_t -variables byte-by-byte, e.g. memcmp(&t1, &t2, sizeof(pthread_t) may give an -incorrect result. In practice I'm reasonably confident that compilers routinely -also copy the padding bytes, mainly because assignment of unions would be far -too complicated otherwise. But it just isn't guarranteed by the standard. - -Illustration: - -We have two thread IDs t1 and t2 - -pthread_t t1, t2; - -In an application we create the threads and intend to store the thread IDs in an -ordered data structure (linked list, tree, etc) so we need to be able to compare -them in order to insert them initially and also to traverse. - -Suppose pthread_t contains undefined padding bits and our compiler copies our -pthread_t [struct] element-by-element, then for the assignment: - -pthread_t temp = t1; - -temp and t1 will be equivalent and correct but a byte-for-byte comparison such as -memcmp(&temp, &t1, sizeof(pthread_t)) == 0 may not return true as we expect because -the undefined bits may not have the same values in the two variable instances. - -Similarly if passing by value under the same conditions. - -If, on the other hand, the undefined bits are at least constant through every -assignment and pass-by-value then the byte-for-byte comparison -memcmp(&temp, &t1, sizeof(pthread_t)) == 0 will always return the expected result. -How can we force the behaviour we need? - - -Solutions - -Adding new functions to the standard API or as non-portable extentions is -the only reliable and portable way to provide the necessary operations. -Remember also that POSIX is not tied to the C language. The most common -functions that have been suggested are: - -pthread_null() -pthread_compare() -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 -to pthread_t so that we can be sure our solution is compatible with the -standard. - -What is known or may be deduced from the standard: -1) pthread_t must be able to be passed by value, so it must be a single object. -2) from (1) it must be copyable so cannot embed thread-state information, locks -or other volatile objects required to manage the thread it associates with. -3) pthread_t may carry additional information, e.g. for debugging or to manage -itself. -4) there is an implicit requirement that the size of pthread_t is determinable -at compile-time and size-invariant, because it must be able to copy the object -(i.e. through assignment and pass-by-value). Such copies must be genuine -duplicates, not merely a copy of a pointer to a common instance such as -would be the case if pthread_t were defined as an array. - - -Suppose we define the following function: - -/* This function shall return it's argument */ -pthread_t* pthread_normalize(pthread_t* thread); - -For scalar or aggregate pthread_t types this function would simply zero any bits -within the pthread_t that don't uniquely identify the thread, including padding, -such that client code can return consistent results from operations done on the -result. If the additional bits are a pointer to an associate structure then -this function would ensure that the memory used to store that associate -structure does not leak. After normalization the following compare would be -valid and repeatable: - -memcmp(pthread_normalize(&t1),pthread_normalize(&t2),sizeof(pthread_t)) - -Note 1: such comparisons are intended merely to order and sort pthread_t values -and allow them to index various data structures. They are not intended to reveal -anything about the relationships between threads, like startup order. - -Note 2: the normalized pthread_t is also a valid pthread_t that uniquely -identifies the same thread. - -Advantages: -1) In most existing implementations this function would reduce to a no-op that -emits no additional instructions, i.e after in-lining or optimisation, or if -defined as a macro: -#define pthread_normalise(tptr) (tptr) - -2) This single function allows an application to portably derive -application-level versions of any of the other required functions. - -3) It is a generic function that could enable unanticipated uses. - -Disadvantages: -1) Less efficient than dedicated compare or hash functions for implementations -that include significant extra non-id elements in pthread_t. - -2) Still need to be concerned about padding if copying normalized pthread_t. -See the later section on defining pthread_t to neutralise padding issues. - -Generally a pthread_t may need to be normalized every time it is used, -which could have a significant impact. However, this is a design decision -for the implementor in a competitive environment. An implementation is free -to define a pthread_t in a way that minimises or eliminates padding or -renders this function a no-op. - -Hazards: -1) Pass-by-reference directly modifies 'thread' so the application must -synchronise access or ensure that the pointer refers to a copy. The alternative -of pass-by-value/return-by-value was considered but then this requires two copy -operations, disadvantaging implementations where this function is not a no-op -in terms of speed of execution. This function is intended to be used in high -frequency situations and needs to be efficient, or at least not unnecessarily -inefficient. The alternative also sits awkwardly with functions like memcmp. - -2) [Non-compliant] code that uses relational and equality operators on -arithmetic or pointer style pthread_t types would need to be rewritten, but it -should be rewritten anyway. - - -C implementation of null/compare/hash functions using pthread_normalize(): - -/* In pthread.h */ -pthread_t* pthread_normalize(pthread_t* thread); - -/* In user code */ -/* User-level bitclear function - clear bits in loc corresponding to mask */ -void* bitclear (void* loc, void* mask, size_t count); - -typedef unsigned int hash_t; - -/* User-level hash function */ -hash_t hash(void* ptr, size_t count); - -/* - * User-level pthr_null function - modifies the origin thread handle. - * The concept of a null pthread_t is highly implementation dependent - * and this design may be far from the mark. For example, in an - * implementation "null" may mean setting a special value inside one - * element of pthread_t to mean "INVALID". However, if that value was zero and - * formed part of the id component then we may get away with this design. - */ -pthread_t* pthr_null(pthread_t* tp) -{ - /* - * This should have the same effect as memset(tp, 0, sizeof(pthread_t)) - * We're just showing that we can do it. - */ - void* p = (void*) pthread_normalize(tp); - return (pthread_t*) bitclear(p, p, sizeof(pthread_t)); -} - -/* - * Safe user-level pthr_compare function - modifies temporary thread handle copies - */ -int pthr_compare_safe(pthread_t thread1, pthread_t thread2) -{ - return memcmp(pthread_normalize(&thread1), pthread_normalize(&thread2), sizeof(pthread_t)); -} - -/* - * Fast user-level pthr_compare function - modifies origin thread handles - */ -int pthr_compare_fast(pthread_t* thread1, pthread_t* thread2) -{ - return memcmp(pthread_normalize(&thread1), pthread_normalize(&thread2), sizeof(pthread_t)); -} - -/* - * Safe user-level pthr_hash function - modifies temporary thread handle copy - */ -hash_t pthr_hash_safe(pthread_t thread) -{ - return hash((void *) pthread_normalize(&thread), sizeof(pthread_t)); -} - -/* - * Fast user-level pthr_hash function - modifies origin thread handle - */ -hash_t pthr_hash_fast(pthread_t thread) -{ - return hash((void *) pthread_normalize(&thread), sizeof(pthread_t)); -} - -/* User-level bitclear function - modifies the origin array */ -void* bitclear(void* loc, void* mask, size_t count) -{ - int i; - for (i=0; i < count; i++) { - (unsigned char) *loc++ &= ~((unsigned char) *mask++); - } -} - -/* Donald Knuth hash */ -hash_t hash(void* str, size_t count) -{ - hash_t hash = (hash_t) count; - unsigned int i = 0; - - for(i = 0; i < len; str++, i++) - { - hash = ((hash << 5) ^ (hash >> 27)) ^ (*str); - } - return hash; -} - -/* Example of advantage point (3) - split a thread handle into its id and non-id values */ -pthread_t id = thread, non-id = thread; -bitclear((void*) &non-id, (void*) pthread_normalize(&id), sizeof(pthread_t)); - - -A pthread_t type change proposal to neutralise the effects of padding - -Even if pthread_nornalize() is available, padding is still a problem because -the standard only garrantees element-by-element equivalence through -copy operations (assignment and pass-by-value). So padding bit values can -still change randomly after calls to pthread_normalize(). - -[I suspect that most compilers take the easy path and always byte-copy anyway, -partly because it becomes too complex to do (e.g. unions that contain sub-aggregates) -but also because programmers can easily design their aggregates to minimise and -often eliminate padding]. - -How can we eliminate the problem of padding bytes in structs? Could -defining pthread_t as a union rather than a struct provide a solution? - -In fact, the Linux pthread.h defines most of it's pthread_*_t objects (but not -pthread_t itself) as unions, possibly for this and/or other reasons. We'll -borrow some element naming from there but the ideas themselves are well known -- the __align element used to force alignment of the union comes from K&R's -storage allocator example. - -/* Essentially our current pthread_t renamed */ -typedef struct { - struct thread_state_t * __p; - long __x; /* sequence counter */ -} thread_id_t; - -Ensuring that the last element in the above struct is a long ensures that the -overall struct size is a multiple of sizeof(long), so there should be no trailing -padding in this struct or the union we define below. -(Later we'll see that we can handle internal but not trailing padding.) - -/* New pthread_t */ -typedef union { - char __size[sizeof(thread_id_t)]; /* array as the first element */ - thread_id_t __tid; - long __align; /* Ensure that the union starts on long boundary */ -} pthread_t; - -This guarrantees that, during an assignment or pass-by-value, the compiler copies -every byte in our thread_id_t because the compiler guarrantees that the __size -array, which we have ensured is the equal-largest element in the union, retains -equivalence. - -This means that pthread_t values stored, assigned and passed by value will at least -carry the value of any undefined padding bytes along and therefore ensure that -those values remain consistent. Our comparisons will return consistent results and -our hashes of [zero initialised] pthread_t values will also return consistent -results. - -We have also removed the need for a pthread_null() function; we can initialise -at declaration time or easily create our own const pthread_t to use in assignments -later: - -const pthread_t null_tid = {0}; /* braces are required */ - -pthread_t t; -... -t = null_tid; - - -Note that we don't have to explicitly make use of the __size array at all. It's -there just to force the compiler behaviour we want. - - -Partial solutions without a pthread_normalize function - - -An application-level pthread_null and pthread_compare proposal -(and pthread_hash proposal by extention) - -In order to deal with the problem of scalar/aggregate pthread_t type disparity in -portable code I suggest using an old-fashioned union, e.g.: - -Contraints: -- there is no padding, or padding values are preserved through assignment and - pass-by-value (see above); -- there are no extra non-id values in the pthread_t. - - -Example 1: A null initialiser for pthread_t variables... - -typedef union { - unsigned char b[sizeof(pthread_t)]; - pthread_t t; -} init_t; - -const init_t initial = {0}; - -pthread_t tid = initial.t; /* init tid to all zeroes */ - - -Example 2: A comparison function for pthread_t values - -typedef union { - unsigned char b[sizeof(pthread_t)]; - pthread_t t; -} pthcmp_t; - -int pthcmp(pthread_t left, pthread_t right) -{ - /* - * Compare two pthread handles in a way that imposes a repeatable but arbitrary - * ordering on them. - * I.e. given the same set of pthread_t handles the ordering should be the same - * each time but the order has no particular meaning other than that. E.g. - * the ordering does not imply the thread start sequence, or any other - * relationship between threads. - * - * Return values are: - * 1 : left is greater than right - * 0 : left is equal to right - * -1 : left is less than right - */ - int i; - pthcmp_t L, R; - L.t = left; - R.t = right; - for (i = 0; i < sizeof(pthread_t); i++) - { - if (L.b[i] > R.b[i]) - return 1; - else if (L.b[i] < R.b[i]) - return -1; - } - return 0; -} - -It has been pointed out that the C99 standard allows for the possibility that -integer types also may include padding bits, which could invalidate the above -method. This addition to C99 was specifically included after it was pointed -out that there was one, presumably not particularly well known, architecture -that included a padding bit in it's 32 bit integer type. See section 6.2.6.2 -of both the standard and the rationale, specifically the paragraph starting at -line 16 on page 43 of the rationale. - - -An aside - -Certain compilers, e.g. gcc and one of the IBM compilers, include a feature -extention: provided the union contains a member of the same type as the -object then the object may be cast to the union itself. - -We could use this feature to speed up the pthrcmp() function from example 2 -above by casting rather than assigning the pthread_t arguments to the union, e.g.: - -int pthcmp(pthread_t left, pthread_t right) -{ - /* - * Compare two pthread handles in a way that imposes a repeatable but arbitrary - * ordering on them. - * I.e. given the same set of pthread_t handles the ordering should be the same - * each time but the order has no particular meaning other than that. E.g. - * the ordering does not imply the thread start sequence, or any other - * relationship between threads. - * - * Return values are: - * 1 : left is greater than right - * 0 : left is equal to right - * -1 : left is less than right - */ - int i; - for (i = 0; i < sizeof(pthread_t); i++) - { - if (((pthcmp_t)left).b[i] > ((pthcmp_t)right).b[i]) - return 1; - else if (((pthcmp_t)left).b[i] < ((pthcmp_t)right).b[i]) - return -1; - } - return 0; -} - - -Result thus far - -We can't remove undefined bits if they are there in pthread_t already, but we have -attempted to render them inert for comparison and hashing functions by making them -consistent through assignment, copy and pass-by-value. - -Note: Hashing pthread_t values requires that all pthread_t variables be initialised -to the same value (usually all zeros) before being assigned a proper thread ID, i.e. -to ensure that any padding bits are zero, or at least the same value for all -pthread_t. Since all pthread_t values are generated by the library in the first -instance this need not be an application-level operation. - - -Conclusion - -I've attempted to resolve the multiple issues of type opacity and the possible -presence of undefined bits and bytes in pthread_t values, which prevent -applications from comparing or hashing pthread handles. - -Two complimentary partial solutions have been proposed, one an application-level -scheme to handle both scalar and aggregate pthread_t types equally, plus a -definition of pthread_t itself that neutralises padding bits and bytes by -coercing semantics out of the compiler to eliminate variations in the values of -padding bits. - -I have not provided any solution to the problem of handling extra values embedded -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. -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. diff --git a/vendor/pthreads/include/README.Watcom b/vendor/pthreads/include/README.Watcom deleted file mode 100644 index 2974928a38..0000000000 --- a/vendor/pthreads/include/README.Watcom +++ /dev/null @@ -1,62 +0,0 @@ -Watcom compiler notes -===================== - -Status ------- -Not yet usable. Although the library builds under Watcom it -substantially fails the test suite. - -There is a working Wmakefile for wmake for the library build. - -invoke as any of: -wmake -f Wmakefile clean WC -wmake -f Wmakefile clean WC-inlined -wmake -f Wmakefile clean WCE -wmake -f Wmakefile clean WCE-inlined - -These build pthreadWC.dll and pthreadWCE.dll. - -There is a working Wmakefile for wmake for the test suite. - -invoke as any of: -wmake -f Wmakefile clean WC -wmake -f Wmakefile clean WCX -wmake -f Wmakefile clean WCE -wmake -f Wmakefile clean WC-bench -wmake -f Wmakefile clean WCX-bench -wmake -f Wmakefile clean WCE-bench - - -Current known problems ----------------------- - -Library build: -The Watcom compiler uses a different default call convention to MS C or GNU C and so -applications are not compatible with pthreadVC.dll etc using pre 2003-10-14 versions -of pthread.h, sched.h, or semaphore.h. The cdecl attribute can be used on exposed -function prototypes to force compatibility with MS C built DLLs. - -However, there appear to be other incompatibilities. Errno.h, for example, defines -different values for the standard C and POSIX errors to those defined by the MS C -errno.h. It may be that references to Watcom's threads compatible 'errno' do set -and return translated numbers consistently, but I have not verified this. - -Watcom defines errno as a dereferenced pointer returned by the function -_get_errno_ptr(). This is similar to both the MS and GNU C environments for -multithreaded use. However, the Watcom version appears to have a number of problems: - -- different threads return the same pointer value. Compare with the MS and GNU C -versions which correctly return different values (since each thread must maintain -a thread specific errno value). - -- an errno value set within the DLL appears as zero in the application even though -both share the same thread. - -Therefore applications built using the Watcom compiler may need to use -a Watcom built version of the library (pthreadWC.dll). If this is the case, then -the cdecl function attribute should not be required. - -Application builds: -The test suite fails with the Watcom compiler. - -Test semaphore1.c fails for pthreadWC.dll because errno returns 0 instead of EAGAIN. diff --git a/vendor/pthreads/include/README.WinCE b/vendor/pthreads/include/README.WinCE deleted file mode 100644 index a2cd8c2133..0000000000 --- a/vendor/pthreads/include/README.WinCE +++ /dev/null @@ -1,6 +0,0 @@ -WinCE port ----------- -(See the file WinCE-PORT for a detailed explanation.) - -Make sure you define "WINCE" amongst your compiler flags (eg. -DWINCE). -The config.h file will define all the necessary defines for you. diff --git a/vendor/pthreads/include/TODO b/vendor/pthreads/include/TODO deleted file mode 100644 index fa9efc46e7..0000000000 --- a/vendor/pthreads/include/TODO +++ /dev/null @@ -1,7 +0,0 @@ - Things that aren't done yet - --------------------------- - -1. Implement PTHREAD_PROCESS_SHARED for semaphores, mutexes, - condition variables, read/write locks, barriers. - - diff --git a/vendor/pthreads/include/WinCE-PORT b/vendor/pthreads/include/WinCE-PORT deleted file mode 100644 index 7bcfdea6cc..0000000000 --- a/vendor/pthreads/include/WinCE-PORT +++ /dev/null @@ -1,222 +0,0 @@ -NOTE: The comments in this file relate to the original WinCE port -done by Tristan Savatier. The semaphore routines have been -completely rewritten since (2005-04-25), having been progressively -broken more and more by changes to the library. All of the semaphore -routines implemented for W9x/WNT/2000 and up should now also work for -WinCE. Also, pthread_mutex_timedlock should now work. - -Additional WinCE updates have been applied since this as well. Check the -ChangeLog file and search for WINCE for example. (2007-01-07) - -[RPJ] - ----- - -Some interesting news: - -I have been able to port pthread-win32 to Windows-CE, -which uses a subset of the WIN32 API. - -Since we intend to keep using pthread-win32 for our -Commercial WinCE developments, I would be very interested -if WinCE support could be added to the main source tree -of pthread-win32. Also, I would like to be credited -for this port :-) - -Now, here is the story... - -The port was performed and tested on a Casio "Cassiopeia" -PalmSize PC, which runs a MIP processor. The OS in the -Casio is WinCE version 2.11, but I used VC++ 6.0 with -the WinCE SDK for version 2.01. - -I used pthread-win32 to port a heavily multithreaded -commercial application (real-time MPEG video player) -from Linux to WinCE. I consider the changes that -I have done to be quite well tested. - -Overall the modifications that we had to do are minor. - -The WinCE port were based on pthread-win32-snap-1999-05-30, -but I am certain that they can be integrated very easiely -to more recent versions of the source. - -I have attached the modified source code: -pthread-win32-snap-1999-05-30-WinCE. - -All the changes do not affect the code compiled on non-WinCE -environment, provided that the macros used for WinCE compilation -are not used, of course! - -Overall description of the WinCE port: -------------------------------------- - -Most of the changes had to be made in areas where -pthread-win32 was relying on some standard-C librairies -(e.g. _ftime, calloc, errno), which are not available -on WinCE. We have changed the code to use native Win32 -API instead (or in some cases we made wrappers). - -The Win32 Semaphores are not available, -so we had to re-implement Semaphores using mutexes -and events. - -Limitations / known problems of the WinCE port: ----------------------------------------------- - -Not all the semaphore routines have been ported -(semaphores are defined by Posix but are not part -pf pthread). I have just done enough to make -pthread routines (that rely internally on semaphores) -work, like signal conditions. - -I noticed that the Win32 threads work slightly -differently on WinCE. This may have some impact -on some tricky parts of pthread-win32, but I have -not really investigated. For example, on WinCE, -the process is killed if the main thread falls off -the bottom (or calls pthread_exit), regardless -of the existence of any other detached thread. -Microsoft manual indicates that this behavior is -deffirent from that of Windows Threads for other -Win32 platforms. - - -Detailed descriptions of the changes and rationals: - ------------------------------------- -- use a new macro NEED_ERRNO. - -If defined, the code in errno.c that defines a reentrant errno -is compiled, regardless of _MT and _REENTRANT. - -Rational: On WinCE, there is no support for , or -any other standard C library, i.e. even if _MT or _REENTRANT -is defined, errno is not provided by any library. NEED_ERRNO -must be set to compile for WinCE. - ------------------------------------- -- In implement.h, change #include to #include "semaphore.h". - -Rational: semaphore.h is provided in pthread-win32 and should not -be searched in the systems standard include. would not compile. -This change does not seem to create problems on "classic" win32 -(e.g. win95). - ------------------------------------- -- use a new macro NEED_CALLOC. - -If defined, some code in misc.c will provide a replacement -for calloc, which is not available on Win32. - - ------------------------------------- -- use a new macro NEED_CREATETHREAD. - -If defined, implement.h defines the macro _beginthreadex -and _endthreadex. - -Rational: On WinCE, the wrappers _beginthreadex and _endthreadex -do not exist. The native Win32 routines must be used. - ------------------------------------- -- in misc.c: - -#ifdef NEED_DUPLICATEHANDLE - /* DuplicateHandle does not exist on WinCE */ - self->threadH = GetCurrentThread(); -#else - if( !DuplicateHandle( - GetCurrentProcess(), - GetCurrentThread(), - GetCurrentProcess(), - &self->threadH, - 0, - FALSE, - DUPLICATE_SAME_ACCESS ) ) - { - free( self ); - return (NULL); - } -#endif - -Rational: On WinCE, DuplicateHandle does not exist. I could not understand -why DuplicateHandle must be used. It seems to me that getting the current -thread handle with GetCurrentThread() is sufficient, and it seems to work -perfectly fine, so maybe DuplicateHandle was just plain useless to begin with ? - ------------------------------------- -- In private.c, added some code at the beginning of ptw32_processInitialize -to detect the case of multiple calls to ptw32_processInitialize. - -Rational: In order to debug pthread-win32, it is easier to compile -it as a regular library (it is not possible to debug DLL's on winCE). -In that case, the application must call ptw32_rocessInitialize() -explicitely, to initialize pthread-win32. It is safer in this circumstance -to handle the case where ptw32_processInitialize() is called on -an already initialized library: - -int -ptw32_processInitialize (void) -{ - if (ptw32_processInitialized) { - /* - * ignore if already initialized. this is useful for - * programs that uses a non-dll pthread - * library. such programs must call ptw32_processInitialize() explicitely, - * since this initialization routine is automatically called only when - * the dll is loaded. - */ - return TRUE; - } - ptw32_processInitialized = TRUE; - [...] -} - ------------------------------------- -- in private.c, if macro NEED_FTIME is defined, add routines to -convert timespec_to_filetime and filetime_to_timespec, and modified -code that was using _ftime() to use Win32 API instead. - -Rational: _ftime is not available on WinCE. It is necessary to use -the native Win32 time API instead. - -Note: the routine timespec_to_filetime is provided as a convenience and a mean -to test that filetime_to_timespec works, but it is not used by the library. - ------------------------------------- -- in semaphore.c, if macro NEED_SEM is defined, add code for the routines -_increase_semaphore and _decrease_semaphore, and modify significantly -the implementation of the semaphores so that it does not use CreateSemaphore. - -Rational: CreateSemaphore is not available on WinCE. I had to re-implement -semaphores using mutexes and Events. - -Note: Only the semaphore routines that are used by pthread are implemented -(i.e. signal conditions rely on a subset of the semaphores routines, and -this subset works). Some other semaphore routines (e.g. sem_trywait) are -not yet supported on my WinCE port (and since I don't need them, I am not -planning to do anything about them). - ------------------------------------- -- in tsd.c, changed the code that defines TLS_OUT_OF_INDEXES - -/* TLS_OUT_OF_INDEXES not defined on WinCE */ -#ifndef TLS_OUT_OF_INDEXES -#define TLS_OUT_OF_INDEXES 0xffffffff -#endif - -Rational: TLS_OUT_OF_INDEXES is not defined in any standard include file -on WinCE. - ------------------------------------- -- added file need_errno.h - -Rational: On WinCE, there is no errno.h file. need_errno.h is just a -copy of windows version of errno.h, with minor modifications due to the fact -that some of the error codes are defined by the WinCE socket library. -In pthread.h, if NEED_ERRNO is defined, the file need_errno.h is -included (instead of ). - - --- eof diff --git a/vendor/pthreads/include/_ptw32.h b/vendor/pthreads/include/_ptw32.h new file mode 100644 index 0000000000..94d64e7f97 --- /dev/null +++ b/vendor/pthreads/include/_ptw32.h @@ -0,0 +1,215 @@ +/* + * Module: _ptw32.h + * + * Purpose: + * Pthreads4w internal macros, to be shared by other headers + * comprising the pthreads4w package. + * + * -------------------------------------------------------------------------- + * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * + * The 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: + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * -------------------------------------------------------------------------- + */ + +#ifndef __PTW32_H +#define __PTW32_H + +/* See the README file for an explanation of the pthreads-win32 + * version numbering scheme and how the DLL is named etc. + * + * FIXME: consider moving this to <_ptw32.h>; maybe also add a + * leading underscore to the macro names. + */ +#define __PTW32_VERSION_MAJOR 3 +#define __PTW32_VERSION_MINOR 0 +#define __PTW32_VERSION_MICRO 0 +#define __PTW32_VERION_BUILD 0 +#define __PTW32_VERSION 3,0,0,0 +#define __PTW32_VERSION_STRING "3, 0, 0, 0\0" + +#if defined(__GNUC__) +# pragma GCC system_header +# if ! defined __declspec +# error "Please upgrade your GNU compiler to one that supports __declspec." +# endif +#endif + +#if defined (__cplusplus) +# define __PTW32_BEGIN_C_DECLS extern "C" { +# define __PTW32_END_C_DECLS } +#else +# define __PTW32_BEGIN_C_DECLS +# define __PTW32_END_C_DECLS +#endif + +#if defined __PTW32_STATIC_LIB +# define __PTW32_DLLPORT + +#elif defined __PTW32_BUILD +# define __PTW32_DLLPORT __declspec (dllexport) +#else +# define __PTW32_DLLPORT /*__declspec (dllimport)*/ +#endif + +#ifndef __PTW32_CDECL +/* FIXME: another internal macro; should have two initial underscores; + * Nominally, we prefer to use __cdecl calling convention for all our + * functions, but we map it through this macro alias to facilitate the + * possible choice of alternatives; for example: + */ +# ifdef _OPEN_WATCOM_SOURCE + /* The Open Watcom C/C++ compiler uses a non-standard default calling + * convention, (similar to __fastcall), which passes function arguments + * in registers, unless the __cdecl convention is explicitly specified + * in exposed function prototypes. + * + * Our preference is to specify the __cdecl convention for all calls, + * 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 your + * application, then you may #define _OPEN_WATCOM_SOURCE, so disabling + * the forced specification of __cdecl for all function declarations; + * remember that this must be defined consistently, for both the DLL + * build, and the application build. + */ +# define __PTW32_CDECL +# else +# define __PTW32_CDECL __cdecl +# endif +#endif + +/* + * This is more or less a duplicate of what is in the autoconf config.h, + * which is only used when building the pthreads4w libraries. + */ + +#if !defined (__PTW32_CONFIG_H) && !defined(__PTW32_PSEUDO_CONFIG_H_SOURCED) +# define __PTW32_PSEUDO_CONFIG_H_SOURCED +# if defined(WINCE) +# undef HAVE_CPU_AFFINITY +# define NEED_DUPLICATEHANDLE +# define NEED_CREATETHREAD +# define NEED_ERRNO +# define NEED_CALLOC +# define NEED_UNICODE_CONSTS +# define NEED_PROCESS_AFFINITY_MASK +/* This may not be needed */ +# define RETAIN_WSALASTERROR +# elif defined(_MSC_VER) +# if _MSC_VER >= 1900 +# define HAVE_STRUCT_TIMESPEC +# elif _MSC_VER < 1300 +# define __PTW32_CONFIG_MSVC6 +# elif _MSC_VER < 1400 +# define __PTW32_CONFIG_MSVC7 +# endif +# elif defined(_UWIN) +# define HAVE_MODE_T +# define HAVE_STRUCT_TIMESPEC +# define HAVE_SIGNAL_H +# endif +#endif + +/* + * If HAVE_ERRNO_H is defined then assume that autoconf has been used + * to overwrite config.h, otherwise the original config.h is in use + * at build-time or the above block of defines is in use otherwise + * and NEED_ERRNO is either defined or not defined. + */ +#if defined(HAVE_ERRNO_H) || !defined(NEED_ERRNO) +# include +#else +# include "need_errno.h" +#endif + +#if defined(__BORLANDC__) +# define int64_t LONGLONG +# define uint64_t ULONGLONG +#elif !defined(__MINGW32__) + typedef _int64 int64_t; + typedef unsigned _int64 uint64_t; +# if defined (__PTW32_CONFIG_MSVC6) + typedef long intptr_t; +# endif +#elif defined(HAVE_STDINT_H) && HAVE_STDINT_H == 1 +# include +#endif + +/* + * In case ETIMEDOUT hasn't been defined above somehow. + */ +#if !defined(ETIMEDOUT) + /* + * note: ETIMEDOUT is no longer defined in winsock.h + * WSAETIMEDOUT is so use its value. + */ +# include +# if defined(WSAETIMEDOUT) +# define ETIMEDOUT WSAETIMEDOUT +# else +# define ETIMEDOUT 10060 /* This is the value of WSAETIMEDOUT in winsock.h. */ +# endif +#endif + +/* + * Several systems may not define some error numbers; + * defining those which are likely to be missing here will let + * us complete the library builds. + */ +#if !defined(ENOTSUP) +# define ENOTSUP 48 /* This is the value in Solaris. */ +#endif + +#if !defined(ENOSYS) +# define ENOSYS 140 /* Semi-arbitrary value */ +#endif + +#if !defined(EDEADLK) +# if defined(EDEADLOCK) +# define EDEADLK EDEADLOCK +# else +# define EDEADLK 36 /* This is the value in MSVC. */ +# endif +#endif + +/* POSIX 2008 - related to robust mutexes */ +#if __PTW32_VERSION_MAJOR > 2 +# if !defined(EOWNERDEAD) +# define EOWNERDEAD 1000 +# endif +# if !defined(ENOTRECOVERABLE) +# define ENOTRECOVERABLE 1001 +# endif +#else +# if !defined(EOWNERDEAD) +# define EOWNERDEAD 42 +# endif +# if !defined(ENOTRECOVERABLE) +# define ENOTRECOVERABLE 43 +# endif +#endif + +#endif /* !__PTW32_H */ diff --git a/vendor/pthreads/include/attr.c b/vendor/pthreads/include/attr.c deleted file mode 100644 index a9d55f4a4b..0000000000 --- a/vendor/pthreads/include/attr.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - * attr.c - * - * Description: - * This translation unit agregates operations on thread attribute objects. - * It is used for inline optimisation. - * - * The included modules are used separately when static executable sizes - * must be minimised. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX 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 "pthread_attr_init.c" -#include "pthread_attr_destroy.c" -#include "pthread_attr_getdetachstate.c" -#include "pthread_attr_setdetachstate.c" -#include "pthread_attr_getstackaddr.c" -#include "pthread_attr_setstackaddr.c" -#include "pthread_attr_getstacksize.c" -#include "pthread_attr_setstacksize.c" -#include "pthread_attr_getscope.c" -#include "pthread_attr_setscope.c" diff --git a/vendor/pthreads/include/autostatic.c b/vendor/pthreads/include/autostatic.c deleted file mode 100644 index 092aff2aee..0000000000 --- a/vendor/pthreads/include/autostatic.c +++ /dev/null @@ -1,69 +0,0 @@ -/* - * autostatic.c - * - * Description: - * This translation unit implements static auto-init and auto-exit logic. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX 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(PTW32_STATIC_LIB) - -#if defined(__MINGW64__) || defined(__MINGW32__) || defined(_MSC_VER) - -#include "pthread.h" -#include "implement.h" - -static void on_process_init(void) -{ - pthread_win32_process_attach_np (); -} - -static void on_process_exit(void) -{ - pthread_win32_thread_detach_np (); - pthread_win32_process_detach_np (); -} - -#if defined(__MINGW64__) || defined(__MINGW32__) -# define attribute_section(a) __attribute__((section(a))) -#elif defined(_MSC_VER) -# define attribute_section(a) __pragma(section(a,long,read)); __declspec(allocate(a)) -#endif - -attribute_section(".ctors") void *gcc_ctor = on_process_init; -attribute_section(".dtors") void *gcc_dtor = on_process_exit; - -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) */ - -#endif /* PTW32_STATIC_LIB */ diff --git a/vendor/pthreads/include/barrier.c b/vendor/pthreads/include/barrier.c deleted file mode 100644 index 41b950cd12..0000000000 --- a/vendor/pthreads/include/barrier.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * barrier.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" - - -#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_getpshared.c" -#include "pthread_barrierattr_setpshared.c" diff --git a/vendor/pthreads/include/builddmc.bat b/vendor/pthreads/include/builddmc.bat deleted file mode 100644 index bf813d8166..0000000000 --- a/vendor/pthreads/include/builddmc.bat +++ /dev/null @@ -1,9 +0,0 @@ -; Build the pthreads library with the Digital Mars Compiler -; -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 - -; 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 diff --git a/vendor/pthreads/include/cancel.c b/vendor/pthreads/include/cancel.c deleted file mode 100644 index 1bd14ebe65..0000000000 --- a/vendor/pthreads/include/cancel.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * cancel.c - * - * Description: - * POSIX thread functions related to thread cancellation. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX 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 "pthread_setcancelstate.c" -#include "pthread_setcanceltype.c" -#include "pthread_testcancel.c" -#include "pthread_cancel.c" diff --git a/vendor/pthreads/include/cleanup.c b/vendor/pthreads/include/cleanup.c index 381d1e87c8..0c3b05bd02 100644 --- a/vendor/pthreads/include/cleanup.c +++ b/vendor/pthreads/include/cleanup.c @@ -8,46 +8,50 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * -------------------------------------------------------------------------- */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" /* - * The functions ptw32_pop_cleanup and ptw32_push_cleanup + * The functions __ptw32_pop_cleanup and __ptw32_push_cleanup * are implemented here for applications written in C with no * SEH or C++ destructor support. */ -ptw32_cleanup_t * -ptw32_pop_cleanup (int execute) +__ptw32_cleanup_t * +__ptw32_pop_cleanup (int execute) /* * ------------------------------------------------------ * DOCPUBLIC @@ -73,9 +77,9 @@ ptw32_pop_cleanup (int execute) * ------------------------------------------------------ */ { - ptw32_cleanup_t *cleanup; + __ptw32_cleanup_t *cleanup; - cleanup = (ptw32_cleanup_t *) pthread_getspecific (ptw32_cleanupKey); + cleanup = (__ptw32_cleanup_t *) pthread_getspecific (__ptw32_cleanupKey); if (cleanup != NULL) { @@ -86,18 +90,18 @@ ptw32_pop_cleanup (int execute) } - pthread_setspecific (ptw32_cleanupKey, (void *) cleanup->prev); + pthread_setspecific (__ptw32_cleanupKey, (void *) cleanup->prev); } return (cleanup); -} /* ptw32_pop_cleanup */ +} /* __ptw32_pop_cleanup */ void -ptw32_push_cleanup (ptw32_cleanup_t * cleanup, - ptw32_cleanup_callback_t routine, void *arg) +__ptw32_push_cleanup (__ptw32_cleanup_t * cleanup, + __ptw32_cleanup_callback_t routine, void *arg) /* * ------------------------------------------------------ * DOCPUBLIC @@ -128,7 +132,7 @@ ptw32_push_cleanup (ptw32_cleanup_t * cleanup, * b) when the thread acts on a cancellation request, * c) or when the thrad calls pthread_cleanup_pop with a nonzero * 'execute' argument - * NOTE: pthread_push_cleanup, ptw32_pop_cleanup must be paired + * NOTE: pthread_push_cleanup, __ptw32_pop_cleanup must be paired * in the same lexical scope. * * RESULTS @@ -141,8 +145,8 @@ ptw32_push_cleanup (ptw32_cleanup_t * cleanup, cleanup->routine = routine; cleanup->arg = arg; - cleanup->prev = (ptw32_cleanup_t *) pthread_getspecific (ptw32_cleanupKey); + cleanup->prev = (__ptw32_cleanup_t *) pthread_getspecific (__ptw32_cleanupKey); - pthread_setspecific (ptw32_cleanupKey, (void *) cleanup); + pthread_setspecific (__ptw32_cleanupKey, (void *) cleanup); -} /* ptw32_push_cleanup */ +} /* __ptw32_push_cleanup */ diff --git a/vendor/pthreads/include/condvar.c b/vendor/pthreads/include/condvar.c deleted file mode 100644 index 704f4d7931..0000000000 --- a/vendor/pthreads/include/condvar.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * condvar.c - * - * Description: - * This translation unit implements condition variables and their 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" - -#include "ptw32_cond_check_need_init.c" -#include "pthread_condattr_init.c" -#include "pthread_condattr_destroy.c" -#include "pthread_condattr_getpshared.c" -#include "pthread_condattr_setpshared.c" -#include "pthread_cond_init.c" -#include "pthread_cond_destroy.c" -#include "pthread_cond_wait.c" -#include "pthread_cond_signal.c" diff --git a/vendor/pthreads/include/config.h b/vendor/pthreads/include/config.h index e231724e33..6da569098c 100644 --- a/vendor/pthreads/include/config.h +++ b/vendor/pthreads/include/config.h @@ -1,14 +1,17 @@ /* config.h */ -#ifndef PTW32_CONFIG_H -#define PTW32_CONFIG_H +#ifndef __PTW32_CONFIG_H +#define __PTW32_CONFIG_H /********************************************************************* * Defaults: see target specific redefinitions below. *********************************************************************/ /* We're building the pthreads-win32 library */ -#define PTW32_BUILD +#define __PTW32_BUILD + +/* CPU affinity */ +#define HAVE_CPU_AFFINITY /* Do we know about the C type sigset_t? */ #undef HAVE_SIGSET_T @@ -31,9 +34,6 @@ /* Define if you don't have Win32 calloc. (eg. WinCE) */ #undef NEED_CALLOC -/* Define if you don't have Win32 ftime. (eg. WinCE) */ -#undef NEED_FTIME - /* Define if you don't have Win32 semaphores. (eg. WinCE 2.1 or earlier) */ #undef NEED_SEM @@ -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 @@ -77,7 +77,7 @@ # applications that make assumptions that POSIX does not guarantee are # not strictly compliant and may fail or misbehave with some settings. # -# PTW32_THREAD_ID_REUSE_INCREMENT +# __PTW32_THREAD_ID_REUSE_INCREMENT # Purpose: # POSIX says that applications should assume that thread IDs can be # recycled. However, Solaris (and some other systems) use a [very large] @@ -95,11 +95,11 @@ # (i.e. will wrap sooner). This might be useful to emulate some embedded # systems. # -# define PTW32_THREAD_ID_REUSE_INCREMENT 0 +# define __PTW32_THREAD_ID_REUSE_INCREMENT 0 # # ---------------------------------------------------------------------- */ -#undef PTW32_THREAD_ID_REUSE_INCREMENT +#undef __PTW32_THREAD_ID_REUSE_INCREMENT /********************************************************************* @@ -109,32 +109,27 @@ * to the pthreads-win32 maintainer. Thanks. *********************************************************************/ #if defined(WINCE) -#define NEED_DUPLICATEHANDLE -#define NEED_CREATETHREAD -#define NEED_ERRNO -#define NEED_CALLOC -#define NEED_FTIME -/* #define NEED_SEM */ -#define NEED_UNICODE_CONSTS -#define NEED_PROCESS_AFFINITY_MASK +# undef HAVE_CPU_AFFINITY +# define NEED_DUPLICATEHANDLE +# define NEED_CREATETHREAD +# define NEED_ERRNO +# define NEED_CALLOC +# define NEED_FTIME +/* # define NEED_SEM */ +# define NEED_UNICODE_CONSTS +# define NEED_PROCESS_AFFINITY_MASK /* This may not be needed */ -#define RETAIN_WSALASTERROR +# define RETAIN_WSALASTERROR #endif #if defined(_UWIN) -#define HAVE_MODE_T -#define HAVE_STRUCT_TIMESPEC +# define HAVE_MODE_T +# define HAVE_STRUCT_TIMESPEC +# define HAVE_SIGNAL_H #endif #if defined(__GNUC__) -#define HAVE_C_INLINE -#endif - -#if defined(__MINGW64__) -#define HAVE_MODE_T -#define HAVE_STRUCT_TIMESPEC -#elif defined(__MINGW32__) -#define HAVE_MODE_T +# define HAVE_C_INLINE #endif #if defined(__BORLANDC__) @@ -148,6 +143,8 @@ #define HAVE_C_INLINE #endif - - +#if defined(_MSC_VER) && _MSC_VER >= 1900 +#define HAVE_STRUCT_TIMESPEC #endif + +#endif /* __PTW32_CONFIG_H */ diff --git a/vendor/pthreads/include/context.h b/vendor/pthreads/include/context.h index 29a28aed33..33294c150b 100644 --- a/vendor/pthreads/include/context.h +++ b/vendor/pthreads/include/context.h @@ -6,68 +6,66 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ -#ifndef PTW32_CONTEXT_H -#define PTW32_CONTEXT_H +#ifndef __PTW32_CONTEXT_H +#define __PTW32_CONTEXT_H -#undef PTW32_PROGCTR +#undef __PTW32_PROGCTR #if defined(_M_IX86) || (defined(_X86_) && !defined(__amd64__)) -#define PTW32_PROGCTR(Context) ((Context).Eip) +#define __PTW32_PROGCTR(Context) ((Context).Eip) #endif #if defined (_M_IA64) || defined(_IA64) -#define PTW32_PROGCTR(Context) ((Context).StIIP) +#define __PTW32_PROGCTR(Context) ((Context).StIIP) #endif #if defined(_MIPS_) || defined(MIPS) -#define PTW32_PROGCTR(Context) ((Context).Fir) +#define __PTW32_PROGCTR(Context) ((Context).Fir) #endif #if defined(_ALPHA_) -#define PTW32_PROGCTR(Context) ((Context).Fir) +#define __PTW32_PROGCTR(Context) ((Context).Fir) #endif #if defined(_PPC_) -#define PTW32_PROGCTR(Context) ((Context).Iar) +#define __PTW32_PROGCTR(Context) ((Context).Iar) #endif #if defined(_AMD64_) || defined(__amd64__) -#define PTW32_PROGCTR(Context) ((Context).Rip) +#define __PTW32_PROGCTR(Context) ((Context).Rip) #endif -#if defined(_ARM_) || defined(ARM) || defined(_ARM64_) +#if defined(_ARM_) || defined(ARM) || defined(_M_ARM) || defined(_M_ARM64) #define PTW32_PROGCTR(Context) ((Context).Pc) #endif -#if !defined(PTW32_PROGCTR) +#if !defined (__PTW32_PROGCTR) #error Module contains CPU-specific code; modify and recompile. #endif diff --git a/vendor/pthreads/include/create.c b/vendor/pthreads/include/create.c index 8b036cc2e9..3ed7ca9165 100644 --- a/vendor/pthreads/include/create.c +++ b/vendor/pthreads/include/create.c @@ -7,34 +7,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" #if ! defined(_UWIN) && ! defined(WINCE) @@ -43,56 +45,56 @@ int pthread_create (pthread_t * tid, - const pthread_attr_t * attr, - void *(PTW32_CDECL *start) (void *), void *arg) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function creates a thread running the start function, - * passing it the parameter value, 'arg'. The 'attr' - * argument specifies optional creation attributes. - * The identity of the new thread is returned - * via 'tid', which should not be NULL. - * - * PARAMETERS - * tid - * pointer to an instance of pthread_t - * - * attr - * optional pointer to an instance of pthread_attr_t - * - * start - * pointer to the starting routine for the new thread - * - * arg - * optional parameter passed to 'start' - * - * - * DESCRIPTION - * This function creates a thread running the start function, - * passing it the parameter value, 'arg'. The 'attr' - * argument specifies optional creation attributes. - * The identity of the new thread is returned - * via 'tid', which should not be the NULL pointer. - * - * RESULTS - * 0 successfully created thread, - * EINVAL attr invalid, - * EAGAIN insufficient resources. - * - * ------------------------------------------------------ - */ + const pthread_attr_t * attr, + void * (__PTW32_CDECL *start) (void *), void *arg) +/* + * ------------------------------------------------------ + * DOCPUBLIC + * This function creates a thread running the start function, + * passing it the parameter value, 'arg'. The 'attr' + * argument specifies optional creation attributes. + * The identity of the new thread is returned + * via 'tid', which should not be NULL. + * + * PARAMETERS + * tid + * pointer to an instance of pthread_t + * + * attr + * optional pointer to an instance of pthread_attr_t + * + * start + * pointer to the starting routine for the new thread + * + * arg + * optional parameter passed to 'start' + * + * + * DESCRIPTION + * This function creates a thread running the start function, + * passing it the parameter value, 'arg'. The 'attr' + * argument specifies optional creation attributes. + * The identity of the new thread is returned + * via 'tid', which should not be the NULL pointer. + * + * RESULTS + * 0 successfully created thread, + * EINVAL attr invalid, + * EAGAIN insufficient resources. + * + * ------------------------------------------------------ + */ { pthread_t thread; - ptw32_thread_t * tp; + __ptw32_thread_t * tp; + __ptw32_thread_t * sp; register pthread_attr_t a; HANDLE threadH = 0; int result = EAGAIN; - int run = PTW32_TRUE; + int run = __PTW32_TRUE; ThreadParms *parms = NULL; unsigned int stackSize; int priority; - pthread_t self; /* * Before doing anything, check that tid can be stored through @@ -102,6 +104,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; @@ -111,12 +118,13 @@ pthread_create (pthread_t * tid, a = NULL; } - if ((thread = ptw32_new ()).p == NULL) + thread = __ptw32_new(); + if (thread.p == NULL) { goto FAIL0; } - tp = (ptw32_thread_t *) thread.p; + tp = (__ptw32_thread_t *) thread.p; priority = tp->sched_priority; @@ -129,22 +137,34 @@ 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 +#if defined(HAVE_CPU_AFFINITY) + tp->cpuset = sp->cpuset; +#endif if (a != NULL) { +#if defined(HAVE_CPU_AFFINITY) + cpu_set_t none; + cpu_set_t attr_cpuset; + ((_sched_cpu_set_vector_*)&attr_cpuset)->_cpuset = a->cpuset; + + CPU_ZERO(&none); + if (! CPU_EQUAL(&attr_cpuset, &none)) + { + tp->cpuset = a->cpuset; + } +#endif stackSize = (unsigned int)a->stacksize; tp->detachState = a->detachstate; priority = a->param.sched_priority; + if (a->thrname != NULL) + tp->name = _strdup(a->thrname); #if (THREAD_PRIORITY_LOWEST > THREAD_PRIORITY_NORMAL) /* WinCE */ @@ -164,17 +184,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 @@ -187,7 +204,11 @@ pthread_create (pthread_t * tid, stackSize = PTHREAD_STACK_MIN; } - tp->state = run ? PThreadStateInitial : PThreadStateSuspended; + /* + * State must be >= PThreadStateRunning before we return to the caller. + * __ptw32_threadStart will set state to PThreadStateRunning. + */ + tp->state = PThreadStateSuspended; tp->keys = NULL; @@ -200,46 +221,52 @@ pthread_create (pthread_t * tid, * finished with it here. */ -#if ! (defined (__MINGW64__) || defined(__MINGW32__)) || defined (__MSVCRT__) || defined (__DMC__) +#if ! defined (__MINGW32__) || defined (__MSVCRT__) || defined (__DMC__) tp->threadH = - threadH = - (HANDLE) _beginthreadex ((void *) NULL, /* No security info */ - stackSize, /* default stack size */ - ptw32_threadStart, - parms, - (unsigned) - CREATE_SUSPENDED, - (unsigned *) &(tp->thread)); + threadH = + (HANDLE) _beginthreadex ((void *) NULL, /* No security info */ + stackSize, /* default stack size */ + __ptw32_threadStart, + parms, + (unsigned) + CREATE_SUSPENDED, + (unsigned *) &(tp->thread)); if (threadH != 0) { if (a != NULL) - { - (void) ptw32_setthreadpriority (thread, SCHED_OTHER, priority); - } + { + (void) __ptw32_setthreadpriority (thread, SCHED_OTHER, priority); + } + +#if defined(HAVE_CPU_AFFINITY) + + SetThreadAffinityMask(tp->threadH, tp->cpuset); + +#endif if (run) - { - ResumeThread (threadH); - } + { + ResumeThread (threadH); + } } #else { - ptw32_mcs_local_node_t stateLock; + __ptw32_mcs_local_node_t stateLock; /* * This lock will force pthread_threadStart() to wait until we have * the thread handle and have set the priority. */ - ptw32_mcs_lock_acquire(&tp->stateLock, &stateLock); + __ptw32_mcs_lock_acquire(&tp->stateLock, &stateLock); tp->threadH = - threadH = - (HANDLE) _beginthread (ptw32_threadStart, stackSize, /* default stack size */ - parms); + threadH = + (HANDLE) _beginthread (__ptw32_threadStart, stackSize, /* default stack size */ + parms); /* * Make the return code match _beginthreadex's. @@ -251,22 +278,29 @@ 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); + } + +#if defined(HAVE_CPU_AFFINITY) + + SetThreadAffinityMask(tp->threadH, tp->cpuset); + +#endif + } - ptw32_mcs_lock_release (&stateLock); + __ptw32_mcs_lock_release (&stateLock); } #endif @@ -282,17 +316,17 @@ pthread_create (pthread_t * tid, * ------------ */ -FAIL0: + FAIL0: if (result != 0) { - ptw32_threadDestroy (thread); + __ptw32_threadDestroy (thread); tp = NULL; if (parms != NULL) - { - free (parms); - } + { + free (parms); + } } else { @@ -304,5 +338,4 @@ pthread_create (pthread_t * tid, pthread_count++; #endif return (result); - } /* pthread_create */ diff --git a/vendor/pthreads/include/dll.c b/vendor/pthreads/include/dll.c index 05e01bee76..1dccfb0b97 100644 --- a/vendor/pthreads/include/dll.c +++ b/vendor/pthreads/include/dll.c @@ -6,41 +6,43 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ -#if !defined(PTW32_STATIC_LIB) +#ifdef HAVE_CONFIG_H +# include +#endif #include "pthread.h" #include "implement.h" +#if !defined (__PTW32_STATIC_LIB) + #if defined(_MSC_VER) -/* +/* * lpvReserved yields an unreferenced formal parameter; * ignore it */ @@ -53,10 +55,9 @@ */ extern "C" #endif /* __cplusplus */ - BOOL WINAPI -DllMain (HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpvReserved) + BOOL WINAPI DllMain (HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpvReserved) { - BOOL result = PTW32_TRUE; + BOOL result = __PTW32_TRUE; switch (fdwReason) { @@ -89,4 +90,78 @@ 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 + +#if defined(__PTW32_STATIC_LIB) + +/* + * Note: MSVC 8 and higher use code in dll.c, which enables TLS cleanup + * on thread exit. Code here can only do process init and exit functions. + */ + +#if defined(__MINGW32__) || 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 int on_process_exit(void) +{ + pthread_win32_thread_detach_np (); + pthread_win32_process_detach_np (); + return 0; +} + +#if defined(__GNUC__) +__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) +# 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 + +#endif /* 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 */ + diff --git a/vendor/pthreads/include/errno.c b/vendor/pthreads/include/errno.c index 78aa920a5b..36eb301e94 100644 --- a/vendor/pthreads/include/errno.c +++ b/vendor/pthreads/include/errno.c @@ -7,34 +7,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #if defined(NEED_ERRNO) #include "pthread.h" @@ -84,7 +86,7 @@ _errno (void) } else { - result = (int *)(&self.p->exitStatus); + result = (int *)(&((__ptw32_thread_t *)self.p)->exitStatus); } return (result); @@ -92,3 +94,10 @@ _errno (void) } /* _errno */ #endif /* (NEED_ERRNO) */ + +#if ! defined (__PTW32_BUILD_INLINED) +/* + * Avoid "translation unit is empty" warnings + */ +typedef int foo; +#endif diff --git a/vendor/pthreads/include/exit.c b/vendor/pthreads/include/exit.c deleted file mode 100644 index 94369d007c..0000000000 --- a/vendor/pthreads/include/exit.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * exit.c - * - * Description: - * This translation unit implements routines associated with exiting from - * a 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 - */ - -#include "pthread.h" -#include "implement.h" -#if ! defined(_UWIN) && ! defined(WINCE) -# include -#endif - -#include "pthread_exit.c" diff --git a/vendor/pthreads/include/fork.c b/vendor/pthreads/include/fork.c deleted file mode 100644 index 8a29550caf..0000000000 --- a/vendor/pthreads/include/fork.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - * fork.c - * - * Description: - * Implementation of fork() for POSIX threads. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX 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" diff --git a/vendor/pthreads/include/global.c b/vendor/pthreads/include/global.c index f1e9b3f669..f1f0ecfcf5 100644 --- a/vendor/pthreads/include/global.c +++ b/vendor/pthreads/include/global.c @@ -7,97 +7,99 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" -int ptw32_processInitialized = PTW32_FALSE; -ptw32_thread_t * ptw32_threadReuseTop = PTW32_THREAD_REUSE_EMPTY; -ptw32_thread_t * ptw32_threadReuseBottom = PTW32_THREAD_REUSE_EMPTY; -pthread_key_t ptw32_selfThreadKey = NULL; -pthread_key_t ptw32_cleanupKey = NULL; -pthread_cond_t ptw32_cond_list_head = NULL; -pthread_cond_t ptw32_cond_list_tail = NULL; +int __ptw32_processInitialized = __PTW32_FALSE; +__ptw32_thread_t * __ptw32_threadReuseTop = __PTW32_THREAD_REUSE_EMPTY; +__ptw32_thread_t * __ptw32_threadReuseBottom = __PTW32_THREAD_REUSE_EMPTY; +pthread_key_t __ptw32_selfThreadKey = NULL; +pthread_key_t __ptw32_cleanupKey = NULL; +pthread_cond_t __ptw32_cond_list_head = NULL; +pthread_cond_t __ptw32_cond_list_tail = NULL; -int ptw32_concurrency = 0; +int __ptw32_concurrency = 0; /* What features have been auto-detected */ -int ptw32_features = 0; +int __ptw32_features = 0; /* * Global [process wide] thread sequence Number */ -unsigned __int64 ptw32_threadSeqNumber = 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. */ -ptw32_mcs_lock_t ptw32_thread_reuse_lock = 0; +__ptw32_mcs_lock_t __ptw32_thread_reuse_lock = 0; /* * Global lock for testing internal state of statically declared mutexes. */ -ptw32_mcs_lock_t ptw32_mutex_test_init_lock = 0; +__ptw32_mcs_lock_t __ptw32_mutex_test_init_lock = 0; /* * Global lock for testing internal state of PTHREAD_COND_INITIALIZER * created condition variables. */ -ptw32_mcs_lock_t ptw32_cond_test_init_lock = 0; +__ptw32_mcs_lock_t __ptw32_cond_test_init_lock = 0; /* * Global lock for testing internal state of PTHREAD_RWLOCK_INITIALIZER * created read/write locks. */ -ptw32_mcs_lock_t ptw32_rwlock_test_init_lock = 0; +__ptw32_mcs_lock_t __ptw32_rwlock_test_init_lock = 0; /* * Global lock for testing internal state of PTHREAD_SPINLOCK_INITIALIZER * created spin locks. */ -ptw32_mcs_lock_t ptw32_spinlock_test_init_lock = 0; +__ptw32_mcs_lock_t __ptw32_spinlock_test_init_lock = 0; /* * Global lock for condition variable linked list. The list exists * to wake up CVs when a WM_TIMECHANGE message arrives. See * w32_TimeChangeHandler.c. */ -ptw32_mcs_lock_t ptw32_cond_list_lock = 0; +__ptw32_mcs_lock_t __ptw32_cond_list_lock = 0; #if defined(_UWIN) /* diff --git a/vendor/pthreads/include/implement.h b/vendor/pthreads/include/implement.h index 693be26a24..78623e9312 100644 --- a/vendor/pthreads/include/implement.h +++ b/vendor/pthreads/include/implement.h @@ -7,43 +7,49 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: Ross.Johnson@homemail.com.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #if !defined(_IMPLEMENT_H) #define _IMPLEMENT_H +#if !defined (__PTW32_CONFIG_H) +# error "config.h was not #included" +#endif + +#include <_ptw32.h> + #if !defined(_WIN32_WINNT) -#define _WIN32_WINNT 0x0400 +# define _WIN32_WINNT 0x0400 #endif -#include +#define WIN32_LEAN_AND_MEAN +#include +#include /* * In case windows.h doesn't define it (e.g. WinCE perhaps) */ @@ -52,117 +58,141 @@ typedef VOID (APIENTRY *PAPCFUNC)(DWORD dwParam); #endif /* - * note: ETIMEDOUT is correctly defined in winsock.h - */ -#include - -/* - * In case ETIMEDOUT hasn't been defined above somehow. + * Designed to allow error values to be set and retrieved in builds where + * MSCRT libraries are statically linked to DLLs. + * + * This does not handle the case where a static pthreads4w lib is linked + * to a static linked app. Compiling and linking pthreads.c with app.c + * as one does work with the right macros defined. See tests/Makefile + * for clues or just "cd tests && nmake clean VC-static". */ -#if !defined(ETIMEDOUT) -# define ETIMEDOUT 10060 /* This is the value in winsock.h. */ +#if ! defined(WINCE) && \ + (( defined(__MINGW32__) && __MSVCRT_VERSION__ >= 0x0800 ) || \ + ( defined(_MSC_VER) && _MSC_VER >= 1400 )) /* MSVC8+ */ +# if defined(__MINGW32__) +__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(__MINGW32__) +__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_GET_ERRNO() (errno) +# if defined(__MINGW32__) +__attribute__((unused)) +# endif +static void __ptw32_set_errno(int err) { errno = err; SetLastError(err); } +# define __PTW32_SET_ERRNO(err) __ptw32_set_errno(err) #endif #if !defined(malloc) -#include +# include #endif -#if defined(__CLEANUP_C) +#if defined(__PTW32_CLEANUP_C) # include #endif #if !defined(INT_MAX) -#include +# include #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(__MINGW64__) || defined(__MINGW32__) -# include -#elif defined(__BORLANDC__) -# define int64_t ULONGLONG + +#define __PTW32_INTERLOCKED_LONG long +#define __PTW32_INTERLOCKED_PVOID PVOID +#define __PTW32_INTERLOCKED_LONGPTR __PTW32_INTERLOCKED_VOLATILE long* +#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 int64_t _int64 -# if defined(_MSC_VER) && _MSC_VER < 1300 - typedef long intptr_t; -# endif +# define __PTW32_INTERLOCKED_SIZE long +# define __PTW32_INTERLOCKED_SIZEPTR __PTW32_INTERLOCKED_VOLATILE long* +#endif + +/* + * Don't allow the linker to optimize away dll.obj (dll.o) in static builds. + */ +#if defined (__PTW32_STATIC_LIB) && defined (__PTW32_BUILD) && !defined (__PTW32_TEST_SNEAK_PEEK) + void __ptw32_autostatic_anchor(void); +# if defined(__GNUC__) + __attribute__((unused, used)) +# endif + static void (*local_autostatic_anchor)(void) = __ptw32_autostatic_anchor; #endif typedef enum { /* * This enumeration represents the state of the thread; - * The thread is still "alive" if the numeric value of the + * The thread is still valid if the numeric value of the * state is greater or equal "PThreadStateRunning". */ PThreadStateInitial = 0, /* Thread not running */ + PThreadStateReuse, /* In reuse pool. */ 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 */ PThreadStateExiting, /* Thread alive but exiting */ /* due to an exception */ - PThreadStateLast, /* All handlers have been run and now */ + PThreadStateLast /* All handlers have been run and now */ /* final cleanup can be done. */ - PThreadStateReuse /* In reuse pool. */ } PThreadState; -typedef struct ptw32_mcs_node_t_ ptw32_mcs_local_node_t; -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; - +typedef struct __ptw32_mcs_node_t_ __ptw32_mcs_local_node_t; +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_ +struct __ptw32_thread_t_ { unsigned __int64 seqNumber; /* Process-unique thread sequence number */ HANDLE threadH; /* Win32 thread handle - POSIX thread is invalid if threadH == 0 */ pthread_t ptHandle; /* This thread's permanent pthread_t handle */ - ptw32_thread_t * prevReuse; /* Links threads on reuse stack */ + __ptw32_thread_t * prevReuse; /* Links threads on reuse stack */ volatile PThreadState state; - ptw32_mcs_lock_t threadLock; /* Used for serialised access to public thread state */ - ptw32_mcs_lock_t stateLock; /* Used for async-cancel safety */ + __ptw32_mcs_lock_t threadLock; /* Used for serialised access to public thread state */ + __ptw32_mcs_lock_t stateLock; /* Used for async-cancel safety */ HANDLE cancelEvent; void *exitStatus; void *parms; void *keys; void *nextAssoc; -#if defined(__CLEANUP_C) +#if defined(__PTW32_CLEANUP_C) jmp_buf start_mark; /* Jump buffer follows void* so should be aligned */ -#endif /* __CLEANUP_C */ +#endif /* __PTW32_CLEANUP_C */ #if defined(HAVE_SIGSET_T) sigset_t sigmask; #endif /* HAVE_SIGSET_T */ - ptw32_mcs_lock_t + __ptw32_mcs_lock_t robustMxListLock; /* robustMxList lock */ - ptw32_robust_node_t* + __ptw32_robust_node_t* robustMxList; /* List of currenty held robust mutexes */ int ptErrno; int detachState; @@ -170,7 +200,11 @@ struct ptw32_thread_t_ int cancelState; int cancelType; int implicit:1; - DWORD thread; /* Win32 thread ID */ + DWORD thread; /* Windows thread ID */ +#if defined(HAVE_CPU_AFFINITY) + size_t cpuset; /* Thread CPU affinity set */ +#endif + char * name; /* Thread name */ #if defined(_UWIN) DWORD dummy[5]; #endif @@ -178,10 +212,10 @@ struct ptw32_thread_t_ }; -/* +/* * Special value to mark attribute objects as valid. */ -#define PTW32_ATTR_VALID ((unsigned long) 0xC4C0FFEE) +#define __PTW32_ATTR_VALID ((unsigned long) 0xC4C0FFEE) struct pthread_attr_t_ { @@ -192,6 +226,8 @@ struct pthread_attr_t_ struct sched_param param; int inheritsched; int contentionscope; + size_t cpuset; + char * thrname; #if defined(HAVE_SIGSET_T) sigset_t sigmask; #endif /* HAVE_SIGSET_T */ @@ -209,15 +245,15 @@ struct pthread_attr_t_ struct sem_t_ { int value; - pthread_mutex_t lock; + __ptw32_mcs_lock_t lock; HANDLE sem; #if defined(NEED_SEM) int leftToUnblock; #endif }; -#define PTW32_OBJECT_AUTO_INIT ((void *)(size_t) -1) -#define PTW32_OBJECT_INVALID NULL +#define __PTW32_OBJECT_AUTO_INIT ((void *)(size_t) -1) +#define __PTW32_OBJECT_INVALID NULL struct pthread_mutex_t_ { @@ -234,28 +270,28 @@ struct pthread_mutex_t_ pthread_t ownerThread; HANDLE event; /* Mutex release notification to waiting threads. */ - ptw32_robust_node_t* + __ptw32_robust_node_t* robustNode; /* Extra state for robust mutexes */ }; -enum ptw32_robust_state_t_ +enum __ptw32_robust_state_t_ { - PTW32_ROBUST_CONSISTENT, - PTW32_ROBUST_INCONSISTENT, - PTW32_ROBUST_NOTRECOVERABLE + __PTW32_ROBUST_CONSISTENT, + __PTW32_ROBUST_INCONSISTENT, + __PTW32_ROBUST_NOTRECOVERABLE }; -typedef enum ptw32_robust_state_t_ ptw32_robust_state_t; +typedef enum __ptw32_robust_state_t_ __ptw32_robust_state_t; /* * Node used to manage per-thread lists of currently-held robust mutexes. */ -struct ptw32_robust_node_t_ +struct __ptw32_robust_node_t_ { pthread_mutex_t mx; - ptw32_robust_state_t stateInconsistent; - ptw32_robust_node_t* prev; - ptw32_robust_node_t* next; + __ptw32_robust_state_t stateInconsistent; + __ptw32_robust_node_t* prev; + __ptw32_robust_node_t* next; }; struct pthread_mutexattr_t_ @@ -266,15 +302,15 @@ struct pthread_mutexattr_t_ }; /* - * Possible values, other than PTW32_OBJECT_INVALID, + * Possible values, other than __PTW32_OBJECT_INVALID, * for the "interlock" element in a spinlock. * * In this implementation, when a spinlock is initialised, * the number of cpus available to the process is checked. * If there is only one cpu then "interlock" is set equal to - * PTW32_SPIN_USE_MUTEX and u.mutex is an initialised mutex. + * __PTW32_SPIN_USE_MUTEX and u.mutex is an initialised mutex. * If the number of cpus is greater than 1 then "interlock" - * is set equal to PTW32_SPIN_UNLOCKED and the number is + * is set equal to __PTW32_SPIN_UNLOCKED and the number is * stored in u.cpus. This arrangement allows the spinlock * routines to attempt an InterlockedCompareExchange on "interlock" * immediately and, if that fails, to try the inferior mutex. @@ -282,10 +318,10 @@ struct pthread_mutexattr_t_ * "u.cpus" isn't used for anything yet, but could be used at * some point to optimise spinlock behaviour. */ -#define PTW32_SPIN_INVALID (0) -#define PTW32_SPIN_UNLOCKED (1) -#define PTW32_SPIN_LOCKED (2) -#define PTW32_SPIN_USE_MUTEX (3) +#define __PTW32_SPIN_INVALID (0) +#define __PTW32_SPIN_UNLOCKED (1) +#define __PTW32_SPIN_LOCKED (2) +#define __PTW32_SPIN_USE_MUTEX (3) struct pthread_spinlock_t_ { @@ -300,10 +336,10 @@ struct pthread_spinlock_t_ /* * MCS lock queue node - see ptw32_MCS_lock.c */ -struct ptw32_mcs_node_t_ +struct __ptw32_mcs_node_t_ { - struct ptw32_mcs_node_t_ **lock; /* ptr to tail of queue */ - struct ptw32_mcs_node_t_ *next; /* ptr to successor in queue */ + struct __ptw32_mcs_node_t_ **lock; /* ptr to tail of queue */ + struct __ptw32_mcs_node_t_ *next; /* ptr to successor in queue */ HANDLE readyFlag; /* set after lock is released by predecessor */ HANDLE nextFlag; /* set after 'next' ptr is set by @@ -317,8 +353,8 @@ struct pthread_barrier_t_ unsigned int nInitialBarrierHeight; int pshared; sem_t semBarrierBreeched; - ptw32_mcs_lock_t lock; - ptw32_mcs_local_node_t proxynode; + __ptw32_mcs_lock_t lock; + __ptw32_mcs_local_node_t proxynode; }; struct pthread_barrierattr_t_ @@ -329,8 +365,8 @@ struct pthread_barrierattr_t_ struct pthread_key_t_ { DWORD key; - void (PTW32_CDECL *destructor) (void *); - ptw32_mcs_lock_t keyLock; + void (__PTW32_CDECL *destructor) (void *); + __ptw32_mcs_lock_t keyLock; void *threads; }; @@ -340,7 +376,7 @@ typedef struct ThreadParms ThreadParms; struct ThreadParms { pthread_t tid; - void *(PTW32_CDECL *start) (void *); + void * (__PTW32_CDECL *start) (void *); void *arg; }; @@ -368,7 +404,7 @@ struct pthread_condattr_t_ int pshared; }; -#define PTW32_RWLOCK_MAGIC 0xfacade2 +#define __PTW32_RWLOCK_MAGIC 0xfacade2 struct pthread_rwlock_t_ { @@ -386,6 +422,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 +511,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. * @@ -487,7 +529,7 @@ struct ThreadKeyAssoc * * */ - ptw32_thread_t * thread; + __ptw32_thread_t * thread; pthread_key_t key; ThreadKeyAssoc *nextKey; ThreadKeyAssoc *nextThread; @@ -496,7 +538,7 @@ struct ThreadKeyAssoc }; -#if defined(__CLEANUP_SEH) +#if defined(__PTW32_CLEANUP_SEH) /* * -------------------------------------------------------------- * MAKE_SOFTWARE_EXCEPTION @@ -533,66 +575,63 @@ struct ThreadKeyAssoc */ #define EXCEPTION_PTW32_SERVICES \ MAKE_SOFTWARE_EXCEPTION( SE_ERROR, \ - PTW32_SERVICES_FACILITY, \ - PTW32_SERVICES_ERROR ) + __PTW32_SERVICES_FACILITY, \ + __PTW32_SERVICES_ERROR ) -#define PTW32_SERVICES_FACILITY 0xBAD -#define PTW32_SERVICES_ERROR 0xDEED +#define __PTW32_SERVICES_FACILITY 0xBAD +#define __PTW32_SERVICES_ERROR 0xDEED -#endif /* __CLEANUP_SEH */ +#endif /* __PTW32_CLEANUP_SEH */ /* * Services available through EXCEPTION_PTW32_SERVICES - * and also used [as parameters to ptw32_throw()] as + * and also used [as parameters to __ptw32_throw()] as * generic exception selectors. */ -#define PTW32_EPS_EXIT (1) -#define PTW32_EPS_CANCEL (2) +#define __PTW32_EPS_EXIT (1) +#define __PTW32_EPS_CANCEL (2) /* Useful macros */ -#define PTW32_MAX(a,b) ((a)<(b)?(b):(a)) -#define PTW32_MIN(a,b) ((a)>(b)?(b):(a)) +#define __PTW32_MAX(a,b) ((a)<(b)?(b):(a)) +#define __PTW32_MIN(a,b) ((a)>(b)?(b):(a)) /* Declared in 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) +#define __PTW32_THREAD_REUSE_EMPTY ((__ptw32_thread_t *)(size_t) 1) -extern int ptw32_processInitialized; -extern ptw32_thread_t * ptw32_threadReuseTop; -extern ptw32_thread_t * ptw32_threadReuseBottom; -extern pthread_key_t ptw32_selfThreadKey; -extern pthread_key_t ptw32_cleanupKey; -extern pthread_cond_t ptw32_cond_list_head; -extern pthread_cond_t ptw32_cond_list_tail; +extern int __ptw32_processInitialized; +extern __ptw32_thread_t * __ptw32_threadReuseTop; +extern __ptw32_thread_t * __ptw32_threadReuseBottom; +extern pthread_key_t __ptw32_selfThreadKey; +extern pthread_key_t __ptw32_cleanupKey; +extern pthread_cond_t __ptw32_cond_list_head; +extern pthread_cond_t __ptw32_cond_list_tail; -extern int ptw32_mutex_default_kind; +extern int __ptw32_mutex_default_kind; -extern unsigned __int64 ptw32_threadSeqNumber; +extern unsigned __int64 __ptw32_threadSeqNumber; -extern int ptw32_concurrency; +extern int __ptw32_concurrency; -extern int ptw32_features; +extern int __ptw32_features; -extern ptw32_mcs_lock_t ptw32_thread_reuse_lock; -extern ptw32_mcs_lock_t ptw32_mutex_test_init_lock; -extern ptw32_mcs_lock_t ptw32_cond_list_lock; -extern ptw32_mcs_lock_t ptw32_cond_test_init_lock; -extern ptw32_mcs_lock_t ptw32_rwlock_test_init_lock; -extern ptw32_mcs_lock_t ptw32_spinlock_test_init_lock; +extern __ptw32_mcs_lock_t __ptw32_thread_reuse_lock; +extern __ptw32_mcs_lock_t __ptw32_mutex_test_init_lock; +extern __ptw32_mcs_lock_t __ptw32_cond_list_lock; +extern __ptw32_mcs_lock_t __ptw32_cond_test_init_lock; +extern __ptw32_mcs_lock_t __ptw32_rwlock_test_init_lock; +extern __ptw32_mcs_lock_t __ptw32_spinlock_test_init_lock; #if defined(_UWIN) extern int pthread_count; #endif -#if defined(__cplusplus) -extern "C" -{ -#endif /* __cplusplus */ +__PTW32_BEGIN_C_DECLS /* * ===================== @@ -602,102 +641,86 @@ extern "C" * ===================== */ - int ptw32_is_attr (const pthread_attr_t * attr); + int __ptw32_is_attr (const pthread_attr_t * attr); - 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_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); + 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); + int __ptw32_processInitialize (void); - void ptw32_processTerminate (void); + void __ptw32_processTerminate (void); - void ptw32_threadDestroy (pthread_t tid); + void __ptw32_threadDestroy (pthread_t tid); - void ptw32_pop_cleanup_all (int execute); + void __ptw32_pop_cleanup_all (int execute); - pthread_t ptw32_new (void); + pthread_t __ptw32_new (void); - pthread_t ptw32_threadReusePop (void); + pthread_t __ptw32_threadReusePop (void); - void ptw32_threadReusePush (pthread_t thread); + void __ptw32_threadReusePush (pthread_t thread); - int ptw32_getprocessors (int *count); + int __ptw32_getprocessors (int *count); - int ptw32_setthreadpriority (pthread_t thread, int policy, int priority); + int __ptw32_setthreadpriority (pthread_t thread, int policy, int priority); - void ptw32_rwlock_cancelwrwait (void *arg); + void __ptw32_rwlock_cancelwrwait (void *arg); -#if ! (defined (__MINGW64__) || defined(__MINGW32__)) || (defined(__MSVCRT__) && ! defined(__DMC__)) +#if ! defined (__MINGW32__) || (defined (__MSVCRT__) && ! defined (__DMC__)) unsigned __stdcall #else void #endif - ptw32_threadStart (void *vthreadParms); + __ptw32_threadStart (void *vthreadParms); - void ptw32_callUserDestroyRoutines (pthread_t thread); + void __ptw32_callUserDestroyRoutines (pthread_t thread); - int ptw32_tkAssocCreate (ptw32_thread_t * thread, pthread_key_t key); + int __ptw32_tkAssocCreate (__ptw32_thread_t * thread, pthread_key_t key); - void ptw32_tkAssocDestroy (ThreadKeyAssoc * assoc); + void __ptw32_tkAssocDestroy (ThreadKeyAssoc * assoc); - int ptw32_semwait (sem_t * sem); + int __ptw32_semwait (sem_t * sem); - DWORD ptw32_relmillisecs (const struct timespec * abstime); + DWORD __ptw32_relmillisecs (const struct timespec * abstime); - void ptw32_mcs_lock_acquire (ptw32_mcs_lock_t * lock, ptw32_mcs_local_node_t * node); + void __ptw32_mcs_lock_acquire (__ptw32_mcs_lock_t * lock, __ptw32_mcs_local_node_t * node); - int ptw32_mcs_lock_try_acquire (ptw32_mcs_lock_t * lock, ptw32_mcs_local_node_t * node); + int __ptw32_mcs_lock_try_acquire (__ptw32_mcs_lock_t * lock, __ptw32_mcs_local_node_t * node); - void ptw32_mcs_lock_release (ptw32_mcs_local_node_t * node); + void __ptw32_mcs_lock_release (__ptw32_mcs_local_node_t * node); - void ptw32_mcs_node_transfer (ptw32_mcs_local_node_t * new_node, ptw32_mcs_local_node_t * old_node); + void __ptw32_mcs_node_transfer (__ptw32_mcs_local_node_t * new_node, __ptw32_mcs_local_node_t * old_node); -#if defined(NEED_FTIME) - void ptw32_timespec_to_filetime (const struct timespec *ts, FILETIME * ft); - void ptw32_filetime_to_timespec (const FILETIME * ft, struct timespec *ts); -#endif + void __ptw32_timespec_to_filetime (const struct timespec *ts, FILETIME * ft); + + void __ptw32_filetime_to_timespec (const FILETIME * ft, struct timespec *ts); -/* Declared in misc.c */ +/* Declared in pthw32_calloc.c */ #if defined(NEED_CALLOC) -#define calloc(n, s) ptw32_calloc(n, s) - void *ptw32_calloc (size_t n, size_t s); +#define calloc(n, s) __ptw32_calloc(n, s) + void *__ptw32_calloc (size_t n, size_t s); #endif -/* Declared in private.c */ -#if defined(_MSC_VER) -/* - * Ignore the warning: - * "C++ exception specification ignored except to indicate that - * the function is not __declspec(nothrow)." - */ -#pragma warning(disable:4290) -#endif - void ptw32_throw (DWORD exception) -#if defined(__CLEANUP_CXX) - throw(ptw32_exception_cancel,ptw32_exception_exit) -#endif -; - -#if defined(__cplusplus) -} -#endif /* __cplusplus */ +/* Declared in ptw32_throw.c */ +void __ptw32_throw (DWORD exception); +__PTW32_END_C_DECLS #if defined(_UWIN_) # if defined(_MT) -# if defined(__cplusplus) -extern "C" -{ -# endif + +__PTW32_BEGIN_C_DECLS + _CRTIMP unsigned long __cdecl _beginthread (void (__cdecl *) (void *), unsigned, void *); _CRTIMP void __cdecl _endthread (void); @@ -705,13 +728,15 @@ extern "C" unsigned (__stdcall *) (void *), void *, unsigned, unsigned *); _CRTIMP void __cdecl _endthreadex (unsigned); -# if defined(__cplusplus) -} -# endif + +__PTW32_END_C_DECLS + # endif #else -# include +# if ! defined(WINCE) +# include # endif +#endif /* @@ -746,9 +771,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(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__ \ @@ -760,7 +791,7 @@ extern "C" :"memory", "cc"); \ _result; \ }) -# define PTW32_INTERLOCKED_EXCHANGE_64(location, value) \ +# define __PTW32_INTERLOCKED_EXCHANGE_64(location, value) \ ({ \ __typeof (value) _result; \ __asm__ __volatile__ \ @@ -771,7 +802,7 @@ extern "C" :"memory", "cc"); \ _result; \ }) -# define PTW32_INTERLOCKED_EXCHANGE_ADD_64(location, value) \ +# define __PTW32_INTERLOCKED_EXCHANGE_ADD_64(location, value) \ ({ \ __typeof (value) _result; \ __asm__ __volatile__ \ @@ -783,9 +814,9 @@ extern "C" :"memory", "cc"); \ _result; \ }) -# define PTW32_INTERLOCKED_INCREMENT_64(location) \ +# define __PTW32_INTERLOCKED_INCREMENT_64(location) \ ({ \ - PTW32_INTERLOCKED_LONG _temp = 1; \ + __PTW32_INTERLOCKED_LONG _temp = 1; \ __asm__ __volatile__ \ ( \ "lock\n\t" \ @@ -795,9 +826,9 @@ extern "C" :"memory", "cc"); \ ++_temp; \ }) -# define PTW32_INTERLOCKED_DECREMENT_64(location) \ +# define __PTW32_INTERLOCKED_DECREMENT_64(location) \ ({ \ - PTW32_INTERLOCKED_LONG _temp = -1; \ + __PTW32_INTERLOCKED_LONG _temp = -1; \ __asm__ __volatile__ \ ( \ "lock\n\t" \ @@ -808,7 +839,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__ \ @@ -820,7 +851,7 @@ extern "C" :"memory", "cc"); \ _result; \ }) -# define PTW32_INTERLOCKED_EXCHANGE_LONG(location, value) \ +# define __PTW32_INTERLOCKED_EXCHANGE_LONG(location, value) \ ({ \ __typeof (value) _result; \ __asm__ __volatile__ \ @@ -831,7 +862,7 @@ extern "C" :"memory", "cc"); \ _result; \ }) -# define PTW32_INTERLOCKED_EXCHANGE_ADD_LONG(location, value) \ +# define __PTW32_INTERLOCKED_EXCHANGE_ADD_LONG(location, value) \ ({ \ __typeof (value) _result; \ __asm__ __volatile__ \ @@ -843,9 +874,9 @@ extern "C" :"memory", "cc"); \ _result; \ }) -# define PTW32_INTERLOCKED_INCREMENT_LONG(location) \ +# define __PTW32_INTERLOCKED_INCREMENT_LONG(location) \ ({ \ - PTW32_INTERLOCKED_LONG _temp = 1; \ + __PTW32_INTERLOCKED_LONG _temp = 1; \ __asm__ __volatile__ \ ( \ "lock\n\t" \ @@ -855,9 +886,9 @@ extern "C" :"memory", "cc"); \ ++_temp; \ }) -# define PTW32_INTERLOCKED_DECREMENT_LONG(location) \ +# define __PTW32_INTERLOCKED_DECREMENT_LONG(location) \ ({ \ - PTW32_INTERLOCKED_LONG _temp = -1; \ + __PTW32_INTERLOCKED_LONG _temp = -1; \ __asm__ __volatile__ \ ( \ "lock\n\t" \ @@ -867,57 +898,57 @@ extern "C" :"memory", "cc"); \ --_temp; \ }) -# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR(location, value, comparand) \ - PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE((PTW32_INTERLOCKED_SIZEPTR)location, \ - (PTW32_INTERLOCKED_SIZE)value, \ - (PTW32_INTERLOCKED_SIZE)comparand) -# define PTW32_INTERLOCKED_EXCHANGE_PTR(location, value) \ - PTW32_INTERLOCKED_EXCHANGE_SIZE((PTW32_INTERLOCKED_SIZEPTR)location, \ - (PTW32_INTERLOCKED_SIZE)value) +# define __PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR(location, value, comparand) \ + __PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE ((__PTW32_INTERLOCKED_SIZEPTR)location, \ + (__PTW32_INTERLOCKED_SIZE)value, \ + (__PTW32_INTERLOCKED_SIZE)comparand) +# define __PTW32_INTERLOCKED_EXCHANGE_PTR(location, value) \ + __PTW32_INTERLOCKED_EXCHANGE_SIZE ((__PTW32_INTERLOCKED_SIZEPTR)location, \ + (__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 */ -# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG(location, value, comparand) \ +# 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 +# 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_COMPARE_EXCHANGE_PTR InterlockedCompareExchange -# define PTW32_INTERLOCKED_EXCHANGE_PTR(location, value) \ +# 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/vendor/pthreads/include/md5.sum b/vendor/pthreads/include/md5.sum deleted file mode 100644 index 3b1a1b9e1b..0000000000 --- a/vendor/pthreads/include/md5.sum +++ /dev/null @@ -1,189 +0,0 @@ -9ed050c3ecd7492552e517f4e3e6e820 ANNOUNCE -c4619d75e3cfb33c29b4f621008dcee5 BUGS -708d10bccda9431cd3c1fd8f1930ca70 Bmakefile -baeed6ffd83e11be665b97fe2a8d37ec CONTRIBUTORS -ef963ced39cab4fb5b2a6f0ceb5dcc9c COPYING -7fbc338309ac38fefcd64b04bb903e34 COPYING.LIB -244b485ed9e69136ed4db3b4630b5233 ChangeLog -9812db7513fb5f99180f096d825246ee FAQ -ffa7cd3332a4103c0e07271ba0f8dd46 GNUmakefile -602c38975d11fab16e9188c0c5f99f51 MAINTAINERS -a18906cf3f1c6979f0e84a0371c460d3 Makefile -b8e44303a307eb87d2462a27c5591824 NEWS -9c6c65c7a9c94bddc37aae69b1e332d3 Nmakefile -1cbf2337b0c6d5f3e8634fb5e48aa854 Nmakefile.tests -08f057411eba740f816f52736fe8dfba PROGRESS -4b04aa58dce46a4606c1dfe1d3130e60 README -c429065353f02fe3ce854cd6459fbbd2 README.Borland -c91954b1e78cc8565303bb7b2858cfa0 README.CV -054489e490b5fbbedba61678f8bb98b3 README.NONPORTABLE -b9ac7cbd2ccc8047023325c42cbb29be README.Watcom -14b8839851fe810d496e8769403e1fbc README.WinCE -83c29797af9a181054c7bb572f503bb1 TODO -f717f20ea96b6f8d764de9c4b2a3ba72 WinCE-PORT -9eaafb4447a9be708901f105f5af55d2 attr.c -ea1b66c803da3afae683b847887bdaf2 autostatic.c -310183379e21bdc4edcd87df45bfee49 barrier.c -98ad07cf1242c4fb80a36fd2c4acf245 builddmc.bat -b16e9525465a4c8ca12e62c6c18ebcb8 cancel.c -16284d6af18110027a3421899c46484c cleanup.c -3067a38b51cd40aa6633341c74e91290 condvar.c -15e620dde4ec4e843e81ac7508740d67 config.h -501e14b78cf90902aa202e137c311710 context.h -5e8daabcf6ca404d3fc51b0175377c55 create.c -bf757506fbd1433e5da17902c60c1cc7 dll.c -a48b9beb7c806ebe5b3ae8d31ddce7c5 errno.c -abcfa590d701dd3228159aad1fbd72d3 exit.c -206a887d735be97e34d83b284a082156 fork.c -e1cc30e185b71544cfcc4da1ebcb5eff global.c -482d6cd1d2334a7834f258a26fba406e implement.h -2b092d7d3e84f2d6cfcd510111862933 misc.c -a32d0cd7e6c4c07798fe0d428e2a9432 mutex.c -067c97a8432daf14f408b4781003bd9c need_errno.h -2bba1f02e9b172b4989604bf18b0f44f nonportable.c -6acbbb189b132fddd782a5853de18da9 private.c -b167d87ec192c94fcbfe11b111bf4a4c pthread.c -4b19b711141a56ae49ab8fe2b8e8284f pthread.dsp -e4383ef0774c3433abefd4bab0148b66 pthread.dsw -2e8d6b08559dc03ef4bd9465bb1f5693 pthread.h -d9349b7a9f48acbbdbb6c8667bbd8b6c pthread_attr_destroy.c -70b2ae2bfcd6754a074fa6516269233c pthread_attr_getdetachstate.c -2fe5a4f6b03fc1e8b2170cf6df1c6244 pthread_attr_getinheritsched.c -81b0a10b7fcd84da425b3243b87ae61d pthread_attr_getschedparam.c -f0fb647e0fcc515cfd1d5b4364bc494b pthread_attr_getschedpolicy.c -b9fb1ca295576e95d3547cbaa0214a84 pthread_attr_getscope.c -49c7733cc3f3a0cf75d3ef7ac42d8bf0 pthread_attr_getstackaddr.c -ae77eb7b2c45079e4a5b2823cffc1309 pthread_attr_getstacksize.c -2e6040cfc683e811399cbd6c57bd464c pthread_attr_init.c -0e8e667bfd462319911ea85947efd401 pthread_attr_setdetachstate.c -ce48c551b00c0620fd19af164dffdbb0 pthread_attr_setinheritsched.c -a2c000ea63acb17dbd4b574e8e82f7fb pthread_attr_setschedparam.c -f0337b4f0224fcb5a8afe8db3b18f60b pthread_attr_setschedpolicy.c -66e1c818f721d8d81976bfbd75a2be10 pthread_attr_setscope.c -04a744036d80e7cc7bf4c123d63d86da pthread_attr_setstackaddr.c -740bf0bc7f727b72267717f1f52b29e5 pthread_attr_setstacksize.c -30fac537408686a34986dd7e8f438aaa pthread_barrier_destroy.c -adcd52a45b3847b2521395ad404fbfed pthread_barrier_init.c -c554da3146bbeba17d42689b8e2f898c pthread_barrier_wait.c -38dd59a11ebca517c61887af9773a87b pthread_barrierattr_destroy.c -bf729c845e64b5638e13b20e73cdf936 pthread_barrierattr_getpshared.c -38483537085d300ab0151e9528b11778 pthread_barrierattr_init.c -5c1418617f4fe8994a7af389572c4102 pthread_barrierattr_setpshared.c -a0969666f64973f3fbbd41ea5fc04790 pthread_cancel.c -4247ff4f69231bf48ca41ab7c7c30928 pthread_cond_destroy.c -401d23bff941f6786aa79b0891fde803 pthread_cond_init.c -0e114b30bbb1679ba77533db1a10b1fb pthread_cond_signal.c -669583574f4ff190c3c7c0da3cc3af4b pthread_cond_wait.c -7749dfc43a16366731712b43fa26f1ab pthread_condattr_destroy.c -0e8e2a0def11b95884f88febfb52ae37 pthread_condattr_getpshared.c -33f3f42e7259ebfd279f55e2742a87f7 pthread_condattr_init.c -7fe0deac5cab74d549d55eb4d30ec54b pthread_condattr_setpshared.c -ff8f8cdb7c2827a1a5fb251d4b965c7a pthread_delay_np.c -568a03dcbb26a7c2a12f2e37d34d4660 pthread_detach.c -412f0fdd742080551066c88d45645b34 pthread_equal.c -d584668ea079dca52be893d7e0035ee9 pthread_exit.c -5e5e29d9cdf61e68841aa2ec9bf1f657 pthread_getconcurrency.c -62955e2301056930d5860b522ca79af3 pthread_getschedparam.c -8c8b08873b1113e21cfcc3e04230879c pthread_getspecific.c -1a3578e7e4c67418b9c87bace12e64a3 pthread_getunique_np.c -d7e6a7d9be4cf99bf372709eca6d0b7c pthread_getw32threadhandle_np.c -af42b26cc1e4f2077e2d363fe547bea4 pthread_join.c -df1967c207791bd030cba7ce831180c0 pthread_key_create.c -6c231839601ddc80b57bf55fae325660 pthread_key_delete.c -6cda2defe0445bbbf27e22ebd7857a25 pthread_kill.c -da5c9679ed9ffb26932091e07942e94b pthread_mutex_consistent.c -89911a8e811989ca27857116f24313a6 pthread_mutex_destroy.c -3e24605ea55ce6652f62c1bf0651b57a pthread_mutex_init.c -4c5a04bebd2a2b3409624957863d3262 pthread_mutex_lock.c -d7124cbe86ed520193f0db01aa787d70 pthread_mutex_timedlock.c -481613aff8bd18cb697e767bbc3ce613 pthread_mutex_trylock.c -f0adb2b756d4ee503ade6b624958af22 pthread_mutex_unlock.c -66868124b23f9d98995e0e43a80d5fc3 pthread_mutexattr_destroy.c -2066dac4351db6bcf2d2ebb6bf090450 pthread_mutexattr_getkind_np.c -64b349e3d9788dfce9a79629890ebc64 pthread_mutexattr_getpshared.c -273f5ef47b6fbf56d2a0093ea0ee5653 pthread_mutexattr_getrobust.c -b11bb0d06acb40dfe08c5603e4f28c74 pthread_mutexattr_gettype.c -dd2b7191322d0aa1f2860a2f0a937b19 pthread_mutexattr_init.c -d6474e163e052d6f89ca967857a3cb7f pthread_mutexattr_setkind_np.c -1859fd41620a9e382a653c869865e237 pthread_mutexattr_setpshared.c -8270bea0ea13e5bf2ca6dc1b645ab368 pthread_mutexattr_setrobust.c -08fe9a5f31f883b18553b0f0800a1c8a pthread_mutexattr_settype.c -eedde99f224d515c339bae0272fb79c6 pthread_num_processors_np.c -19f97a3c85d35be649c171a44059c95a pthread_once.c -a2bdd60dd797b2c06198f88d7904b3a6 pthread_rwlock_destroy.c -0a6771669b076e7608d971e14f8e3446 pthread_rwlock_init.c -ca81dab1545e0ec057293e1cd12339dc pthread_rwlock_rdlock.c -aea04063b96b1e97cb4178e5ae4bf104 pthread_rwlock_timedrdlock.c -3b2d3d61c2ab781367a2f1509f046e71 pthread_rwlock_timedwrlock.c -902e23e8057dc0625ab539d551302ed8 pthread_rwlock_tryrdlock.c -d73a348a65a22a0465bb3ffb0d9361e0 pthread_rwlock_trywrlock.c -699ba61af24f52cad64fec61968c0ec3 pthread_rwlock_unlock.c -4d337d153f7d4f4d53b041db17c33ccf pthread_rwlock_wrlock.c -7b04d9b9f533a5091e9c9002e4379393 pthread_rwlockattr_destroy.c -205e520f06c057c8f5c5d6f89ebaeca1 pthread_rwlockattr_getpshared.c -be6274c2920c9bc756e02c78b7372cb2 pthread_rwlockattr_init.c -0e5df03b7f80eccbecd9752beebe49d7 pthread_rwlockattr_setpshared.c -ca65da9f40dbb05c80babe7ba6fe8edc pthread_self.c -d7bba3f753fadded49519e977d48d764 pthread_setcancelstate.c -77023c745649b80b81716ea08d8e4ee8 pthread_setcanceltype.c -40bf325fb6e869d30b8645d220280da3 pthread_setconcurrency.c -717810998fc417b8cffa631a089edd13 pthread_setschedparam.c -b76edff74d9dbccb41a5497dde13dc4b pthread_setspecific.c -8375f6a76884350800890252a66d3684 pthread_spin_destroy.c -f81726eedd7fca43d6d2ab2e4c2f6155 pthread_spin_init.c -7a0eca78b3faaaf6e331a5c7c73b552d pthread_spin_lock.c -35875f886e3a5e0c02753753c6398768 pthread_spin_trylock.c -c36140543953a62310e50571b08d9678 pthread_spin_unlock.c -c80cc2d56e1b3307b22b9784344e20ee pthread_testcancel.c -ee61be127860b72e80905fba15ac2c8f pthread_timechange_handler_np.c -0dc95fa001a1c87f1ae441dbcf2925c1 pthread_win32_attach_detach_np.c -1aa5d17994daeb48bc8ac110989e587f ptw32_MCS_lock.c -c3a16cf1fe704332bbc093f3f2da7aa7 ptw32_OLL_lock.c -89727eae47969cc665da4df5433eaa02 ptw32_callUserDestroyRoutines.c -682d97ed5a393b2298fb83a60c916061 ptw32_calloc.c -738ff489581899b610b9193be09371d4 ptw32_cond_check_need_init.c -88158036bfd76905214aa59d1e7dbd71 ptw32_getprocessors.c -7fbe9e31f85fbc622e1304376f7e2f5f ptw32_is_attr.c -65a63faecc9af77d7c03b305f9d3ec42 ptw32_mutex_check_need_init.c -bc0374b446c91322059de7809bb8c2bc ptw32_new.c -3ec7a8af82e12ef6567a2abf33d7dcb8 ptw32_processInitialize.c -62ebd2b7a6351b6d1c998c30859cd017 ptw32_processTerminate.c -f01ff46fc142759c20e08969270f0592 ptw32_relmillisecs.c -e425e732decd11a0652c4b2b61cb4ca7 ptw32_reuse.c -6857d656348cb622caa5a7375a770289 ptw32_rwlock_cancelwrwait.c -5afacf0f984519a6ea48a49d1f869cf1 ptw32_rwlock_check_need_init.c -51053da3e8fe69a9447b10ee7b00f768 ptw32_semwait.c -1f4dfaa526cc10ca8b9a15f9ec05923a ptw32_spinlock_check_need_init.c -76f961ccc61966e9a5483826ff315d6b ptw32_threadDestroy.c -337a844d8047a302e9d3f1a41647b8ab ptw32_threadStart.c -5ac55004ba9e39118744ad10822d4c8c ptw32_throw.c -7188301e9378cccbf770f820c8b0ef23 ptw32_timespec.c -8735ba31b3ba7a7eb98edcd18de8471f ptw32_tkAssocCreate.c -9c1b547b0d600eabdb14373e1686be8a ptw32_tkAssocDestroy.c -529fdf670591ce990c2b61d448368bbd rwlock.c -cec0814c6d9271b8fa74b4378630ee25 sched.c -37cb7e0c214b62b37a57ab46d72e1034 sched.h -152d904dd07fb95cee15d388fec4b00b sched_get_priority_max.c -eed67d59b766f6f41b507ab3fbc4cdcb sched_get_priority_min.c -e8569028fdfeb4e94d66dd5af0092bdf sched_getscheduler.c -bcb2ea745f078a724619bef05260e327 sched_setscheduler.c -7892a20ce9d2a109d2282fbf68f90822 sched_yield.c -81eff83d74f149360ba24996bdc492be sem_close.c -239992a9454cea20084164f2ef125d7f sem_destroy.c -911293f2dd48f704df823d0473239a22 sem_getvalue.c -8db59300cb12c8e1c7eec4cf044cc3cb sem_init.c -fe57012020a553689995af0cd0c52852 sem_open.c -9e3a5ab21013eeb640fee98923dab000 sem_post.c -3b7fd7b5febe2ad3772980d8adfb39e2 sem_post_multiple.c -74b0e5a1734de30924b984896d2d55f1 sem_timedwait.c -c4eebad957cc68c913c4cd811e8e5b2c sem_trywait.c -80e63b47e07be12c09e2258e63b8b99e sem_unlink.c -705041e1944c628ed2fe658798c99dea sem_wait.c -ce6f31a01a6ab60b0155e7810accad5a semaphore.c -2c928d43a30ca0b0ad39a0accbae775e semaphore.h -00e755fd5b5025e36f20945a594859a2 signal.c -7a3a1c6501868b4c5706ad15bcc11dea spin.c -c92ffc2c5e3db9d6cf177d9d7f3c5d9c sync.c -01eed66c629073743369f3a0c80dfec0 tsd.c -1b0e28443fd55f496dc6b9811a6733bd version.rc -9af2202151069606beca008baaff6116 w32_CancelableWait.c diff --git a/vendor/pthreads/include/misc.c b/vendor/pthreads/include/misc.c deleted file mode 100644 index 06d1d21374..0000000000 --- a/vendor/pthreads/include/misc.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * misc.c - * - * Description: - * This translation unit implements miscellaneous 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" - - -#include "pthread_kill.c" -#include "pthread_once.c" -#include "pthread_self.c" -#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/vendor/pthreads/include/mutex.c b/vendor/pthreads/include/mutex.c deleted file mode 100644 index c2b3607ca2..0000000000 --- a/vendor/pthreads/include/mutex.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - * mutex.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 - */ - -#if ! defined(_UWIN) && ! defined(WINCE) -# include -#endif -#if !defined(NEED_FTIME) -#include -#endif -#include "pthread.h" -#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" -#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" diff --git a/vendor/pthreads/include/need_errno.h b/vendor/pthreads/include/need_errno.h index abf1c95574..fc79f2ece2 100644 --- a/vendor/pthreads/include/need_errno.h +++ b/vendor/pthreads/include/need_errno.h @@ -24,7 +24,7 @@ #error ERROR: Only Win32 targets supported! #endif -#include +//#include #if defined(__cplusplus) extern "C" { @@ -59,20 +59,22 @@ extern "C" { #endif #endif -#if !defined(PTW32_STATIC_LIB) -# if defined(PTW32_BUILD) -# define PTW32_DLLPORT __declspec (dllexport) +#if defined(__PTW32_STATIC_LIB) && defined(_MSC_VER) && _MSC_VER >= 1400 +# define __PTW32_STATIC_TLSLIB +#endif + +#if defined (__PTW32_STATIC_LIB) || defined (__PTW32_STATIC_TLSLIB) +# define __PTW32_DLLPORT +#elif defined (__PTW32_BUILD) +# define __PTW32_DLLPORT __declspec (dllexport) # else -# define PTW32_DLLPORT __declspec (dllimport) +# define __PTW32_DLLPORT __declspec (dllimport) # endif -#else -# define PTW32_DLLPORT -#endif /* declare reference to errno */ #if (defined(_MT) || defined(_MD) || defined(_DLL)) && !defined(_MAC) -PTW32_DLLPORT int * __cdecl _errno(void); +__PTW32_DLLPORT int * __cdecl _errno(void); #define errno (*_errno()) #else /* ndef _MT && ndef _MD && ndef _DLL */ _CRTIMP extern int errno; @@ -114,27 +116,46 @@ _CRTIMP extern int errno; #define ERANGE 34 #define EDEADLK 36 -/* defined differently in winsock.h on WinCE */ -#if !defined(ENAMETOOLONG) -#define ENAMETOOLONG 38 -#endif +/* defined differently in winsock.h on WinCE + * We don't use this value. + */ +//#if !defined(ENAMETOOLONG) +//#define ENAMETOOLONG 38 +//#endif #define ENOLCK 39 #define ENOSYS 40 -/* defined differently in winsock.h on WinCE */ -#if !defined(ENOTEMPTY) -#define ENOTEMPTY 41 -#endif +/* defined differently in winsock.h on WinCE + * We don't use this value. + */ +//#if !defined(ENOTEMPTY) +//#define ENOTEMPTY 41 +//#endif #define EILSEQ 42 -/* POSIX 2008 - robust mutexes */ -#define EOWNERDEAD 43 -#define ENOTRECOVERABLE 44 +/* + * POSIX 2008 - robust mutexes. + */ +#if __PTW32_VERSION_MAJOR > 2 +# if !defined(EOWNERDEAD) +# define EOWNERDEAD 1000 +# endif +# if !defined(ENOTRECOVERABLE) +# define ENOTRECOVERABLE 1001 +# endif +#else +# if !defined(EOWNERDEAD) +# define EOWNERDEAD 42 +# endif +# if !defined(ENOTRECOVERABLE) +# define ENOTRECOVERABLE 43 +# endif +#endif /* - * Support EDEADLOCK for compatibiity with older MS-C versions. + * Support EDEADLOCK for compatibility with older MS-C versions. */ #define EDEADLOCK EDEADLK diff --git a/vendor/pthreads/include/nonportable.c b/vendor/pthreads/include/nonportable.c deleted file mode 100644 index 742cb969b4..0000000000 --- a/vendor/pthreads/include/nonportable.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * nonportable.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" - -#include "pthread_mutexattr_setkind_np.c" -#include "pthread_mutexattr_getkind_np.c" -#include "pthread_getw32threadhandle_np.c" -#include "pthread_getunique_np.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" diff --git a/vendor/pthreads/include/private.c b/vendor/pthreads/include/private.c deleted file mode 100644 index 1b1ccb7c52..0000000000 --- a/vendor/pthreads/include/private.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - * private.c - * - * Description: - * This translation unit implements routines which are private to - * the implementation and may be used throughout it. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX 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 "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_relmillisecs.c" -#include "ptw32_throw.c" -#include "ptw32_getprocessors.c" diff --git a/vendor/pthreads/include/pthread.c b/vendor/pthreads/include/pthread.c index 60b53412be..61828f3775 100644 --- a/vendor/pthreads/include/pthread.c +++ b/vendor/pthreads/include/pthread.c @@ -8,59 +8,183 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #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 "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_getaffinity_np.c" +#include "pthread_attr_setaffinity_np.c" +#include "pthread_attr_getdetachstate.c" +#include "pthread_attr_setdetachstate.c" +#include "pthread_attr_getname_np.c" +#include "pthread_attr_setname_np.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 "exit.c" -#include "fork.c" +#include "pthread_exit.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" +#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_getname_np.c" +#include "pthread_setname_np.c" +#include "pthread_setspecific.c" +#include "pthread_getspecific.c" diff --git a/vendor/pthreads/include/pthread.dsp b/vendor/pthreads/include/pthread.dsp deleted file mode 100644 index 112bff72a5..0000000000 --- a/vendor/pthreads/include/pthread.dsp +++ /dev/null @@ -1,142 +0,0 @@ -# Microsoft Developer Studio Project File - Name="pthread" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=pthread - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "pthread.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "pthread.mak" CFG="pthread - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "pthread - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "pthread - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "pthread - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "." -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PTW32_BUILD" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /D "__CLEANUP_C" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PTW32_BUILD" /YX /FD /c -# SUBTRACT CPP /u -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x809 /d "NDEBUG" -# ADD RSC /l 0x409 /i "." /d "NDEBUG" /d "PTW32_RC_MSC" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib ws2_32.lib /nologo /dll /pdb:none /machine:I386 /out:".\pthreadVC2.dll" - -!ELSEIF "$(CFG)" == "pthread - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "." -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PTW32_BUILD" /YX /FD /GZ /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "." /D "__CLEANUP_C" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PTW32_BUILD" /YX /FD /GZ /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x809 /d "_DEBUG" -# ADD RSC /l 0x409 /i "." /d "_DEBUG" /d "PTW32_RC_MSC" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib ws2_32.lib /nologo /dll /map /debug /machine:I386 /out:".\pthreadVC2.dll" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "pthread - Win32 Release" -# Name "pthread - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=.\pthread.c -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# Begin Source File - -SOURCE=.\implement.h -# End Source File -# Begin Source File - -SOURCE=.\pthread.h -# End Source File -# Begin Source File - -SOURCE=.\sched.h -# End Source File -# Begin Source File - -SOURCE=.\semaphore.h -# End Source File -# End Group -# Begin Group "Resource Files" - -# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" -# Begin Source File - -SOURCE=.\version.rc - -!IF "$(CFG)" == "pthread - Win32 Release" - -# ADD BASE RSC /l 0xc09 -# ADD RSC /l 0x409 /i "." /d "PTW32_RC_MSC" - -!ELSEIF "$(CFG)" == "pthread - Win32 Debug" - -# ADD BASE RSC /l 0xc09 -# ADD RSC /l 0x409 /i "." /d "PTW32_RC_MSC" - -!ENDIF - -# End Source File -# End Group -# End Target -# End Project diff --git a/vendor/pthreads/include/pthread.dsw b/vendor/pthreads/include/pthread.dsw deleted file mode 100644 index 815a678728..0000000000 --- a/vendor/pthreads/include/pthread.dsw +++ /dev/null @@ -1,29 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "pthread"=.\pthread.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/vendor/pthreads/include/pthread.h b/vendor/pthreads/include/pthread.h index b4072f72c6..f35a39b571 100644 --- a/vendor/pthreads/include/pthread.h +++ b/vendor/pthreads/include/pthread.h @@ -1,45 +1,36 @@ -/* This is an implementation of the threads API of POSIX 1003.1-2001. +/* This is an implementation of the threads API of the Single Unix Specification. * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #if !defined( PTHREAD_H ) #define PTHREAD_H -/* - * 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,1,0 -#define PTW32_VERSION_STRING "2, 9, 1, 0\0" - /* There are three implementations of cancel cleanup. * Note that pthread.h is included in both application * compilation units and also internally for the library. @@ -65,55 +56,44 @@ * 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. */ -#if !defined( __CLEANUP_SEH ) && !defined( __CLEANUP_CXX ) && !defined( __CLEANUP_C ) -# define __CLEANUP_C +#if !defined( __PTW32_CLEANUP_SEH ) && !defined( __PTW32_CLEANUP_CXX ) && !defined( __PTW32_CLEANUP_C ) +# define __PTW32_CLEANUP_C #endif -#if defined( __CLEANUP_SEH ) && ( !defined( _MSC_VER ) && !defined(PTW32_RC_MSC)) +#if defined( __PTW32_CLEANUP_SEH ) && ( !defined( _MSC_VER ) && !defined (__PTW32_RC_MSC)) #error ERROR [__FILE__, line __LINE__]: SEH is not supported for this compiler. #endif +#include <_ptw32.h> + /* * Stop here if we are being included by the resource compiler. */ #if !defined(RC_INVOKED) -#undef PTW32_LEVEL +#undef __PTW32_LEVEL +#undef __PTW32_LEVEL_MAX +#define __PTW32_LEVEL_MAX 3 -#if defined(_POSIX_SOURCE) -#define PTW32_LEVEL 0 -/* Early POSIX */ -#endif +#if _POSIX_C_SOURCE >= 200112L /* POSIX.1-2001 and later */ +# define __PTW32_LEVEL __PTW32_LEVEL_MAX /* include everything */ -#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309 -#undef PTW32_LEVEL -#define PTW32_LEVEL 1 -/* Include 1b, 1c and 1d */ -#endif +#elif defined INCLUDE_NP /* earlier than POSIX.1-2001, but... */ +# define __PTW32_LEVEL 2 /* include non-portable extensions */ -#if defined(INCLUDE_NP) -#undef PTW32_LEVEL -#define PTW32_LEVEL 2 -/* Include Non-Portable extensions */ -#endif +#elif _POSIX_C_SOURCE >= 199309L /* POSIX.1-1993 */ +# define __PTW32_LEVEL 1 /* include 1b, 1c, and 1d */ -#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 */ -#endif +#elif defined _POSIX_SOURCE /* early POSIX */ +# define __PTW32_LEVEL 0 /* minimal support */ -#if defined(_UWIN) -# define HAVE_STRUCT_TIMESPEC 1 -# define HAVE_SIGNAL_H 1 -# undef HAVE_PTW32_CONFIG_H -# pragma comment(lib, "pthread") +#else /* unspecified support level */ +# define __PTW32_LEVEL __PTW32_LEVEL_MAX /* include everything anyway */ #endif /* @@ -184,163 +164,19 @@ * The source code and other information about this library * are available from * - * http://sources.redhat.com/pthreads-win32/ + * https://sourceforge.net/projects/pthreads4w/ * * ------------------------------------------------------------- */ - -/* Try to avoid including windows.h */ -#if (defined(__MINGW64__) || defined(__MINGW32__)) && defined(__cplusplus) -#define PTW32_INCLUDE_WINDOWS_H -#endif - -#if defined(PTW32_INCLUDE_WINDOWS_H) -#include -#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 -#else /* NEED_FTIME */ -/* use native WIN32 time API */ -#endif /* NEED_FTIME */ - -#if defined(HAVE_SIGNAL_H) -#include -#endif /* HAVE_SIGNAL_H */ - -#include - -/* - * Boolean values to make us independent of system includes. - */ -enum { - PTW32_FALSE = 0, - PTW32_TRUE = (! PTW32_FALSE) +enum +{ /* Boolean values to make us independent of system includes. */ + __PTW32_FALSE = 0, + __PTW32_TRUE = (! __PTW32_FALSE) }; -/* - * This is a duplicate of what is in the autoconf config.h, - * which is only used when building the pthread-win32 libraries. - */ - -#if !defined(PTW32_CONFIG_H) -# if defined(WINCE) -# define NEED_ERRNO -# define NEED_SEM -# endif -# if defined(__MINGW64__) -# define HAVE_STRUCT_TIMESPEC -# define HAVE_MODE_T -# elif defined(_UWIN) || defined(__MINGW32__) -# define HAVE_MODE_T -# endif -#endif - -/* - * - */ - -#if PTW32_LEVEL >= PTW32_LEVEL_MAX -#if defined(NEED_ERRNO) -#include "need_errno.h" -#else -#include -#endif -#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ - -/* - * Several systems don't define some error numbers. - */ -#if !defined(ENOTSUP) -# define ENOTSUP 48 /* This is the value in Solaris. */ -#endif - -#if !defined(ETIMEDOUT) -# define ETIMEDOUT 10060 /* Same as WSAETIMEDOUT */ -#endif - -#if !defined(ENOSYS) -# define ENOSYS 140 /* Semi-arbitrary value */ -#endif - -#if !defined(EDEADLK) -# if defined(EDEADLOCK) -# define EDEADLK EDEADLOCK -# else -# define EDEADLK 36 /* This is the value in MSVC. */ -# endif -#endif - -/* POSIX 2008 - related to robust mutexes */ -#if !defined(EOWNERDEAD) -# define EOWNERDEAD 43 -#endif -#if !defined(ENOTRECOVERABLE) -# define ENOTRECOVERABLE 44 -#endif - +#include #include -/* - * To avoid including windows.h we define only those things that we - * actually need from it. - */ -#if !defined(PTW32_INCLUDE_WINDOWS_H) -#if !defined(HANDLE) -# define PTW32__HANDLE_DEF -# define HANDLE void * -#endif -#if !defined(DWORD) -# define PTW32__DWORD_DEF -# define DWORD unsigned long -#endif -#endif - -#if !defined(HAVE_STRUCT_TIMESPEC) -#define HAVE_STRUCT_TIMESPEC -#if !defined(_TIMESPEC_DEFINED) -#define _TIMESPEC_DEFINED -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -#endif /* _TIMESPEC_DEFINED */ -#endif /* HAVE_STRUCT_TIMESPEC */ - -#if !defined(SIG_BLOCK) -#define SIG_BLOCK 0 -#endif /* SIG_BLOCK */ - -#if !defined(SIG_UNBLOCK) -#define SIG_UNBLOCK 1 -#endif /* SIG_UNBLOCK */ - -#if !defined(SIG_SETMASK) -#define SIG_SETMASK 2 -#endif /* SIG_SETMASK */ - -#if defined(__cplusplus) -extern "C" -{ -#endif /* __cplusplus */ - /* * ------------------------------------------------------------- * @@ -352,23 +188,23 @@ extern "C" * * For conformance with the Single Unix Specification (version 3), all of the * options below are defined, and have a value of either -1 (not supported) - * or 200112L (supported). + * or yyyymm[dd]L (supported). * * These options can neither be left undefined nor have a value of 0, because * 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 +219,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 +244,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. * * ------------------------------------------------------------- */ @@ -431,42 +269,45 @@ extern "C" /* * POSIX Options */ -#undef _POSIX_THREADS -#define _POSIX_THREADS 200809L +#undef _POSIX_THREADS +#define _POSIX_THREADS 200809L + +#undef _POSIX_READER_WRITER_LOCKS +#define _POSIX_READER_WRITER_LOCKS 200809L -#undef _POSIX_READER_WRITER_LOCKS -#define _POSIX_READER_WRITER_LOCKS 200809L +#undef _POSIX_SPIN_LOCKS +#define _POSIX_SPIN_LOCKS 200809L -#undef _POSIX_SPIN_LOCKS -#define _POSIX_SPIN_LOCKS 200809L +#undef _POSIX_BARRIERS +#define _POSIX_BARRIERS 200809L -#undef _POSIX_BARRIERS -#define _POSIX_BARRIERS 200809L +#undef _POSIX_THREAD_SAFE_FUNCTIONS +#define _POSIX_THREAD_SAFE_FUNCTIONS 200809L -#undef _POSIX_THREAD_SAFE_FUNCTIONS -#define _POSIX_THREAD_SAFE_FUNCTIONS 200809L +#undef _POSIX_THREAD_ATTR_STACKSIZE +#define _POSIX_THREAD_ATTR_STACKSIZE 200809L -#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 */ -#undef _POSIX_THREAD_ATTR_STACKADDR -#define _POSIX_THREAD_ATTR_STACKADDR -1 +#undef _POSIX_THREAD_ATTR_STACKADDR +#define _POSIX_THREAD_ATTR_STACKADDR -1 -#undef _POSIX_THREAD_PRIO_INHERIT -#define _POSIX_THREAD_PRIO_INHERIT -1 +#undef _POSIX_THREAD_PRIO_INHERIT +#define _POSIX_THREAD_PRIO_INHERIT -1 -#undef _POSIX_THREAD_PRIO_PROTECT -#define _POSIX_THREAD_PRIO_PROTECT -1 +#undef _POSIX_THREAD_PRIO_PROTECT +#define _POSIX_THREAD_PRIO_PROTECT -1 /* TPS is not fully supported. */ -#undef _POSIX_THREAD_PRIORITY_SCHEDULING -#define _POSIX_THREAD_PRIORITY_SCHEDULING -1 +#undef _POSIX_THREAD_PRIORITY_SCHEDULING +#define _POSIX_THREAD_PRIORITY_SCHEDULING -1 -#undef _POSIX_THREAD_PROCESS_SHARED -#define _POSIX_THREAD_PROCESS_SHARED -1 +#undef _POSIX_THREAD_PROCESS_SHARED +#define _POSIX_THREAD_PROCESS_SHARED -1 /* @@ -501,88 +342,69 @@ extern "C" * (must be at least 32767) * */ -#undef _POSIX_THREAD_DESTRUCTOR_ITERATIONS +#undef _POSIX_THREAD_DESTRUCTOR_ITERATIONS #define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4 -#undef PTHREAD_DESTRUCTOR_ITERATIONS +#undef PTHREAD_DESTRUCTOR_ITERATIONS #define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS -#undef _POSIX_THREAD_KEYS_MAX +#undef _POSIX_THREAD_KEYS_MAX #define _POSIX_THREAD_KEYS_MAX 128 -#undef PTHREAD_KEYS_MAX +#undef PTHREAD_KEYS_MAX #define PTHREAD_KEYS_MAX _POSIX_THREAD_KEYS_MAX -#undef PTHREAD_STACK_MIN +#undef PTHREAD_STACK_MIN #define PTHREAD_STACK_MIN 0 -#undef _POSIX_THREAD_THREADS_MAX +#undef _POSIX_THREAD_THREADS_MAX #define _POSIX_THREAD_THREADS_MAX 64 - /* Arbitrary value */ -#undef PTHREAD_THREADS_MAX +/* Arbitrary value */ +#undef PTHREAD_THREADS_MAX #define PTHREAD_THREADS_MAX 2019 -#undef _POSIX_SEM_NSEMS_MAX +#undef _POSIX_SEM_NSEMS_MAX #define _POSIX_SEM_NSEMS_MAX 256 - /* Arbitrary value */ -#undef SEM_NSEMS_MAX +/* Arbitrary value */ +#undef SEM_NSEMS_MAX #define SEM_NSEMS_MAX 1024 -#undef _POSIX_SEM_VALUE_MAX +#undef _POSIX_SEM_VALUE_MAX #define _POSIX_SEM_VALUE_MAX 32767 -#undef SEM_VALUE_MAX +#undef SEM_VALUE_MAX #define SEM_VALUE_MAX INT_MAX -#if defined(__GNUC__) && !defined(__declspec) -# error Please upgrade your GNU compiler to one that supports __declspec. -#endif - -/* - * When building the library, you should define PTW32_BUILD so that - * the variables/functions are exported correctly. When using the library, - * do NOT define PTW32_BUILD, and then the variables/functions will - * be imported correctly. - */ -#if !defined(PTW32_STATIC_LIB) -# if defined(PTW32_BUILD) -# define PTW32_DLLPORT __declspec (dllexport) -# else -# define PTW32_DLLPORT __declspec (dllimport) -# endif +#if defined(_UWIN) && __PTW32_LEVEL >= __PTW32_LEVEL_MAX +# include #else -# 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. +/* Generic handle type - intended to provide the lifetime-uniqueness that + * a simple pointer can't. It should scale for either + * 32 or 64 bit systems. + * + * The constraint with this approach is that applications must + * strictly comply with POSIX, e.g. not assume scalar type, only + * compare pthread_t using the API function pthread_equal(), etc. * - * 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. + * Non-conforming applications could use the element 'p' to compare, + * e.g. for sorting, but it will be up to the application to determine + * if handles are live or dead, or resurrected for an entirely + * new/different thread. I.e. the thread is valid iff + * x == p->ptHandle.x */ -#define PTW32_CDECL __cdecl - -#if defined(_UWIN) && PTW32_LEVEL >= PTW32_LEVEL_MAX -# include +typedef struct +{ void * p; /* Pointer to actual object */ +#if __PTW32_VERSION_MAJOR > 2 + size_t x; /* Extra information - reuse count etc */ #else -/* - * Generic handle type - intended to extend uniqueness beyond - * that available with a simple pointer. It should scale for either - * IA-32 or IA-64. - */ -typedef struct { - void * p; /* Pointer to actual object */ - unsigned int x; /* Extra information - reuse count etc */ -} ptw32_handle_t; + unsigned int x; /* Extra information - reuse count etc */ +#endif +} __ptw32_handle_t; -typedef ptw32_handle_t pthread_t; +typedef __ptw32_handle_t pthread_t; typedef struct pthread_attr_t_ * pthread_attr_t; typedef struct pthread_once_t_ pthread_once_t; typedef struct pthread_key_t_ * pthread_key_t; @@ -591,6 +413,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; @@ -605,60 +428,52 @@ typedef struct pthread_barrierattr_t_ * pthread_barrierattr_t; * ==================== */ -enum { -/* - * pthread_attr_{get,set}detachstate - */ +enum +{ /* pthread_attr_{get,set}detachstate + */ PTHREAD_CREATE_JOINABLE = 0, /* Default */ PTHREAD_CREATE_DETACHED = 1, - -/* - * pthread_attr_{get,set}inheritsched - */ + /* + * pthread_attr_{get,set}inheritsched + */ PTHREAD_INHERIT_SCHED = 0, PTHREAD_EXPLICIT_SCHED = 1, /* Default */ - -/* - * pthread_{get,set}scope - */ + /* + * pthread_{get,set}scope + */ PTHREAD_SCOPE_PROCESS = 0, PTHREAD_SCOPE_SYSTEM = 1, /* Default */ - -/* - * pthread_setcancelstate paramters - */ + /* + * pthread_setcancelstate paramters + */ PTHREAD_CANCEL_ENABLE = 0, /* Default */ PTHREAD_CANCEL_DISABLE = 1, - -/* - * pthread_setcanceltype parameters - */ + /* + * pthread_setcanceltype parameters + */ PTHREAD_CANCEL_ASYNCHRONOUS = 0, PTHREAD_CANCEL_DEFERRED = 1, /* Default */ - -/* - * pthread_mutexattr_{get,set}pshared - * pthread_condattr_{get,set}pshared - */ + /* + * pthread_mutexattr_{get,set}pshared + * pthread_condattr_{get,set}pshared + */ PTHREAD_PROCESS_PRIVATE = 0, PTHREAD_PROCESS_SHARED = 1, - -/* - * pthread_mutexattr_{get,set}robust - */ + /* + * pthread_mutexattr_{get,set}robust + */ PTHREAD_MUTEX_STALLED = 0, /* Default */ PTHREAD_MUTEX_ROBUST = 1, - -/* - * pthread_barrier_wait - */ + /* + * pthread_barrier_wait + */ PTHREAD_BARRIER_SERIAL_THREAD = -1 }; /* * ==================== * ==================== - * Cancelation + * cancellation * ==================== * ==================== */ @@ -672,16 +487,30 @@ enum { * ==================== * ==================== */ -#define PTHREAD_ONCE_INIT { PTW32_FALSE, 0, 0, 0} +#if __PTW32_VERSION_MAJOR > 2 + +#define PTHREAD_ONCE_INIT { 0, __PTW32_FALSE } struct pthread_once_t_ { - int done; /* indicates if user function has been executed */ - void * lock; + void * lock; /* MCS lock */ + int done; /* indicates if user function has been executed */ +}; + +#else + +#define PTHREAD_ONCE_INIT { __PTW32_FALSE, 0, 0, 0 } + +struct pthread_once_t_ +{ + int done; /* indicates if user function has been executed */ + void * lock; /* MCS lock */ int reserved1; int reserved2; }; +#endif + /* * ==================== @@ -726,36 +555,36 @@ enum }; -typedef struct ptw32_cleanup_t ptw32_cleanup_t; +typedef struct __ptw32_cleanup_t __ptw32_cleanup_t; #if defined(_MSC_VER) /* Disable MSVC 'anachronism used' warning */ #pragma warning( disable : 4229 ) #endif -typedef void (* PTW32_CDECL ptw32_cleanup_callback_t)(void *); +typedef void (* __PTW32_CDECL __ptw32_cleanup_callback_t)(void *); #if defined(_MSC_VER) #pragma warning( default : 4229 ) #endif -struct ptw32_cleanup_t +struct __ptw32_cleanup_t { - ptw32_cleanup_callback_t routine; + __ptw32_cleanup_callback_t routine; void *arg; - struct ptw32_cleanup_t *prev; + struct __ptw32_cleanup_t *prev; }; -#if defined(__CLEANUP_SEH) +#if defined(__PTW32_CLEANUP_SEH) /* * WIN32 SEH version of cancel cleanup. */ #define pthread_cleanup_push( _rout, _arg ) \ { \ - ptw32_cleanup_t _cleanup; \ + __ptw32_cleanup_t _cleanup; \ \ - _cleanup.routine = (ptw32_cleanup_callback_t)(_rout); \ + _cleanup.routine = (__ptw32_cleanup_callback_t)(_rout); \ _cleanup.arg = (_arg); \ __try \ { \ @@ -771,9 +600,9 @@ struct ptw32_cleanup_t } \ } -#else /* __CLEANUP_SEH */ +#else /* __PTW32_CLEANUP_SEH */ -#if defined(__CLEANUP_C) +#if defined(__PTW32_CLEANUP_C) /* * C implementation of PThreads cancel cleanup @@ -781,17 +610,17 @@ struct ptw32_cleanup_t #define pthread_cleanup_push( _rout, _arg ) \ { \ - ptw32_cleanup_t _cleanup; \ + __ptw32_cleanup_t _cleanup; \ \ - ptw32_push_cleanup( &_cleanup, (ptw32_cleanup_callback_t) (_rout), (_arg) ); \ + __ptw32_push_cleanup( &_cleanup, (__ptw32_cleanup_callback_t) (_rout), (_arg) ); \ #define pthread_cleanup_pop( _execute ) \ - (void) ptw32_pop_cleanup( _execute ); \ + (void) __ptw32_pop_cleanup( _execute ); \ } -#else /* __CLEANUP_C */ +#else /* __PTW32_CLEANUP_C */ -#if defined(__CLEANUP_CXX) +#if defined(__PTW32_CLEANUP_CXX) /* * C++ version of cancel cleanup. @@ -811,7 +640,7 @@ struct ptw32_cleanup_t * of how the code exits the scope * (i.e. such as by an exception) */ - ptw32_cleanup_callback_t cleanUpRout; + __ptw32_cleanup_callback_t cleanUpRout; void * obj; int executeIt; @@ -827,7 +656,7 @@ struct ptw32_cleanup_t } PThreadCleanup( - ptw32_cleanup_callback_t routine, + __ptw32_cleanup_callback_t routine, void * arg ) : cleanUpRout( routine ), obj( arg ), @@ -860,7 +689,7 @@ struct ptw32_cleanup_t */ #define pthread_cleanup_push( _rout, _arg ) \ { \ - PThreadCleanup cleanup((ptw32_cleanup_callback_t)(_rout), \ + PThreadCleanup cleanup((__ptw32_cleanup_callback_t)(_rout), \ (void *) (_arg) ); #define pthread_cleanup_pop( _execute ) \ @@ -871,11 +700,12 @@ struct ptw32_cleanup_t #error ERROR [__FILE__, line __LINE__]: Cleanup type undefined. -#endif /* __CLEANUP_CXX */ +#endif /* __PTW32_CLEANUP_CXX */ -#endif /* __CLEANUP_C */ +#endif /* __PTW32_CLEANUP_C */ + +#endif /* __PTW32_CLEANUP_SEH */ -#endif /* __CLEANUP_SEH */ /* * =============== @@ -885,279 +715,289 @@ struct ptw32_cleanup_t * =============== */ +__PTW32_BEGIN_C_DECLS + /* * PThread Attribute Functions */ -PTW32_DLLPORT int PTW32_CDECL pthread_attr_init (pthread_attr_t * attr); +__PTW32_DLLPORT int __PTW32_CDECL pthread_attr_init (pthread_attr_t * attr); -PTW32_DLLPORT int PTW32_CDECL pthread_attr_destroy (pthread_attr_t * attr); +__PTW32_DLLPORT int __PTW32_CDECL pthread_attr_destroy (pthread_attr_t * attr); -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getdetachstate (const pthread_attr_t * attr, +__PTW32_DLLPORT int __PTW32_CDECL pthread_attr_getaffinity_np (const pthread_attr_t * attr, + size_t cpusetsize, + cpu_set_t * cpuset); + +__PTW32_DLLPORT int __PTW32_CDECL pthread_attr_getdetachstate (const pthread_attr_t * attr, int *detachstate); -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getstackaddr (const pthread_attr_t * attr, +__PTW32_DLLPORT int __PTW32_CDECL pthread_attr_getstackaddr (const pthread_attr_t * attr, void **stackaddr); -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getstacksize (const pthread_attr_t * attr, +__PTW32_DLLPORT int __PTW32_CDECL pthread_attr_getstacksize (const pthread_attr_t * attr, size_t * stacksize); -PTW32_DLLPORT int PTW32_CDECL pthread_attr_setdetachstate (pthread_attr_t * attr, +__PTW32_DLLPORT int __PTW32_CDECL pthread_attr_setaffinity_np (pthread_attr_t * attr, + size_t cpusetsize, + const cpu_set_t * cpuset); + +__PTW32_DLLPORT int __PTW32_CDECL pthread_attr_setdetachstate (pthread_attr_t * attr, int detachstate); -PTW32_DLLPORT int PTW32_CDECL pthread_attr_setstackaddr (pthread_attr_t * attr, +__PTW32_DLLPORT int __PTW32_CDECL pthread_attr_setstackaddr (pthread_attr_t * attr, void *stackaddr); -PTW32_DLLPORT int PTW32_CDECL pthread_attr_setstacksize (pthread_attr_t * attr, +__PTW32_DLLPORT int __PTW32_CDECL pthread_attr_setstacksize (pthread_attr_t * attr, size_t stacksize); -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getschedparam (const pthread_attr_t *attr, +__PTW32_DLLPORT int __PTW32_CDECL pthread_attr_getschedparam (const pthread_attr_t *attr, struct sched_param *param); -PTW32_DLLPORT int PTW32_CDECL pthread_attr_setschedparam (pthread_attr_t *attr, +__PTW32_DLLPORT int __PTW32_CDECL pthread_attr_setschedparam (pthread_attr_t *attr, const struct sched_param *param); -PTW32_DLLPORT int PTW32_CDECL pthread_attr_setschedpolicy (pthread_attr_t *, +__PTW32_DLLPORT int __PTW32_CDECL pthread_attr_setschedpolicy (pthread_attr_t *, int); -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getschedpolicy (const pthread_attr_t *, +__PTW32_DLLPORT int __PTW32_CDECL pthread_attr_getschedpolicy (const pthread_attr_t *, int *); -PTW32_DLLPORT int PTW32_CDECL pthread_attr_setinheritsched(pthread_attr_t * attr, +__PTW32_DLLPORT int __PTW32_CDECL pthread_attr_setinheritsched(pthread_attr_t * attr, int inheritsched); -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getinheritsched(const pthread_attr_t * attr, +__PTW32_DLLPORT int __PTW32_CDECL pthread_attr_getinheritsched(const pthread_attr_t * attr, int * inheritsched); -PTW32_DLLPORT int PTW32_CDECL pthread_attr_setscope (pthread_attr_t *, +__PTW32_DLLPORT int __PTW32_CDECL pthread_attr_setscope (pthread_attr_t *, int); -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getscope (const pthread_attr_t *, +__PTW32_DLLPORT int __PTW32_CDECL pthread_attr_getscope (const pthread_attr_t *, int *); /* * PThread Functions */ -PTW32_DLLPORT int PTW32_CDECL pthread_create (pthread_t * tid, +__PTW32_DLLPORT int __PTW32_CDECL pthread_create (pthread_t * tid, const pthread_attr_t * attr, - void *(PTW32_CDECL *start) (void *), + void * (__PTW32_CDECL *start) (void *), void *arg); -PTW32_DLLPORT int PTW32_CDECL pthread_detach (pthread_t tid); +__PTW32_DLLPORT int __PTW32_CDECL pthread_detach (pthread_t tid); -PTW32_DLLPORT int PTW32_CDECL pthread_equal (pthread_t t1, +__PTW32_DLLPORT int __PTW32_CDECL pthread_equal (pthread_t t1, pthread_t t2); -PTW32_DLLPORT void PTW32_CDECL pthread_exit (void *value_ptr); +__PTW32_DLLPORT void __PTW32_CDECL pthread_exit (void *value_ptr); -PTW32_DLLPORT int PTW32_CDECL pthread_join (pthread_t thread, +__PTW32_DLLPORT int __PTW32_CDECL pthread_join (pthread_t thread, void **value_ptr); -PTW32_DLLPORT pthread_t PTW32_CDECL pthread_self (void); +__PTW32_DLLPORT pthread_t __PTW32_CDECL pthread_self (void); -PTW32_DLLPORT int PTW32_CDECL pthread_cancel (pthread_t thread); +__PTW32_DLLPORT int __PTW32_CDECL pthread_cancel (pthread_t thread); -PTW32_DLLPORT int PTW32_CDECL pthread_setcancelstate (int state, +__PTW32_DLLPORT int __PTW32_CDECL pthread_setcancelstate (int state, int *oldstate); -PTW32_DLLPORT int PTW32_CDECL pthread_setcanceltype (int type, +__PTW32_DLLPORT int __PTW32_CDECL pthread_setcanceltype (int type, int *oldtype); -PTW32_DLLPORT void PTW32_CDECL pthread_testcancel (void); +__PTW32_DLLPORT void __PTW32_CDECL pthread_testcancel (void); -PTW32_DLLPORT int PTW32_CDECL pthread_once (pthread_once_t * once_control, - void (PTW32_CDECL *init_routine) (void)); +__PTW32_DLLPORT int __PTW32_CDECL pthread_once (pthread_once_t * once_control, + void (__PTW32_CDECL *init_routine) (void)); -#if PTW32_LEVEL >= PTW32_LEVEL_MAX -PTW32_DLLPORT ptw32_cleanup_t * PTW32_CDECL ptw32_pop_cleanup (int execute); +#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, - ptw32_cleanup_callback_t routine, +__PTW32_DLLPORT void __PTW32_CDECL __ptw32_push_cleanup (__ptw32_cleanup_t * cleanup, + __ptw32_cleanup_callback_t routine, void *arg); -#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ +#endif /* __PTW32_LEVEL >= __PTW32_LEVEL_MAX */ /* * Thread Specific Data Functions */ -PTW32_DLLPORT int PTW32_CDECL pthread_key_create (pthread_key_t * key, - void (PTW32_CDECL *destructor) (void *)); +__PTW32_DLLPORT int __PTW32_CDECL pthread_key_create (pthread_key_t * key, + void (__PTW32_CDECL *destructor) (void *)); -PTW32_DLLPORT int PTW32_CDECL pthread_key_delete (pthread_key_t key); +__PTW32_DLLPORT int __PTW32_CDECL pthread_key_delete (pthread_key_t key); -PTW32_DLLPORT int PTW32_CDECL pthread_setspecific (pthread_key_t key, +__PTW32_DLLPORT int __PTW32_CDECL pthread_setspecific (pthread_key_t key, const void *value); -PTW32_DLLPORT void * PTW32_CDECL pthread_getspecific (pthread_key_t key); +__PTW32_DLLPORT void * __PTW32_CDECL pthread_getspecific (pthread_key_t key); /* * Mutex Attribute Functions */ -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_init (pthread_mutexattr_t * attr); +__PTW32_DLLPORT int __PTW32_CDECL pthread_mutexattr_init (pthread_mutexattr_t * attr); -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_destroy (pthread_mutexattr_t * attr); +__PTW32_DLLPORT int __PTW32_CDECL pthread_mutexattr_destroy (pthread_mutexattr_t * attr); -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_getpshared (const pthread_mutexattr_t +__PTW32_DLLPORT int __PTW32_CDECL pthread_mutexattr_getpshared (const pthread_mutexattr_t * attr, int *pshared); -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_setpshared (pthread_mutexattr_t * attr, +__PTW32_DLLPORT int __PTW32_CDECL pthread_mutexattr_setpshared (pthread_mutexattr_t * attr, int pshared); -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_settype (pthread_mutexattr_t * attr, int kind); -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_gettype (const pthread_mutexattr_t * attr, int *kind); +__PTW32_DLLPORT int __PTW32_CDECL pthread_mutexattr_settype (pthread_mutexattr_t * attr, int kind); +__PTW32_DLLPORT int __PTW32_CDECL pthread_mutexattr_gettype (const pthread_mutexattr_t * attr, int *kind); -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_setrobust( +__PTW32_DLLPORT int __PTW32_CDECL pthread_mutexattr_setrobust( pthread_mutexattr_t *attr, int robust); -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_getrobust( +__PTW32_DLLPORT int __PTW32_CDECL pthread_mutexattr_getrobust( const pthread_mutexattr_t * attr, int * robust); /* * Barrier Attribute Functions */ -PTW32_DLLPORT int PTW32_CDECL pthread_barrierattr_init (pthread_barrierattr_t * attr); +__PTW32_DLLPORT int __PTW32_CDECL pthread_barrierattr_init (pthread_barrierattr_t * attr); -PTW32_DLLPORT int PTW32_CDECL pthread_barrierattr_destroy (pthread_barrierattr_t * attr); +__PTW32_DLLPORT int __PTW32_CDECL pthread_barrierattr_destroy (pthread_barrierattr_t * attr); -PTW32_DLLPORT int PTW32_CDECL pthread_barrierattr_getpshared (const pthread_barrierattr_t +__PTW32_DLLPORT int __PTW32_CDECL pthread_barrierattr_getpshared (const pthread_barrierattr_t * attr, int *pshared); -PTW32_DLLPORT int PTW32_CDECL pthread_barrierattr_setpshared (pthread_barrierattr_t * attr, +__PTW32_DLLPORT int __PTW32_CDECL pthread_barrierattr_setpshared (pthread_barrierattr_t * attr, int pshared); /* * Mutex Functions */ -PTW32_DLLPORT int PTW32_CDECL pthread_mutex_init (pthread_mutex_t * mutex, +__PTW32_DLLPORT int __PTW32_CDECL pthread_mutex_init (pthread_mutex_t * mutex, const pthread_mutexattr_t * attr); -PTW32_DLLPORT int PTW32_CDECL pthread_mutex_destroy (pthread_mutex_t * mutex); +__PTW32_DLLPORT int __PTW32_CDECL pthread_mutex_destroy (pthread_mutex_t * mutex); -PTW32_DLLPORT int PTW32_CDECL pthread_mutex_lock (pthread_mutex_t * mutex); +__PTW32_DLLPORT int __PTW32_CDECL pthread_mutex_lock (pthread_mutex_t * mutex); -PTW32_DLLPORT int PTW32_CDECL pthread_mutex_timedlock(pthread_mutex_t * mutex, +__PTW32_DLLPORT int __PTW32_CDECL pthread_mutex_timedlock(pthread_mutex_t * mutex, const struct timespec *abstime); -PTW32_DLLPORT int PTW32_CDECL pthread_mutex_trylock (pthread_mutex_t * mutex); +__PTW32_DLLPORT int __PTW32_CDECL pthread_mutex_trylock (pthread_mutex_t * mutex); -PTW32_DLLPORT int PTW32_CDECL pthread_mutex_unlock (pthread_mutex_t * mutex); +__PTW32_DLLPORT int __PTW32_CDECL pthread_mutex_unlock (pthread_mutex_t * mutex); -PTW32_DLLPORT int PTW32_CDECL pthread_mutex_consistent (pthread_mutex_t * mutex); +__PTW32_DLLPORT int __PTW32_CDECL pthread_mutex_consistent (pthread_mutex_t * mutex); /* * Spinlock Functions */ -PTW32_DLLPORT int PTW32_CDECL pthread_spin_init (pthread_spinlock_t * lock, int pshared); +__PTW32_DLLPORT int __PTW32_CDECL pthread_spin_init (pthread_spinlock_t * lock, int pshared); -PTW32_DLLPORT int PTW32_CDECL pthread_spin_destroy (pthread_spinlock_t * lock); +__PTW32_DLLPORT int __PTW32_CDECL pthread_spin_destroy (pthread_spinlock_t * lock); -PTW32_DLLPORT int PTW32_CDECL pthread_spin_lock (pthread_spinlock_t * lock); +__PTW32_DLLPORT int __PTW32_CDECL pthread_spin_lock (pthread_spinlock_t * lock); -PTW32_DLLPORT int PTW32_CDECL pthread_spin_trylock (pthread_spinlock_t * lock); +__PTW32_DLLPORT int __PTW32_CDECL pthread_spin_trylock (pthread_spinlock_t * lock); -PTW32_DLLPORT int PTW32_CDECL pthread_spin_unlock (pthread_spinlock_t * lock); +__PTW32_DLLPORT int __PTW32_CDECL pthread_spin_unlock (pthread_spinlock_t * lock); /* * Barrier Functions */ -PTW32_DLLPORT int PTW32_CDECL pthread_barrier_init (pthread_barrier_t * barrier, +__PTW32_DLLPORT int __PTW32_CDECL pthread_barrier_init (pthread_barrier_t * barrier, const pthread_barrierattr_t * attr, unsigned int count); -PTW32_DLLPORT int PTW32_CDECL pthread_barrier_destroy (pthread_barrier_t * barrier); +__PTW32_DLLPORT int __PTW32_CDECL pthread_barrier_destroy (pthread_barrier_t * barrier); -PTW32_DLLPORT int PTW32_CDECL pthread_barrier_wait (pthread_barrier_t * barrier); +__PTW32_DLLPORT int __PTW32_CDECL pthread_barrier_wait (pthread_barrier_t * barrier); /* * Condition Variable Attribute Functions */ -PTW32_DLLPORT int PTW32_CDECL pthread_condattr_init (pthread_condattr_t * attr); +__PTW32_DLLPORT int __PTW32_CDECL pthread_condattr_init (pthread_condattr_t * attr); -PTW32_DLLPORT int PTW32_CDECL pthread_condattr_destroy (pthread_condattr_t * attr); +__PTW32_DLLPORT int __PTW32_CDECL pthread_condattr_destroy (pthread_condattr_t * attr); -PTW32_DLLPORT int PTW32_CDECL pthread_condattr_getpshared (const pthread_condattr_t * attr, +__PTW32_DLLPORT int __PTW32_CDECL pthread_condattr_getpshared (const pthread_condattr_t * attr, int *pshared); -PTW32_DLLPORT int PTW32_CDECL pthread_condattr_setpshared (pthread_condattr_t * attr, +__PTW32_DLLPORT int __PTW32_CDECL pthread_condattr_setpshared (pthread_condattr_t * attr, int pshared); /* * Condition Variable Functions */ -PTW32_DLLPORT int PTW32_CDECL pthread_cond_init (pthread_cond_t * cond, +__PTW32_DLLPORT int __PTW32_CDECL pthread_cond_init (pthread_cond_t * cond, const pthread_condattr_t * attr); -PTW32_DLLPORT int PTW32_CDECL pthread_cond_destroy (pthread_cond_t * cond); +__PTW32_DLLPORT int __PTW32_CDECL pthread_cond_destroy (pthread_cond_t * cond); -PTW32_DLLPORT int PTW32_CDECL pthread_cond_wait (pthread_cond_t * cond, +__PTW32_DLLPORT int __PTW32_CDECL pthread_cond_wait (pthread_cond_t * cond, pthread_mutex_t * mutex); -PTW32_DLLPORT int PTW32_CDECL pthread_cond_timedwait (pthread_cond_t * cond, +__PTW32_DLLPORT int __PTW32_CDECL pthread_cond_timedwait (pthread_cond_t * cond, pthread_mutex_t * mutex, const struct timespec *abstime); -PTW32_DLLPORT int PTW32_CDECL pthread_cond_signal (pthread_cond_t * cond); +__PTW32_DLLPORT int __PTW32_CDECL pthread_cond_signal (pthread_cond_t * cond); -PTW32_DLLPORT int PTW32_CDECL pthread_cond_broadcast (pthread_cond_t * cond); +__PTW32_DLLPORT int __PTW32_CDECL pthread_cond_broadcast (pthread_cond_t * cond); /* * Scheduling */ -PTW32_DLLPORT int PTW32_CDECL pthread_setschedparam (pthread_t thread, +__PTW32_DLLPORT int __PTW32_CDECL pthread_setschedparam (pthread_t thread, int policy, const struct sched_param *param); -PTW32_DLLPORT int PTW32_CDECL pthread_getschedparam (pthread_t thread, +__PTW32_DLLPORT int __PTW32_CDECL pthread_getschedparam (pthread_t thread, int *policy, struct sched_param *param); -PTW32_DLLPORT int PTW32_CDECL pthread_setconcurrency (int); - -PTW32_DLLPORT int PTW32_CDECL pthread_getconcurrency (void); +__PTW32_DLLPORT int __PTW32_CDECL pthread_setconcurrency (int); + +__PTW32_DLLPORT int __PTW32_CDECL pthread_getconcurrency (void); /* * Read-Write Lock Functions */ -PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_init(pthread_rwlock_t *lock, +__PTW32_DLLPORT int __PTW32_CDECL pthread_rwlock_init(pthread_rwlock_t *lock, const pthread_rwlockattr_t *attr); -PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_destroy(pthread_rwlock_t *lock); +__PTW32_DLLPORT int __PTW32_CDECL pthread_rwlock_destroy(pthread_rwlock_t *lock); -PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_tryrdlock(pthread_rwlock_t *); +__PTW32_DLLPORT int __PTW32_CDECL pthread_rwlock_tryrdlock(pthread_rwlock_t *); -PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_trywrlock(pthread_rwlock_t *); +__PTW32_DLLPORT int __PTW32_CDECL pthread_rwlock_trywrlock(pthread_rwlock_t *); -PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_rdlock(pthread_rwlock_t *lock); +__PTW32_DLLPORT int __PTW32_CDECL pthread_rwlock_rdlock(pthread_rwlock_t *lock); -PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_timedrdlock(pthread_rwlock_t *lock, +__PTW32_DLLPORT int __PTW32_CDECL pthread_rwlock_timedrdlock(pthread_rwlock_t *lock, const struct timespec *abstime); -PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_wrlock(pthread_rwlock_t *lock); +__PTW32_DLLPORT int __PTW32_CDECL pthread_rwlock_wrlock(pthread_rwlock_t *lock); -PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_timedwrlock(pthread_rwlock_t *lock, +__PTW32_DLLPORT int __PTW32_CDECL pthread_rwlock_timedwrlock(pthread_rwlock_t *lock, const struct timespec *abstime); -PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_unlock(pthread_rwlock_t *lock); +__PTW32_DLLPORT int __PTW32_CDECL pthread_rwlock_unlock(pthread_rwlock_t *lock); -PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_init (pthread_rwlockattr_t * attr); +__PTW32_DLLPORT int __PTW32_CDECL pthread_rwlockattr_init (pthread_rwlockattr_t * attr); -PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_destroy (pthread_rwlockattr_t * attr); +__PTW32_DLLPORT int __PTW32_CDECL pthread_rwlockattr_destroy (pthread_rwlockattr_t * attr); -PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_getpshared (const pthread_rwlockattr_t * attr, +__PTW32_DLLPORT int __PTW32_CDECL pthread_rwlockattr_getpshared (const pthread_rwlockattr_t * attr, int *pshared); -PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_setpshared (pthread_rwlockattr_t * attr, +__PTW32_DLLPORT int __PTW32_CDECL pthread_rwlockattr_setpshared (pthread_rwlockattr_t * attr, int pshared); -#if PTW32_LEVEL >= PTW32_LEVEL_MAX - 1 +#if __PTW32_LEVEL >= __PTW32_LEVEL_MAX - 1 /* * Signal Functions. Should be defined in but MSVC and MinGW32 * already have signal.h that don't define these. */ -PTW32_DLLPORT int PTW32_CDECL pthread_kill(pthread_t thread, int sig); +__PTW32_DLLPORT int __PTW32_CDECL pthread_kill(pthread_t thread, int sig); /* * Non-portable functions @@ -1166,34 +1006,55 @@ PTW32_DLLPORT int PTW32_CDECL pthread_kill(pthread_t thread, int sig); /* * Compatibility with Linux. */ -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_setkind_np(pthread_mutexattr_t * attr, +__PTW32_DLLPORT int __PTW32_CDECL pthread_mutexattr_setkind_np(pthread_mutexattr_t * attr, int kind); -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_getkind_np(pthread_mutexattr_t * attr, +__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 */ -PTW32_DLLPORT int PTW32_CDECL pthread_delay_np (struct timespec * interval); -PTW32_DLLPORT int PTW32_CDECL pthread_num_processors_np(void); -PTW32_DLLPORT unsigned __int64 PTW32_CDECL pthread_getunique_np(pthread_t thread); +__PTW32_DLLPORT int __PTW32_CDECL pthread_delay_np (struct timespec * interval); +__PTW32_DLLPORT int __PTW32_CDECL pthread_num_processors_np(void); +__PTW32_DLLPORT unsigned __int64 __PTW32_CDECL pthread_getunique_np(pthread_t thread); /* * Useful if an application wants to statically link * the lib rather than load the DLL at run-time. */ -PTW32_DLLPORT int PTW32_CDECL pthread_win32_process_attach_np(void); -PTW32_DLLPORT int PTW32_CDECL pthread_win32_process_detach_np(void); -PTW32_DLLPORT int PTW32_CDECL pthread_win32_thread_attach_np(void); -PTW32_DLLPORT int PTW32_CDECL pthread_win32_thread_detach_np(void); +__PTW32_DLLPORT int __PTW32_CDECL pthread_win32_process_attach_np(void); +__PTW32_DLLPORT int __PTW32_CDECL pthread_win32_process_detach_np(void); +__PTW32_DLLPORT int __PTW32_CDECL pthread_win32_thread_attach_np(void); +__PTW32_DLLPORT int __PTW32_CDECL pthread_win32_thread_detach_np(void); + +/* + * Returns the first parameter "abstime" modified to represent the current system time. + * If "relative" is not NULL it represents an interval to add to "abstime". + */ + +__PTW32_DLLPORT struct timespec * __PTW32_CDECL pthread_win32_getabstime_np( + struct timespec * abstime, + const struct timespec * relative); /* * Features that are auto-detected at load/run time. */ -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_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. */ }; /* @@ -1204,27 +1065,43 @@ enum ptw32_features { * WM_TIMECHANGE message. It can be passed directly to * pthread_create() as a new thread if desired. */ -PTW32_DLLPORT void * PTW32_CDECL pthread_timechange_handler_np(void *); +__PTW32_DLLPORT void * __PTW32_CDECL pthread_timechange_handler_np(void *); -#endif /*PTW32_LEVEL >= PTW32_LEVEL_MAX - 1 */ +#endif /* __PTW32_LEVEL >= __PTW32_LEVEL_MAX - 1 */ -#if PTW32_LEVEL >= PTW32_LEVEL_MAX +#if __PTW32_LEVEL >= __PTW32_LEVEL_MAX /* * Returns the Win32 HANDLE for the POSIX thread. */ -PTW32_DLLPORT HANDLE PTW32_CDECL pthread_getw32threadhandle_np(pthread_t thread); +__PTW32_DLLPORT void * __PTW32_CDECL pthread_getw32threadhandle_np(pthread_t thread); /* * Returns the win32 thread ID for POSIX thread. */ -PTW32_DLLPORT DWORD PTW32_CDECL pthread_getw32threadid_np (pthread_t thread); +__PTW32_DLLPORT unsigned long __PTW32_CDECL pthread_getw32threadid_np (pthread_t thread); + +/* + * Sets the POSIX thread name. If _MSC_VER is defined the name should be displayed by + * the MSVS debugger. + */ +#if defined (__PTW32_COMPATIBILITY_BSD) || defined (__PTW32_COMPATIBILITY_TRU64) +#define PTHREAD_MAX_NAMELEN_NP 16 +__PTW32_DLLPORT int __PTW32_CDECL pthread_setname_np (pthread_t thr, const char * name, void * arg); +__PTW32_DLLPORT int __PTW32_CDECL pthread_attr_setname_np (pthread_attr_t * attr, const char * name, void * arg); +#else +__PTW32_DLLPORT int __PTW32_CDECL pthread_setname_np (pthread_t thr, const char * name); +__PTW32_DLLPORT int __PTW32_CDECL pthread_attr_setname_np (pthread_attr_t * attr, const char * name); +#endif + +__PTW32_DLLPORT int __PTW32_CDECL pthread_getname_np (pthread_t thr, char * name, int len); +__PTW32_DLLPORT int __PTW32_CDECL pthread_attr_getname_np (pthread_attr_t * attr, char * name, int len); /* * Protected Methods * * This function blocks until the given WIN32 handle - * is signaled or pthread_cancel had been called. + * is signalled or pthread_cancel had been called. * This function allows the caller to hook into the * PThreads cancel mechanism. It is implemented using * @@ -1235,34 +1112,26 @@ PTW32_DLLPORT DWORD PTW32_CDECL pthread_getw32threadid_np (pthread_t thread); * argument to TimedWait is simply passed to * WaitForMultipleObjects. */ -PTW32_DLLPORT int PTW32_CDECL pthreadCancelableWait (HANDLE waitHandle); -PTW32_DLLPORT int PTW32_CDECL pthreadCancelableTimedWait (HANDLE waitHandle, - DWORD timeout); +__PTW32_DLLPORT int __PTW32_CDECL pthreadCancelableWait (void *waitHandle); +__PTW32_DLLPORT int __PTW32_CDECL pthreadCancelableTimedWait (void *waitHandle, + unsigned long timeout); -#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ +#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 -/* - * Some compiler environments don't define some things. - */ -#if defined(__BORLANDC__) -# define _ftime ftime -# define _timeb timeb +#if defined (__PTW32_USES_SEPARATE_CRT) && (defined(__PTW32_CLEANUP_CXX) || defined(__PTW32_CLEANUP_SEH)) +typedef void (*__ptw32_terminate_handler)(); +__PTW32_DLLPORT __ptw32_terminate_handler __PTW32_CDECL pthread_win32_set_terminate_np(__ptw32_terminate_handler termFunction); #endif #if defined(__cplusplus) @@ -1270,37 +1139,37 @@ PTW32_DLLPORT int PTW32_CDECL pthreadCancelableTimedWait (HANDLE waitHandle, /* * Internal exceptions */ -class ptw32_exception {}; -class ptw32_exception_cancel : public ptw32_exception {}; -class ptw32_exception_exit : public ptw32_exception {}; +class __ptw32_exception {}; +class __ptw32_exception_cancel : public __ptw32_exception {}; +class __ptw32_exception_exit : public __ptw32_exception {}; #endif -#if PTW32_LEVEL >= PTW32_LEVEL_MAX +#if __PTW32_LEVEL >= __PTW32_LEVEL_MAX /* FIXME: This is only required if the library was built using SEH */ /* * Get internal SEH tag */ -PTW32_DLLPORT DWORD PTW32_CDECL ptw32_get_exception_services_code(void); +__PTW32_DLLPORT unsigned long __PTW32_CDECL __ptw32_get_exception_services_code(void); -#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ +#endif /* __PTW32_LEVEL >= __PTW32_LEVEL_MAX */ -#if !defined(PTW32_BUILD) +#if !defined (__PTW32_BUILD) -#if defined(__CLEANUP_SEH) +#if defined(__PTW32_CLEANUP_SEH) /* * Redefine the SEH __except keyword to ensure that applications * propagate our internal exceptions up to the library's internal handlers. */ #define __except( E ) \ - __except( ( GetExceptionCode() == ptw32_get_exception_services_code() ) \ + __except( ( GetExceptionCode() == __ptw32_get_exception_services_code() ) \ ? EXCEPTION_CONTINUE_SEARCH : ( E ) ) -#endif /* __CLEANUP_SEH */ +#endif /* __PTW32_CLEANUP_SEH */ -#if defined(__CLEANUP_CXX) +#if defined(__PTW32_CLEANUP_CXX) /* * Redefine the C++ catch keyword to ensure that applications @@ -1308,21 +1177,21 @@ 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. + * WARNING: Replace any 'catch( ... )' with '__PtW32CatchAll' + * if you want Pthread-Win32 cancellation and pthread_exit to work. */ -#if !defined(PtW32NoCatchWarn) +#if !defined(__PtW32NoCatchWarn) -#pragma message("Specify \"/DPtW32NoCatchWarn\" compiler flag to skip this message.") +#pragma message("Specify \"/D__PtW32NoCatchWarn\" compiler flag to skip this message.") #pragma message("------------------------------------------------------------------") #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(" with '__PtW32CatchAll' or 'CATCHALL' if you want POSIX thread") +#pragma message(" cancellation and pthread_exit to work. For example:") #pragma message("") -#pragma message(" #if defined(PtW32CatchAll)") -#pragma message(" PtW32CatchAll") +#pragma message(" #if defined(__PtW32CatchAll)") +#pragma message(" __PtW32CatchAll") #pragma message(" #else") #pragma message(" catch(...)") #pragma message(" #endif") @@ -1333,35 +1202,26 @@ PTW32_DLLPORT DWORD PTW32_CDECL ptw32_get_exception_services_code(void); #endif -#define PtW32CatchAll \ - catch( ptw32_exception & ) { throw; } \ +#define __PtW32CatchAll \ + catch( __ptw32_exception & ) { throw; } \ catch( ... ) #else /* _MSC_VER */ #define catch( E ) \ - catch( ptw32_exception & ) { throw; } \ + catch( __ptw32_exception & ) { throw; } \ catch( E ) #endif /* _MSC_VER */ -#endif /* __CLEANUP_CXX */ +#endif /* __PTW32_CLEANUP_CXX */ -#endif /* ! PTW32_BUILD */ +#endif /* ! __PTW32_BUILD */ -#if defined(__cplusplus) -} /* End of extern "C" */ -#endif /* __cplusplus */ - -#if defined(PTW32__HANDLE_DEF) -# undef HANDLE -#endif -#if defined(PTW32__DWORD_DEF) -# undef DWORD -#endif +__PTW32_END_C_DECLS -#undef PTW32_LEVEL -#undef PTW32_LEVEL_MAX +#undef __PTW32_LEVEL +#undef __PTW32_LEVEL_MAX #endif /* ! RC_INVOKED */ diff --git a/vendor/pthreads/include/pthread_attr_destroy.c b/vendor/pthreads/include/pthread_attr_destroy.c index 8b3e04c536..cc9a47178e 100644 --- a/vendor/pthreads/include/pthread_attr_destroy.c +++ b/vendor/pthreads/include/pthread_attr_destroy.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" @@ -63,7 +65,7 @@ pthread_attr_destroy (pthread_attr_t * attr) * ------------------------------------------------------ */ { - if (ptw32_is_attr (attr) != 0) + if (__ptw32_is_attr (attr) != 0) { return EINVAL; } diff --git a/vendor/pthreads/include/pthread_attr_getaffinity_np.c b/vendor/pthreads/include/pthread_attr_getaffinity_np.c new file mode 100644 index 0000000000..adec7305ff --- /dev/null +++ b/vendor/pthreads/include/pthread_attr_getaffinity_np.c @@ -0,0 +1,54 @@ +/* + * pthread_attr_getaffinity_np.c + * + * Description: + * POSIX thread functions that deal with thread CPU affinity. + * + * -------------------------------------------------------------------------- + * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * + * The 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: + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include "pthread.h" +#include "implement.h" +#include "sched.h" + +int +pthread_attr_getaffinity_np (const pthread_attr_t * attr, size_t cpusetsize, cpu_set_t * cpuset) +{ + if (__ptw32_is_attr (attr) != 0 || cpuset == NULL) + { + return EINVAL; + } + + ((_sched_cpu_set_vector_*)cpuset)->_cpuset = (*attr)->cpuset; + + return 0; +} diff --git a/vendor/pthreads/include/pthread_attr_getdetachstate.c b/vendor/pthreads/include/pthread_attr_getdetachstate.c index 188533b13c..2d8bbb0793 100644 --- a/vendor/pthreads/include/pthread_attr_getdetachstate.c +++ b/vendor/pthreads/include/pthread_attr_getdetachstate.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" @@ -76,7 +78,7 @@ pthread_attr_getdetachstate (const pthread_attr_t * attr, int *detachstate) * ------------------------------------------------------ */ { - if (ptw32_is_attr (attr) != 0 || detachstate == NULL) + if (__ptw32_is_attr (attr) != 0 || detachstate == NULL) { return EINVAL; } diff --git a/vendor/pthreads/include/pthread_attr_getinheritsched.c b/vendor/pthreads/include/pthread_attr_getinheritsched.c index 9c6885ed92..6a24862f0d 100644 --- a/vendor/pthreads/include/pthread_attr_getinheritsched.c +++ b/vendor/pthreads/include/pthread_attr_getinheritsched.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" #include "sched.h" @@ -41,7 +43,7 @@ int pthread_attr_getinheritsched (const pthread_attr_t * attr, int *inheritsched) { - if (ptw32_is_attr (attr) != 0 || inheritsched == NULL) + if (__ptw32_is_attr (attr) != 0 || inheritsched == NULL) { return EINVAL; } diff --git a/vendor/pthreads/include/pthread_attr_getname_np.c b/vendor/pthreads/include/pthread_attr_getname_np.c new file mode 100644 index 0000000000..cec14d4278 --- /dev/null +++ b/vendor/pthreads/include/pthread_attr_getname_np.c @@ -0,0 +1,51 @@ +/* + * pthread_attr_getname_np.c + * + * -------------------------------------------------------------------------- + * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * + * The 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: + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include "pthread.h" +#include "implement.h" + +int +pthread_attr_getname_np(pthread_attr_t * attr, char *name, int len) +{ + //strncpy_s(name, len - 1, (*attr)->thrname, len - 1); +#if defined(_MSVCRT_) +# pragma warning(suppress:4996) + strncpy(name, (*attr)->thrname, len - 1); + (*attr)->thrname[len - 1] = '\0'; +#endif + + return 0; +} diff --git a/vendor/pthreads/include/pthread_attr_getschedparam.c b/vendor/pthreads/include/pthread_attr_getschedparam.c index ab89b2241a..515a0af941 100644 --- a/vendor/pthreads/include/pthread_attr_getschedparam.c +++ b/vendor/pthreads/include/pthread_attr_getschedparam.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" #include "sched.h" @@ -42,7 +44,7 @@ int pthread_attr_getschedparam (const pthread_attr_t * attr, struct sched_param *param) { - if (ptw32_is_attr (attr) != 0 || param == NULL) + if (__ptw32_is_attr (attr) != 0 || param == NULL) { return EINVAL; } diff --git a/vendor/pthreads/include/pthread_attr_getschedpolicy.c b/vendor/pthreads/include/pthread_attr_getschedpolicy.c index 94a257d609..85762f3881 100644 --- a/vendor/pthreads/include/pthread_attr_getschedpolicy.c +++ b/vendor/pthreads/include/pthread_attr_getschedpolicy.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" #include "sched.h" @@ -41,16 +43,7 @@ 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) + if (__ptw32_is_attr (attr) != 0 || policy == NULL) { return EINVAL; } diff --git a/vendor/pthreads/include/pthread_attr_getscope.c b/vendor/pthreads/include/pthread_attr_getscope.c index 2efdb2fe6d..9f6c13fe21 100644 --- a/vendor/pthreads/include/pthread_attr_getscope.c +++ b/vendor/pthreads/include/pthread_attr_getscope.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" diff --git a/vendor/pthreads/include/pthread_attr_getstackaddr.c b/vendor/pthreads/include/pthread_attr_getstackaddr.c index 1a2da01c78..2a21805903 100644 --- a/vendor/pthreads/include/pthread_attr_getstackaddr.c +++ b/vendor/pthreads/include/pthread_attr_getstackaddr.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" @@ -72,16 +74,16 @@ pthread_attr_getstackaddr (const pthread_attr_t * attr, void **stackaddr) * address.. * * RESULTS - * 0 successfully retreived stack address, + * 0 successfully retrieved stack address, * EINVAL 'attr' is invalid * ENOSYS function not supported * * ------------------------------------------------------ */ { -#if defined( _POSIX_THREAD_ATTR_STACKADDR ) +#if defined( _POSIX_THREAD_ATTR_STACKADDR ) && _POSIX_THREAD_ATTR_STACKADDR != -1 - if (ptw32_is_attr (attr) != 0) + if (__ptw32_is_attr (attr) != 0) { return EINVAL; } diff --git a/vendor/pthreads/include/pthread_attr_getstacksize.c b/vendor/pthreads/include/pthread_attr_getstacksize.c index dff9230f28..3916a7c7ea 100644 --- a/vendor/pthreads/include/pthread_attr_getstacksize.c +++ b/vendor/pthreads/include/pthread_attr_getstacksize.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" @@ -80,9 +82,9 @@ pthread_attr_getstacksize (const pthread_attr_t * attr, size_t * stacksize) * ------------------------------------------------------ */ { -#if defined(_POSIX_THREAD_ATTR_STACKSIZE) +#if defined(_POSIX_THREAD_ATTR_STACKSIZE) && _POSIX_THREAD_ATTR_STACKSIZE != -1 - if (ptw32_is_attr (attr) != 0) + if (__ptw32_is_attr (attr) != 0) { return EINVAL; } diff --git a/vendor/pthreads/include/pthread_attr_init.c b/vendor/pthreads/include/pthread_attr_init.c index ae9d3eb5f4..ff671e753f 100644 --- a/vendor/pthreads/include/pthread_attr_init.c +++ b/vendor/pthreads/include/pthread_attr_init.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" @@ -66,6 +68,7 @@ pthread_attr_init (pthread_attr_t * attr) */ { pthread_attr_t attr_result; + cpu_set_t cpuset; if (attr == NULL) { @@ -108,8 +111,11 @@ pthread_attr_init (pthread_attr_t * attr) attr_result->param.sched_priority = THREAD_PRIORITY_NORMAL; attr_result->inheritsched = PTHREAD_EXPLICIT_SCHED; attr_result->contentionscope = PTHREAD_SCOPE_SYSTEM; + CPU_ZERO(&cpuset); + attr_result->cpuset = ((_sched_cpu_set_vector_*)&cpuset)->_cpuset; + attr_result->thrname = NULL; - attr_result->valid = PTW32_ATTR_VALID; + attr_result->valid = __PTW32_ATTR_VALID; *attr = attr_result; diff --git a/vendor/pthreads/include/pthread_attr_setaffinity_np.c b/vendor/pthreads/include/pthread_attr_setaffinity_np.c new file mode 100644 index 0000000000..c3da27e51e --- /dev/null +++ b/vendor/pthreads/include/pthread_attr_setaffinity_np.c @@ -0,0 +1,54 @@ +/* + * pthread_attr_setaffinity_np.c + * + * Description: + * POSIX thread functions that deal with thread CPU affinity. + * + * -------------------------------------------------------------------------- + * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * + * The 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: + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include "pthread.h" +#include "implement.h" +#include "sched.h" + +int +pthread_attr_setaffinity_np (pthread_attr_t * attr, size_t cpusetsize, const cpu_set_t * cpuset) +{ + if (__ptw32_is_attr (attr) != 0 || cpuset == NULL) + { + return EINVAL; + } + + (*attr)->cpuset = ((_sched_cpu_set_vector_*)cpuset)->_cpuset; + + return 0; +} diff --git a/vendor/pthreads/include/pthread_attr_setdetachstate.c b/vendor/pthreads/include/pthread_attr_setdetachstate.c index 784642a807..b12ff955a6 100644 --- a/vendor/pthreads/include/pthread_attr_setdetachstate.c +++ b/vendor/pthreads/include/pthread_attr_setdetachstate.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" @@ -75,7 +77,7 @@ pthread_attr_setdetachstate (pthread_attr_t * attr, int detachstate) * ------------------------------------------------------ */ { - if (ptw32_is_attr (attr) != 0) + if (__ptw32_is_attr (attr) != 0) { return EINVAL; } diff --git a/vendor/pthreads/include/pthread_attr_setinheritsched.c b/vendor/pthreads/include/pthread_attr_setinheritsched.c index e0a407a3b7..003a821d43 100644 --- a/vendor/pthreads/include/pthread_attr_setinheritsched.c +++ b/vendor/pthreads/include/pthread_attr_setinheritsched.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" #include "sched.h" @@ -41,7 +43,7 @@ int pthread_attr_setinheritsched (pthread_attr_t * attr, int inheritsched) { - if (ptw32_is_attr (attr) != 0) + if (__ptw32_is_attr (attr) != 0) { return EINVAL; } diff --git a/vendor/pthreads/include/pthread_attr_setname_np.c b/vendor/pthreads/include/pthread_attr_setname_np.c new file mode 100644 index 0000000000..3161bf192a --- /dev/null +++ b/vendor/pthreads/include/pthread_attr_setname_np.c @@ -0,0 +1,96 @@ +/* + * pthread_attr_setname_np.c + * + * -------------------------------------------------------------------------- + * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * + * The 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: + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include +#include "pthread.h" +#include "implement.h" + +#if defined (__PTW32_COMPATIBILITY_BSD) || defined (__PTW32_COMPATIBILITY_TRU64) +int +pthread_attr_setname_np(pthread_attr_t * attr, const char *name, void *arg) +{ + int len; + int result; + char tmpbuf[PTHREAD_MAX_NAMELEN_NP]; + char * newname; + char * oldname; + + /* + * According to the MSDN description for snprintf() + * where count is the second parameter: + * If len < count, then len characters are stored in buffer, a null-terminator is appended, and len is returned. + * If len = count, then len characters are stored in buffer, no null-terminator is appended, and len is returned. + * If len > count, then count characters are stored in buffer, no null-terminator is appended, and a negative value is returned. + * + * This is different to the POSIX behaviour which returns the number of characters that would have been written in all cases. + */ + len = snprintf(tmpbuf, PTHREAD_MAX_NAMELEN_NP-1, name, arg); + tmpbuf[PTHREAD_MAX_NAMELEN_NP-1] = '\0'; + if (len < 0) + { + return EINVAL; + } + + newname = _strdup(tmpbuf); + + oldname = (*attr)->thrname; + (*attr)->thrname = newname; + if (oldname) + { + free(oldname); + } + + return 0; +} +#else +int +pthread_attr_setname_np(pthread_attr_t * attr, const char *name) +{ + char * newname; + char * oldname; + + newname = _strdup(name); + + oldname = (*attr)->thrname; + (*attr)->thrname = newname; + if (oldname) + { + free(oldname); + } + + return 0; +} +#endif diff --git a/vendor/pthreads/include/pthread_attr_setschedparam.c b/vendor/pthreads/include/pthread_attr_setschedparam.c index f246bfae7a..36e64eb008 100644 --- a/vendor/pthreads/include/pthread_attr_setschedparam.c +++ b/vendor/pthreads/include/pthread_attr_setschedparam.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" #include "sched.h" @@ -44,7 +46,7 @@ pthread_attr_setschedparam (pthread_attr_t * attr, { int priority; - if (ptw32_is_attr (attr) != 0 || param == NULL) + if (__ptw32_is_attr (attr) != 0 || param == NULL) { return EINVAL; } diff --git a/vendor/pthreads/include/pthread_attr_setschedpolicy.c b/vendor/pthreads/include/pthread_attr_setschedpolicy.c index 45ff165973..af6fb9e934 100644 --- a/vendor/pthreads/include/pthread_attr_setschedpolicy.c +++ b/vendor/pthreads/include/pthread_attr_setschedpolicy.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" #include "sched.h" @@ -41,7 +43,7 @@ int pthread_attr_setschedpolicy (pthread_attr_t * attr, int policy) { - if (ptw32_is_attr (attr) != 0) + if (__ptw32_is_attr (attr) != 0) { return EINVAL; } diff --git a/vendor/pthreads/include/pthread_attr_setscope.c b/vendor/pthreads/include/pthread_attr_setscope.c index 39a51df887..81765b87fe 100644 --- a/vendor/pthreads/include/pthread_attr_setscope.c +++ b/vendor/pthreads/include/pthread_attr_setscope.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" diff --git a/vendor/pthreads/include/pthread_attr_setstackaddr.c b/vendor/pthreads/include/pthread_attr_setstackaddr.c index 1316c06592..20a53dd4c7 100644 --- a/vendor/pthreads/include/pthread_attr_setstackaddr.c +++ b/vendor/pthreads/include/pthread_attr_setstackaddr.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" @@ -79,9 +81,9 @@ pthread_attr_setstackaddr (pthread_attr_t * attr, void *stackaddr) * ------------------------------------------------------ */ { -#if defined( _POSIX_THREAD_ATTR_STACKADDR ) +#if defined( _POSIX_THREAD_ATTR_STACKADDR ) && _POSIX_THREAD_ATTR_STACKADDR != -1 - if (ptw32_is_attr (attr) != 0) + if (__ptw32_is_attr (attr) != 0) { return EINVAL; } diff --git a/vendor/pthreads/include/pthread_attr_setstacksize.c b/vendor/pthreads/include/pthread_attr_setstacksize.c index eb13589a00..fe930ef9d4 100644 --- a/vendor/pthreads/include/pthread_attr_setstacksize.c +++ b/vendor/pthreads/include/pthread_attr_setstacksize.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" @@ -80,7 +82,7 @@ pthread_attr_setstacksize (pthread_attr_t * attr, size_t stacksize) * ------------------------------------------------------ */ { -#if defined(_POSIX_THREAD_ATTR_STACKSIZE) +#if defined(_POSIX_THREAD_ATTR_STACKSIZE) && _POSIX_THREAD_ATTR_STACKSIZE != -1 #if PTHREAD_STACK_MIN > 0 @@ -92,7 +94,7 @@ pthread_attr_setstacksize (pthread_attr_t * attr, size_t stacksize) #endif - if (ptw32_is_attr (attr) != 0) + if (__ptw32_is_attr (attr) != 0) { return EINVAL; } diff --git a/vendor/pthreads/include/pthread_barrier_destroy.c b/vendor/pthreads/include/pthread_barrier_destroy.c index 55163cc858..a2904c0ee9 100644 --- a/vendor/pthreads/include/pthread_barrier_destroy.c +++ b/vendor/pthreads/include/pthread_barrier_destroy.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" @@ -42,14 +44,14 @@ pthread_barrier_destroy (pthread_barrier_t * barrier) { int result = 0; pthread_barrier_t b; - ptw32_mcs_local_node_t node; + __ptw32_mcs_local_node_t node; - if (barrier == NULL || *barrier == (pthread_barrier_t) PTW32_OBJECT_INVALID) + if (barrier == NULL || *barrier == (pthread_barrier_t) __PTW32_OBJECT_INVALID) { return EINVAL; } - if (0 != ptw32_mcs_lock_try_acquire(&(*barrier)->lock, &node)) + if (0 != __ptw32_mcs_lock_try_acquire(&(*barrier)->lock, &node)) { return EBUSY; } @@ -64,7 +66,7 @@ pthread_barrier_destroy (pthread_barrier_t * barrier) { if (0 == (result = sem_destroy (&(b->semBarrierBreeched)))) { - *barrier = (pthread_barrier_t) PTW32_OBJECT_INVALID; + *barrier = (pthread_barrier_t) __PTW32_OBJECT_INVALID; /* * Release the lock before freeing b. * @@ -75,7 +77,7 @@ pthread_barrier_destroy (pthread_barrier_t * barrier) * pthread_barrier_t_ to an instance. This is a change to the ABI * and will require a major version number increment. */ - ptw32_mcs_lock_release(&node); + __ptw32_mcs_lock_release(&node); (void) free (b); return 0; } @@ -98,6 +100,6 @@ pthread_barrier_destroy (pthread_barrier_t * barrier) } } - ptw32_mcs_lock_release(&node); + __ptw32_mcs_lock_release(&node); return (result); } diff --git a/vendor/pthreads/include/pthread_barrier_init.c b/vendor/pthreads/include/pthread_barrier_init.c index 618bfae264..ac5c07b317 100644 --- a/vendor/pthreads/include/pthread_barrier_init.c +++ b/vendor/pthreads/include/pthread_barrier_init.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" diff --git a/vendor/pthreads/include/pthread_barrier_wait.c b/vendor/pthreads/include/pthread_barrier_wait.c index e0e97e6c78..ad180f4b3f 100644 --- a/vendor/pthreads/include/pthread_barrier_wait.c +++ b/vendor/pthreads/include/pthread_barrier_wait.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" @@ -44,14 +46,14 @@ pthread_barrier_wait (pthread_barrier_t * barrier) int result; pthread_barrier_t b; - ptw32_mcs_local_node_t node; + __ptw32_mcs_local_node_t node; - if (barrier == NULL || *barrier == (pthread_barrier_t) PTW32_OBJECT_INVALID) + if (barrier == NULL || *barrier == (pthread_barrier_t) __PTW32_OBJECT_INVALID) { return EINVAL; } - ptw32_mcs_lock_acquire(&(*barrier)->lock, &node); + __ptw32_mcs_lock_acquire(&(*barrier)->lock, &node); b = *barrier; if (--b->nCurrentBarrierHeight == 0) @@ -61,7 +63,7 @@ pthread_barrier_wait (pthread_barrier_t * barrier) * Move our MCS local node to the global scope barrier handle so that the * last thread out (not necessarily us) can release the lock. */ - ptw32_mcs_node_transfer(&b->proxynode, &node); + __ptw32_mcs_node_transfer(&b->proxynode, &node); /* * Any threads that have not quite entered sem_wait below when the @@ -74,7 +76,7 @@ pthread_barrier_wait (pthread_barrier_t * barrier) } else { - ptw32_mcs_lock_release(&node); + __ptw32_mcs_lock_release(&node); /* * Use the non-cancelable version of sem_wait(). * @@ -84,16 +86,16 @@ pthread_barrier_wait (pthread_barrier_t * barrier) * If pthread_barrier_destroy is called at that moment then the * barrier will be destroyed along with the semas. */ - result = ptw32_semwait (&(b->semBarrierBreeched)); + result = __ptw32_semwait (&(b->semBarrierBreeched)); } - if ((PTW32_INTERLOCKED_LONG)PTW32_INTERLOCKED_INCREMENT_LONG((PTW32_INTERLOCKED_LONGPTR)&b->nCurrentBarrierHeight) - == (PTW32_INTERLOCKED_LONG)b->nInitialBarrierHeight) + if ((__PTW32_INTERLOCKED_LONG)__PTW32_INTERLOCKED_INCREMENT_LONG ((__PTW32_INTERLOCKED_LONGPTR)&b->nCurrentBarrierHeight) + == (__PTW32_INTERLOCKED_LONG)b->nInitialBarrierHeight) { /* * We are the last thread to cross this barrier */ - ptw32_mcs_lock_release(&b->proxynode); + __ptw32_mcs_lock_release(&b->proxynode); if (0 == result) { result = PTHREAD_BARRIER_SERIAL_THREAD; diff --git a/vendor/pthreads/include/pthread_barrierattr_destroy.c b/vendor/pthreads/include/pthread_barrierattr_destroy.c index 5ab662e3f4..b4bf719ac4 100644 --- a/vendor/pthreads/include/pthread_barrierattr_destroy.c +++ b/vendor/pthreads/include/pthread_barrierattr_destroy.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" diff --git a/vendor/pthreads/include/pthread_barrierattr_getpshared.c b/vendor/pthreads/include/pthread_barrierattr_getpshared.c index 44c467e2bf..dd26705ff6 100644 --- a/vendor/pthreads/include/pthread_barrierattr_getpshared.c +++ b/vendor/pthreads/include/pthread_barrierattr_getpshared.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" diff --git a/vendor/pthreads/include/pthread_barrierattr_init.c b/vendor/pthreads/include/pthread_barrierattr_init.c index 342f8b0c69..6aac0eb858 100644 --- a/vendor/pthreads/include/pthread_barrierattr_init.c +++ b/vendor/pthreads/include/pthread_barrierattr_init.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" diff --git a/vendor/pthreads/include/pthread_barrierattr_setpshared.c b/vendor/pthreads/include/pthread_barrierattr_setpshared.c index 08c6fde30b..6aa9314aa3 100644 --- a/vendor/pthreads/include/pthread_barrierattr_setpshared.c +++ b/vendor/pthreads/include/pthread_barrierattr_setpshared.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" diff --git a/vendor/pthreads/include/pthread_cancel.c b/vendor/pthreads/include/pthread_cancel.c index ae60b72936..fddf216cef 100644 --- a/vendor/pthreads/include/pthread_cancel.c +++ b/vendor/pthreads/include/pthread_cancel.c @@ -6,67 +6,69 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" #include "context.h" static void -ptw32_cancel_self (void) +__ptw32_cancel_self (void) { - ptw32_throw (PTW32_EPS_CANCEL); + __ptw32_throw (__PTW32_EPS_CANCEL); /* Never reached */ } static void CALLBACK -ptw32_cancel_callback (ULONG_PTR unused) +__ptw32_cancel_callback (ULONG_PTR unused) { - ptw32_throw (PTW32_EPS_CANCEL); + __ptw32_throw (__PTW32_EPS_CANCEL); /* Never reached */ } /* - * 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; context.ContextFlags = CONTEXT_CONTROL; GetThreadContext (threadH, &context); - PTW32_PROGCTR (context) = (DWORD_PTR) ptw32_cancel_self; + __PTW32_PROGCTR (context) = (DWORD_PTR) __ptw32_cancel_self; SetThreadContext (threadH, &context); return 0; } @@ -98,11 +100,15 @@ pthread_cancel (pthread_t thread) int result; int cancel_self; pthread_t self; - ptw32_thread_t * tp; - ptw32_mcs_local_node_t stateLock; + __ptw32_thread_t * tp; + __ptw32_mcs_local_node_t stateLock; + /* + * Validate the thread id. This method works for pthreads-win32 because + * pthread_kill and pthread_t are designed to accommodate it, but the + * method is not portable. + */ result = pthread_kill (thread, 0); - if (0 != result) { return result; @@ -121,12 +127,12 @@ pthread_cancel (pthread_t thread) */ cancel_self = pthread_equal (thread, self); - tp = (ptw32_thread_t *) thread.p; + tp = (__ptw32_thread_t *) thread.p; /* * Lock for async-cancel safety. */ - ptw32_mcs_lock_acquire (&tp->stateLock, &stateLock); + __ptw32_mcs_lock_acquire (&tp->stateLock, &stateLock); if (tp->cancelType == PTHREAD_CANCEL_ASYNCHRONOUS && tp->cancelState == PTHREAD_CANCEL_ENABLE @@ -137,8 +143,8 @@ pthread_cancel (pthread_t thread) tp->state = PThreadStateCanceling; tp->cancelState = PTHREAD_CANCEL_DISABLE; - ptw32_mcs_lock_release (&stateLock); - ptw32_throw (PTW32_EPS_CANCEL); + __ptw32_mcs_lock_release (&stateLock); + __ptw32_throw (__PTW32_EPS_CANCEL); /* Never reached */ } @@ -155,11 +161,11 @@ 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_mcs_lock_release (&stateLock); + __ptw32_register_cancellation ((PAPCFUNC)__ptw32_cancel_callback, threadH, 0); + __ptw32_mcs_lock_release (&stateLock); ResumeThread (threadH); } } @@ -182,7 +188,7 @@ pthread_cancel (pthread_t thread) result = ESRCH; } - ptw32_mcs_lock_release (&stateLock); + __ptw32_mcs_lock_release (&stateLock); } return (result); diff --git a/vendor/pthreads/include/pthread_cond_destroy.c b/vendor/pthreads/include/pthread_cond_destroy.c index 40d4a0896c..f1928fd530 100644 --- a/vendor/pthreads/include/pthread_cond_destroy.c +++ b/vendor/pthreads/include/pthread_cond_destroy.c @@ -7,34 +7,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" @@ -126,8 +128,8 @@ pthread_cond_destroy (pthread_cond_t * cond) if (*cond != PTHREAD_COND_INITIALIZER) { - ptw32_mcs_local_node_t node; - ptw32_mcs_lock_acquire(&ptw32_cond_list_lock, &node); + __ptw32_mcs_local_node_t node; + __ptw32_mcs_lock_acquire(&__ptw32_cond_list_lock, &node); cv = *cond; @@ -136,9 +138,9 @@ pthread_cond_destroy (pthread_cond_t * cond) * all already signaled waiters to let them retract their * waiter status - SEE NOTE 1 ABOVE!!! */ - if (ptw32_semwait (&(cv->semBlockLock)) != 0) /* Non-cancelable */ + if (__ptw32_semwait (&(cv->semBlockLock)) != 0) /* Non-cancelable */ { - result = errno; + result = __PTW32_GET_ERRNO(); } else { @@ -155,7 +157,7 @@ pthread_cond_destroy (pthread_cond_t * cond) if (result != 0) { - ptw32_mcs_lock_release(&node); + __ptw32_mcs_lock_release(&node); return result; } @@ -166,7 +168,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 +182,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) { @@ -193,18 +195,18 @@ pthread_cond_destroy (pthread_cond_t * cond) /* Unlink the CV from the list */ - if (ptw32_cond_list_head == cv) + if (__ptw32_cond_list_head == cv) { - ptw32_cond_list_head = cv->next; + __ptw32_cond_list_head = cv->next; } else { cv->prev->next = cv->next; } - if (ptw32_cond_list_tail == cv) + if (__ptw32_cond_list_tail == cv) { - ptw32_cond_list_tail = cv->prev; + __ptw32_cond_list_tail = cv->prev; } else { @@ -214,15 +216,15 @@ pthread_cond_destroy (pthread_cond_t * cond) (void) free (cv); } - ptw32_mcs_lock_release(&node); + __ptw32_mcs_lock_release(&node); } else { - ptw32_mcs_local_node_t node; + __ptw32_mcs_local_node_t node; /* - * See notes in ptw32_cond_check_need_init() above also. + * See notes in __ptw32_cond_check_need_init() above also. */ - ptw32_mcs_lock_acquire(&ptw32_cond_test_init_lock, &node); + __ptw32_mcs_lock_acquire(&__ptw32_cond_test_init_lock, &node); /* * Check again. @@ -246,7 +248,7 @@ pthread_cond_destroy (pthread_cond_t * cond) result = EBUSY; } - ptw32_mcs_lock_release(&node); + __ptw32_mcs_lock_release(&node); } return ((result != 0) ? result : ((result1 != 0) ? result1 : result2)); diff --git a/vendor/pthreads/include/pthread_cond_init.c b/vendor/pthreads/include/pthread_cond_init.c index f28fd67b43..127c7b4883 100644 --- a/vendor/pthreads/include/pthread_cond_init.c +++ b/vendor/pthreads/include/pthread_cond_init.c @@ -7,34 +7,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" @@ -101,13 +103,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; } @@ -138,26 +140,26 @@ pthread_cond_init (pthread_cond_t * cond, const pthread_condattr_t * attr) DONE: if (0 == result) { - ptw32_mcs_local_node_t node; + __ptw32_mcs_local_node_t node; - ptw32_mcs_lock_acquire(&ptw32_cond_list_lock, &node); + __ptw32_mcs_lock_acquire(&__ptw32_cond_list_lock, &node); cv->next = NULL; - cv->prev = ptw32_cond_list_tail; + cv->prev = __ptw32_cond_list_tail; - if (ptw32_cond_list_tail != NULL) + if (__ptw32_cond_list_tail != NULL) { - ptw32_cond_list_tail->next = cv; + __ptw32_cond_list_tail->next = cv; } - ptw32_cond_list_tail = cv; + __ptw32_cond_list_tail = cv; - if (ptw32_cond_list_head == NULL) + if (__ptw32_cond_list_head == NULL) { - ptw32_cond_list_head = cv; + __ptw32_cond_list_head = cv; } - ptw32_mcs_lock_release(&node); + __ptw32_mcs_lock_release(&node); } *cond = cv; diff --git a/vendor/pthreads/include/pthread_cond_signal.c b/vendor/pthreads/include/pthread_cond_signal.c index 2b4f6d4d44..226fd13354 100644 --- a/vendor/pthreads/include/pthread_cond_signal.c +++ b/vendor/pthreads/include/pthread_cond_signal.c @@ -7,43 +7,45 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * * ------------------------------------------------------------- * Algorithm: * See the comments at the top of pthread_cond_wait.c. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" static INLINE int -ptw32_cond_unblock (pthread_cond_t * cond, int unblockAll) +__ptw32_cond_unblock (pthread_cond_t * cond, int unblockAll) /* * Notes. * @@ -110,9 +112,9 @@ ptw32_cond_unblock (pthread_cond_t * cond, int unblockAll) else if (cv->nWaitersBlocked > cv->nWaitersGone) { /* Use the non-cancellable version of sem_wait() */ - if (ptw32_semwait (&(cv->semBlockLock)) != 0) + if (__ptw32_semwait (&(cv->semBlockLock)) != 0) { - result = errno; + result = __PTW32_GET_ERRNO(); (void) pthread_mutex_unlock (&(cv->mtxUnblockLock)); return result; } @@ -141,13 +143,13 @@ ptw32_cond_unblock (pthread_cond_t * cond, int unblockAll) { if (sem_post_multiple (&(cv->semBlockQueue), nSignalsToIssue) != 0) { - result = errno; + result = __PTW32_GET_ERRNO(); } } return result; -} /* ptw32_cond_unblock */ +} /* __ptw32_cond_unblock */ int pthread_cond_signal (pthread_cond_t * cond) @@ -187,7 +189,7 @@ pthread_cond_signal (pthread_cond_t * cond) /* * The '0'(FALSE) unblockAll arg means unblock ONE waiter. */ - return (ptw32_cond_unblock (cond, 0)); + return (__ptw32_cond_unblock (cond, 0)); } /* pthread_cond_signal */ @@ -226,6 +228,6 @@ pthread_cond_broadcast (pthread_cond_t * cond) /* * The TRUE unblockAll arg means unblock ALL waiters. */ - return (ptw32_cond_unblock (cond, PTW32_TRUE)); + return (__ptw32_cond_unblock (cond, __PTW32_TRUE)); } /* pthread_cond_broadcast */ diff --git a/vendor/pthreads/include/pthread_cond_wait.c b/vendor/pthreads/include/pthread_cond_wait.c index 359219ae9b..fdb11ce287 100644 --- a/vendor/pthreads/include/pthread_cond_wait.c +++ b/vendor/pthreads/include/pthread_cond_wait.c @@ -7,32 +7,30 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * * ------------------------------------------------------------- * Algorithm: @@ -255,9 +253,12 @@ * return result; * } * ------------------------------------------------------------- - * */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" @@ -270,13 +271,13 @@ typedef struct pthread_mutex_t *mutexPtr; pthread_cond_t cv; int *resultPtr; -} ptw32_cond_wait_cleanup_args_t; +} __ptw32_cond_wait_cleanup_args_t; -static void PTW32_CDECL -ptw32_cond_wait_cleanup (void *args) +static void __PTW32_CDECL +__ptw32_cond_wait_cleanup (void *args) { - ptw32_cond_wait_cleanup_args_t *cleanup_args = - (ptw32_cond_wait_cleanup_args_t *) args; + __ptw32_cond_wait_cleanup_args_t *cleanup_args = + (__ptw32_cond_wait_cleanup_args_t *) args; pthread_cond_t cv = cleanup_args->cv; int *resultPtr = cleanup_args->resultPtr; int nSignalsWasLeft; @@ -301,9 +302,9 @@ ptw32_cond_wait_cleanup (void *args) else if (INT_MAX / 2 == ++(cv->nWaitersGone)) { /* Use the non-cancellable version of sem_wait() */ - if (ptw32_semwait (&(cv->semBlockLock)) != 0) + 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 +315,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 +336,7 @@ ptw32_cond_wait_cleanup (void *args) { if (sem_post (&(cv->semBlockLock)) != 0) { - *resultPtr = errno; + *resultPtr = __PTW32_GET_ERRNO(); return; } } @@ -348,15 +349,15 @@ ptw32_cond_wait_cleanup (void *args) { *resultPtr = result; } -} /* ptw32_cond_wait_cleanup */ +} /* __ptw32_cond_wait_cleanup */ static INLINE int -ptw32_cond_timedwait (pthread_cond_t * cond, +__ptw32_cond_timedwait (pthread_cond_t * cond, pthread_mutex_t * mutex, const struct timespec *abstime) { int result = 0; pthread_cond_t cv; - ptw32_cond_wait_cleanup_args_t cleanup_args; + __ptw32_cond_wait_cleanup_args_t cleanup_args; if (cond == NULL || *cond == NULL) { @@ -366,12 +367,12 @@ ptw32_cond_timedwait (pthread_cond_t * cond, /* * We do a quick check to see if we need to do more work * to initialise a static condition variable. We check - * again inside the guarded section of ptw32_cond_check_need_init() + * again inside the guarded section of __ptw32_cond_check_need_init() * to avoid race conditions. */ if (*cond == PTHREAD_COND_INITIALIZER) { - result = ptw32_cond_check_need_init (cond); + result = __ptw32_cond_check_need_init (cond); } if (result != 0 && result != EBUSY) @@ -384,14 +385,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,10 +402,10 @@ 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); + pthread_cleanup_push (__ptw32_cond_wait_cleanup, (void *) &cleanup_args); /* * Now we can release 'mutex' and... @@ -430,7 +431,7 @@ ptw32_cond_timedwait (pthread_cond_t * cond, */ if (sem_timedwait (&(cv->semBlockQueue), abstime) != 0) { - result = errno; + result = __PTW32_GET_ERRNO(); } } @@ -438,7 +439,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 @@ -447,7 +448,7 @@ ptw32_cond_timedwait (pthread_cond_t * cond, */ return result; -} /* ptw32_cond_timedwait */ +} /* __ptw32_cond_timedwait */ int @@ -503,7 +504,7 @@ pthread_cond_wait (pthread_cond_t * cond, pthread_mutex_t * mutex) /* * The NULL abstime arg means INFINITE waiting. */ - return (ptw32_cond_timedwait (cond, mutex, NULL)); + return (__ptw32_cond_timedwait (cond, mutex, NULL)); } /* pthread_cond_wait */ @@ -562,6 +563,6 @@ pthread_cond_timedwait (pthread_cond_t * cond, return EINVAL; } - return (ptw32_cond_timedwait (cond, mutex, abstime)); + return (__ptw32_cond_timedwait (cond, mutex, abstime)); } /* pthread_cond_timedwait */ diff --git a/vendor/pthreads/include/pthread_condattr_destroy.c b/vendor/pthreads/include/pthread_condattr_destroy.c index 58a14828fd..faaa97b7e6 100644 --- a/vendor/pthreads/include/pthread_condattr_destroy.c +++ b/vendor/pthreads/include/pthread_condattr_destroy.c @@ -7,34 +7,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" diff --git a/vendor/pthreads/include/pthread_condattr_getpshared.c b/vendor/pthreads/include/pthread_condattr_getpshared.c index a0ac6d8829..8c3fea348a 100644 --- a/vendor/pthreads/include/pthread_condattr_getpshared.c +++ b/vendor/pthreads/include/pthread_condattr_getpshared.c @@ -7,34 +7,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" diff --git a/vendor/pthreads/include/pthread_condattr_init.c b/vendor/pthreads/include/pthread_condattr_init.c index 5987878e0c..56b89fed95 100644 --- a/vendor/pthreads/include/pthread_condattr_init.c +++ b/vendor/pthreads/include/pthread_condattr_init.c @@ -7,34 +7,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" diff --git a/vendor/pthreads/include/pthread_condattr_setpshared.c b/vendor/pthreads/include/pthread_condattr_setpshared.c index 954fb38299..a9b5b9d618 100644 --- a/vendor/pthreads/include/pthread_condattr_setpshared.c +++ b/vendor/pthreads/include/pthread_condattr_setpshared.c @@ -7,34 +7,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" diff --git a/vendor/pthreads/include/pthread_delay_np.c b/vendor/pthreads/include/pthread_delay_np.c index e6c96d8070..9aad6409ca 100644 --- a/vendor/pthreads/include/pthread_delay_np.c +++ b/vendor/pthreads/include/pthread_delay_np.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" @@ -50,7 +52,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: * @@ -86,7 +88,7 @@ pthread_delay_np (struct timespec *interval) DWORD millisecs; DWORD status; pthread_t self; - ptw32_thread_t * sp; + __ptw32_thread_t * sp; if (interval == NULL) { @@ -130,32 +132,32 @@ pthread_delay_np (struct timespec *interval) return ENOMEM; } - sp = (ptw32_thread_t *) self.p; + sp = (__ptw32_thread_t *) self.p; 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))) { - ptw32_mcs_local_node_t stateLock; + __ptw32_mcs_local_node_t stateLock; /* * Canceling! */ - ptw32_mcs_lock_acquire (&sp->stateLock, &stateLock); + __ptw32_mcs_lock_acquire (&sp->stateLock, &stateLock); if (sp->state < PThreadStateCanceling) { sp->state = PThreadStateCanceling; sp->cancelState = PTHREAD_CANCEL_DISABLE; - ptw32_mcs_lock_release (&stateLock); + __ptw32_mcs_lock_release (&stateLock); - ptw32_throw (PTW32_EPS_CANCEL); + __ptw32_throw (__PTW32_EPS_CANCEL); } - ptw32_mcs_lock_release (&stateLock); + __ptw32_mcs_lock_release (&stateLock); return ESRCH; } else if (status != WAIT_TIMEOUT) diff --git a/vendor/pthreads/include/pthread_detach.c b/vendor/pthreads/include/pthread_detach.c index 9ff6587f3c..4062487f54 100644 --- a/vendor/pthreads/include/pthread_detach.c +++ b/vendor/pthreads/include/pthread_detach.c @@ -7,34 +7,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" @@ -75,11 +77,11 @@ 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; + BOOL destroyIt = __PTW32_FALSE; + __ptw32_thread_t * tp = (__ptw32_thread_t *) thread.p; + __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) @@ -92,30 +94,34 @@ pthread_detach (pthread_t thread) } else { - ptw32_mcs_local_node_t stateLock; + __ptw32_mcs_local_node_t stateLock; /* - * Joinable ptw32_thread_t structs are not scavenged until + * Joinable __ptw32_thread_t structs are not scavenged until * a join or detach is done. The thread may have exited already, * but all of the state and locks etc are still there. */ result = 0; - ptw32_mcs_lock_acquire (&tp->stateLock, &stateLock); - if (tp->state != PThreadStateLast) + __ptw32_mcs_lock_acquire (&tp->stateLock, &stateLock); + if (tp->state < PThreadStateLast) { tp->detachState = PTHREAD_CREATE_DETACHED; + if (tp->state == PThreadStateExiting) + { + destroyIt = __PTW32_TRUE; + } } else if (tp->detachState != PTHREAD_CREATE_DETACHED) { /* * Thread is joinable and has exited or is exiting. */ - destroyIt = PTW32_TRUE; + destroyIt = __PTW32_TRUE; } - ptw32_mcs_lock_release (&stateLock); + __ptw32_mcs_lock_release (&stateLock); } - ptw32_mcs_lock_release(&node); + __ptw32_mcs_lock_release(&reuseLock); if (result == 0) { @@ -127,7 +133,7 @@ pthread_detach (pthread_t thread) * detached. Need to wait in case it's still exiting. */ (void) WaitForSingleObject(tp->threadH, INFINITE); - ptw32_threadDestroy (thread); + __ptw32_threadDestroy (thread); } } diff --git a/vendor/pthreads/include/pthread_equal.c b/vendor/pthreads/include/pthread_equal.c index 5ddd82acba..b94ec03c23 100644 --- a/vendor/pthreads/include/pthread_equal.c +++ b/vendor/pthreads/include/pthread_equal.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" diff --git a/vendor/pthreads/include/pthread_exit.c b/vendor/pthreads/include/pthread_exit.c index 37b3c09902..58679af6fb 100644 --- a/vendor/pthreads/include/pthread_exit.c +++ b/vendor/pthreads/include/pthread_exit.c @@ -7,34 +7,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" #if !defined(_UWIN) @@ -65,13 +67,13 @@ pthread_exit (void *value_ptr) * ------------------------------------------------------ */ { - ptw32_thread_t * sp; + __ptw32_thread_t * sp; /* * Don't use pthread_self() to avoid creating an implicit POSIX thread handle * unnecessarily. */ - sp = (ptw32_thread_t *) pthread_getspecific (ptw32_selfThreadKey); + sp = (__ptw32_thread_t *) pthread_getspecific (__ptw32_selfThreadKey); #if defined(_UWIN) if (--pthread_count <= 0) @@ -85,10 +87,10 @@ pthread_exit (void *value_ptr) * Win32 thread that has never called a pthreads-win32 routine that * required a POSIX handle. * - * Implicit POSIX handles are cleaned up in ptw32_throw() now. + * Implicit POSIX handles are cleaned up in __ptw32_throw() now. */ -#if ! (defined (__MINGW64__) || defined(__MINGW32__)) || defined (__MSVCRT__) || defined (__DMC__) +#if ! defined (__MINGW32__) || defined (__MSVCRT__) || defined (__DMC__) _endthreadex ((unsigned) (size_t) value_ptr); #else _endthread (); @@ -99,7 +101,7 @@ pthread_exit (void *value_ptr) sp->exitStatus = value_ptr; - ptw32_throw (PTW32_EPS_EXIT); + __ptw32_throw (__PTW32_EPS_EXIT); /* Never reached. */ diff --git a/vendor/pthreads/include/pthread_getconcurrency.c b/vendor/pthreads/include/pthread_getconcurrency.c index cf9e9c85c2..7f6cdb4d4b 100644 --- a/vendor/pthreads/include/pthread_getconcurrency.c +++ b/vendor/pthreads/include/pthread_getconcurrency.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" @@ -41,5 +43,5 @@ int pthread_getconcurrency (void) { - return ptw32_concurrency; + return __ptw32_concurrency; } diff --git a/vendor/pthreads/include/pthread_getname_np.c b/vendor/pthreads/include/pthread_getname_np.c new file mode 100644 index 0000000000..8fc32b1cf5 --- /dev/null +++ b/vendor/pthreads/include/pthread_getname_np.c @@ -0,0 +1,69 @@ +/* + * pthread_getname_np.c + * + * -------------------------------------------------------------------------- + * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * + * The 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: + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include "pthread.h" +#include "implement.h" + +int +pthread_getname_np(pthread_t thr, char *name, int len) +{ + __ptw32_mcs_local_node_t threadLock; + __ptw32_thread_t * tp; + char * s, * d; + int result; + + /* + * Validate the thread id. This method works for pthreads-win32 because + * pthread_kill and pthread_t are designed to accommodate it, but the + * method is not portable. + */ + result = pthread_kill (thr, 0); + if (0 != result) + { + return result; + } + + tp = (__ptw32_thread_t *) thr.p; + + __ptw32_mcs_lock_acquire (&tp->threadLock, &threadLock); + + for (s = tp->name, d = name; *s && d < &name[len - 1]; *d++ = *s++) + {} + + *d = '\0'; + __ptw32_mcs_lock_release (&threadLock); + + return result; +} diff --git a/vendor/pthreads/include/pthread_getschedparam.c b/vendor/pthreads/include/pthread_getschedparam.c index 0afcfb74a9..5b10d6c788 100644 --- a/vendor/pthreads/include/pthread_getschedparam.c +++ b/vendor/pthreads/include/pthread_getschedparam.c @@ -1,39 +1,41 @@ /* * sched_getschedparam.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 - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" #include "sched.h" @@ -44,18 +46,18 @@ pthread_getschedparam (pthread_t thread, int *policy, { int result; - /* Validate the thread id. */ + /* + * Validate the thread id. This method works for pthreads-win32 because + * pthread_kill and pthread_t are designed to accommodate it, but the + * method is not portable. + */ result = pthread_kill (thread, 0); if (0 != result) { 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; } @@ -69,7 +71,7 @@ pthread_getschedparam (pthread_t thread, int *policy, * for the target thread. It must not return the actual thread * priority as altered by any system priority adjustments etc. */ - param->sched_priority = ((ptw32_thread_t *)thread.p)->sched_priority; + param->sched_priority = ((__ptw32_thread_t *)thread.p)->sched_priority; return 0; } diff --git a/vendor/pthreads/include/pthread_getspecific.c b/vendor/pthreads/include/pthread_getspecific.c index 5ee1641dc1..ea6bef4111 100644 --- a/vendor/pthreads/include/pthread_getspecific.c +++ b/vendor/pthreads/include/pthread_getspecific.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" diff --git a/vendor/pthreads/include/pthread_getunique_np.c b/vendor/pthreads/include/pthread_getunique_np.c index 4496c68bf5..51e11fb1e1 100644 --- a/vendor/pthreads/include/pthread_getunique_np.c +++ b/vendor/pthreads/include/pthread_getunique_np.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" @@ -43,5 +45,5 @@ unsigned __int64 pthread_getunique_np (pthread_t thread) { - return ((ptw32_thread_t*)thread.p)->seqNumber; + return ((__ptw32_thread_t*)thread.p)->seqNumber; } diff --git a/vendor/pthreads/include/pthread_getw32threadhandle_np.c b/vendor/pthreads/include/pthread_getw32threadhandle_np.c index 309a8f281f..3ecdaa808b 100644 --- a/vendor/pthreads/include/pthread_getw32threadhandle_np.c +++ b/vendor/pthreads/include/pthread_getw32threadhandle_np.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" @@ -49,7 +51,7 @@ HANDLE pthread_getw32threadhandle_np (pthread_t thread) { - return ((ptw32_thread_t *)thread.p)->threadH; + return ((__ptw32_thread_t *)thread.p)->threadH; } /* @@ -61,5 +63,5 @@ pthread_getw32threadhandle_np (pthread_t thread) DWORD pthread_getw32threadid_np (pthread_t thread) { - return ((ptw32_thread_t *)thread.p)->thread; + return ((__ptw32_thread_t *)thread.p)->thread; } diff --git a/vendor/pthreads/include/pthread_join.c b/vendor/pthreads/include/pthread_join.c index c2b7c1e757..a2dd89590d 100644 --- a/vendor/pthreads/include/pthread_join.c +++ b/vendor/pthreads/include/pthread_join.c @@ -7,34 +7,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" @@ -84,10 +86,10 @@ pthread_join (pthread_t thread, void **value_ptr) { int result; pthread_t self; - ptw32_thread_t * tp = (ptw32_thread_t *) thread.p; - ptw32_mcs_local_node_t node; + __ptw32_thread_t * tp = (__ptw32_thread_t *) thread.p; + __ptw32_mcs_local_node_t node; - ptw32_mcs_lock_acquire(&ptw32_thread_reuse_lock, &node); + __ptw32_mcs_lock_acquire(&__ptw32_thread_reuse_lock, &node); if (NULL == tp || thread.x != tp->ptHandle.x) @@ -103,7 +105,7 @@ pthread_join (pthread_t thread, void **value_ptr) result = 0; } - ptw32_mcs_lock_release(&node); + __ptw32_mcs_lock_release(&node); if (result == 0) { @@ -123,9 +125,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/vendor/pthreads/include/pthread_key_create.c b/vendor/pthreads/include/pthread_key_create.c index 65c6f95081..a23585c38f 100644 --- a/vendor/pthreads/include/pthread_key_create.c +++ b/vendor/pthreads/include/pthread_key_create.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" @@ -44,7 +46,7 @@ #endif int -pthread_key_create (pthread_key_t * key, void (PTW32_CDECL *destructor) (void *)) +pthread_key_create (pthread_key_t * key, void (__PTW32_CDECL *destructor) (void *)) /* * ------------------------------------------------------ * DOCPUBLIC diff --git a/vendor/pthreads/include/pthread_key_delete.c b/vendor/pthreads/include/pthread_key_delete.c index 09d70c63f5..0c44d05898 100644 --- a/vendor/pthreads/include/pthread_key_delete.c +++ b/vendor/pthreads/include/pthread_key_delete.c @@ -6,114 +6,116 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" int pthread_key_delete (pthread_key_t key) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function deletes a thread-specific data key. This - * does not change the value of the thread specific data key - * for any thread and does not run the key's destructor - * in any thread so it should be used with caution. - * - * PARAMETERS - * key - * pointer to an instance of pthread_key_t - * - * - * DESCRIPTION - * This function deletes a thread-specific data key. This - * does not change the value of the thread specific data key - * for any thread and does not run the key's destructor - * in any thread so it should be used with caution. - * - * RESULTS - * 0 successfully deleted the key, - * EINVAL key is invalid, - * - * ------------------------------------------------------ - */ +/* + * ------------------------------------------------------ + * DOCPUBLIC + * This function deletes a thread-specific data key. This + * does not change the value of the thread specific data key + * for any thread and does not run the key's destructor + * in any thread so it should be used with caution. + * + * PARAMETERS + * key + * pointer to an instance of pthread_key_t + * + * + * DESCRIPTION + * This function deletes a thread-specific data key. This + * does not change the value of the thread specific data key + * for any thread and does not run the key's destructor + * in any thread so it should be used with caution. + * + * RESULTS + * 0 successfully deleted the key, + * EINVAL key is invalid, + * + * ------------------------------------------------------ + */ { - ptw32_mcs_local_node_t keyLock; + __ptw32_mcs_local_node_t keyLock; int result = 0; if (key != NULL) { if (key->threads != NULL && key->destructor != NULL) - { - ThreadKeyAssoc *assoc; - ptw32_mcs_lock_acquire (&(key->keyLock), &keyLock); - /* - * Run through all Thread<-->Key associations - * for this key. - * - * While we hold at least one of the locks guarding - * the assoc, we know that the assoc pointed to by - * key->threads is valid. - */ - while ((assoc = (ThreadKeyAssoc *) key->threads) != NULL) - { - ptw32_mcs_local_node_t threadLock; - ptw32_thread_t * thread = assoc->thread; + { + ThreadKeyAssoc *assoc; + __ptw32_mcs_lock_acquire (&(key->keyLock), &keyLock); + /* + * Run through all Thread<-->Key associations + * for this key. + * + * While we hold at least one of the locks guarding + * the assoc, we know that the assoc pointed to by + * key->threads is valid. + */ + while ((assoc = (ThreadKeyAssoc *) key->threads) != NULL) + { + __ptw32_mcs_local_node_t threadLock; + __ptw32_thread_t * thread = assoc->thread; - if (assoc == NULL) - { - /* Finished */ - break; - } + if (assoc == NULL) + { + /* Finished */ + break; + } - ptw32_mcs_lock_acquire (&(thread->threadLock), &threadLock); - /* - * Since we are starting at the head of the key's threads - * chain, this will also point key->threads at the next assoc. - * While we hold key->keyLock, no other thread can insert - * a new assoc via pthread_setspecific. - */ - ptw32_tkAssocDestroy (assoc); - ptw32_mcs_lock_release (&threadLock); - ptw32_mcs_lock_release (&keyLock); - } - } + __ptw32_mcs_lock_acquire (&(thread->threadLock), &threadLock); + /* + * Since we are starting at the head of the key's threads + * chain, this will also point key->threads at the next assoc. + * While we hold key->keyLock, no other thread can insert + * a new assoc for this key via pthread_setspecific. + */ + __ptw32_tkAssocDestroy (assoc); + __ptw32_mcs_lock_release (&threadLock); + } + __ptw32_mcs_lock_release (&keyLock); + } TlsFree (key->key); if (key->destructor != NULL) - { - /* A thread could be holding the keyLock */ - ptw32_mcs_lock_acquire (&(key->keyLock), &keyLock); - ptw32_mcs_lock_release (&keyLock); - } + { + /* A thread could be holding the keyLock */ + __ptw32_mcs_lock_acquire (&(key->keyLock), &keyLock); + __ptw32_mcs_lock_release (&keyLock); + } #if defined( _DEBUG ) memset ((char *) key, 0, sizeof (*key)); diff --git a/vendor/pthreads/include/pthread_kill.c b/vendor/pthreads/include/pthread_kill.c index 5473b43cd4..3efc421a54 100644 --- a/vendor/pthreads/include/pthread_kill.c +++ b/vendor/pthreads/include/pthread_kill.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" @@ -76,29 +78,32 @@ pthread_kill (pthread_t thread, int sig) */ { 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; - } - - ptw32_mcs_lock_release(&node); - - if (0 == result && 0 != sig) + if (0 != sig) { /* * Currently does not support any signals. */ result = EINVAL; } + else + { + __ptw32_mcs_local_node_t node; + __ptw32_thread_t * tp; + + __ptw32_mcs_lock_acquire(&__ptw32_thread_reuse_lock, &node); + + tp = (__ptw32_thread_t *) thread.p; + + if (NULL == tp + || thread.x != tp->ptHandle.x + || tp->state < PThreadStateRunning) + { + result = ESRCH; + } + + __ptw32_mcs_lock_release(&node); + } return result; diff --git a/vendor/pthreads/include/pthread_mutex_consistent.c b/vendor/pthreads/include/pthread_mutex_consistent.c index b7805e7b19..1253b0e20e 100644 --- a/vendor/pthreads/include/pthread_mutex_consistent.c +++ b/vendor/pthreads/include/pthread_mutex_consistent.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + /* * From the Sun Multi-threaded Programming Guide * @@ -41,29 +43,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) @@ -74,21 +76,21 @@ INLINE int -ptw32_robust_mutex_inherit(pthread_mutex_t * mutex) +__ptw32_robust_mutex_inherit(pthread_mutex_t * mutex) { int result; pthread_mutex_t mx = *mutex; - ptw32_robust_node_t* robust = mx->robustNode; + __ptw32_robust_node_t* robust = mx->robustNode; - switch ((LONG)PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG( - (PTW32_INTERLOCKED_LONGPTR)&robust->stateInconsistent, - (PTW32_INTERLOCKED_LONG)PTW32_ROBUST_INCONSISTENT, - (PTW32_INTERLOCKED_LONG)-1 /* The terminating thread sets this */)) + switch ((LONG)__PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG( + (__PTW32_INTERLOCKED_LONGPTR)&robust->stateInconsistent, + (__PTW32_INTERLOCKED_LONG)__PTW32_ROBUST_INCONSISTENT, + (__PTW32_INTERLOCKED_LONG)-1 /* The terminating thread sets this */)) { case -1L: result = EOWNERDEAD; break; - case (LONG)PTW32_ROBUST_NOTRECOVERABLE: + case (LONG)__PTW32_ROBUST_NOTRECOVERABLE: result = ENOTRECOVERABLE; break; default: @@ -100,9 +102,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 @@ -113,12 +115,12 @@ ptw32_robust_mutex_inherit(pthread_mutex_t * mutex) INLINE void -ptw32_robust_mutex_add(pthread_mutex_t* mutex, pthread_t self) +__ptw32_robust_mutex_add(pthread_mutex_t* mutex, pthread_t self) { - ptw32_robust_node_t** list; + __ptw32_robust_node_t** list; pthread_mutex_t mx = *mutex; - ptw32_thread_t* tp = (ptw32_thread_t*)self.p; - ptw32_robust_node_t* robust = mx->robustNode; + __ptw32_thread_t* tp = (__ptw32_thread_t*)self.p; + __ptw32_robust_node_t* robust = mx->robustNode; list = &tp->robustMxList; mx->ownerThread = self; @@ -139,13 +141,13 @@ ptw32_robust_mutex_add(pthread_mutex_t* mutex, pthread_t self) INLINE void -ptw32_robust_mutex_remove(pthread_mutex_t* mutex, ptw32_thread_t* otp) +__ptw32_robust_mutex_remove(pthread_mutex_t* mutex, __ptw32_thread_t* otp) { - ptw32_robust_node_t** list; + __ptw32_robust_node_t** list; pthread_mutex_t mx = *mutex; - ptw32_robust_node_t* robust = mx->robustNode; + __ptw32_robust_node_t* robust = mx->robustNode; - list = &(((ptw32_thread_t*)mx->ownerThread.p)->robustMxList); + list = &(((__ptw32_thread_t*)mx->ownerThread.p)->robustMxList); mx->ownerThread.p = otp; if (robust->next != NULL) { @@ -177,10 +179,10 @@ pthread_mutex_consistent (pthread_mutex_t* mutex) } if (mx->kind >= 0 - || (PTW32_INTERLOCKED_LONG)PTW32_ROBUST_INCONSISTENT != PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG( - (PTW32_INTERLOCKED_LONGPTR)&mx->robustNode->stateInconsistent, - (PTW32_INTERLOCKED_LONG)PTW32_ROBUST_CONSISTENT, - (PTW32_INTERLOCKED_LONG)PTW32_ROBUST_INCONSISTENT)) + || (__PTW32_INTERLOCKED_LONG)__PTW32_ROBUST_INCONSISTENT != __PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG( + (__PTW32_INTERLOCKED_LONGPTR)&mx->robustNode->stateInconsistent, + (__PTW32_INTERLOCKED_LONG)__PTW32_ROBUST_CONSISTENT, + (__PTW32_INTERLOCKED_LONG)__PTW32_ROBUST_INCONSISTENT)) { result = EINVAL; } diff --git a/vendor/pthreads/include/pthread_mutex_destroy.c b/vendor/pthreads/include/pthread_mutex_destroy.c index 7b8c9cd65b..688201f186 100644 --- a/vendor/pthreads/include/pthread_mutex_destroy.c +++ b/vendor/pthreads/include/pthread_mutex_destroy.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" @@ -112,13 +114,13 @@ pthread_mutex_destroy (pthread_mutex_t * mutex) } else { - ptw32_mcs_local_node_t node; + __ptw32_mcs_local_node_t node; /* - * See notes in ptw32_mutex_check_need_init() above also. + * See notes in __ptw32_mutex_check_need_init() above also. */ - ptw32_mcs_lock_acquire(&ptw32_mutex_test_init_lock, &node); + __ptw32_mcs_lock_acquire(&__ptw32_mutex_test_init_lock, &node); /* * Check again. @@ -141,7 +143,7 @@ pthread_mutex_destroy (pthread_mutex_t * mutex) */ result = EBUSY; } - ptw32_mcs_lock_release(&node); + __ptw32_mcs_lock_release(&node); } return (result); diff --git a/vendor/pthreads/include/pthread_mutex_init.c b/vendor/pthreads/include/pthread_mutex_init.c index daf805e5bc..bc61dfcdc4 100644 --- a/vendor/pthreads/include/pthread_mutex_init.c +++ b/vendor/pthreads/include/pthread_mutex_init.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" @@ -102,26 +104,44 @@ pthread_mutex_init (pthread_mutex_t * mutex, const pthread_mutexattr_t * attr) */ mx->kind = -mx->kind - 1; - mx->robustNode = (ptw32_robust_node_t*) malloc(sizeof(ptw32_robust_node_t)); - mx->robustNode->stateInconsistent = PTW32_ROBUST_CONSISTENT; - mx->robustNode->mx = mx; - mx->robustNode->next = NULL; - mx->robustNode->prev = NULL; + mx->robustNode = (__ptw32_robust_node_t*) malloc(sizeof(__ptw32_robust_node_t)); + if (NULL == mx->robustNode) + { + result = ENOMEM; + } + else + { + mx->robustNode->stateInconsistent = __PTW32_ROBUST_CONSISTENT; + mx->robustNode->mx = mx; + mx->robustNode->next = NULL; + mx->robustNode->prev = NULL; + } } } - mx->ownerThread.p = NULL; + if (0 == result) + { + mx->ownerThread.p = NULL; - mx->event = CreateEvent (NULL, PTW32_FALSE, /* manual reset = No */ - PTW32_FALSE, /* initial state = not signaled */ - NULL); /* event name */ + mx->event = CreateEvent (NULL, __PTW32_FALSE, /* manual reset = No */ + __PTW32_FALSE, /* initial state = not signalled */ + NULL); /* event name */ - if (0 == mx->event) - { - result = ENOSPC; - free (mx); - mx = NULL; - } + if (0 == mx->event) + { + result = ENOSPC; + } + } + } + + if (0 != result) + { + if (NULL != mx->robustNode) + { + free (mx->robustNode); + } + free (mx); + mx = NULL; } *mutex = mx; diff --git a/vendor/pthreads/include/pthread_mutex_lock.c b/vendor/pthreads/include/pthread_mutex_lock.c index eee9abe8c7..fcfedaa82d 100644 --- a/vendor/pthreads/include/pthread_mutex_lock.c +++ b/vendor/pthreads/include/pthread_mutex_lock.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #if !defined(_UWIN) /*# include */ #endif @@ -43,14 +45,14 @@ int pthread_mutex_lock (pthread_mutex_t * mutex) { - int kind; - pthread_mutex_t mx; - int result = 0; - /* * Let the system deal with invalid pointers. */ - if (*mutex == NULL) + pthread_mutex_t mx = *mutex; + int kind; + int result = 0; + + if (mx == NULL) { return EINVAL; } @@ -58,18 +60,18 @@ pthread_mutex_lock (pthread_mutex_t * mutex) /* * We do a quick check to see if we need to do more work * to initialise a static mutex. We check - * again inside the guarded section of ptw32_mutex_check_need_init() + * again inside the guarded section of __ptw32_mutex_check_need_init() * to avoid race conditions. */ - if (*mutex >= PTHREAD_ERRORCHECK_MUTEX_INITIALIZER) + if (mx >= PTHREAD_ERRORCHECK_MUTEX_INITIALIZER) { - if ((result = ptw32_mutex_check_need_init (mutex)) != 0) + if ((result = __ptw32_mutex_check_need_init (mutex)) != 0) { return (result); } + mx = *mutex; } - mx = *mutex; kind = mx->kind; if (kind >= 0) @@ -77,13 +79,13 @@ pthread_mutex_lock (pthread_mutex_t * mutex) /* Non-robust */ if (PTHREAD_MUTEX_NORMAL == kind) { - if ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG( - (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, - (PTW32_INTERLOCKED_LONG) 1) != 0) + if ((__PTW32_INTERLOCKED_LONG) __PTW32_INTERLOCKED_EXCHANGE_LONG( + (__PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, + (__PTW32_INTERLOCKED_LONG) 1) != 0) { - while ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG( - (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, - (PTW32_INTERLOCKED_LONG) -1) != 0) + while ((__PTW32_INTERLOCKED_LONG) __PTW32_INTERLOCKED_EXCHANGE_LONG( + (__PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, + (__PTW32_INTERLOCKED_LONG) -1) != 0) { if (WAIT_OBJECT_0 != WaitForSingleObject (mx->event, INFINITE)) { @@ -97,10 +99,10 @@ pthread_mutex_lock (pthread_mutex_t * mutex) { pthread_t self = pthread_self(); - if ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG( - (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, - (PTW32_INTERLOCKED_LONG) 1, - (PTW32_INTERLOCKED_LONG) 0) == 0) + if ((__PTW32_INTERLOCKED_LONG) __PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG( + (__PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, + (__PTW32_INTERLOCKED_LONG) 1, + (__PTW32_INTERLOCKED_LONG) 0) == 0) { mx->recursive_count = 1; mx->ownerThread = self; @@ -120,9 +122,9 @@ pthread_mutex_lock (pthread_mutex_t * mutex) } else { - while ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG( - (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, - (PTW32_INTERLOCKED_LONG) -1) != 0) + while ((__PTW32_INTERLOCKED_LONG) __PTW32_INTERLOCKED_EXCHANGE_LONG( + (__PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, + (__PTW32_INTERLOCKED_LONG) -1) != 0) { if (WAIT_OBJECT_0 != WaitForSingleObject (mx->event, INFINITE)) { @@ -147,11 +149,11 @@ pthread_mutex_lock (pthread_mutex_t * mutex) * All types record the current owner thread. * The mutex is added to a per thread list when ownership is acquired. */ - ptw32_robust_state_t* statePtr = &mx->robustNode->stateInconsistent; + __ptw32_robust_state_t* statePtr = &mx->robustNode->stateInconsistent; - if ((PTW32_INTERLOCKED_LONG)PTW32_ROBUST_NOTRECOVERABLE == PTW32_INTERLOCKED_EXCHANGE_ADD_LONG( - (PTW32_INTERLOCKED_LONGPTR)statePtr, - (PTW32_INTERLOCKED_LONG)0)) + if ((__PTW32_INTERLOCKED_LONG)__PTW32_ROBUST_NOTRECOVERABLE == __PTW32_INTERLOCKED_EXCHANGE_ADD_LONG( + (__PTW32_INTERLOCKED_LONGPTR)statePtr, + (__PTW32_INTERLOCKED_LONG)0)) { result = ENOTRECOVERABLE; } @@ -163,24 +165,24 @@ pthread_mutex_lock (pthread_mutex_t * mutex) if (PTHREAD_MUTEX_NORMAL == kind) { - if ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG( - (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, - (PTW32_INTERLOCKED_LONG) 1) != 0) + if ((__PTW32_INTERLOCKED_LONG) __PTW32_INTERLOCKED_EXCHANGE_LONG( + (__PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, + (__PTW32_INTERLOCKED_LONG) 1) != 0) { - while (0 == (result = ptw32_robust_mutex_inherit(mutex)) - && (PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG( - (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, - (PTW32_INTERLOCKED_LONG) -1) != 0) + while (0 == (result = __ptw32_robust_mutex_inherit(mutex)) + && (__PTW32_INTERLOCKED_LONG) __PTW32_INTERLOCKED_EXCHANGE_LONG( + (__PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, + (__PTW32_INTERLOCKED_LONG) -1) != 0) { if (WAIT_OBJECT_0 != WaitForSingleObject (mx->event, INFINITE)) { result = EINVAL; break; } - if ((PTW32_INTERLOCKED_LONG)PTW32_ROBUST_NOTRECOVERABLE == - PTW32_INTERLOCKED_EXCHANGE_ADD_LONG( - (PTW32_INTERLOCKED_LONGPTR)statePtr, - (PTW32_INTERLOCKED_LONG)0)) + if ((__PTW32_INTERLOCKED_LONG)__PTW32_ROBUST_NOTRECOVERABLE == + __PTW32_INTERLOCKED_EXCHANGE_ADD_LONG( + (__PTW32_INTERLOCKED_LONGPTR)statePtr, + (__PTW32_INTERLOCKED_LONG)0)) { /* Unblock the next thread */ SetEvent(mx->event); @@ -195,22 +197,22 @@ pthread_mutex_lock (pthread_mutex_t * mutex) * Add mutex to the per-thread robust mutex currently-held list. * If the thread terminates, all mutexes in this list will be unlocked. */ - ptw32_robust_mutex_add(mutex, self); + __ptw32_robust_mutex_add(mutex, self); } } else { - if ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG( - (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, - (PTW32_INTERLOCKED_LONG) 1, - (PTW32_INTERLOCKED_LONG) 0) == 0) + if ((__PTW32_INTERLOCKED_LONG) __PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG( + (__PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, + (__PTW32_INTERLOCKED_LONG) 1, + (__PTW32_INTERLOCKED_LONG) 0) == 0) { mx->recursive_count = 1; /* * Add mutex to the per-thread robust mutex currently-held list. * If the thread terminates, all mutexes in this list will be unlocked. */ - ptw32_robust_mutex_add(mutex, self); + __ptw32_robust_mutex_add(mutex, self); } else { @@ -227,20 +229,20 @@ pthread_mutex_lock (pthread_mutex_t * mutex) } else { - while (0 == (result = ptw32_robust_mutex_inherit(mutex)) - && (PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG( - (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, - (PTW32_INTERLOCKED_LONG) -1) != 0) + while (0 == (result = __ptw32_robust_mutex_inherit(mutex)) + && (__PTW32_INTERLOCKED_LONG) __PTW32_INTERLOCKED_EXCHANGE_LONG( + (__PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, + (__PTW32_INTERLOCKED_LONG) -1) != 0) { if (WAIT_OBJECT_0 != WaitForSingleObject (mx->event, INFINITE)) { result = EINVAL; break; } - if ((PTW32_INTERLOCKED_LONG)PTW32_ROBUST_NOTRECOVERABLE == - PTW32_INTERLOCKED_EXCHANGE_ADD_LONG( - (PTW32_INTERLOCKED_LONGPTR)statePtr, - (PTW32_INTERLOCKED_LONG)0)) + if ((__PTW32_INTERLOCKED_LONG)__PTW32_ROBUST_NOTRECOVERABLE == + __PTW32_INTERLOCKED_EXCHANGE_ADD_LONG( + (__PTW32_INTERLOCKED_LONGPTR)statePtr, + (__PTW32_INTERLOCKED_LONG)0)) { /* Unblock the next thread */ SetEvent(mx->event); @@ -256,7 +258,7 @@ pthread_mutex_lock (pthread_mutex_t * mutex) * Add mutex to the per-thread robust mutex currently-held list. * If the thread terminates, all mutexes in this list will be unlocked. */ - ptw32_robust_mutex_add(mutex, self); + __ptw32_robust_mutex_add(mutex, self); } } } diff --git a/vendor/pthreads/include/pthread_mutex_timedlock.c b/vendor/pthreads/include/pthread_mutex_timedlock.c index 1745316795..10d5bd1506 100644 --- a/vendor/pthreads/include/pthread_mutex_timedlock.c +++ b/vendor/pthreads/include/pthread_mutex_timedlock.c @@ -6,40 +6,42 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" static INLINE int -ptw32_timed_eventwait (HANDLE event, const struct timespec *abstime) +__ptw32_timed_eventwait (HANDLE event, const struct timespec *abstime) /* * ------------------------------------------------------ * DESCRIPTION @@ -52,7 +54,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, @@ -81,72 +83,75 @@ ptw32_timed_eventwait (HANDLE event, const struct timespec *abstime) /* * Calculate timeout as milliseconds from current system time. */ - milliseconds = ptw32_relmillisecs (abstime); + milliseconds = __ptw32_relmillisecs (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; -} /* ptw32_timed_semwait */ +} /* __ptw32_timed_semwait */ int pthread_mutex_timedlock (pthread_mutex_t * mutex, const struct timespec *abstime) { - pthread_mutex_t mx; - int kind; - int result = 0; - /* * Let the system deal with invalid pointers. */ + pthread_mutex_t mx = *mutex; + int kind; + int result = 0; + + if (mx == NULL) + { + return EINVAL; + } /* * We do a quick check to see if we need to do more work * to initialise a static mutex. We check - * again inside the guarded section of ptw32_mutex_check_need_init() + * again inside the guarded section of __ptw32_mutex_check_need_init() * to avoid race conditions. */ - if (*mutex >= PTHREAD_ERRORCHECK_MUTEX_INITIALIZER) + if (mx >= PTHREAD_ERRORCHECK_MUTEX_INITIALIZER) { - if ((result = ptw32_mutex_check_need_init (mutex)) != 0) + if ((result = __ptw32_mutex_check_need_init (mutex)) != 0) { return (result); } + mx = *mutex; } - mx = *mutex; kind = mx->kind; if (kind >= 0) { if (mx->kind == PTHREAD_MUTEX_NORMAL) { - if ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG( - (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, - (PTW32_INTERLOCKED_LONG) 1) != 0) + if ((__PTW32_INTERLOCKED_LONG) __PTW32_INTERLOCKED_EXCHANGE_LONG( + (__PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, + (__PTW32_INTERLOCKED_LONG) 1) != 0) { - while ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG( - (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, - (PTW32_INTERLOCKED_LONG) -1) != 0) + while ((__PTW32_INTERLOCKED_LONG) __PTW32_INTERLOCKED_EXCHANGE_LONG( + (__PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, + (__PTW32_INTERLOCKED_LONG) -1) != 0) { - if (0 != (result = ptw32_timed_eventwait (mx->event, abstime))) + if (0 != (result = __ptw32_timed_eventwait (mx->event, abstime))) { return result; } @@ -157,10 +162,10 @@ pthread_mutex_timedlock (pthread_mutex_t * mutex, { pthread_t self = pthread_self(); - if ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG( - (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, - (PTW32_INTERLOCKED_LONG) 1, - (PTW32_INTERLOCKED_LONG) 0) == 0) + if ((__PTW32_INTERLOCKED_LONG) __PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG( + (__PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, + (__PTW32_INTERLOCKED_LONG) 1, + (__PTW32_INTERLOCKED_LONG) 0) == 0) { mx->recursive_count = 1; mx->ownerThread = self; @@ -180,11 +185,11 @@ pthread_mutex_timedlock (pthread_mutex_t * mutex, } else { - while ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG( - (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, - (PTW32_INTERLOCKED_LONG) -1) != 0) + while ((__PTW32_INTERLOCKED_LONG) __PTW32_INTERLOCKED_EXCHANGE_LONG( + (__PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, + (__PTW32_INTERLOCKED_LONG) -1) != 0) { - if (0 != (result = ptw32_timed_eventwait (mx->event, abstime))) + if (0 != (result = __ptw32_timed_eventwait (mx->event, abstime))) { return result; } @@ -203,11 +208,11 @@ pthread_mutex_timedlock (pthread_mutex_t * mutex, * All types record the current owner thread. * The mutex is added to a per thread list when ownership is acquired. */ - ptw32_robust_state_t* statePtr = &mx->robustNode->stateInconsistent; + __ptw32_robust_state_t* statePtr = &mx->robustNode->stateInconsistent; - if ((PTW32_INTERLOCKED_LONG)PTW32_ROBUST_NOTRECOVERABLE == PTW32_INTERLOCKED_EXCHANGE_ADD_LONG( - (PTW32_INTERLOCKED_LONGPTR)statePtr, - (PTW32_INTERLOCKED_LONG)0)) + if ((__PTW32_INTERLOCKED_LONG)__PTW32_ROBUST_NOTRECOVERABLE == __PTW32_INTERLOCKED_EXCHANGE_ADD_LONG( + (__PTW32_INTERLOCKED_LONGPTR)statePtr, + (__PTW32_INTERLOCKED_LONG)0)) { result = ENOTRECOVERABLE; } @@ -219,23 +224,23 @@ pthread_mutex_timedlock (pthread_mutex_t * mutex, if (PTHREAD_MUTEX_NORMAL == kind) { - if ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG( - (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, - (PTW32_INTERLOCKED_LONG) 1) != 0) + if ((__PTW32_INTERLOCKED_LONG) __PTW32_INTERLOCKED_EXCHANGE_LONG( + (__PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, + (__PTW32_INTERLOCKED_LONG) 1) != 0) { - while (0 == (result = ptw32_robust_mutex_inherit(mutex)) - && (PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG( - (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, - (PTW32_INTERLOCKED_LONG) -1) != 0) + while (0 == (result = __ptw32_robust_mutex_inherit(mutex)) + && (__PTW32_INTERLOCKED_LONG) __PTW32_INTERLOCKED_EXCHANGE_LONG( + (__PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, + (__PTW32_INTERLOCKED_LONG) -1) != 0) { - if (0 != (result = ptw32_timed_eventwait (mx->event, abstime))) + if (0 != (result = __ptw32_timed_eventwait (mx->event, abstime))) { return result; } - if ((PTW32_INTERLOCKED_LONG)PTW32_ROBUST_NOTRECOVERABLE == - PTW32_INTERLOCKED_EXCHANGE_ADD_LONG( - (PTW32_INTERLOCKED_LONGPTR)statePtr, - (PTW32_INTERLOCKED_LONG)0)) + if ((__PTW32_INTERLOCKED_LONG)__PTW32_ROBUST_NOTRECOVERABLE == + __PTW32_INTERLOCKED_EXCHANGE_ADD_LONG( + (__PTW32_INTERLOCKED_LONGPTR)statePtr, + (__PTW32_INTERLOCKED_LONG)0)) { /* Unblock the next thread */ SetEvent(mx->event); @@ -250,7 +255,7 @@ pthread_mutex_timedlock (pthread_mutex_t * mutex, * Add mutex to the per-thread robust mutex currently-held list. * If the thread terminates, all mutexes in this list will be unlocked. */ - ptw32_robust_mutex_add(mutex, self); + __ptw32_robust_mutex_add(mutex, self); } } } @@ -258,17 +263,17 @@ pthread_mutex_timedlock (pthread_mutex_t * mutex, { pthread_t self = pthread_self(); - if (0 == (PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG( - (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, - (PTW32_INTERLOCKED_LONG) 1, - (PTW32_INTERLOCKED_LONG) 0)) + if (0 == (__PTW32_INTERLOCKED_LONG) __PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG( + (__PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, + (__PTW32_INTERLOCKED_LONG) 1, + (__PTW32_INTERLOCKED_LONG) 0)) { mx->recursive_count = 1; /* * Add mutex to the per-thread robust mutex currently-held list. * If the thread terminates, all mutexes in this list will be unlocked. */ - ptw32_robust_mutex_add(mutex, self); + __ptw32_robust_mutex_add(mutex, self); } else { @@ -285,21 +290,21 @@ pthread_mutex_timedlock (pthread_mutex_t * mutex, } else { - while (0 == (result = ptw32_robust_mutex_inherit(mutex)) - && (PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG( - (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, - (PTW32_INTERLOCKED_LONG) -1) != 0) + while (0 == (result = __ptw32_robust_mutex_inherit(mutex)) + && (__PTW32_INTERLOCKED_LONG) __PTW32_INTERLOCKED_EXCHANGE_LONG( + (__PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, + (__PTW32_INTERLOCKED_LONG) -1) != 0) { - if (0 != (result = ptw32_timed_eventwait (mx->event, abstime))) + if (0 != (result = __ptw32_timed_eventwait (mx->event, abstime))) { return result; } } - if ((PTW32_INTERLOCKED_LONG)PTW32_ROBUST_NOTRECOVERABLE == - PTW32_INTERLOCKED_EXCHANGE_ADD_LONG( - (PTW32_INTERLOCKED_LONGPTR)statePtr, - (PTW32_INTERLOCKED_LONG)0)) + if ((__PTW32_INTERLOCKED_LONG)__PTW32_ROBUST_NOTRECOVERABLE == + __PTW32_INTERLOCKED_EXCHANGE_ADD_LONG( + (__PTW32_INTERLOCKED_LONGPTR)statePtr, + (__PTW32_INTERLOCKED_LONG)0)) { /* Unblock the next thread */ SetEvent(mx->event); @@ -312,7 +317,7 @@ pthread_mutex_timedlock (pthread_mutex_t * mutex, * Add mutex to the per-thread robust mutex currently-held list. * If the thread terminates, all mutexes in this list will be unlocked. */ - ptw32_robust_mutex_add(mutex, self); + __ptw32_robust_mutex_add(mutex, self); } } } diff --git a/vendor/pthreads/include/pthread_mutex_trylock.c b/vendor/pthreads/include/pthread_mutex_trylock.c index d6b68724db..405542a250 100644 --- a/vendor/pthreads/include/pthread_mutex_trylock.c +++ b/vendor/pthreads/include/pthread_mutex_trylock.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" @@ -41,38 +43,42 @@ int pthread_mutex_trylock (pthread_mutex_t * mutex) { - pthread_mutex_t mx; - int kind; - int result = 0; - /* * Let the system deal with invalid pointers. */ + pthread_mutex_t mx = *mutex; + int kind; + int result = 0; + + if (mx == NULL) + { + return EINVAL; + } /* * We do a quick check to see if we need to do more work * to initialise a static mutex. We check - * again inside the guarded section of ptw32_mutex_check_need_init() + * again inside the guarded section of __ptw32_mutex_check_need_init() * to avoid race conditions. */ - if (*mutex >= PTHREAD_ERRORCHECK_MUTEX_INITIALIZER) + if (mx >= PTHREAD_ERRORCHECK_MUTEX_INITIALIZER) { - if ((result = ptw32_mutex_check_need_init (mutex)) != 0) + if ((result = __ptw32_mutex_check_need_init (mutex)) != 0) { return (result); } + mx = *mutex; } - mx = *mutex; kind = mx->kind; if (kind >= 0) { /* Non-robust */ - if (0 == (PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG ( - (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, - (PTW32_INTERLOCKED_LONG) 1, - (PTW32_INTERLOCKED_LONG) 0)) + if (0 == (__PTW32_INTERLOCKED_LONG) __PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG ( + (__PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, + (__PTW32_INTERLOCKED_LONG) 1, + (__PTW32_INTERLOCKED_LONG) 0)) { if (kind != PTHREAD_MUTEX_NORMAL) { @@ -101,12 +107,12 @@ pthread_mutex_trylock (pthread_mutex_t * mutex) * The mutex is added to a per thread list when ownership is acquired. */ pthread_t self; - ptw32_robust_state_t* statePtr = &mx->robustNode->stateInconsistent; + __ptw32_robust_state_t* statePtr = &mx->robustNode->stateInconsistent; - if ((PTW32_INTERLOCKED_LONG)PTW32_ROBUST_NOTRECOVERABLE == - PTW32_INTERLOCKED_EXCHANGE_ADD_LONG( - (PTW32_INTERLOCKED_LONGPTR)statePtr, - (PTW32_INTERLOCKED_LONG)0)) + if ((__PTW32_INTERLOCKED_LONG)__PTW32_ROBUST_NOTRECOVERABLE == + __PTW32_INTERLOCKED_EXCHANGE_ADD_LONG( + (__PTW32_INTERLOCKED_LONGPTR)statePtr, + (__PTW32_INTERLOCKED_LONG)0)) { return ENOTRECOVERABLE; } @@ -114,16 +120,16 @@ pthread_mutex_trylock (pthread_mutex_t * mutex) self = pthread_self(); kind = -kind - 1; /* Convert to non-robust range */ - if (0 == (PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG ( - (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, - (PTW32_INTERLOCKED_LONG) 1, - (PTW32_INTERLOCKED_LONG) 0)) + if (0 == (__PTW32_INTERLOCKED_LONG) __PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG ( + (__PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, + (__PTW32_INTERLOCKED_LONG) 1, + (__PTW32_INTERLOCKED_LONG) 0)) { if (kind != PTHREAD_MUTEX_NORMAL) { mx->recursive_count = 1; } - ptw32_robust_mutex_add(mutex, self); + __ptw32_robust_mutex_add(mutex, self); } else { @@ -134,10 +140,10 @@ pthread_mutex_trylock (pthread_mutex_t * mutex) } else { - if (EOWNERDEAD == (result = ptw32_robust_mutex_inherit(mutex))) + if (EOWNERDEAD == (result = __ptw32_robust_mutex_inherit(mutex))) { mx->recursive_count = 1; - ptw32_robust_mutex_add(mutex, self); + __ptw32_robust_mutex_add(mutex, self); } else { diff --git a/vendor/pthreads/include/pthread_mutex_unlock.c b/vendor/pthreads/include/pthread_mutex_unlock.c index 3d65d1a957..740f443fd5 100644 --- a/vendor/pthreads/include/pthread_mutex_unlock.c +++ b/vendor/pthreads/include/pthread_mutex_unlock.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" @@ -41,22 +43,19 @@ int pthread_mutex_unlock (pthread_mutex_t * mutex) { - int result = 0; - int kind; - pthread_mutex_t mx; - /* * Let the system deal with invalid pointers. */ - - mx = *mutex; + pthread_mutex_t mx = *mutex; + int kind; + int result = 0; /* * If the thread calling us holds the mutex then there is no * race condition. If another thread holds the * lock then we shouldn't be in here. */ - if (mx < PTHREAD_ERRORCHECK_MUTEX_INITIALIZER) + if (mx < PTHREAD_ERRORCHECK_MUTEX_INITIALIZER) // Remember, pointers are unsigned. { kind = mx->kind; @@ -66,8 +65,8 @@ pthread_mutex_unlock (pthread_mutex_t * mutex) { LONG idx; - idx = (LONG) PTW32_INTERLOCKED_EXCHANGE_LONG ((PTW32_INTERLOCKED_LONGPTR)&mx->lock_idx, - (PTW32_INTERLOCKED_LONG)0); + idx = (LONG) __PTW32_INTERLOCKED_EXCHANGE_LONG ((__PTW32_INTERLOCKED_LONGPTR)&mx->lock_idx, + (__PTW32_INTERLOCKED_LONG)0); if (idx != 0) { if (idx < 0) @@ -91,8 +90,8 @@ pthread_mutex_unlock (pthread_mutex_t * mutex) { mx->ownerThread.p = NULL; - if ((LONG) PTW32_INTERLOCKED_EXCHANGE_LONG ((PTW32_INTERLOCKED_LONGPTR)&mx->lock_idx, - (PTW32_INTERLOCKED_LONG)0) < 0L) + if ((LONG) __PTW32_INTERLOCKED_EXCHANGE_LONG ((__PTW32_INTERLOCKED_LONGPTR)&mx->lock_idx, + (__PTW32_INTERLOCKED_LONG)0) < 0L) { /* Someone may be waiting on that mutex */ if (SetEvent (mx->event) == 0) @@ -120,15 +119,15 @@ pthread_mutex_unlock (pthread_mutex_t * mutex) */ if (pthread_equal (mx->ownerThread, self)) { - PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG((PTW32_INTERLOCKED_LONGPTR) &mx->robustNode->stateInconsistent, - (PTW32_INTERLOCKED_LONG)PTW32_ROBUST_NOTRECOVERABLE, - (PTW32_INTERLOCKED_LONG)PTW32_ROBUST_INCONSISTENT); + __PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG ((__PTW32_INTERLOCKED_LONGPTR) &mx->robustNode->stateInconsistent, + (__PTW32_INTERLOCKED_LONG)__PTW32_ROBUST_NOTRECOVERABLE, + (__PTW32_INTERLOCKED_LONG)__PTW32_ROBUST_INCONSISTENT); if (PTHREAD_MUTEX_NORMAL == kind) { - ptw32_robust_mutex_remove(mutex, NULL); + __ptw32_robust_mutex_remove(mutex, NULL); - if ((LONG) PTW32_INTERLOCKED_EXCHANGE_LONG((PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, - (PTW32_INTERLOCKED_LONG) 0) < 0) + if ((LONG) __PTW32_INTERLOCKED_EXCHANGE_LONG ((__PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, + (__PTW32_INTERLOCKED_LONG) 0) < 0) { /* * Someone may be waiting on that mutex. @@ -144,10 +143,10 @@ pthread_mutex_unlock (pthread_mutex_t * mutex) if (kind != PTHREAD_MUTEX_RECURSIVE || 0 == --mx->recursive_count) { - ptw32_robust_mutex_remove(mutex, NULL); + __ptw32_robust_mutex_remove(mutex, NULL); - if ((LONG) PTW32_INTERLOCKED_EXCHANGE_LONG((PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, - (PTW32_INTERLOCKED_LONG) 0) < 0) + if ((LONG) __PTW32_INTERLOCKED_EXCHANGE_LONG ((__PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, + (__PTW32_INTERLOCKED_LONG) 0) < 0) { /* * Someone may be waiting on that mutex. @@ -168,6 +167,11 @@ pthread_mutex_unlock (pthread_mutex_t * mutex) } else if (mx != PTHREAD_MUTEX_INITIALIZER) { + /* + * If mx is PTHREAD_ERRORCHECK_MUTEX_INITIALIZER or PTHREAD_RECURSIVE_MUTEX_INITIALIZER + * we need to know we are doing something unexpected. For PTHREAD_MUTEX_INITIALIZER + * (normal) mutexes we can just silently ignore it. + */ result = EINVAL; } diff --git a/vendor/pthreads/include/pthread_mutexattr_destroy.c b/vendor/pthreads/include/pthread_mutexattr_destroy.c index 9d424bfa28..09b6bcbda9 100644 --- a/vendor/pthreads/include/pthread_mutexattr_destroy.c +++ b/vendor/pthreads/include/pthread_mutexattr_destroy.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" diff --git a/vendor/pthreads/include/pthread_mutexattr_getkind_np.c b/vendor/pthreads/include/pthread_mutexattr_getkind_np.c index 2d82ec6bc7..2f0799f683 100644 --- a/vendor/pthreads/include/pthread_mutexattr_getkind_np.c +++ b/vendor/pthreads/include/pthread_mutexattr_getkind_np.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" diff --git a/vendor/pthreads/include/pthread_mutexattr_getpshared.c b/vendor/pthreads/include/pthread_mutexattr_getpshared.c index 42f9589c51..dd43a09e33 100644 --- a/vendor/pthreads/include/pthread_mutexattr_getpshared.c +++ b/vendor/pthreads/include/pthread_mutexattr_getpshared.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" diff --git a/vendor/pthreads/include/pthread_mutexattr_getrobust.c b/vendor/pthreads/include/pthread_mutexattr_getrobust.c index be004837bc..7ddd648bbc 100644 --- a/vendor/pthreads/include/pthread_mutexattr_getrobust.c +++ b/vendor/pthreads/include/pthread_mutexattr_getrobust.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" diff --git a/vendor/pthreads/include/pthread_mutexattr_gettype.c b/vendor/pthreads/include/pthread_mutexattr_gettype.c index c63fcfa03a..aaff4148f3 100644 --- a/vendor/pthreads/include/pthread_mutexattr_gettype.c +++ b/vendor/pthreads/include/pthread_mutexattr_gettype.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" diff --git a/vendor/pthreads/include/pthread_mutexattr_init.c b/vendor/pthreads/include/pthread_mutexattr_init.c index d2797ff248..88ac26ab96 100644 --- a/vendor/pthreads/include/pthread_mutexattr_init.c +++ b/vendor/pthreads/include/pthread_mutexattr_init.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" @@ -78,6 +80,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/vendor/pthreads/include/pthread_mutexattr_setkind_np.c b/vendor/pthreads/include/pthread_mutexattr_setkind_np.c index faa936658f..fda1a91b1a 100644 --- a/vendor/pthreads/include/pthread_mutexattr_setkind_np.c +++ b/vendor/pthreads/include/pthread_mutexattr_setkind_np.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" diff --git a/vendor/pthreads/include/pthread_mutexattr_setpshared.c b/vendor/pthreads/include/pthread_mutexattr_setpshared.c index cfa6f71994..6a5770ed3d 100644 --- a/vendor/pthreads/include/pthread_mutexattr_setpshared.c +++ b/vendor/pthreads/include/pthread_mutexattr_setpshared.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" diff --git a/vendor/pthreads/include/pthread_mutexattr_setrobust.c b/vendor/pthreads/include/pthread_mutexattr_setrobust.c index b1acef7572..b5424a2c1c 100644 --- a/vendor/pthreads/include/pthread_mutexattr_setrobust.c +++ b/vendor/pthreads/include/pthread_mutexattr_setrobust.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" diff --git a/vendor/pthreads/include/pthread_mutexattr_settype.c b/vendor/pthreads/include/pthread_mutexattr_settype.c index 8365daf65d..698c566ef5 100644 --- a/vendor/pthreads/include/pthread_mutexattr_settype.c +++ b/vendor/pthreads/include/pthread_mutexattr_settype.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" diff --git a/vendor/pthreads/include/pthread_num_processors_np.c b/vendor/pthreads/include/pthread_num_processors_np.c index 3067d117d3..3549f1609b 100644 --- a/vendor/pthreads/include/pthread_num_processors_np.c +++ b/vendor/pthreads/include/pthread_num_processors_np.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" @@ -47,7 +49,7 @@ pthread_num_processors_np (void) { int count; - if (ptw32_getprocessors (&count) != 0) + if (__ptw32_getprocessors (&count) != 0) { count = 1; } diff --git a/vendor/pthreads/include/pthread_once.c b/vendor/pthreads/include/pthread_once.c index 3bfeb9f0bf..a16362537e 100644 --- a/vendor/pthreads/include/pthread_once.c +++ b/vendor/pthreads/include/pthread_once.c @@ -6,72 +6,74 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" int -pthread_once (pthread_once_t * once_control, void (PTW32_CDECL *init_routine) (void)) +pthread_once (pthread_once_t * once_control, void (__PTW32_CDECL *init_routine) (void)) { if (once_control == NULL || init_routine == NULL) { return EINVAL; } - if ((PTW32_INTERLOCKED_LONG)PTW32_FALSE == - (PTW32_INTERLOCKED_LONG)PTW32_INTERLOCKED_EXCHANGE_ADD_LONG((PTW32_INTERLOCKED_LONGPTR)&once_control->done, - (PTW32_INTERLOCKED_LONG)0)) /* MBR fence */ + if ((__PTW32_INTERLOCKED_LONG)__PTW32_FALSE == + (__PTW32_INTERLOCKED_LONG)__PTW32_INTERLOCKED_EXCHANGE_ADD_LONG ((__PTW32_INTERLOCKED_LONGPTR)&once_control->done, + (__PTW32_INTERLOCKED_LONG)0)) /* MBR fence */ { - ptw32_mcs_local_node_t node; + __ptw32_mcs_local_node_t node; - ptw32_mcs_lock_acquire((ptw32_mcs_lock_t *)&once_control->lock, &node); + __ptw32_mcs_lock_acquire((__ptw32_mcs_lock_t *)&once_control->lock, &node); if (!once_control->done) { -#if defined(_MSC_VER) && _MSC_VER < 1400 +#if defined (__PTW32_CONFIG_MSVC7) #pragma inline_depth(0) #endif - pthread_cleanup_push(ptw32_mcs_lock_release, &node); + pthread_cleanup_push(__ptw32_mcs_lock_release, &node); (*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; + once_control->done = __PTW32_TRUE; } - ptw32_mcs_lock_release(&node); + __ptw32_mcs_lock_release(&node); } return 0; diff --git a/vendor/pthreads/include/pthread_rwlock_destroy.c b/vendor/pthreads/include/pthread_rwlock_destroy.c index 245a892410..359ad36f4c 100644 --- a/vendor/pthreads/include/pthread_rwlock_destroy.c +++ b/vendor/pthreads/include/pthread_rwlock_destroy.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include #include "pthread.h" @@ -54,7 +56,7 @@ pthread_rwlock_destroy (pthread_rwlock_t * rwlock) { rwl = *rwlock; - if (rwl->nMagic != PTW32_RWLOCK_MAGIC) + if (rwl->nMagic != __PTW32_RWLOCK_MAGIC) { return EINVAL; } @@ -108,11 +110,11 @@ pthread_rwlock_destroy (pthread_rwlock_t * rwlock) } else { - ptw32_mcs_local_node_t node; + __ptw32_mcs_local_node_t node; /* - * See notes in ptw32_rwlock_check_need_init() above also. + * See notes in __ptw32_rwlock_check_need_init() above also. */ - ptw32_mcs_lock_acquire(&ptw32_rwlock_test_init_lock, &node); + __ptw32_mcs_lock_acquire(&__ptw32_rwlock_test_init_lock, &node); /* * Check again. @@ -136,7 +138,7 @@ pthread_rwlock_destroy (pthread_rwlock_t * rwlock) result = EBUSY; } - ptw32_mcs_lock_release(&node); + __ptw32_mcs_lock_release(&node); } return ((result != 0) ? result : ((result1 != 0) ? result1 : result2)); diff --git a/vendor/pthreads/include/pthread_rwlock_init.c b/vendor/pthreads/include/pthread_rwlock_init.c index 597c1ff266..4903dd0d2d 100644 --- a/vendor/pthreads/include/pthread_rwlock_init.c +++ b/vendor/pthreads/include/pthread_rwlock_init.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include #include "pthread.h" @@ -87,7 +89,7 @@ pthread_rwlock_init (pthread_rwlock_t * rwlock, goto FAIL2; } - rwl->nMagic = PTW32_RWLOCK_MAGIC; + rwl->nMagic = __PTW32_RWLOCK_MAGIC; result = 0; goto DONE; diff --git a/vendor/pthreads/include/pthread_rwlock_rdlock.c b/vendor/pthreads/include/pthread_rwlock_rdlock.c index 91e180835e..1d141c18da 100644 --- a/vendor/pthreads/include/pthread_rwlock_rdlock.c +++ b/vendor/pthreads/include/pthread_rwlock_rdlock.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include #include "pthread.h" @@ -53,12 +55,12 @@ pthread_rwlock_rdlock (pthread_rwlock_t * rwlock) /* * 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() + * 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); + result = __ptw32_rwlock_check_need_init (rwlock); if (result != 0 && result != EBUSY) { @@ -68,7 +70,7 @@ pthread_rwlock_rdlock (pthread_rwlock_t * rwlock) rwl = *rwlock; - if (rwl->nMagic != PTW32_RWLOCK_MAGIC) + if (rwl->nMagic != __PTW32_RWLOCK_MAGIC) { return EINVAL; } diff --git a/vendor/pthreads/include/pthread_rwlock_timedrdlock.c b/vendor/pthreads/include/pthread_rwlock_timedrdlock.c index 7133778bf1..3099ad97c7 100644 --- a/vendor/pthreads/include/pthread_rwlock_timedrdlock.c +++ b/vendor/pthreads/include/pthread_rwlock_timedrdlock.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include #include "pthread.h" @@ -54,12 +56,12 @@ pthread_rwlock_timedrdlock (pthread_rwlock_t * rwlock, /* * 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() + * 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); + result = __ptw32_rwlock_check_need_init (rwlock); if (result != 0 && result != EBUSY) { @@ -69,7 +71,7 @@ pthread_rwlock_timedrdlock (pthread_rwlock_t * rwlock, rwl = *rwlock; - if (rwl->nMagic != PTW32_RWLOCK_MAGIC) + if (rwl->nMagic != __PTW32_RWLOCK_MAGIC) { return EINVAL; } diff --git a/vendor/pthreads/include/pthread_rwlock_timedwrlock.c b/vendor/pthreads/include/pthread_rwlock_timedwrlock.c index 8c111bbb1b..86f085f890 100644 --- a/vendor/pthreads/include/pthread_rwlock_timedwrlock.c +++ b/vendor/pthreads/include/pthread_rwlock_timedwrlock.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include #include "pthread.h" @@ -54,12 +56,12 @@ pthread_rwlock_timedwrlock (pthread_rwlock_t * rwlock, /* * 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() + * 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); + result = __ptw32_rwlock_check_need_init (rwlock); if (result != 0 && result != EBUSY) { @@ -69,7 +71,7 @@ pthread_rwlock_timedwrlock (pthread_rwlock_t * rwlock, rwl = *rwlock; - if (rwl->nMagic != PTW32_RWLOCK_MAGIC) + if (rwl->nMagic != __PTW32_RWLOCK_MAGIC) { return EINVAL; } @@ -101,13 +103,13 @@ 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); + pthread_cleanup_push (__ptw32_rwlock_cancelwrwait, (void *) rwl); do { @@ -119,7 +121,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/vendor/pthreads/include/pthread_rwlock_tryrdlock.c b/vendor/pthreads/include/pthread_rwlock_tryrdlock.c index 0fc5458579..f95c412d3d 100644 --- a/vendor/pthreads/include/pthread_rwlock_tryrdlock.c +++ b/vendor/pthreads/include/pthread_rwlock_tryrdlock.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include #include "pthread.h" @@ -53,12 +55,12 @@ pthread_rwlock_tryrdlock (pthread_rwlock_t * rwlock) /* * 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() + * 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); + result = __ptw32_rwlock_check_need_init (rwlock); if (result != 0 && result != EBUSY) { @@ -68,7 +70,7 @@ pthread_rwlock_tryrdlock (pthread_rwlock_t * rwlock) rwl = *rwlock; - if (rwl->nMagic != PTW32_RWLOCK_MAGIC) + if (rwl->nMagic != __PTW32_RWLOCK_MAGIC) { return EINVAL; } diff --git a/vendor/pthreads/include/pthread_rwlock_trywrlock.c b/vendor/pthreads/include/pthread_rwlock_trywrlock.c index 9997c5d7fb..373d3a900f 100644 --- a/vendor/pthreads/include/pthread_rwlock_trywrlock.c +++ b/vendor/pthreads/include/pthread_rwlock_trywrlock.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include #include "pthread.h" @@ -53,12 +55,12 @@ pthread_rwlock_trywrlock (pthread_rwlock_t * rwlock) /* * 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() + * 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); + result = __ptw32_rwlock_check_need_init (rwlock); if (result != 0 && result != EBUSY) { @@ -68,7 +70,7 @@ pthread_rwlock_trywrlock (pthread_rwlock_t * rwlock) rwl = *rwlock; - if (rwl->nMagic != PTW32_RWLOCK_MAGIC) + if (rwl->nMagic != __PTW32_RWLOCK_MAGIC) { return EINVAL; } diff --git a/vendor/pthreads/include/pthread_rwlock_unlock.c b/vendor/pthreads/include/pthread_rwlock_unlock.c index d48d18705b..a01e993f4f 100644 --- a/vendor/pthreads/include/pthread_rwlock_unlock.c +++ b/vendor/pthreads/include/pthread_rwlock_unlock.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include #include "pthread.h" @@ -60,7 +62,7 @@ pthread_rwlock_unlock (pthread_rwlock_t * rwlock) rwl = *rwlock; - if (rwl->nMagic != PTW32_RWLOCK_MAGIC) + if (rwl->nMagic != __PTW32_RWLOCK_MAGIC) { return EINVAL; } diff --git a/vendor/pthreads/include/pthread_rwlock_wrlock.c b/vendor/pthreads/include/pthread_rwlock_wrlock.c index e8b4fbb303..36037e0674 100644 --- a/vendor/pthreads/include/pthread_rwlock_wrlock.c +++ b/vendor/pthreads/include/pthread_rwlock_wrlock.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include #include "pthread.h" @@ -53,12 +55,12 @@ pthread_rwlock_wrlock (pthread_rwlock_t * rwlock) /* * 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() + * 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); + result = __ptw32_rwlock_check_need_init (rwlock); if (result != 0 && result != EBUSY) { @@ -68,7 +70,7 @@ pthread_rwlock_wrlock (pthread_rwlock_t * rwlock) rwl = *rwlock; - if (rwl->nMagic != PTW32_RWLOCK_MAGIC) + if (rwl->nMagic != __PTW32_RWLOCK_MAGIC) { return EINVAL; } @@ -97,13 +99,13 @@ 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); + pthread_cleanup_push (__ptw32_rwlock_cancelwrwait, (void *) rwl); do { @@ -113,7 +115,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/vendor/pthreads/include/pthread_rwlockattr_destroy.c b/vendor/pthreads/include/pthread_rwlockattr_destroy.c index 868e727d30..18a7ea058c 100644 --- a/vendor/pthreads/include/pthread_rwlockattr_destroy.c +++ b/vendor/pthreads/include/pthread_rwlockattr_destroy.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include #include "pthread.h" diff --git a/vendor/pthreads/include/pthread_rwlockattr_getpshared.c b/vendor/pthreads/include/pthread_rwlockattr_getpshared.c index eeace207f2..d7bb142147 100644 --- a/vendor/pthreads/include/pthread_rwlockattr_getpshared.c +++ b/vendor/pthreads/include/pthread_rwlockattr_getpshared.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include #include "pthread.h" diff --git a/vendor/pthreads/include/pthread_rwlockattr_init.c b/vendor/pthreads/include/pthread_rwlockattr_init.c index a2d2b945f4..c1ab554a20 100644 --- a/vendor/pthreads/include/pthread_rwlockattr_init.c +++ b/vendor/pthreads/include/pthread_rwlockattr_init.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include #include "pthread.h" diff --git a/vendor/pthreads/include/pthread_rwlockattr_setpshared.c b/vendor/pthreads/include/pthread_rwlockattr_setpshared.c index a83dd70a4b..f5099587f0 100644 --- a/vendor/pthreads/include/pthread_rwlockattr_setpshared.c +++ b/vendor/pthreads/include/pthread_rwlockattr_setpshared.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include #include "pthread.h" diff --git a/vendor/pthreads/include/pthread_self.c b/vendor/pthreads/include/pthread_self.c index 9a1765f82e..67d45f6af0 100644 --- a/vendor/pthreads/include/pthread_self.c +++ b/vendor/pthreads/include/pthread_self.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" @@ -61,14 +63,14 @@ pthread_self (void) { pthread_t self; pthread_t nil = {NULL, 0}; - ptw32_thread_t * sp; + __ptw32_thread_t * sp; #if defined(_UWIN) - if (!ptw32_selfThreadKey) + if (!__ptw32_selfThreadKey) return nil; #endif - sp = (ptw32_thread_t *) pthread_getspecific (ptw32_selfThreadKey); + sp = (__ptw32_thread_t *) pthread_getspecific (__ptw32_selfThreadKey); if (sp != NULL) { @@ -76,66 +78,106 @@ pthread_self (void) } else { + int fail = __PTW32_FALSE; + /* * Need to create an implicit 'self' for the currently * executing thread. */ - self = ptw32_new (); - sp = (ptw32_thread_t *) self.p; + self = __ptw32_new (); + 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 + if (!fail) + { + +#if defined(HAVE_CPU_AFFINITY) + + /* + * 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. + */ + DWORD_PTR vThreadMask, vProcessMask, vSystemMask; + 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; + +#endif + + 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; + } + else + { /* - * No need to explicitly serialise access to sched_priority - * because the new handle is not yet public. + * This implicit POSIX thread is running (it called us). + * No other thread can reference us yet because all API calls + * passing a pthread_t should recognise an invalid thread id + * through the reuse counter inequality. */ - sp->sched_priority = GetThreadPriority (sp->threadH); - pthread_setspecific (ptw32_selfThreadKey, (void *) sp); + sp->state = PThreadStateRunning; } } return (self); - -} /* pthread_self */ +} diff --git a/vendor/pthreads/include/pthread_setaffinity.c b/vendor/pthreads/include/pthread_setaffinity.c new file mode 100644 index 0000000000..badf2e5a26 --- /dev/null +++ b/vendor/pthreads/include/pthread_setaffinity.c @@ -0,0 +1,240 @@ +/* + * pthread_setaffinity.c + * + * Description: + * This translation unit implements thread cpu affinity setting. + * + * -------------------------------------------------------------------------- + * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * + * The 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: + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifdef HAVE_CONFIG_H +# include +#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 + * ENOSYS The platform does not support this function + * + * ------------------------------------------------------ + */ +{ +#if ! defined(HAVE_CPU_AFFINITY) + + return ENOSYS; + +#else + + 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; + +#endif +} + +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 + * ENOSYS The platform does not support this function + * + * ------------------------------------------------------ + */ +{ +#if ! defined(HAVE_CPU_AFFINITY) + + return ENOSYS; + +#else + + 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; + +#endif +} diff --git a/vendor/pthreads/include/pthread_setcancelstate.c b/vendor/pthreads/include/pthread_setcancelstate.c index bbcd624af8..82272537e2 100644 --- a/vendor/pthreads/include/pthread_setcancelstate.c +++ b/vendor/pthreads/include/pthread_setcancelstate.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" @@ -79,10 +81,10 @@ pthread_setcancelstate (int state, int *oldstate) * ------------------------------------------------------ */ { - ptw32_mcs_local_node_t stateLock; + __ptw32_mcs_local_node_t stateLock; int result = 0; pthread_t self = pthread_self (); - ptw32_thread_t * sp = (ptw32_thread_t *) self.p; + __ptw32_thread_t * sp = (__ptw32_thread_t *) self.p; if (sp == NULL || (state != PTHREAD_CANCEL_ENABLE && state != PTHREAD_CANCEL_DISABLE)) @@ -93,7 +95,7 @@ pthread_setcancelstate (int state, int *oldstate) /* * Lock for async-cancel safety. */ - ptw32_mcs_lock_acquire (&sp->stateLock, &stateLock); + __ptw32_mcs_lock_acquire (&sp->stateLock, &stateLock); if (oldstate != NULL) { @@ -112,13 +114,13 @@ pthread_setcancelstate (int state, int *oldstate) sp->state = PThreadStateCanceling; sp->cancelState = PTHREAD_CANCEL_DISABLE; ResetEvent (sp->cancelEvent); - ptw32_mcs_lock_release (&stateLock); - ptw32_throw (PTW32_EPS_CANCEL); + __ptw32_mcs_lock_release (&stateLock); + __ptw32_throw (__PTW32_EPS_CANCEL); /* Never reached */ } - ptw32_mcs_lock_release (&stateLock); + __ptw32_mcs_lock_release (&stateLock); return (result); diff --git a/vendor/pthreads/include/pthread_setcanceltype.c b/vendor/pthreads/include/pthread_setcanceltype.c index 72b0af5bbc..54d7cb6842 100644 --- a/vendor/pthreads/include/pthread_setcanceltype.c +++ b/vendor/pthreads/include/pthread_setcanceltype.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" @@ -52,7 +54,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 @@ -79,10 +81,10 @@ pthread_setcanceltype (int type, int *oldtype) * ------------------------------------------------------ */ { - ptw32_mcs_local_node_t stateLock; + __ptw32_mcs_local_node_t stateLock; int result = 0; pthread_t self = pthread_self (); - ptw32_thread_t * sp = (ptw32_thread_t *) self.p; + __ptw32_thread_t * sp = (__ptw32_thread_t *) self.p; if (sp == NULL || (type != PTHREAD_CANCEL_DEFERRED @@ -94,7 +96,7 @@ pthread_setcanceltype (int type, int *oldtype) /* * Lock for async-cancel safety. */ - ptw32_mcs_lock_acquire (&sp->stateLock, &stateLock); + __ptw32_mcs_lock_acquire (&sp->stateLock, &stateLock); if (oldtype != NULL) { @@ -113,13 +115,13 @@ pthread_setcanceltype (int type, int *oldtype) sp->state = PThreadStateCanceling; sp->cancelState = PTHREAD_CANCEL_DISABLE; ResetEvent (sp->cancelEvent); - ptw32_mcs_lock_release (&stateLock); - ptw32_throw (PTW32_EPS_CANCEL); + __ptw32_mcs_lock_release (&stateLock); + __ptw32_throw (__PTW32_EPS_CANCEL); /* Never reached */ } - ptw32_mcs_lock_release (&stateLock); + __ptw32_mcs_lock_release (&stateLock); return (result); diff --git a/vendor/pthreads/include/pthread_setconcurrency.c b/vendor/pthreads/include/pthread_setconcurrency.c index f62346f8e5..2ba301eb6f 100644 --- a/vendor/pthreads/include/pthread_setconcurrency.c +++ b/vendor/pthreads/include/pthread_setconcurrency.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" @@ -47,7 +49,7 @@ pthread_setconcurrency (int level) } else { - ptw32_concurrency = level; + __ptw32_concurrency = level; return 0; } } diff --git a/vendor/pthreads/include/pthread_setname_np.c b/vendor/pthreads/include/pthread_setname_np.c new file mode 100644 index 0000000000..2cfb0446fa --- /dev/null +++ b/vendor/pthreads/include/pthread_setname_np.c @@ -0,0 +1,190 @@ +/* + * pthread_setname_np.c + * + * -------------------------------------------------------------------------- + * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * + * The 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: + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include +#include "pthread.h" +#include "implement.h" + +#if defined(_MSC_VER) +#define MS_VC_EXCEPTION 0x406D1388 + +#pragma pack(push,8) +typedef struct tagTHREADNAME_INFO +{ + DWORD dwType; // Must be 0x1000. + LPCSTR szName; // Pointer to name (in user addr space). + DWORD dwThreadID; // Thread ID (-1=caller thread). + DWORD dwFlags; // Reserved for future use, must be zero. +} THREADNAME_INFO; +#pragma pack(pop) + +void +SetThreadName( DWORD dwThreadID, char* threadName) +{ + THREADNAME_INFO info; + info.dwType = 0x1000; + info.szName = threadName; + info.dwThreadID = dwThreadID; + info.dwFlags = 0; + + __try + { + RaiseException( MS_VC_EXCEPTION, 0, sizeof(info)/sizeof(ULONG_PTR), (ULONG_PTR*)&info ); + } + __except(EXCEPTION_EXECUTE_HANDLER) + { + } +} +#endif + +#if defined (__PTW32_COMPATIBILITY_BSD) || defined (__PTW32_COMPATIBILITY_TRU64) +int +pthread_setname_np(pthread_t thr, const char *name, void *arg) +{ + __ptw32_mcs_local_node_t threadLock; + int len; + int result; + char tmpbuf[PTHREAD_MAX_NAMELEN_NP]; + char * newname; + char * oldname; + __ptw32_thread_t * tp; +#if defined(_MSC_VER) + DWORD Win32ThreadID; +#endif + + /* + * Validate the thread id. This method works for pthreads-win32 because + * pthread_kill and pthread_t are designed to accommodate it, but the + * method is not portable. + */ + result = pthread_kill (thr, 0); + if (0 != result) + { + return result; + } + + /* + * According to the MSDN description for snprintf() + * where count is the second parameter: + * If len < count, then len characters are stored in buffer, a null-terminator is appended, and len is returned. + * If len = count, then len characters are stored in buffer, no null-terminator is appended, and len is returned. + * If len > count, then count characters are stored in buffer, no null-terminator is appended, and a negative value is returned. + * + * This is different to the POSIX behaviour which returns the number of characters that would have been written in all cases. + */ + len = snprintf(tmpbuf, PTHREAD_MAX_NAMELEN_NP-1, name, arg); + tmpbuf[PTHREAD_MAX_NAMELEN_NP-1] = '\0'; + if (len < 0) + { + return EINVAL; + } + + newname = _strdup(tmpbuf); + +#if defined(_MSC_VER) + Win32ThreadID = pthread_getw32threadid_np (thr); + if (Win32ThreadID) + { + SetThreadName(Win32ThreadID, newname); + } +#endif + + tp = (__ptw32_thread_t *) thr.p; + + __ptw32_mcs_lock_acquire (&tp->threadLock, &threadLock); + + oldname = tp->name; + tp->name = newname; + if (oldname) + { + free(oldname); + } + + __ptw32_mcs_lock_release (&threadLock); + + return 0; +} +#else +int +pthread_setname_np(pthread_t thr, const char *name) +{ + __ptw32_mcs_local_node_t threadLock; + int result; + char * newname; + char * oldname; + __ptw32_thread_t * tp; +#if defined(_MSC_VER) + DWORD Win32ThreadID; +#endif + + /* + * Validate the thread id. This method works for pthreads-win32 because + * pthread_kill and pthread_t are designed to accommodate it, but the + * method is not portable. + */ + result = pthread_kill (thr, 0); + if (0 != result) + { + return result; + } + + newname = _strdup(name); + +#if defined(_MSC_VER) + Win32ThreadID = pthread_getw32threadid_np (thr); + + if (Win32ThreadID) + { + SetThreadName(Win32ThreadID, newname); + } +#endif + + tp = (__ptw32_thread_t *) thr.p; + + __ptw32_mcs_lock_acquire (&tp->threadLock, &threadLock); + + oldname = tp->name; + tp->name = newname; + if (oldname) + { + free(oldname); + } + + __ptw32_mcs_lock_release (&threadLock); + + return 0; +} +#endif diff --git a/vendor/pthreads/include/pthread_setschedparam.c b/vendor/pthreads/include/pthread_setschedparam.c index b762753cdd..8ed2a6b806 100644 --- a/vendor/pthreads/include/pthread_setschedparam.c +++ b/vendor/pthreads/include/pthread_setschedparam.c @@ -1,39 +1,41 @@ /* * sched_setschedparam.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 - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" #include "sched.h" @@ -44,7 +46,11 @@ pthread_setschedparam (pthread_t thread, int policy, { int result; - /* Validate the thread id. */ + /* + * Validate the thread id. This method works for pthreads-win32 because + * pthread_kill and pthread_t are designed to accommodate it, but the + * method is not portable. + */ result = pthread_kill (thread, 0); if (0 != result) { @@ -63,17 +69,17 @@ pthread_setschedparam (pthread_t thread, int policy, return ENOTSUP; } - return (ptw32_setthreadpriority (thread, policy, param->sched_priority)); + return (__ptw32_setthreadpriority (thread, policy, param->sched_priority)); } int -ptw32_setthreadpriority (pthread_t thread, int policy, int priority) +__ptw32_setthreadpriority (pthread_t thread, int policy, int priority) { int prio; - ptw32_mcs_local_node_t threadLock; + __ptw32_mcs_local_node_t threadLock; int result = 0; - ptw32_thread_t * tp = (ptw32_thread_t *) thread.p; + __ptw32_thread_t * tp = (__ptw32_thread_t *) thread.p; prio = priority; @@ -101,7 +107,7 @@ ptw32_setthreadpriority (pthread_t thread, int policy, int priority) #endif - ptw32_mcs_lock_acquire (&tp->threadLock, &threadLock); + __ptw32_mcs_lock_acquire (&tp->threadLock, &threadLock); /* If this fails, the current priority is unchanged. */ if (0 == SetThreadPriority (tp->threadH, prio)) @@ -117,7 +123,7 @@ ptw32_setthreadpriority (pthread_t thread, int policy, int priority) tp->sched_priority = priority; } - ptw32_mcs_lock_release (&threadLock); + __ptw32_mcs_lock_release (&threadLock); return result; } diff --git a/vendor/pthreads/include/pthread_setspecific.c b/vendor/pthreads/include/pthread_setspecific.c index 0f29e704ab..f0d9747c6c 100644 --- a/vendor/pthreads/include/pthread_setspecific.c +++ b/vendor/pthreads/include/pthread_setspecific.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" @@ -68,7 +70,7 @@ pthread_setspecific (pthread_key_t key, const void *value) pthread_t self; int result = 0; - if (key != ptw32_selfThreadKey) + if (key != __ptw32_selfThreadKey) { /* * Using pthread_self will implicitly create @@ -87,7 +89,7 @@ pthread_setspecific (pthread_key_t key, const void *value) * Resolve catch-22 of registering thread with selfThread * key */ - ptw32_thread_t * sp = (ptw32_thread_t *) pthread_getspecific (ptw32_selfThreadKey); + __ptw32_thread_t * sp = (__ptw32_thread_t *) pthread_getspecific (__ptw32_selfThreadKey); if (sp == NULL) { @@ -109,9 +111,9 @@ pthread_setspecific (pthread_key_t key, const void *value) { if (self.p != NULL && key->destructor != NULL && value != NULL) { - ptw32_mcs_local_node_t keyLock; - ptw32_mcs_local_node_t threadLock; - ptw32_thread_t * sp = (ptw32_thread_t *) self.p; + __ptw32_mcs_local_node_t keyLock; + __ptw32_mcs_local_node_t threadLock; + __ptw32_thread_t * sp = (__ptw32_thread_t *) self.p; /* * Only require associations if we have to * call user destroy routine. @@ -123,8 +125,8 @@ pthread_setspecific (pthread_key_t key, const void *value) */ ThreadKeyAssoc *assoc; - ptw32_mcs_lock_acquire(&(key->keyLock), &keyLock); - ptw32_mcs_lock_acquire(&(sp->threadLock), &threadLock); + __ptw32_mcs_lock_acquire(&(key->keyLock), &keyLock); + __ptw32_mcs_lock_acquire(&(sp->threadLock), &threadLock); assoc = (ThreadKeyAssoc *) sp->keys; /* @@ -147,11 +149,11 @@ pthread_setspecific (pthread_key_t key, const void *value) */ if (assoc == NULL) { - result = ptw32_tkAssocCreate (sp, key); + result = __ptw32_tkAssocCreate (sp, key); } - ptw32_mcs_lock_release(&threadLock); - ptw32_mcs_lock_release(&keyLock); + __ptw32_mcs_lock_release(&threadLock); + __ptw32_mcs_lock_release(&keyLock); } if (result == 0) diff --git a/vendor/pthreads/include/pthread_spin_destroy.c b/vendor/pthreads/include/pthread_spin_destroy.c index 786c4e34cd..c25873a63b 100644 --- a/vendor/pthreads/include/pthread_spin_destroy.c +++ b/vendor/pthreads/include/pthread_spin_destroy.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" @@ -51,14 +53,14 @@ pthread_spin_destroy (pthread_spinlock_t * lock) if ((s = *lock) != PTHREAD_SPINLOCK_INITIALIZER) { - if (s->interlock == PTW32_SPIN_USE_MUTEX) + if (s->interlock == __PTW32_SPIN_USE_MUTEX) { result = pthread_mutex_destroy (&(s->u.mutex)); } - else if ((PTW32_INTERLOCKED_LONG) PTW32_SPIN_UNLOCKED != - PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG ((PTW32_INTERLOCKED_LONGPTR) &s->interlock, - (PTW32_INTERLOCKED_LONG) PTW32_SPIN_INVALID, - (PTW32_INTERLOCKED_LONG) PTW32_SPIN_UNLOCKED)) + else if ((__PTW32_INTERLOCKED_LONG) __PTW32_SPIN_UNLOCKED != + __PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG ((__PTW32_INTERLOCKED_LONGPTR) &s->interlock, + (__PTW32_INTERLOCKED_LONG) __PTW32_SPIN_INVALID, + (__PTW32_INTERLOCKED_LONG) __PTW32_SPIN_UNLOCKED)) { result = EINVAL; } @@ -76,11 +78,11 @@ pthread_spin_destroy (pthread_spinlock_t * lock) else { /* - * See notes in ptw32_spinlock_check_need_init() above also. + * See notes in __ptw32_spinlock_check_need_init() above also. */ - ptw32_mcs_local_node_t node; + __ptw32_mcs_local_node_t node; - ptw32_mcs_lock_acquire(&ptw32_spinlock_test_init_lock, &node); + __ptw32_mcs_lock_acquire(&__ptw32_spinlock_test_init_lock, &node); /* * Check again. @@ -104,7 +106,7 @@ pthread_spin_destroy (pthread_spinlock_t * lock) result = EBUSY; } - ptw32_mcs_lock_release(&node); + __ptw32_mcs_lock_release(&node); } return (result); diff --git a/vendor/pthreads/include/pthread_spin_init.c b/vendor/pthreads/include/pthread_spin_init.c index 553af7eac8..ea7604533a 100644 --- a/vendor/pthreads/include/pthread_spin_init.c +++ b/vendor/pthreads/include/pthread_spin_init.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" @@ -50,7 +52,7 @@ pthread_spin_init (pthread_spinlock_t * lock, int pshared) return EINVAL; } - if (0 != ptw32_getprocessors (&cpus)) + if (0 != __ptw32_getprocessors (&cpus)) { cpus = 1; } @@ -90,7 +92,7 @@ pthread_spin_init (pthread_spinlock_t * lock, int pshared) if (cpus > 1) { s->u.cpus = cpus; - s->interlock = PTW32_SPIN_UNLOCKED; + s->interlock = __PTW32_SPIN_UNLOCKED; } else { @@ -103,7 +105,7 @@ pthread_spin_init (pthread_spinlock_t * lock, int pshared) result = pthread_mutex_init (&(s->u.mutex), &ma); if (0 == result) { - s->interlock = PTW32_SPIN_USE_MUTEX; + s->interlock = __PTW32_SPIN_USE_MUTEX; } } (void) pthread_mutexattr_destroy (&ma); diff --git a/vendor/pthreads/include/pthread_spin_lock.c b/vendor/pthreads/include/pthread_spin_lock.c index b560e14891..54e7281a18 100644 --- a/vendor/pthreads/include/pthread_spin_lock.c +++ b/vendor/pthreads/include/pthread_spin_lock.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" @@ -52,7 +54,7 @@ pthread_spin_lock (pthread_spinlock_t * lock) { int result; - if ((result = ptw32_spinlock_check_need_init (lock)) != 0) + if ((result = __ptw32_spinlock_check_need_init (lock)) != 0) { return (result); } @@ -60,18 +62,18 @@ pthread_spin_lock (pthread_spinlock_t * lock) s = *lock; - while ((PTW32_INTERLOCKED_LONG) PTW32_SPIN_LOCKED == - PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG ((PTW32_INTERLOCKED_LONGPTR) &s->interlock, - (PTW32_INTERLOCKED_LONG) PTW32_SPIN_LOCKED, - (PTW32_INTERLOCKED_LONG) PTW32_SPIN_UNLOCKED)) + while ((__PTW32_INTERLOCKED_LONG) __PTW32_SPIN_LOCKED == + __PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG ((__PTW32_INTERLOCKED_LONGPTR) &s->interlock, + (__PTW32_INTERLOCKED_LONG) __PTW32_SPIN_LOCKED, + (__PTW32_INTERLOCKED_LONG) __PTW32_SPIN_UNLOCKED)) { } - if (s->interlock == PTW32_SPIN_LOCKED) + if (s->interlock == __PTW32_SPIN_LOCKED) { return 0; } - else if (s->interlock == PTW32_SPIN_USE_MUTEX) + else if (s->interlock == __PTW32_SPIN_USE_MUTEX) { return pthread_mutex_lock (&(s->u.mutex)); } diff --git a/vendor/pthreads/include/pthread_spin_trylock.c b/vendor/pthreads/include/pthread_spin_trylock.c index a6c65aff6a..b177f6afd1 100644 --- a/vendor/pthreads/include/pthread_spin_trylock.c +++ b/vendor/pthreads/include/pthread_spin_trylock.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" @@ -52,7 +54,7 @@ pthread_spin_trylock (pthread_spinlock_t * lock) { int result; - if ((result = ptw32_spinlock_check_need_init (lock)) != 0) + if ((result = __ptw32_spinlock_check_need_init (lock)) != 0) { return (result); } @@ -61,15 +63,15 @@ pthread_spin_trylock (pthread_spinlock_t * lock) s = *lock; switch ((long) - PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG ((PTW32_INTERLOCKED_LONGPTR) &s->interlock, - (PTW32_INTERLOCKED_LONG) PTW32_SPIN_LOCKED, - (PTW32_INTERLOCKED_LONG) PTW32_SPIN_UNLOCKED)) + __PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG ((__PTW32_INTERLOCKED_LONGPTR) &s->interlock, + (__PTW32_INTERLOCKED_LONG) __PTW32_SPIN_LOCKED, + (__PTW32_INTERLOCKED_LONG) __PTW32_SPIN_UNLOCKED)) { - case PTW32_SPIN_UNLOCKED: + case __PTW32_SPIN_UNLOCKED: return 0; - case PTW32_SPIN_LOCKED: + case __PTW32_SPIN_LOCKED: return EBUSY; - case PTW32_SPIN_USE_MUTEX: + case __PTW32_SPIN_USE_MUTEX: return pthread_mutex_trylock (&(s->u.mutex)); } diff --git a/vendor/pthreads/include/pthread_spin_unlock.c b/vendor/pthreads/include/pthread_spin_unlock.c index 3a6932aef3..5c9d548179 100644 --- a/vendor/pthreads/include/pthread_spin_unlock.c +++ b/vendor/pthreads/include/pthread_spin_unlock.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" @@ -56,14 +58,14 @@ pthread_spin_unlock (pthread_spinlock_t * lock) } switch ((long) - PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG ((PTW32_INTERLOCKED_LONGPTR) &s->interlock, - (PTW32_INTERLOCKED_LONG) PTW32_SPIN_UNLOCKED, - (PTW32_INTERLOCKED_LONG) PTW32_SPIN_LOCKED)) + __PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG ((__PTW32_INTERLOCKED_LONGPTR) &s->interlock, + (__PTW32_INTERLOCKED_LONG) __PTW32_SPIN_UNLOCKED, + (__PTW32_INTERLOCKED_LONG) __PTW32_SPIN_LOCKED)) { - case PTW32_SPIN_LOCKED: - case PTW32_SPIN_UNLOCKED: + case __PTW32_SPIN_LOCKED: + case __PTW32_SPIN_UNLOCKED: return 0; - case PTW32_SPIN_USE_MUTEX: + case __PTW32_SPIN_USE_MUTEX: return pthread_mutex_unlock (&(s->u.mutex)); } diff --git a/vendor/pthreads/include/pthread_testcancel.c b/vendor/pthreads/include/pthread_testcancel.c index 6658650000..999f0e80d2 100644 --- a/vendor/pthreads/include/pthread_testcancel.c +++ b/vendor/pthreads/include/pthread_testcancel.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" @@ -68,9 +70,9 @@ pthread_testcancel (void) * ------------------------------------------------------ */ { - ptw32_mcs_local_node_t stateLock; + __ptw32_mcs_local_node_t stateLock; pthread_t self = pthread_self (); - ptw32_thread_t * sp = (ptw32_thread_t *) self.p; + __ptw32_thread_t * sp = (__ptw32_thread_t *) self.p; if (sp == NULL) { @@ -87,17 +89,17 @@ pthread_testcancel (void) return; } - ptw32_mcs_lock_acquire (&sp->stateLock, &stateLock); + __ptw32_mcs_lock_acquire (&sp->stateLock, &stateLock); if (sp->cancelState != PTHREAD_CANCEL_DISABLE) { ResetEvent(sp->cancelEvent); sp->state = PThreadStateCanceling; sp->cancelState = PTHREAD_CANCEL_DISABLE; - ptw32_mcs_lock_release (&stateLock); - ptw32_throw (PTW32_EPS_CANCEL); + __ptw32_mcs_lock_release (&stateLock); + __ptw32_throw (__PTW32_EPS_CANCEL); /* Never returns here */ } - ptw32_mcs_lock_release (&stateLock); + __ptw32_mcs_lock_release (&stateLock); } /* pthread_testcancel */ diff --git a/vendor/pthreads/include/pthread_timechange_handler_np.c b/vendor/pthreads/include/pthread_timechange_handler_np.c index 0f97e74f14..c1b92e2b9c 100644 --- a/vendor/pthreads/include/pthread_timechange_handler_np.c +++ b/vendor/pthreads/include/pthread_timechange_handler_np.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" @@ -90,11 +92,11 @@ pthread_timechange_handler_np (void *arg) { int result = 0; pthread_cond_t cv; - ptw32_mcs_local_node_t node; + __ptw32_mcs_local_node_t node; - ptw32_mcs_lock_acquire(&ptw32_cond_list_lock, &node); + __ptw32_mcs_lock_acquire(&__ptw32_cond_list_lock, &node); - cv = ptw32_cond_list_head; + cv = __ptw32_cond_list_head; while (cv != NULL && 0 == result) { @@ -102,7 +104,7 @@ pthread_timechange_handler_np (void *arg) cv = cv->next; } - ptw32_mcs_lock_release(&node); + __ptw32_mcs_lock_release(&node); return (void *) (size_t) (result != 0 ? EAGAIN : 0); } diff --git a/vendor/pthreads/include/pthread_timedjoin_np.c b/vendor/pthreads/include/pthread_timedjoin_np.c new file mode 100644 index 0000000000..ab2898aeec --- /dev/null +++ b/vendor/pthreads/include/pthread_timedjoin_np.c @@ -0,0 +1,185 @@ +/* + * pthread_timedjoin_np.c + * + * Description: + * This translation unit implements functions related to thread + * synchronisation. + * + * -------------------------------------------------------------------------- + * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * + * The 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: + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifdef HAVE_CONFIG_H +# include +#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 +#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/vendor/pthreads/include/pthread_tryjoin_np.c b/vendor/pthreads/include/pthread_tryjoin_np.c new file mode 100644 index 0000000000..aa9861d410 --- /dev/null +++ b/vendor/pthreads/include/pthread_tryjoin_np.c @@ -0,0 +1,170 @@ +/* + * pthread_tryjoin_np.c + * + * Description: + * This translation unit implements functions related to thread + * synchronisation. + * + * -------------------------------------------------------------------------- + * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * + * The 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: + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifdef HAVE_CONFIG_H +# include +#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 +#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/vendor/pthreads/include/pthread_win32_attach_detach_np.c b/vendor/pthreads/include/pthread_win32_attach_detach_np.c index bfad450653..b7f16cb141 100644 --- a/vendor/pthreads/include/pthread_win32_attach_detach_np.c +++ b/vendor/pthreads/include/pthread_win32_attach_detach_np.c @@ -6,41 +6,47 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" +#include +#if ! (defined(__GNUC__) || defined (__PTW32_CONFIG_MSVC7) || defined(WINCE)) +# include +#endif /* - * Handle to quserex.dll + * Handle to quserex.dll */ -static HINSTANCE ptw32_h_quserex; +static HINSTANCE __ptw32_h_quserex; BOOL pthread_win32_process_attach_np () @@ -48,19 +54,19 @@ pthread_win32_process_attach_np () TCHAR QuserExDLLPathBuf[1024]; BOOL result = TRUE; - result = ptw32_processInitialize (); + result = __ptw32_processInitialize (); #if defined(_UWIN) pthread_count++; #endif #if defined(__GNUC__) - ptw32_features = 0; + __ptw32_features = 0; #else /* * This is obsolete now. */ - ptw32_features = PTW32_SYSTEM_INTERLOCKED_COMPARE_EXCHANGE; + __ptw32_features = __PTW32_SYSTEM_INTERLOCKED_COMPARE_EXCHANGE; #endif /* @@ -70,43 +76,44 @@ 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, "\\QUSEREX.DLL", sizeof(QuserExDLLPathBuf) - strlen(QuserExDLLPathBuf) - 1); - ptw32_h_quserex = LoadLibrary(QuserExDLLPathBuf); + __ptw32_h_quserex = LoadLibrary(QuserExDLLPathBuf); } #else - /* strncat is secure - this is just to avoid a warning */ - if(GetSystemDirectory(QuserExDLLPathBuf, sizeof(QuserExDLLPathBuf)) && - 0 == strncat_s(QuserExDLLPathBuf, sizeof(QuserExDLLPathBuf), "\\QUSEREX.DLL", 12)) - { - ptw32_h_quserex = LoadLibrary(QuserExDLLPathBuf); - } +# if ! defined(WINCE) + if(GetSystemDirectory(QuserExDLLPathBuf, sizeof(QuserExDLLPathBuf)/sizeof(TCHAR)) && + 0 == _tcsncat_s(QuserExDLLPathBuf, _countof(QuserExDLLPathBuf), TEXT("\\QUSEREX.DLL"), 12)) + { + __ptw32_h_quserex = LoadLibrary(QuserExDLLPathBuf); + } +# endif #endif - if (ptw32_h_quserex != NULL) + 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, + GetProcAddress (__ptw32_h_quserex, (const TCHAR *) TEXT ("QueueUserAPCEx")); #else - GetProcAddress (ptw32_h_quserex, (LPCSTR) "QueueUserAPCEx"); + GetProcAddress (__ptw32_h_quserex, (LPCSTR) "QueueUserAPCEx"); #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) + if (__ptw32_h_quserex != NULL) { - (void) FreeLibrary (ptw32_h_quserex); + (void) FreeLibrary (__ptw32_h_quserex); } - ptw32_h_quserex = 0; + __ptw32_h_quserex = 0; } else { @@ -115,24 +122,24 @@ pthread_win32_process_attach_np () queue_user_apc_ex_init = (BOOL (*)(VOID)) #if defined(NEED_UNICODE_CONSTS) - GetProcAddress (ptw32_h_quserex, + GetProcAddress (__ptw32_h_quserex, (const TCHAR *) TEXT ("QueueUserAPCEx_Init")); #else - GetProcAddress (ptw32_h_quserex, (LPCSTR) "QueueUserAPCEx_Init"); + GetProcAddress (__ptw32_h_quserex, (LPCSTR) "QueueUserAPCEx_Init"); #endif 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; + (void) FreeLibrary (__ptw32_h_quserex); + __ptw32_h_quserex = 0; } } - if (ptw32_h_quserex) + if (__ptw32_h_quserex) { - ptw32_features |= PTW32_ALERTABLE_ASYNC_CANCEL; + __ptw32_features |= __PTW32_ALERTABLE_ASYNC_CANCEL; } return result; @@ -142,9 +149,9 @@ pthread_win32_process_attach_np () BOOL pthread_win32_process_detach_np () { - if (ptw32_processInitialized) + if (__ptw32_processInitialized) { - ptw32_thread_t * sp = (ptw32_thread_t *) pthread_getspecific (ptw32_selfThreadKey); + __ptw32_thread_t * sp = (__ptw32_thread_t *) pthread_getspecific (__ptw32_selfThreadKey); if (sp != NULL) { @@ -154,34 +161,37 @@ pthread_win32_process_detach_np () */ if (sp->detachState == PTHREAD_CREATE_DETACHED) { - ptw32_threadDestroy (sp->ptHandle); - TlsSetValue (ptw32_selfThreadKey->key, NULL); + __ptw32_threadDestroy (sp->ptHandle); + if (__ptw32_selfThreadKey) + { + TlsSetValue (__ptw32_selfThreadKey->key, NULL); + } } } /* * The DLL is being unmapped from the process's address space */ - ptw32_processTerminate (); + __ptw32_processTerminate (); - if (ptw32_h_quserex) + if (__ptw32_h_quserex) { /* Close QueueUserAPCEx */ BOOL (*queue_user_apc_ex_fini) (VOID); queue_user_apc_ex_fini = (BOOL (*)(VOID)) #if defined(NEED_UNICODE_CONSTS) - GetProcAddress (ptw32_h_quserex, + GetProcAddress (__ptw32_h_quserex, (const TCHAR *) TEXT ("QueueUserAPCEx_Fini")); #else - GetProcAddress (ptw32_h_quserex, (LPCSTR) "QueueUserAPCEx_Fini"); + GetProcAddress (__ptw32_h_quserex, (LPCSTR) "QueueUserAPCEx_Fini"); #endif if (queue_user_apc_ex_fini != NULL) { (void) queue_user_apc_ex_fini (); } - (void) FreeLibrary (ptw32_h_quserex); + (void) FreeLibrary (__ptw32_h_quserex); } } @@ -197,26 +207,26 @@ pthread_win32_thread_attach_np () BOOL pthread_win32_thread_detach_np () { - if (ptw32_processInitialized) + if (__ptw32_processInitialized) { /* * Don't use pthread_self() - to avoid creating an implicit POSIX thread handle * unnecessarily. */ - ptw32_thread_t * sp = (ptw32_thread_t *) pthread_getspecific (ptw32_selfThreadKey); + __ptw32_thread_t * sp = (__ptw32_thread_t *) pthread_getspecific (__ptw32_selfThreadKey); if (sp != NULL) // otherwise Win32 thread with no implicit POSIX handle. { - ptw32_mcs_local_node_t stateLock; - ptw32_callUserDestroyRoutines (sp->ptHandle); + __ptw32_mcs_local_node_t stateLock; + __ptw32_callUserDestroyRoutines (sp->ptHandle); - ptw32_mcs_lock_acquire (&sp->stateLock, &stateLock); + __ptw32_mcs_lock_acquire (&sp->stateLock, &stateLock); sp->state = PThreadStateLast; /* * If the thread is joinable at this point then it MUST be joined * or detached explicitly by the application. */ - ptw32_mcs_lock_release (&stateLock); + __ptw32_mcs_lock_release (&stateLock); /* * Robust Mutexes @@ -224,13 +234,13 @@ pthread_win32_thread_detach_np () while (sp->robustMxList != NULL) { pthread_mutex_t mx = sp->robustMxList->mx; - ptw32_robust_mutex_remove(&mx, sp); - (void) PTW32_INTERLOCKED_EXCHANGE_LONG( - (PTW32_INTERLOCKED_LONGPTR)&mx->robustNode->stateInconsistent, - (PTW32_INTERLOCKED_LONG)-1); + __ptw32_robust_mutex_remove(&mx, sp); + (void) __PTW32_INTERLOCKED_EXCHANGE_LONG( + (__PTW32_INTERLOCKED_LONGPTR)&mx->robustNode->stateInconsistent, + (__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); @@ -239,9 +249,12 @@ pthread_win32_thread_detach_np () if (sp->detachState == PTHREAD_CREATE_DETACHED) { - ptw32_threadDestroy (sp->ptHandle); + __ptw32_threadDestroy (sp->ptHandle); - TlsSetValue (ptw32_selfThreadKey->key, NULL); + if (__ptw32_selfThreadKey) + { + TlsSetValue (__ptw32_selfThreadKey->key, NULL); + } } } } @@ -252,5 +265,5 @@ pthread_win32_thread_detach_np () BOOL pthread_win32_test_features_np (int feature_mask) { - return ((ptw32_features & feature_mask) == feature_mask); + return ((__ptw32_features & feature_mask) == feature_mask); } diff --git a/vendor/pthreads/include/ptw32_MCS_lock.c b/vendor/pthreads/include/ptw32_MCS_lock.c index 659cda60de..2f12107379 100644 --- a/vendor/pthreads/include/ptw32_MCS_lock.c +++ b/vendor/pthreads/include/ptw32_MCS_lock.c @@ -6,41 +6,40 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ /* + * About MCS locks: * * MCS locks are queue-based locks, where the queue nodes are local to the * thread. The 'lock' is nothing more than a global pointer that points to * the last node in the queue, or is NULL if the queue is empty. - * + * * Originally designed for use as spin locks requiring no kernel resources * for synchronisation or blocking, the implementation below has adapted * the MCS spin lock for use as a general mutex that will suspend threads @@ -57,56 +56,71 @@ * * Usage of MCS locks: * - * - you need a global ptw32_mcs_lock_t instance initialised to 0 or NULL. - * - you need a local thread-scope ptw32_mcs_local_node_t instance, which + * - you need a global __ptw32_mcs_lock_t instance initialised to 0 or NULL. + * - you need a local thread-scope __ptw32_mcs_local_node_t instance, which * may serve several different locks but you need at least one node for * every lock held concurrently by a thread. * * E.g.: - * - * ptw32_mcs_lock_t lock1 = 0; - * ptw32_mcs_lock_t lock2 = 0; + * + * __ptw32_mcs_lock_t lock1 = 0; + * __ptw32_mcs_lock_t lock2 = 0; * * void *mythread(void *arg) * { - * ptw32_mcs_local_node_t node; + * __ptw32_mcs_local_node_t node; * - * ptw32_mcs_acquire (&lock1, &node); - * ptw32_mcs_lock_release (&node); + * __ptw32_mcs_acquire (&lock1, &node); + * __ptw32_mcs_lock_release (&node); * - * ptw32_mcs_lock_acquire (&lock2, &node); - * ptw32_mcs_lock_release (&node); + * __ptw32_mcs_lock_acquire (&lock2, &node); + * __ptw32_mcs_lock_release (&node); * { - * ptw32_mcs_local_node_t nodex; + * __ptw32_mcs_local_node_t nodex; * - * ptw32_mcs_lock_acquire (&lock1, &node); - * ptw32_mcs_lock_acquire (&lock2, &nodex); + * __ptw32_mcs_lock_acquire (&lock1, &node); + * __ptw32_mcs_lock_acquire (&lock2, &nodex); * - * ptw32_mcs_lock_release (&nodex); - * ptw32_mcs_lock_release (&node); + * __ptw32_mcs_lock_release (&nodex); + * __ptw32_mcs_lock_release (&node); * } * return (void *)0; * } + * */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "sched.h" #include "implement.h" /* - * ptw32_mcs_flag_set -- notify another thread about an event. - * + * __ptw32_mcs_flag_set -- notify another thread about an event. + * * Set event if an event handle has been stored in the flag, and * set flag to -1 otherwise. Note that -1 cannot be a valid handle value. */ -INLINE void -ptw32_mcs_flag_set (HANDLE * flag) +INLINE void +__ptw32_mcs_flag_set (HANDLE * flag) { - HANDLE e = (HANDLE)(PTW32_INTERLOCKED_SIZE)PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE( - (PTW32_INTERLOCKED_SIZEPTR)flag, - (PTW32_INTERLOCKED_SIZE)-1, - (PTW32_INTERLOCKED_SIZE)0); - if ((HANDLE)0 != e) + HANDLE e = (HANDLE) (__PTW32_INTERLOCKED_SIZE)__PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE( + (__PTW32_INTERLOCKED_SIZEPTR)flag, + (__PTW32_INTERLOCKED_SIZE)-1, + (__PTW32_INTERLOCKED_SIZE)0); + /* + * NOTE: when e == -1 and the MSVC debugger is attached to + * the process, we get an exception that halts the + * program noting that the handle value is invalid; + * although innocuous this behavior is cumbersome when + * debugging. Therefore we avoid calling SetEvent() + * for 'known' invalid HANDLE values that can arise + * when the above interlocked-compare-and-exchange + * is executed. + */ + if (((HANDLE)0 != e) && ((HANDLE)-1 != e)) { /* another thread has already stored an event handle in the flag */ SetEvent(e); @@ -114,26 +128,26 @@ 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. */ -INLINE void -ptw32_mcs_flag_wait (HANDLE * flag) +INLINE void +__ptw32_mcs_flag_wait (HANDLE * flag) { - if ((PTW32_INTERLOCKED_LONG)0 == - PTW32_INTERLOCKED_EXCHANGE_ADD_SIZE((PTW32_INTERLOCKED_SIZEPTR)flag, - (PTW32_INTERLOCKED_SIZE)0)) /* MBR fence */ + if ((__PTW32_INTERLOCKED_SIZE)0 == + __PTW32_INTERLOCKED_EXCHANGE_ADD_SIZE ((__PTW32_INTERLOCKED_SIZEPTR)flag, + (__PTW32_INTERLOCKED_SIZE)0)) /* MBR fence */ { /* the flag is not set. create event. */ - HANDLE e = CreateEvent(NULL, PTW32_FALSE, PTW32_FALSE, NULL); + HANDLE e = CreateEvent(NULL, __PTW32_FALSE, __PTW32_FALSE, NULL); - if ((PTW32_INTERLOCKED_SIZE)0 == PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE( - (PTW32_INTERLOCKED_SIZEPTR)flag, - (PTW32_INTERLOCKED_SIZE)e, - (PTW32_INTERLOCKED_SIZE)0)) + if ((__PTW32_INTERLOCKED_SIZE)0 == __PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE( + (__PTW32_INTERLOCKED_SIZEPTR)flag, + (__PTW32_INTERLOCKED_SIZE)e, + (__PTW32_INTERLOCKED_SIZE)0)) { /* stored handle in the flag. wait on it now. */ WaitForSingleObject(e, INFINITE); @@ -144,103 +158,108 @@ ptw32_mcs_flag_wait (HANDLE * flag) } /* - * ptw32_mcs_lock_acquire -- acquire an MCS lock. - * - * See: + * __ptw32_mcs_lock_acquire -- acquire an MCS lock. + * + * See: * J. M. Mellor-Crummey and M. L. Scott. * Algorithms for Scalable Synchronization on Shared-Memory Multiprocessors. * ACM Transactions on Computer Systems, 9(1):21-65, Feb. 1991. */ -#if defined(PTW32_BUILD_INLINED) -INLINE -#endif /* PTW32_BUILD_INLINED */ -void -ptw32_mcs_lock_acquire (ptw32_mcs_lock_t * lock, ptw32_mcs_local_node_t * node) +#if defined (__PTW32_BUILD_INLINED) +INLINE +#endif /* __PTW32_BUILD_INLINED */ +void +__ptw32_mcs_lock_acquire (__ptw32_mcs_lock_t * lock, __ptw32_mcs_local_node_t * node) { - ptw32_mcs_local_node_t *pred; - + __ptw32_mcs_local_node_t *pred; + node->lock = lock; node->nextFlag = 0; node->readyFlag = 0; node->next = 0; /* initially, no successor */ - + /* queue for the lock */ - pred = (ptw32_mcs_local_node_t *)PTW32_INTERLOCKED_EXCHANGE_PTR((PTW32_INTERLOCKED_PVOID_PTR)lock, - (PTW32_INTERLOCKED_PVOID)node); + pred = (__ptw32_mcs_local_node_t *)__PTW32_INTERLOCKED_EXCHANGE_PTR ((__PTW32_INTERLOCKED_PVOID_PTR)lock, + (__PTW32_INTERLOCKED_PVOID)node); if (0 != pred) { /* the lock was not free. link behind predecessor. */ - pred->next = node; - ptw32_mcs_flag_set(&pred->nextFlag); - ptw32_mcs_flag_wait(&node->readyFlag); + __PTW32_INTERLOCKED_EXCHANGE_PTR ((__PTW32_INTERLOCKED_PVOID_PTR)&pred->next, (__PTW32_INTERLOCKED_PVOID)node); + __ptw32_mcs_flag_set(&pred->nextFlag); + __ptw32_mcs_flag_wait(&node->readyFlag); } } /* - * ptw32_mcs_lock_release -- release an MCS lock. - * - * See: + * __ptw32_mcs_lock_release -- release an MCS lock. + * + * See: * J. M. Mellor-Crummey and M. L. Scott. * Algorithms for Scalable Synchronization on Shared-Memory Multiprocessors. * ACM Transactions on Computer Systems, 9(1):21-65, Feb. 1991. */ -#if defined(PTW32_BUILD_INLINED) -INLINE -#endif /* PTW32_BUILD_INLINED */ -void -ptw32_mcs_lock_release (ptw32_mcs_local_node_t * node) +#if defined (__PTW32_BUILD_INLINED) +INLINE +#endif /* __PTW32_BUILD_INLINED */ +void +__ptw32_mcs_lock_release (__ptw32_mcs_local_node_t * node) { - ptw32_mcs_lock_t *lock = node->lock; - ptw32_mcs_local_node_t *next = - (ptw32_mcs_local_node_t *) - PTW32_INTERLOCKED_EXCHANGE_ADD_SIZE((PTW32_INTERLOCKED_SIZEPTR)&node->next, (PTW32_INTERLOCKED_SIZE)0); /* MBR fence */ + __ptw32_mcs_lock_t *lock = node->lock; + __ptw32_mcs_local_node_t *next = + (__ptw32_mcs_local_node_t *) + __PTW32_INTERLOCKED_EXCHANGE_ADD_SIZE ((__PTW32_INTERLOCKED_SIZEPTR)&node->next, (__PTW32_INTERLOCKED_SIZE)0); /* MBR fence */ if (0 == next) { /* no known successor */ - if (node == (ptw32_mcs_local_node_t *) - PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR((PTW32_INTERLOCKED_PVOID_PTR)lock, - (PTW32_INTERLOCKED_PVOID)0, - (PTW32_INTERLOCKED_PVOID)node)) + if (node == (__ptw32_mcs_local_node_t *) + __PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR ((__PTW32_INTERLOCKED_PVOID_PTR)lock, + (__PTW32_INTERLOCKED_PVOID)0, + (__PTW32_INTERLOCKED_PVOID)node)) { /* no successor, lock is free now */ return; } - - /* A successor has started enqueueing behind us so wait for them to link to us */ - ptw32_mcs_flag_wait(&node->nextFlag); - next = (ptw32_mcs_local_node_t *) - PTW32_INTERLOCKED_EXCHANGE_ADD_SIZE((PTW32_INTERLOCKED_SIZEPTR)&node->next, (PTW32_INTERLOCKED_SIZE)0); /* MBR fence */ + + /* wait for successor */ + __ptw32_mcs_flag_wait(&node->nextFlag); + next = (__ptw32_mcs_local_node_t *) + __PTW32_INTERLOCKED_EXCHANGE_ADD_SIZE ((__PTW32_INTERLOCKED_SIZEPTR)&node->next, (__PTW32_INTERLOCKED_SIZE)0); /* MBR fence */ + } + else + { + /* Even if the next is non-0, the successor may still be trying to set the next flag on us, therefore we must wait. */ + __ptw32_mcs_flag_wait(&node->nextFlag); } /* pass the lock */ - ptw32_mcs_flag_set(&next->readyFlag); + __ptw32_mcs_flag_set(&next->readyFlag); } /* - * ptw32_mcs_lock_try_acquire + * __ptw32_mcs_lock_try_acquire */ -#if defined(PTW32_BUILD_INLINED) -INLINE -#endif /* PTW32_BUILD_INLINED */ -int -ptw32_mcs_lock_try_acquire (ptw32_mcs_lock_t * lock, ptw32_mcs_local_node_t * node) +#if defined (__PTW32_BUILD_INLINED) +INLINE +#endif /* __PTW32_BUILD_INLINED */ +int +__ptw32_mcs_lock_try_acquire (__ptw32_mcs_lock_t * lock, __ptw32_mcs_local_node_t * node) { node->lock = lock; node->nextFlag = 0; node->readyFlag = 0; node->next = 0; /* initially, no successor */ - return ((PTW32_INTERLOCKED_PVOID)PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR((PTW32_INTERLOCKED_PVOID_PTR)lock, - (PTW32_INTERLOCKED_PVOID)node, - (PTW32_INTERLOCKED_PVOID)0) - == (PTW32_INTERLOCKED_PVOID)0) ? 0 : EBUSY; + return ((__PTW32_INTERLOCKED_PVOID)__PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR ((__PTW32_INTERLOCKED_PVOID_PTR)lock, + (__PTW32_INTERLOCKED_PVOID)node, + (__PTW32_INTERLOCKED_PVOID)0) + == (__PTW32_INTERLOCKED_PVOID)0) ? 0 : EBUSY; } /* - * ptw32_mcs_node_transfer -- move an MCS lock local node, usually from thread + * __ptw32_mcs_node_transfer -- move an MCS lock local node, usually from thread * space to, for example, global space so that another thread can release * the lock on behalf of the current lock owner. * @@ -250,29 +269,37 @@ ptw32_mcs_lock_try_acquire (ptw32_mcs_lock_t * lock, ptw32_mcs_local_node_t * no * * Should only be called by the thread that has the lock. */ -#if defined(PTW32_BUILD_INLINED) -INLINE -#endif /* PTW32_BUILD_INLINED */ -void -ptw32_mcs_node_transfer (ptw32_mcs_local_node_t * new_node, ptw32_mcs_local_node_t * old_node) +#if defined (__PTW32_BUILD_INLINED) +INLINE +#endif /* __PTW32_BUILD_INLINED */ +void +__ptw32_mcs_node_transfer (__ptw32_mcs_local_node_t * new_node, __ptw32_mcs_local_node_t * old_node) { new_node->lock = old_node->lock; new_node->nextFlag = 0; /* Not needed - used only in initial Acquire */ new_node->readyFlag = 0; /* Not needed - we were waiting on this */ new_node->next = 0; - if ((ptw32_mcs_local_node_t *)PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR((PTW32_INTERLOCKED_PVOID_PTR)new_node->lock, - (PTW32_INTERLOCKED_PVOID)new_node, - (PTW32_INTERLOCKED_PVOID)old_node) + if ((__ptw32_mcs_local_node_t *)__PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR ((__PTW32_INTERLOCKED_PVOID_PTR)new_node->lock, + (__PTW32_INTERLOCKED_PVOID)new_node, + (__PTW32_INTERLOCKED_PVOID)old_node) != old_node) { /* * A successor has queued after us, so wait for them to link to us */ - while (old_node->next == 0) + while (0 == old_node->next) { sched_yield(); } + + /* we must wait for the next Node to finish inserting itself. */ + __ptw32_mcs_flag_wait(&old_node->nextFlag); + /* + * Copy the nextFlag state also so we don't block on it when releasing + * this lock. + */ new_node->next = old_node->next; + new_node->nextFlag = old_node->nextFlag; } } diff --git a/vendor/pthreads/include/ptw32_OLL_lock.c b/vendor/pthreads/include/ptw32_OLL_lock.c deleted file mode 100644 index 789d0ad8c6..0000000000 --- a/vendor/pthreads/include/ptw32_OLL_lock.c +++ /dev/null @@ -1,734 +0,0 @@ -/* - * ptw32_OLL_lock.c - * - * Description: - * This translation unit implements extended reader/writer queue-based locks. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX 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 - */ - -/* - * About the OLL lock (Scalable Reader-Writer Lock): - * - * OLL locks are queue-based locks similar to the MCS queue lock, where the queue - * nodes are local to the thread but where reader threads can enter the critical - * section immediately without going through a central guard lock if there are - * already readers holding the lock. - * - * Covered by United States Patent Application 20100241774 (Oracle) - */ - -#include "pthread.h" -#include "sched.h" -#include "implement.h" - -/* - * C-SNZI support - */ -typedef union ptw32_oll_counter_t_ ptw32_oll_counter_t; -typedef struct ptw32_oll_snziRoot_t_ ptw32_oll_snziRoot_t; -typedef struct ptw32_oll_snziNode_t_ ptw32_oll_snziNode_t; -typedef union ptw32_oll_snziNodeOrRoot_t_ ptw32_oll_snziNodeOrRoot_t; -typedef struct ptw32_oll_queryResult_t_ ptw32_oll_queryResult_t; -typedef struct ptw32_oll_ticket_t_ ptw32_oll_ticket_t; -typedef struct ptw32_oll_csnzi_t_ ptw32_oll_csnzi_t; - -enum -{ - ptw32_archWidth = sizeof(size_t)*8, - ptw32_oll_countWidth = ptw32_archWidth-2 -}; - -#define PTW32_OLL_MAXREADERS (((size_t)2<<(ptw32_oll_countWidth-1))-1) - -union ptw32_oll_counter_t_ -{ - size_t word : ptw32_archWidth; - struct - { - /* - * This needs to be a single word - * - * ------------------------------------ - * | STATE | ROOT | COUNT (readers) | - * ------------------------------------ - * 63 / 31 62 / 30 61 / 29 .. 0 - */ - size_t count : ptw32_oll_countWidth; - size_t root : 1; /* ROOT or NODE */ - size_t state : 1; /* OPEN or CLOSED (root only) */ - } internal; -}; - -struct ptw32_oll_snziRoot_t_ -{ - /* - * "counter" must be at same offset in both - * ptw32_oll_snziNode_t and ptw32_oll_snziRoot_t - */ - ptw32_oll_counter_t counter; -}; - -enum -{ - ptw32_oll_snziRoot_open = 0, - ptw32_oll_snziRoot_closed = 1 -}; - -enum -{ - ptw32_oll_snzi_root = 0, - ptw32_oll_snzi_node = 1 -}; - -/* - * Some common SNZI root whole-word states that can be used to set or compare - * root words with a single operation. - */ -ptw32_oll_snziRoot_t ptw32_oll_snziRoot_openAndZero = {.counter.internal.count = 0, - .counter.internal.root = ptw32_oll_snzi_root, - .counter.internal.state = ptw32_oll_snziRoot_open}; -ptw32_oll_snziRoot_t ptw32_oll_snziRoot_closedAndZero = {.counter.internal.count = 0, - .counter.internal.root = ptw32_oll_snzi_root, - .counter.internal.state = ptw32_oll_snziRoot_closed}; - -struct ptw32_oll_queryResult_t_ -{ - BOOL nonZero; - BOOL open; -}; - -union ptw32_oll_snziNodeOrRoot_t_ -{ - ptw32_oll_snziRoot_t* rootPtr; - ptw32_oll_snziNode_t* nodePtr; -}; - -struct ptw32_oll_snziNode_t_ -{ - /* "counter" must be at same offset in both - * ptw32_oll_snziNode_t and ptw32_oll_snziRoot_t - */ - ptw32_oll_counter_t counter; - ptw32_oll_snziNodeOrRoot_t parentPtr; -}; - -struct ptw32_oll_ticket_t_ -{ - ptw32_oll_snziNodeOrRoot_t snziNodeOrRoot; -}; - -ptw32_oll_ticket_t ptw32_oll_ticket_null = {NULL}; - -struct ptw32_oll_csnzi_t_ -{ - ptw32_oll_snziRoot_t proxyRoot; - ptw32_oll_snziNode_t leafs[]; -}; - -/* - * FOLL lock support - */ - -typedef struct ptw32_foll_node_t_ ptw32_foll_node_t; -typedef struct ptw32_foll_local_t_ ptw32_foll_local_t; -typedef struct ptw32_foll_rwlock_t_ ptw32_foll_rwlock_t; - -enum -{ - ptw32_srwl_reader, - ptw32_srwl_writer -}; - -enum -{ - ptw32_srwl_free, - ptw32_srwl_in_use -}; - -struct ptw32_foll_node_t_ -{ - ptw32_foll_node_t* qNextPtr; - ptw32_oll_csnzi_t* csnziPtr; - ptw32_foll_node_t* nextPtr; - int kind; - int allocState; - BOOL spin; -}; - -struct ptw32_foll_local_t_ -{ - ptw32_foll_node_t* rNodePtr; // Default read node. Immutable - ptw32_foll_node_t* wNodePtr; // Write node. Immutable. - ptw32_foll_node_t* departFromPtr; // List node we last arrived at. - ptw32_oll_ticket_t ticket; // C-SNZI ticket -}; - -struct ptw32_foll_rwlock_t_ -{ - ptw32_foll_node_t* tailPtr; - ptw32_foll_node_t* rNodesPtr; // Head of reader node -}; - -/* - * ShouldArriveAtTree() returns true if: - * the compare_exchange in Arrive() fails too often under read access; or - * ?? - * Note that this is measured across all access to - * this lock, not just this attempt, so that highly - * read-contended locks will use C-SNZI. Lightly - * read-contended locks can reduce memory usage and some - * processing by using the root directly. - */ -BOOL -ptw32_oll_ShouldArriveAtTree() -{ - return PTW32_FALSE; -} - -size_t -ptw32_oll_GetLeafForThread() -{ - return 0; -} - -/* - * Only readers call ptw32_oll_Arrive() - * - * Checks whether the C-SNZI state is OPEN, and if so, - * increments the surplus of the C-SNZI by either directly - * arriving at the root node, or calling TreeArrive on one - * of the leaf nodes. Returns a ticket pointing to the node - * that was arrived at. If the state is CLOSED, makes no - * change and returns a ticket that contains no pointer. - */ -ptw32_oll_ticket_t -ptw32_oll_Arrive(ptw32_oll_csnzi_t* csnzi) -{ - for (;;) - { - ptw32_oll_ticket_t ticket; - ptw32_oll_snziRoot_t oldProxy = csnzi->proxyRoot; - if (oldProxy.counter.internal.state != ptw32_oll_snziRoot_open) - { - ticket.snziNodeOrRoot.rootPtr = (ptw32_oll_snziRoot_t*)NULL; - return ticket; - } - if (!ptw32_oll_ShouldArriveAtTree()) - { - ptw32_oll_snziRoot_t newProxy = oldProxy; - newProxy.counter.internal.count++; - if (PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE( - (PTW32_INTERLOCKED_SIZEPTR)&csnzi->proxyRoot.counter, - (PTW32_INTERLOCKED_SIZE)newProxy.counter.word, - (PTW32_INTERLOCKED_SIZE)oldProxy.counter.word) - == (PTW32_INTERLOCKED_SIZE)oldProxy.counter.word) - { - /* Exchange successful */ - ticket.snziNodeOrRoot.rootPtr = &csnzi->proxyRoot; - return ticket; - } - } - else - { - ptw32_oll_snziNode_t* leafPtr = &csnzi->leafs[ptw32_oll_GetLeafForThread()]; - ticket.snziNodeOrRoot.nodePtr = (ptw32_oll_TreeArrive(leafPtr) ? leafPtr : (ptw32_oll_snziNode_t*)NULL); - return ticket; - } - } -} - -/* - * Decrements the C-SNZI surplus. Returns false iff the - * resulting state is CLOSED and the surplus is zero. - * Ticket must have been returned by an arrival. Must have - * received this ticket from Arrive more times than Depart - * has been called with the ticket. (Thus, the surplus - * must be greater than zero.) - */ -BOOL -ptw32_oll_Depart(ptw32_oll_ticket_t ticket) -{ - return ptw32_oll_TreeDepart(ticket.snziNodeOrRoot); -} - -/* - * Increments the C-SNZI surplus and returns true if the - * C-SNZI is open or has a surplus. Calls TreeArrive - * recursively on the nodeā€™s parent if needed. - * Otherwise, returns false without making any changes. - */ -BOOL -ptw32_oll_TreeArrive(ptw32_oll_snziNodeOrRoot_t snziNodeOrRoot) -{ - if (snziNodeOrRoot.nodePtr->counter.internal.root != ptw32_oll_snzi_root) - { - /* Non-root node */ - ptw32_oll_counter_t newCounter, oldCounter; - BOOL arrivedAtParent = PTW32_FALSE; - do - { - oldCounter = snziNodeOrRoot.nodePtr->counter; - if (0 == oldCounter.internal.count && !arrivedAtParent) - { - if (ptw32_oll_TreeArrive(snziNodeOrRoot.nodePtr->parentPtr)) - arrivedAtParent = PTW32_TRUE; - else - return PTW32_FALSE; - } - newCounter = oldCounter; - newCounter.internal.count++; - } while (PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE( - (PTW32_INTERLOCKED_SIZEPTR)&snziNodeOrRoot.nodePtr->counter, - (PTW32_INTERLOCKED_SIZE)newCounter.word, - (PTW32_INTERLOCKED_SIZE)oldCounter.word) - != (PTW32_INTERLOCKED_SIZE)oldCounter.word); - if (newCounter.internal.count != 0 && arrivedAtParent) - ptw32_oll_TreeDepart(snziNodeOrRoot.nodePtr->parentPtr); - return PTW32_TRUE; - } - else - { - /* Root node */ - ptw32_oll_snziRoot_t newRoot, oldRoot; - do - { - oldRoot = *(ptw32_oll_snziRoot_t*)snziNodeOrRoot.rootPtr; - if (oldRoot.counter.word == ptw32_oll_snziRoot_closedAndZero.counter.word) - return PTW32_FALSE; - newRoot = oldRoot; - newRoot.counter.internal.count++; - } while (PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE( - (PTW32_INTERLOCKED_SIZEPTR)&snziNodeOrRoot.rootPtr->counter, - (PTW32_INTERLOCKED_SIZE)newRoot.counter.word, - (PTW32_INTERLOCKED_SIZE)oldRoot.counter.word) - != (PTW32_INTERLOCKED_SIZE)oldRoot.counter.word); - return PTW32_TRUE; - } -} - -/* - * Decrements the C-SNZI surplus, calling TreeDepart - * recursively on the nodeā€™s parent if needed. Returns - * false iff the resulting state of the C-SNZI is CLOSED - * and the surplus is zero. Otherwise, returns true. - */ -BOOL -ptw32_oll_TreeDepart(ptw32_oll_snziNodeOrRoot_t snziNodeOrRoot) -{ - if (snziNodeOrRoot.nodePtr->counter.internal.root != ptw32_oll_snzi_root) - { - /* Non-root node */ - ptw32_oll_counter_t newCounter, oldCounter; - do - { - newCounter = oldCounter = snziNodeOrRoot.nodePtr->counter; - newCounter.internal.count--; - } while (PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE( - (PTW32_INTERLOCKED_SIZEPTR)&snziNodeOrRoot.nodePtr->counter, - (PTW32_INTERLOCKED_SIZE)newCounter.word, - (PTW32_INTERLOCKED_SIZE)oldCounter.word) - != (PTW32_INTERLOCKED_SIZE)oldCounter.word); - return (0 == newCounter.internal.count) - ? ptw32_oll_TreeDepart(snziNodeOrRoot.nodePtr->parentPtr) - : PTW32_TRUE; - } - else - { - /* Root node */ - ptw32_oll_snziRoot_t newRoot, oldRoot; - do - { - newRoot = oldRoot = *(ptw32_oll_snziRoot_t*)snziNodeOrRoot.rootPtr; - newRoot.counter.internal.count--; - } while (PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE( - (PTW32_INTERLOCKED_SIZEPTR)&snziNodeOrRoot.rootPtr->counter, - (PTW32_INTERLOCKED_SIZE)newRoot.counter.word, - (PTW32_INTERLOCKED_SIZE)oldRoot.counter.word) - != (PTW32_INTERLOCKED_SIZE)oldRoot.counter.word); - return (newRoot.counter.word != ptw32_oll_snziRoot_closedAndZero.counter.word); - } -} - -/* - * Opens a C-SNZI object. Requires C-SNZI state to be - * CLOSED and the surplus to be zero. - */ -void -ptw32_oll_Open(ptw32_oll_csnzi_t* csnziPtr) -{ - csnziPtr->proxyRoot = ptw32_oll_snziRoot_openAndZero; -} - -/* - * Opens a C-SNZI object while atomically performing count - * arrivals. Requires C-SNZI state to be CLOSED and - * the surplus to be zero. - */ -void -ptw32_oll_OpenWithArrivals(ptw32_oll_csnzi_t* csnziPtr, size_t count, BOOL close) -{ - csnziPtr->proxyRoot.counter.internal.count = count; - csnziPtr->proxyRoot.counter.internal.state = (close ? ptw32_oll_snziRoot_closed : ptw32_oll_snziRoot_open); -} - -/* - * Closes a C-SNZI object. Returns true iff the C-SNZI - * state changed from OPEN to CLOSED and the surplus is - * zero. - */ -BOOL -ptw32_oll_Close(ptw32_oll_csnzi_t* csnziPtr) -{ - ptw32_oll_snziRoot_t newProxy, oldProxy; - do - { - oldProxy = csnziPtr->proxyRoot; - if (oldProxy.counter.internal.state != ptw32_oll_snziRoot_open) - { - return PTW32_FALSE; - } - newProxy = oldProxy; - newProxy.counter.internal.state = ptw32_oll_snziRoot_closed; - } while (PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE( - (PTW32_INTERLOCKED_SIZEPTR)&csnziPtr->proxyRoot.counter, - (PTW32_INTERLOCKED_SIZE)newProxy.counter.word, - (PTW32_INTERLOCKED_SIZE)oldProxy.counter.word) - != (PTW32_INTERLOCKED_SIZE)oldProxy.counter.word); - return (newProxy.counter.word == ptw32_oll_snziRoot_closedAndZero.counter.word); -} - -/* - * Closes a C-SNZI if its surplus is zero. Otherwise, does - * nothing. Returns true iff C-SNZI state changed from - * OPEN to CLOSED. - */ -BOOL -ptw32_oll_CloseIfEmpty(ptw32_oll_csnzi_t* csnziPtr) -{ - ptw32_oll_snziRoot_t newProxy, oldProxy; - do - { - oldProxy = csnziPtr->proxyRoot; - if (oldProxy.counter.word != ptw32_oll_snziRoot_openAndZero.counter.word) - { - return PTW32_FALSE; - } - newProxy = ptw32_oll_snziRoot_closedAndZero; - } while (PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE( - (PTW32_INTERLOCKED_SIZEPTR)&csnziPtr->proxyRoot.counter, - (PTW32_INTERLOCKED_SIZE)newProxy.counter.word, - (PTW32_INTERLOCKED_SIZE)oldProxy.counter.word) - != (PTW32_INTERLOCKED_SIZE)oldProxy.counter.word); - return PTW32_TRUE; -} - -/* - * Returns whether the C-SNZI has a nonzero surplus and - * whether the C-SNZI is open. - * "nonZero" doesn't appear to be used anywhere in the algorithms. - */ -ptw32_oll_queryResult_t -ptw32_oll_Query(ptw32_oll_csnzi_t* csnziPtr) -{ - ptw32_oll_queryResult_t query; - ptw32_oll_snziRoot_t proxy = csnziPtr->proxyRoot; - - query.nonZero = (proxy.counter.internal.count > 0); - query.open = (proxy.counter.internal.state == ptw32_oll_snziRoot_open); - return query; -} - -/* - * Returns whether the Arrive operation that returned - * the ticket succeeded. - */ -BOOL -ptw32_oll_Arrived(ptw32_oll_ticket_t t) -{ - return (t.snziNodeOrRoot.nodePtr != NULL); -} - -/* - * Constructs and returns a ticket that can be used to - * depart from the root node. - */ -ptw32_oll_ticket_t -ptw32_oll_DirectTicket(ptw32_oll_csnzi_t* csnziPtr) -{ - ptw32_oll_ticket_t ticket; - ticket.snziNodeOrRoot.rootPtr = &csnziPtr->proxyRoot; - return ticket; -} - -/* Scalable RW Locks */ - -typedef struct ptw32_srwl_rwlock_t_ ptw32_srwl_rwlock_t; -typedef struct ptw32_srwl_node_t_ ptw32_srwl_node_t; -typedef struct ptw32_srwl_local_t_ ptw32_srwl_local_t; - -enum -{ - ptw32_srwl_reader = 0, - ptw32_srwl_writer = 1 -}; - -enum -{ - ptw32_srwl_free = 0, - ptw32_srwl_in_use = 1 -}; - -struct ptw32_srwl_rwlock_t_ -{ - ptw32_srwl_node_t* tailPtr; - ptw32_srwl_node_t* readerNodePtr; -}; - -struct ptw32_srwl_node_t_ -{ - ptw32_srwl_node_t* qNextPtr; - ptw32_oll_csnzi_t* csnziPtr; - ptw32_srwl_node_t* nextReaderPtr; - int kind; /* ptw32_srwl_reader, ptw32_srwl_writer */ - int allocState; /* ptw32_srwl_free, ptw32_srwl_in_use */ - BOOL spin; -}; - -/* - * When a ptw32_srwl_local_t is instantiated the "kind" of each of - * rNode and wNode must be set as appropriate. This is the only - * time "kind" is set. - */ -struct ptw32_srwl_local_t_ -{ - ptw32_srwl_node_t* rNodePtr; - ptw32_srwl_node_t* wNodePtr; - ptw32_srwl_node_t* departFromPtr; - ptw32_oll_ticket_t ticket; -}; - -/* Allocates a new reader node. */ -ptw32_srwl_node_t* -ptw32_srwl_AllocReaderNode(ptw32_srwl_local_t* local) -{ - ptw32_srwl_node_t* currNodePtr = local->rNodePtr; - for (;;) - { - if (currNodePtr->allocState == ptw32_srwl_free) - { - if (PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG( - (PTW32_INTERLOCKED_LONGPTR)&currNodePtr->allocState, - (PTW32_INTERLOCKED_LONG)ptw32_srwl_in_use, - (PTW32_INTERLOCKED_LONG)ptw32_srwl_free) - == (PTW32_INTERLOCKED_LONG)ptw32_srwl_in_use) - { - return currNodePtr; - } - } - currNodePtr = currNodePtr->next; - } -} - -/* - * Frees a reader node. Requires that its allocState - * is ptw32_srwl_in_use. - */ -void -ptw32_srwl_FreeReaderNode(ptw32_srwl_node_t* nodePtr) -{ - nodePtr->allocState := ptw32_srwl_free; -} - -void -ptw32_srwl_WriterLock(ptw32_srwl_rwlock_t* lockPtr, ptw32_srwl_local_t* localPtr) -{ - oldTailPtr = (ptw32_srwl_rwlock_t*)PTW32_INTERLOCKED_EXCHANGE_PTR( - (PTW32_INTERLOCKED_PVOID_PTR)&lockPtr->tailPtr, - (PTW32_INTERLOCKED_PVOID)localPtr->wNodePtr); - if (oldTailPtr != NULL) - { - localPtr->wNodePtr->spin := PTW32_TRUE; - oldTailPtr->qNextPtr = localPtr->wNodePtr; - if (oldTailPtr->kind == ptw32_srwl_writer) - { - while (localPtr->wNodePtr->spin); - } - else - { - /* Wait until node is properly recycled */ - while (ptw32_oll_Query(oldTailPtr->csnzi).open); - /* - * Close C-SNZI of previous reader node. - * If there are no readers to signal us, spin on - * previous node and free it before entering - * critical section. - */ - if (ptw32_oll_Close(oldTailPtr->csnzi)) - { - while (oldTailPtr->spin); - ptw32_srwl_FreeReaderNode(oldTailPtr); - } - else - { - while (localPtr->wNodePtr->spin); - } - } - } -} - -void -ptw32_srwl_WriterUnlock(ptw32_srwl_rwlock_t* lockPtr, ptw32_srwl_local_t* localPtr) -{ - if (localPtr->wNodePtr->qNextPtr == NULL) - { - if (PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR( - (PTW32_INTERLOCKED_PVOIDPTR)&lockPtr->tailPtr, - (PTW32_INTERLOCKED_PVOID)NULL, - (PTW32_INTERLOCKED_PVOID)localPtr->wNodePtr) - == (PTW32_INTERLOCKED_PVOID)NULL) - { - return; - } - else - { - while (localPtr->wNodePtr->qNextPtr == NULL); - } - } - /* Clean up */ - localPtr->wNodePtr->qNextPtr->spin = PTW32_FALSE; - localPtr->wNodePtr->qNextPtr = NULL; -} - -void -ptw32_srwl_ReaderLock(ptw32_srwl_rwlock_t* lockPtr, ptw32_srwl_local_t* localPtr) -{ - ptw32_srwl_node_t* rNodePtr = NULL; - for (;;) - { - ptw32_srwl_node_t* tailPtr = lockPtr->tailPtr; - /* If no nodes are in the queue */ - if (tailPtr == NULL) - { - if (rNodePtr == NULL) - { - rNodePtr = ptw32_srwl_AllocReaderNode(localPtr); - } - rNodePtr->spin = PTW32_FALSE; - if (PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR( - (PTW32_INTERLOCKED_PVOIDPTR)&lockPtr->tailPtr, - (PTW32_INTERLOCKED_PVOID)rNodePtr, - (PTW32_INTERLOCKED_PVOID)NULL) - == (PTW32_INTERLOCKED_PVOID)rNodePtr) - { - ptw32_oll_Open(rNodePtr->csnzi); - localPtr->ticket = ptw32_oll_Arrive(rNodePtr->csnzi); - if (ptw32_oll_Arrived(localPtr->ticket)) - { - localPtr->departFromPtr = rNodePtr; - return; - } - /* Avoid reusing inserted node */ - rNodePtr = NULL; - } - } - /* Otherwise, there is a node in the queue */ - else - { - /* Is last node a writer node? */ - if (tailPtr->kind == ptw32_srwl_writer) - { - if (rNodePtr == NULL) - { - rNodePtr = ptw32_srwl_AllocReaderNode(localPtr); - } - rNodePtr->spin = PTW32_TRUE; - if (PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR( - (PTW32_INTERLOCKED_PVOIDPTR)&lockPtr->tailPtr, - (PTW32_INTERLOCKED_PVOID)rNodePtr, - (PTW32_INTERLOCKED_PVOID)tailPtr) - == (PTW32_INTERLOCKED_PVOID)rNodePtr) - { - tailPtr->qNextPtr = rNodePtr; - localPtr->ticket = ptw32_oll_Arrive(rNodePtr->csnzi); - if (ptw32_oll_Arrived(localPtr->ticket)) - { - localPtr->departFromPtr = rNodePtr; - while (rNodePtr->spin); - return; - } - /* Avoid reusing inserted node */ - rNodePtr = NULL; - } - } - /* - * Otherwise, last node is a reader node. - * (tailPtr->kind == ptw32_srwl_reader) - */ - else - { - localPtr->ticket = ptw32_oll_Arrive(tailPtr->csnzi); - if (ptw32_oll_Arrived(localPtr->ticket)) - { - if (rNodePtr != NULL) - { - ptw32_srwl_FreeReaderNode(rNodePtr); - } - localPtr->departFromPtr = tailPtr; - while (tailPtr->spin); - return; - } - } - } - } -} - -void -ptw32_srwl_ReaderUnlock(ptw32_srwl_rwlock_t* lockPtr, ptw32_srwl_local_t* localPtr) -{ - if (ptw32_oll_Depart(localPtr->departFromPtr->csnzi, localPtr->ticket)) - { - return; - } - /* Clean up */ - localPtr->departFromPtr->qNextPtr->spin = PTW32_FALSE; - localPtr->departFromPtr->qNextPtr = NULL; - ptw32_srwl_FreeReaderNode(localPtr->departFromPtr); -} - - -#include - -int main() -{ - printf("%lx\n", PTW32_OLL_MAXREADERS); - return 0; -} - diff --git a/vendor/pthreads/include/ptw32_callUserDestroyRoutines.c b/vendor/pthreads/include/ptw32_callUserDestroyRoutines.c index f290f7ba54..9d85e05076 100644 --- a/vendor/pthreads/include/ptw32_callUserDestroyRoutines.c +++ b/vendor/pthreads/include/ptw32_callUserDestroyRoutines.c @@ -7,38 +7,40 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" -#if defined(__CLEANUP_CXX) +#if defined(__PTW32_CLEANUP_CXX) # if defined(_MSC_VER) # include # elif defined(__WATCOMC__) @@ -56,7 +58,7 @@ #endif void -ptw32_callUserDestroyRoutines (pthread_t thread) +__ptw32_callUserDestroyRoutines (pthread_t thread) /* * ------------------------------------------------------------------- * DOCPRIVATE @@ -78,11 +80,11 @@ ptw32_callUserDestroyRoutines (pthread_t thread) if (thread.p != NULL) { - ptw32_mcs_local_node_t threadLock; - ptw32_mcs_local_node_t keyLock; + __ptw32_mcs_local_node_t threadLock; + __ptw32_mcs_local_node_t keyLock; int assocsRemaining; int iterations = 0; - ptw32_thread_t * sp = (ptw32_thread_t *) thread.p; + __ptw32_thread_t * sp = (__ptw32_thread_t *) thread.p; /* * Run through all Thread<-->Key associations @@ -95,7 +97,7 @@ ptw32_callUserDestroyRoutines (pthread_t thread) assocsRemaining = 0; iterations++; - ptw32_mcs_lock_acquire(&(sp->threadLock), &threadLock); + __ptw32_mcs_lock_acquire(&(sp->threadLock), &threadLock); /* * The pointer to the next assoc is stored in the thread struct so that * the assoc destructor in pthread_key_delete can adjust it @@ -105,7 +107,7 @@ ptw32_callUserDestroyRoutines (pthread_t thread) * before us. */ sp->nextAssoc = sp->keys; - ptw32_mcs_lock_release(&threadLock); + __ptw32_mcs_lock_release(&threadLock); for (;;) { @@ -118,12 +120,12 @@ ptw32_callUserDestroyRoutines (pthread_t thread) * both assoc guards, but in the reverse order to our convention, * so we must be careful to avoid deadlock. */ - ptw32_mcs_lock_acquire(&(sp->threadLock), &threadLock); + __ptw32_mcs_lock_acquire(&(sp->threadLock), &threadLock); if ((assoc = (ThreadKeyAssoc *)sp->nextAssoc) == NULL) { /* Finished */ - ptw32_mcs_lock_release(&threadLock); + __ptw32_mcs_lock_release(&threadLock); break; } else @@ -138,9 +140,9 @@ ptw32_callUserDestroyRoutines (pthread_t thread) * If we fail, we need to relinquish the first lock and the * processor and then try to acquire them all again. */ - if (ptw32_mcs_lock_try_acquire(&(assoc->key->keyLock), &keyLock) == EBUSY) + if (__ptw32_mcs_lock_try_acquire(&(assoc->key->keyLock), &keyLock) == EBUSY) { - ptw32_mcs_lock_release(&threadLock); + __ptw32_mcs_lock_release(&threadLock); Sleep(0); /* * Go around again. @@ -177,8 +179,8 @@ ptw32_callUserDestroyRoutines (pthread_t thread) * pthread_setspecific can also be run from destructors and * also needs to be able to access the assocs. */ - ptw32_mcs_lock_release(&threadLock); - ptw32_mcs_lock_release(&keyLock); + __ptw32_mcs_lock_release(&threadLock); + __ptw32_mcs_lock_release(&keyLock); assocsRemaining++; @@ -221,12 +223,12 @@ ptw32_callUserDestroyRoutines (pthread_t thread) * Remove association from both the key and thread chains * and reclaim it's memory resources. */ - ptw32_tkAssocDestroy (assoc); - ptw32_mcs_lock_release(&threadLock); - ptw32_mcs_lock_release(&keyLock); + __ptw32_tkAssocDestroy (assoc); + __ptw32_mcs_lock_release(&threadLock); + __ptw32_mcs_lock_release(&keyLock); } } } while (assocsRemaining); } -} /* ptw32_callUserDestroyRoutines */ +} /* __ptw32_callUserDestroyRoutines */ diff --git a/vendor/pthreads/include/ptw32_calloc.c b/vendor/pthreads/include/ptw32_calloc.c index e7b9e64fe6..926801c0c6 100644 --- a/vendor/pthreads/include/ptw32_calloc.c +++ b/vendor/pthreads/include/ptw32_calloc.c @@ -6,41 +6,43 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" #if defined(NEED_CALLOC) void * -ptw32_calloc (size_t n, size_t s) +__ptw32_calloc (size_t n, size_t s) { unsigned int m = n * s; void *p; diff --git a/vendor/pthreads/include/ptw32_cond_check_need_init.c b/vendor/pthreads/include/ptw32_cond_check_need_init.c index ec3e8bbd69..1e849d015c 100644 --- a/vendor/pthreads/include/ptw32_cond_check_need_init.c +++ b/vendor/pthreads/include/ptw32_cond_check_need_init.c @@ -7,49 +7,51 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" INLINE int -ptw32_cond_check_need_init (pthread_cond_t * cond) +__ptw32_cond_check_need_init (pthread_cond_t * cond) { int result = 0; - ptw32_mcs_local_node_t node; + __ptw32_mcs_local_node_t node; /* * The following guarded test is specifically for statically * initialised condition variables (via PTHREAD_OBJECT_INITIALIZER). */ - ptw32_mcs_lock_acquire(&ptw32_cond_test_init_lock, &node); + __ptw32_mcs_lock_acquire(&__ptw32_cond_test_init_lock, &node); /* * We got here possibly under race @@ -72,7 +74,7 @@ ptw32_cond_check_need_init (pthread_cond_t * cond) result = EINVAL; } - ptw32_mcs_lock_release(&node); + __ptw32_mcs_lock_release(&node); return result; } diff --git a/vendor/pthreads/include/ptw32_getprocessors.c b/vendor/pthreads/include/ptw32_getprocessors.c index e60c3143f9..1f52415926 100644 --- a/vendor/pthreads/include/ptw32_getprocessors.c +++ b/vendor/pthreads/include/ptw32_getprocessors.c @@ -7,40 +7,42 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" /* - * ptw32_getprocessors() + * __ptw32_getprocessors() * * Get the number of CPUs available to the process. * @@ -53,7 +55,7 @@ * newly initialised spinlocks will notice. */ int -ptw32_getprocessors (int *count) +__ptw32_getprocessors (int *count) { DWORD_PTR vProcessCPUs; DWORD_PTR vSystemCPUs; diff --git a/vendor/pthreads/include/ptw32_is_attr.c b/vendor/pthreads/include/ptw32_is_attr.c index 36395f81f0..f8fe077870 100644 --- a/vendor/pthreads/include/ptw32_is_attr.c +++ b/vendor/pthreads/include/ptw32_is_attr.c @@ -6,42 +6,44 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" int -ptw32_is_attr (const pthread_attr_t * attr) +__ptw32_is_attr (const pthread_attr_t * attr) { /* Return 0 if the attr object is valid, non-zero otherwise. */ return (attr == NULL || - *attr == NULL || (*attr)->valid != PTW32_ATTR_VALID); + *attr == NULL || (*attr)->valid != __PTW32_ATTR_VALID); } diff --git a/vendor/pthreads/include/ptw32_mutex_check_need_init.c b/vendor/pthreads/include/ptw32_mutex_check_need_init.c index 897db3c68e..c7b1301d7b 100644 --- a/vendor/pthreads/include/ptw32_mutex_check_need_init.c +++ b/vendor/pthreads/include/ptw32_mutex_check_need_init.c @@ -6,53 +6,55 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" -static struct pthread_mutexattr_t_ ptw32_recursive_mutexattr_s = - {PTHREAD_PROCESS_PRIVATE, PTHREAD_MUTEX_RECURSIVE}; -static struct pthread_mutexattr_t_ ptw32_errorcheck_mutexattr_s = - {PTHREAD_PROCESS_PRIVATE, PTHREAD_MUTEX_ERRORCHECK}; -static pthread_mutexattr_t ptw32_recursive_mutexattr = &ptw32_recursive_mutexattr_s; -static pthread_mutexattr_t ptw32_errorcheck_mutexattr = &ptw32_errorcheck_mutexattr_s; +static struct pthread_mutexattr_t_ __ptw32_recursive_mutexattr_s = + {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_MUTEX_STALLED}; +static pthread_mutexattr_t __ptw32_recursive_mutexattr = &__ptw32_recursive_mutexattr_s; +static pthread_mutexattr_t __ptw32_errorcheck_mutexattr = &__ptw32_errorcheck_mutexattr_s; INLINE int -ptw32_mutex_check_need_init (pthread_mutex_t * mutex) +__ptw32_mutex_check_need_init (pthread_mutex_t * mutex) { register int result = 0; register pthread_mutex_t mtx; - ptw32_mcs_local_node_t node; + __ptw32_mcs_local_node_t node; - ptw32_mcs_lock_acquire(&ptw32_mutex_test_init_lock, &node); + __ptw32_mcs_lock_acquire(&__ptw32_mutex_test_init_lock, &node); /* * We got here possibly under race @@ -70,11 +72,11 @@ ptw32_mutex_check_need_init (pthread_mutex_t * mutex) } else if (mtx == PTHREAD_RECURSIVE_MUTEX_INITIALIZER) { - result = pthread_mutex_init (mutex, &ptw32_recursive_mutexattr); + result = pthread_mutex_init (mutex, &__ptw32_recursive_mutexattr); } else if (mtx == PTHREAD_ERRORCHECK_MUTEX_INITIALIZER) { - result = pthread_mutex_init (mutex, &ptw32_errorcheck_mutexattr); + result = pthread_mutex_init (mutex, &__ptw32_errorcheck_mutexattr); } else if (mtx == NULL) { @@ -86,7 +88,7 @@ ptw32_mutex_check_need_init (pthread_mutex_t * mutex) result = EINVAL; } - ptw32_mcs_lock_release(&node); + __ptw32_mcs_lock_release(&node); return (result); } diff --git a/vendor/pthreads/include/ptw32_new.c b/vendor/pthreads/include/ptw32_new.c index ac836ead3a..767fba6e67 100644 --- a/vendor/pthreads/include/ptw32_new.c +++ b/vendor/pthreads/include/ptw32_new.c @@ -6,71 +6,73 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" pthread_t -ptw32_new (void) +__ptw32_new (void) { pthread_t t; pthread_t nil = {NULL, 0}; - ptw32_thread_t * tp; + __ptw32_thread_t * tp; /* * If there's a reusable pthread_t then use it. */ - t = ptw32_threadReusePop (); + t = __ptw32_threadReusePop (); if (NULL != t.p) { - tp = (ptw32_thread_t *) t.p; + tp = (__ptw32_thread_t *) t.p; } else { /* No reuse threads available */ - tp = (ptw32_thread_t *) calloc (1, sizeof(ptw32_thread_t)); + tp = (__ptw32_thread_t *) calloc (1, sizeof(__ptw32_thread_t)); if (tp == NULL) { return nil; } - /* ptHandle.p needs to point to it's parent ptw32_thread_t. */ + /* ptHandle.p needs to point to it's parent __ptw32_thread_t. */ t.p = tp->ptHandle.p = tp; t.x = tp->ptHandle.x = 0; } /* Set default state. */ - tp->seqNumber = ++ptw32_threadSeqNumber; + tp->seqNumber = ++__ptw32_threadSeqNumber; tp->sched_priority = THREAD_PRIORITY_NORMAL; tp->detachState = PTHREAD_CREATE_JOINABLE; tp->cancelState = PTHREAD_CANCEL_ENABLE; @@ -79,13 +81,17 @@ ptw32_new (void) tp->threadLock = 0; tp->robustMxListLock = 0; tp->robustMxList = NULL; - tp->cancelEvent = CreateEvent (0, (int) PTW32_TRUE, /* manualReset */ - (int) PTW32_FALSE, /* setSignaled */ + tp->name = NULL; +#if defined(HAVE_CPU_AFFINITY) + CPU_ZERO((cpu_set_t*)&tp->cpuset); +#endif + tp->cancelEvent = CreateEvent (0, (int) __PTW32_TRUE, /* manualReset */ + (int) __PTW32_FALSE, /* setSignaled */ NULL); if (tp->cancelEvent == NULL) { - ptw32_threadReusePush (tp->ptHandle); + __ptw32_threadReusePush (tp->ptHandle); return nil; } diff --git a/vendor/pthreads/include/ptw32_processInitialize.c b/vendor/pthreads/include/ptw32_processInitialize.c index 8da3e41fa1..d7b85f9435 100644 --- a/vendor/pthreads/include/ptw32_processInitialize.c +++ b/vendor/pthreads/include/ptw32_processInitialize.c @@ -7,40 +7,42 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" int -ptw32_processInitialize (void) +__ptw32_processInitialize (void) /* * ------------------------------------------------------ * DOCPRIVATE @@ -54,7 +56,7 @@ ptw32_processInitialize (void) * This function performs process wide initialization for * the pthread library. * If successful, this routine sets the global variable - * ptw32_processInitialized to TRUE. + * __ptw32_processInitialized to TRUE. * * RESULTS * TRUE if successful, @@ -63,30 +65,92 @@ ptw32_processInitialize (void) * ------------------------------------------------------ */ { - if (ptw32_processInitialized) + if (__ptw32_processInitialized) { - /* - * Ignore if already initialized. this is useful for - * programs that uses a non-dll pthread - * library. Such programs must call ptw32_processInitialize() explicitly, - * since this initialization routine is automatically called only when - * the dll is loaded. - */ - return PTW32_TRUE; + return __PTW32_TRUE; } - ptw32_processInitialized = PTW32_TRUE; + /* + * Explicitly initialise all variables from global.c + */ + __ptw32_threadReuseTop = __PTW32_THREAD_REUSE_EMPTY; + __ptw32_threadReuseBottom = __PTW32_THREAD_REUSE_EMPTY; + __ptw32_selfThreadKey = NULL; + __ptw32_cleanupKey = NULL; + __ptw32_cond_list_head = NULL; + __ptw32_cond_list_tail = NULL; + + __ptw32_concurrency = 0; + + /* What features have been auto-detected */ + __ptw32_features = 0; + + /* + * Global [process wide] thread sequence Number + */ + __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. + */ + __ptw32_register_cancellation = NULL; + + /* + * Global lock for managing pthread_t struct reuse. + */ + __ptw32_thread_reuse_lock = 0; + + /* + * Global lock for testing internal state of statically declared mutexes. + */ + __ptw32_mutex_test_init_lock = 0; + + /* + * Global lock for testing internal state of PTHREAD_COND_INITIALIZER + * created condition variables. + */ + __ptw32_cond_test_init_lock = 0; + + /* + * Global lock for testing internal state of PTHREAD_RWLOCK_INITIALIZER + * created read/write locks. + */ + __ptw32_rwlock_test_init_lock = 0; + + /* + * Global lock for testing internal state of PTHREAD_SPINLOCK_INITIALIZER + * created spin locks. + */ + __ptw32_spinlock_test_init_lock = 0; + + /* + * Global lock for condition variable linked list. The list exists + * to wake up CVs when a WM_TIMECHANGE message arrives. See + * w32_TimeChangeHandler.c. + */ + __ptw32_cond_list_lock = 0; + + #if defined(_UWIN) + /* + * Keep a count of the number of threads. + */ + pthread_count = 0; + #endif + + __ptw32_processInitialized = __PTW32_TRUE; /* * Initialize Keys */ - if ((pthread_key_create (&ptw32_selfThreadKey, NULL) != 0) || - (pthread_key_create (&ptw32_cleanupKey, NULL) != 0)) + if ((pthread_key_create (&__ptw32_selfThreadKey, NULL) != 0) || + (pthread_key_create (&__ptw32_cleanupKey, NULL) != 0)) { - ptw32_processTerminate (); + __ptw32_processTerminate (); } - return (ptw32_processInitialized); + return (__ptw32_processInitialized); } /* processInitialize */ diff --git a/vendor/pthreads/include/ptw32_processTerminate.c b/vendor/pthreads/include/ptw32_processTerminate.c index 83f0f23cab..b8cf9f158f 100644 --- a/vendor/pthreads/include/ptw32_processTerminate.c +++ b/vendor/pthreads/include/ptw32_processTerminate.c @@ -7,40 +7,42 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" void -ptw32_processTerminate (void) +__ptw32_processTerminate (void) /* * ------------------------------------------------------ * DOCPRIVATE @@ -54,7 +56,7 @@ ptw32_processTerminate (void) * This function performs process wide termination for * the pthread library. * This routine sets the global variable - * ptw32_processInitialized to FALSE + * __ptw32_processInitialized to FALSE * * RESULTS * N/A @@ -62,44 +64,44 @@ ptw32_processTerminate (void) * ------------------------------------------------------ */ { - if (ptw32_processInitialized) + if (__ptw32_processInitialized) { - ptw32_thread_t * tp, * tpNext; - ptw32_mcs_local_node_t node; + __ptw32_thread_t * tp, * tpNext; + __ptw32_mcs_local_node_t node; - if (ptw32_selfThreadKey != NULL) + if (__ptw32_selfThreadKey != NULL) { /* - * Release ptw32_selfThreadKey + * Release __ptw32_selfThreadKey */ - pthread_key_delete (ptw32_selfThreadKey); + pthread_key_delete (__ptw32_selfThreadKey); - ptw32_selfThreadKey = NULL; + __ptw32_selfThreadKey = NULL; } - if (ptw32_cleanupKey != NULL) + if (__ptw32_cleanupKey != NULL) { /* - * Release ptw32_cleanupKey + * Release __ptw32_cleanupKey */ - pthread_key_delete (ptw32_cleanupKey); + pthread_key_delete (__ptw32_cleanupKey); - ptw32_cleanupKey = NULL; + __ptw32_cleanupKey = NULL; } - ptw32_mcs_lock_acquire(&ptw32_thread_reuse_lock, &node); + __ptw32_mcs_lock_acquire(&__ptw32_thread_reuse_lock, &node); - tp = ptw32_threadReuseTop; - while (tp != PTW32_THREAD_REUSE_EMPTY) + tp = __ptw32_threadReuseTop; + while (tp != __PTW32_THREAD_REUSE_EMPTY) { tpNext = tp->prevReuse; free (tp); tp = tpNext; } - ptw32_mcs_lock_release(&node); + __ptw32_mcs_lock_release(&node); - ptw32_processInitialized = PTW32_FALSE; + __ptw32_processInitialized = __PTW32_FALSE; } } /* processTerminate */ diff --git a/vendor/pthreads/include/ptw32_relmillisecs.c b/vendor/pthreads/include/ptw32_relmillisecs.c index 894d5c9d46..34b2c4eaf4 100644 --- a/vendor/pthreads/include/ptw32_relmillisecs.c +++ b/vendor/pthreads/include/ptw32_relmillisecs.c @@ -6,68 +6,62 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" -#if !defined(NEED_FTIME) -#include -#endif +static const int64_t NANOSEC_PER_SEC = 1000000000; +static const int64_t NANOSEC_PER_MILLISEC = 1000000; +static const int64_t MILLISEC_PER_SEC = 1000; -#if defined(PTW32_BUILD_INLINED) -INLINE -#endif /* PTW32_BUILD_INLINED */ +#if defined (__PTW32_BUILD_INLINED) +INLINE +#endif /* __PTW32_BUILD_INLINED */ DWORD -ptw32_relmillisecs (const struct timespec * abstime) +__ptw32_relmillisecs (const struct timespec * abstime) { - const int64_t NANOSEC_PER_MILLISEC = 1000000; - const int64_t MILLISEC_PER_SEC = 1000; DWORD milliseconds; - int64_t tmpAbsMilliseconds; - int64_t tmpCurrMilliseconds; -#if defined(NEED_FTIME) + int64_t tmpAbsNanoseconds; + int64_t tmpCurrNanoseconds; + struct timespec currSysTime; FILETIME ft; + +# if defined(WINCE) SYSTEMTIME st; -#else /* ! NEED_FTIME */ -#if ( defined(_MSC_VER) && _MSC_VER >= 1300 ) || \ - ( (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 ) - struct __timeb64 currSysTime; -#else - struct _timeb currSysTime; #endif -#endif /* NEED_FTIME */ - - /* - * Calculate timeout as milliseconds from current system time. + /* + * Calculate timeout as milliseconds from current system time. */ /* @@ -77,50 +71,34 @@ ptw32_relmillisecs (const struct timespec * abstime) * * Assume all integers are unsigned, i.e. cannot test if less than 0. */ - tmpAbsMilliseconds = (int64_t)abstime->tv_sec * MILLISEC_PER_SEC; - tmpAbsMilliseconds += ((int64_t)abstime->tv_nsec + (NANOSEC_PER_MILLISEC/2)) / NANOSEC_PER_MILLISEC; + tmpAbsNanoseconds = (int64_t)abstime->tv_nsec + ((int64_t)abstime->tv_sec * NANOSEC_PER_SEC); /* get current system time */ -#if defined(NEED_FTIME) - +# if defined(WINCE) GetSystemTime(&st); SystemTimeToFileTime(&st, &ft); - /* - * GetSystemTimeAsFileTime(&ft); would be faster, - * but it does not exist on WinCE - */ - - ptw32_filetime_to_timespec(&ft, &currSysTime); +# else + GetSystemTimeAsFileTime(&ft); +# endif - tmpCurrMilliseconds = (int64_t)currSysTime.tv_sec * MILLISEC_PER_SEC; - tmpCurrMilliseconds += ((int64_t)currSysTime.tv_nsec + (NANOSEC_PER_MILLISEC/2)) - / NANOSEC_PER_MILLISEC; + __ptw32_filetime_to_timespec(&ft, &currSysTime); -#else /* ! NEED_FTIME */ + tmpCurrNanoseconds = (int64_t)currSysTime.tv_nsec + ((int64_t)currSysTime.tv_sec * NANOSEC_PER_SEC); -#if defined(_MSC_VER) && _MSC_VER >= 1400 - _ftime64_s(&currSysTime); -#elif ( defined(_MSC_VER) && _MSC_VER >= 1300 ) || \ - ( (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 ) - _ftime64(&currSysTime); -#else - _ftime(&currSysTime); -#endif - - tmpCurrMilliseconds = (int64_t) currSysTime.time * MILLISEC_PER_SEC; - tmpCurrMilliseconds += (int64_t) currSysTime.millitm; - -#endif /* NEED_FTIME */ - - if (tmpAbsMilliseconds > tmpCurrMilliseconds) + if (tmpAbsNanoseconds > tmpCurrNanoseconds) { - milliseconds = (DWORD) (tmpAbsMilliseconds - tmpCurrMilliseconds); - if (milliseconds == INFINITE) - { - /* Timeouts must be finite */ - milliseconds--; - } + int64_t deltaNanoseconds = tmpAbsNanoseconds - tmpCurrNanoseconds; + + if (deltaNanoseconds >= ((int64_t)INFINITE * NANOSEC_PER_MILLISEC)) + { + /* Timeouts must be finite */ + milliseconds = INFINITE - 1; + } + else + { + milliseconds = (DWORD)(deltaNanoseconds / NANOSEC_PER_MILLISEC); + } } else { @@ -128,5 +106,61 @@ ptw32_relmillisecs (const struct timespec * abstime) milliseconds = 0; } + if (milliseconds == 0 && tmpAbsNanoseconds > tmpCurrNanoseconds) { + /* + * millisecond granularity was too small to represent the wait time. + * return the minimum time in milliseconds. + */ + milliseconds = 1; + } + return milliseconds; } + + +/* + * Return the first parameter "abstime" modified to represent the current system time. + * If "relative" is not NULL it represents an interval to add to "abstime". + */ + +struct timespec * +pthread_win32_getabstime_np (struct timespec * abstime, const struct timespec * relative) +{ + int64_t sec; + int64_t nsec; + + struct timespec currSysTime; + FILETIME ft; + + /* get current system time */ + +# if defined(WINCE) + + SYSTEMTIME st; + GetSystemTime(&st); + SystemTimeToFileTime(&st, &ft); +# else + GetSystemTimeAsFileTime(&ft); +# endif + + __ptw32_filetime_to_timespec(&ft, &currSysTime); + + sec = currSysTime.tv_sec; + nsec = currSysTime.tv_nsec; + + if (NULL != relative) + { + nsec += relative->tv_nsec; + if (nsec >= NANOSEC_PER_SEC) + { + sec++; + nsec -= NANOSEC_PER_SEC; + } + sec += relative->tv_sec; + } + + abstime->tv_sec = (time_t) sec; + abstime->tv_nsec = (long) nsec; + + return abstime; +} diff --git a/vendor/pthreads/include/ptw32_reuse.c b/vendor/pthreads/include/ptw32_reuse.c index 7325857ba2..822e4bb259 100644 --- a/vendor/pthreads/include/ptw32_reuse.c +++ b/vendor/pthreads/include/ptw32_reuse.c @@ -6,66 +6,70 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" /* * How it works: - * A pthread_t is a struct (2x32 bit scalar types on IA-32, 2x64 bit on IA-64) + * A pthread_t is a struct (2x32 bit scalar types on x86, 2x64 bit on x86_64) + * [FIXME: This is not true, x86_64 is 64 bit pointer and 32 bit counter. This + * should be fixed in version 3.0.0] * which is normally passed/returned by value to/from pthreads routines. * Applications are therefore storing a copy of the struct as it is at that * time. * * The original pthread_t struct plus all copies of it contain the address of - * the thread state struct ptw32_thread_t_ (p), plus a reuse counter (x). Each - * ptw32_thread_t contains the original copy of it's pthread_t. - * Once malloced, a ptw32_thread_t_ struct is not freed until the process exits. - * + * the thread state struct __ptw32_thread_t_ (p), plus a reuse counter (x). Each + * __ptw32_thread_t contains the original copy of it's pthread_t (ptHandle). + * Once malloced, a __ptw32_thread_t_ struct is not freed until the process exits. + * * The thread reuse stack is a simple LILO stack managed through a singly - * linked list element in the ptw32_thread_t. + * linked list element in the __ptw32_thread_t. * - * Each time a thread is destroyed, the ptw32_thread_t address is pushed onto the + * Each time a thread is destroyed, the __ptw32_thread_t address is pushed onto the * reuse stack after it's ptHandle's reuse counter has been incremented. - * + * * The following can now be said from this: - * - two pthread_t's are identical if their ptw32_thread_t reference pointers - * are equal and their reuse counters are equal. That is, + * - two pthread_t's refer to the same thread iff their __ptw32_thread_t reference + * pointers are equal and their reuse counters are equal. That is, * * equal = (a.p == b.p && a.x == b.x) * * - a pthread_t copy refers to a destroyed thread if the reuse counter in - * the copy is not equal to the reuse counter in the original. + * the copy is not equal to (i.e less than) the reuse counter in the original. * - * threadDestroyed = (copy.x != ((ptw32_thread_t *)copy.p)->ptHandle.x) + * threadDestroyed = (copy.x != ((__ptw32_thread_t *)copy.p)->ptHandle.x) * */ @@ -73,24 +77,24 @@ * Pop a clean pthread_t struct off the reuse stack. */ pthread_t -ptw32_threadReusePop (void) +__ptw32_threadReusePop (void) { pthread_t t = {NULL, 0}; - ptw32_mcs_local_node_t node; + __ptw32_mcs_local_node_t node; - ptw32_mcs_lock_acquire(&ptw32_thread_reuse_lock, &node); + __ptw32_mcs_lock_acquire(&__ptw32_thread_reuse_lock, &node); - if (PTW32_THREAD_REUSE_EMPTY != ptw32_threadReuseTop) + if (__PTW32_THREAD_REUSE_EMPTY != __ptw32_threadReuseTop) { - ptw32_thread_t * tp; + __ptw32_thread_t * tp; - tp = ptw32_threadReuseTop; + tp = __ptw32_threadReuseTop; - ptw32_threadReuseTop = tp->prevReuse; + __ptw32_threadReuseTop = tp->prevReuse; - if (PTW32_THREAD_REUSE_EMPTY == ptw32_threadReuseTop) + if (__PTW32_THREAD_REUSE_EMPTY == __ptw32_threadReuseTop) { - ptw32_threadReuseBottom = PTW32_THREAD_REUSE_EMPTY; + __ptw32_threadReuseBottom = __PTW32_THREAD_REUSE_EMPTY; } tp->prevReuse = NULL; @@ -98,7 +102,7 @@ ptw32_threadReusePop (void) t = tp->ptHandle; } - ptw32_mcs_lock_release(&node); + __ptw32_mcs_lock_release(&node); return t; @@ -108,44 +112,44 @@ ptw32_threadReusePop (void) * Push a clean pthread_t struct onto the reuse stack. * Must be re-initialised when reused. * All object elements (mutexes, events etc) must have been either - * detroyed before this, or never initialised. + * destroyed before this, or never initialised. */ void -ptw32_threadReusePush (pthread_t thread) +__ptw32_threadReusePush (pthread_t thread) { - ptw32_thread_t * tp = (ptw32_thread_t *) thread.p; + __ptw32_thread_t * tp = (__ptw32_thread_t *) thread.p; pthread_t t; - ptw32_mcs_local_node_t node; + __ptw32_mcs_local_node_t node; - ptw32_mcs_lock_acquire(&ptw32_thread_reuse_lock, &node); + __ptw32_mcs_lock_acquire(&__ptw32_thread_reuse_lock, &node); t = tp->ptHandle; - memset(tp, 0, sizeof(ptw32_thread_t)); + memset(tp, 0, sizeof(__ptw32_thread_t)); /* Must restore the original POSIX handle that we just wiped. */ tp->ptHandle = t; /* Bump the reuse counter now */ -#if defined(PTW32_THREAD_ID_REUSE_INCREMENT) - tp->ptHandle.x += PTW32_THREAD_ID_REUSE_INCREMENT; +#if defined (__PTW32_THREAD_ID_REUSE_INCREMENT) + tp->ptHandle.x += __PTW32_THREAD_ID_REUSE_INCREMENT; #else tp->ptHandle.x++; #endif tp->state = PThreadStateReuse; - tp->prevReuse = PTW32_THREAD_REUSE_EMPTY; + tp->prevReuse = __PTW32_THREAD_REUSE_EMPTY; - if (PTW32_THREAD_REUSE_EMPTY != ptw32_threadReuseBottom) + if (__PTW32_THREAD_REUSE_EMPTY != __ptw32_threadReuseBottom) { - ptw32_threadReuseBottom->prevReuse = tp; + __ptw32_threadReuseBottom->prevReuse = tp; } else { - ptw32_threadReuseTop = tp; + __ptw32_threadReuseTop = tp; } - ptw32_threadReuseBottom = tp; + __ptw32_threadReuseBottom = tp; - ptw32_mcs_lock_release(&node); + __ptw32_mcs_lock_release(&node); } diff --git a/vendor/pthreads/include/ptw32_rwlock_cancelwrwait.c b/vendor/pthreads/include/ptw32_rwlock_cancelwrwait.c index a057bd1d72..8f15996ca6 100644 --- a/vendor/pthreads/include/ptw32_rwlock_cancelwrwait.c +++ b/vendor/pthreads/include/ptw32_rwlock_cancelwrwait.c @@ -6,39 +6,41 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" void -ptw32_rwlock_cancelwrwait (void *arg) +__ptw32_rwlock_cancelwrwait (void *arg) { pthread_rwlock_t rwl = (pthread_rwlock_t) arg; diff --git a/vendor/pthreads/include/ptw32_rwlock_check_need_init.c b/vendor/pthreads/include/ptw32_rwlock_check_need_init.c index 858ee271ce..014f8d1a1d 100644 --- a/vendor/pthreads/include/ptw32_rwlock_check_need_init.c +++ b/vendor/pthreads/include/ptw32_rwlock_check_need_init.c @@ -6,48 +6,50 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" INLINE int -ptw32_rwlock_check_need_init (pthread_rwlock_t * rwlock) +__ptw32_rwlock_check_need_init (pthread_rwlock_t * rwlock) { int result = 0; - ptw32_mcs_local_node_t node; + __ptw32_mcs_local_node_t node; /* * The following guarded test is specifically for statically * initialised rwlocks (via PTHREAD_RWLOCK_INITIALIZER). */ - ptw32_mcs_lock_acquire(&ptw32_rwlock_test_init_lock, &node); + __ptw32_mcs_lock_acquire(&__ptw32_rwlock_test_init_lock, &node); /* * We got here possibly under race @@ -71,7 +73,7 @@ ptw32_rwlock_check_need_init (pthread_rwlock_t * rwlock) result = EINVAL; } - ptw32_mcs_lock_release(&node); + __ptw32_mcs_lock_release(&node); return result; } diff --git a/vendor/pthreads/include/ptw32_semwait.c b/vendor/pthreads/include/ptw32_semwait.c index c3c4fd0e5e..ae21181ba9 100644 --- a/vendor/pthreads/include/ptw32_semwait.c +++ b/vendor/pthreads/include/ptw32_semwait.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #if !defined(_UWIN) /*# include */ #endif @@ -42,94 +44,67 @@ int -ptw32_semwait (sem_t * sem) - /* - * ------------------------------------------------------ - * DESCRIPTION - * This function waits on a POSIX semaphore. If the - * semaphore value is greater than zero, it decreases - * its value by one. If the semaphore value is zero, then - * the calling thread (or process) is blocked until it can - * successfully decrease the value. - * - * Unlike sem_wait(), this routine is non-cancelable. - * - * RESULTS - * 0 successfully decreased semaphore, - * -1 failed, error in errno. - * ERRNO - * EINVAL 'sem' is not a valid semaphore, - * ENOSYS semaphores are not supported, - * EINTR the function was interrupted by a signal, - * EDEADLK a deadlock condition was detected. - * - * ------------------------------------------------------ - */ +__ptw32_semwait (sem_t * sem) +/* + * ------------------------------------------------------ + * DESCRIPTION + * This function waits on a POSIX semaphore. If the + * semaphore value is greater than zero, it decreases + * its value by one. If the semaphore value is zero, then + * the calling thread (or process) is blocked until it can + * successfully decrease the value. + * + * Unlike sem_wait(), this routine is non-cancelable. + * + * RESULTS + * 0 successfully decreased semaphore, + * -1 failed, error in errno. + * ERRNO + * EINVAL 'sem' is not a valid semaphore, + * ENOSYS semaphores are not supported, + * EINTR the function was interrupted by a signal, + * EDEADLK a deadlock condition was detected. + * + * ------------------------------------------------------ + */ { + __ptw32_mcs_local_node_t node; + int v; int result = 0; sem_t s = *sem; - if (s == NULL) - { - result = EINVAL; - } - else + __ptw32_mcs_lock_acquire(&s->lock, &node); + v = --s->value; + __ptw32_mcs_lock_release(&node); + + if (v < 0) { - if ((result = pthread_mutex_lock (&s->lock)) == 0) + /* Must wait */ + if (WaitForSingleObject (s->sem, INFINITE) == WAIT_OBJECT_0) { - int v; - - /* See sem_destroy.c - */ - if (*sem == NULL) - { - (void) pthread_mutex_unlock (&s->lock); - errno = EINVAL; - return -1; - } - - v = --s->value; - (void) pthread_mutex_unlock (&s->lock); - - if (v < 0) - { - /* Must wait */ - if (WaitForSingleObject (s->sem, INFINITE) == WAIT_OBJECT_0) - { #if defined(NEED_SEM) - if (pthread_mutex_lock (&s->lock) == 0) - { - if (*sem == NULL) - { - (void) pthread_mutex_unlock (&s->lock); - errno = EINVAL; - return -1; - } - - if (s->leftToUnblock > 0) - { - --s->leftToUnblock; - SetEvent(s->sem); - } - (void) pthread_mutex_unlock (&s->lock); - } -#endif - return 0; - } + __ptw32_mcs_lock_acquire(&s->lock, &node); + if (s->leftToUnblock > 0) + { + --s->leftToUnblock; + SetEvent(s->sem); } - else - { - return 0; - } + __ptw32_mcs_lock_release(&node); +#endif +return 0; } } + else + { + return 0; + } if (result != 0) { - errno = result; + __PTW32_SET_ERRNO(result); return -1; } return 0; -} /* ptw32_semwait */ +} /* __ptw32_semwait */ diff --git a/vendor/pthreads/include/ptw32_spinlock_check_need_init.c b/vendor/pthreads/include/ptw32_spinlock_check_need_init.c index 8808454ee8..1ca7afafcd 100644 --- a/vendor/pthreads/include/ptw32_spinlock_check_need_init.c +++ b/vendor/pthreads/include/ptw32_spinlock_check_need_init.c @@ -6,49 +6,51 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" INLINE int -ptw32_spinlock_check_need_init (pthread_spinlock_t * lock) +__ptw32_spinlock_check_need_init (pthread_spinlock_t * lock) { int result = 0; - ptw32_mcs_local_node_t node; + __ptw32_mcs_local_node_t node; /* * The following guarded test is specifically for statically * initialised spinlocks (via PTHREAD_SPINLOCK_INITIALIZER). */ - ptw32_mcs_lock_acquire(&ptw32_spinlock_test_init_lock, &node); + __ptw32_mcs_lock_acquire(&__ptw32_spinlock_test_init_lock, &node); /* * We got here possibly under race @@ -72,7 +74,7 @@ ptw32_spinlock_check_need_init (pthread_spinlock_t * lock) result = EINVAL; } - ptw32_mcs_lock_release(&node); + __ptw32_mcs_lock_release(&node); return (result); } diff --git a/vendor/pthreads/include/ptw32_threadDestroy.c b/vendor/pthreads/include/ptw32_threadDestroy.c index 41499b11b6..5b13556341 100644 --- a/vendor/pthreads/include/ptw32_threadDestroy.c +++ b/vendor/pthreads/include/ptw32_threadDestroy.c @@ -7,73 +7,77 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" void -ptw32_threadDestroy (pthread_t thread) +__ptw32_threadDestroy (pthread_t thread) { - ptw32_thread_t * tp = (ptw32_thread_t *) thread.p; - ptw32_thread_t threadCopy; + __ptw32_thread_t * tp = (__ptw32_thread_t *) thread.p; if (tp != NULL) { /* * Copy thread state so that the thread can be atomically NULLed. */ - memcpy (&threadCopy, tp, sizeof (threadCopy)); +#if ! defined(__MINGW32__) || defined (__MSVCRT__) || defined (__DMC__) + HANDLE threadH = tp->threadH; +#endif + HANDLE cancelEvent = tp->cancelEvent; /* * Thread ID structs are never freed. They're NULLed and reused. - * This also sets the thread to PThreadStateInitial (invalid). + * This also sets the thread state to PThreadStateInitial before + * it is finally set to PThreadStateReuse. */ - ptw32_threadReusePush (thread); + __ptw32_threadReusePush (thread); - /* Now work on the copy. */ - if (threadCopy.cancelEvent != NULL) + if (cancelEvent != NULL) { - CloseHandle (threadCopy.cancelEvent); + CloseHandle (cancelEvent); } -#if ! (defined(__MINGW64__) || defined(__MINGW32__)) || defined (__MSVCRT__) || defined (__DMC__) +#if ! defined(__MINGW32__) || defined (__MSVCRT__) || defined (__DMC__) /* * See documentation for endthread vs endthreadex. */ - if (threadCopy.threadH != 0) + if (threadH != 0) { - CloseHandle (threadCopy.threadH); + CloseHandle (threadH); } #endif } -} /* ptw32_threadDestroy */ +} /* __ptw32_threadDestroy */ diff --git a/vendor/pthreads/include/ptw32_threadStart.c b/vendor/pthreads/include/ptw32_threadStart.c index e83ede0ec4..fc41ca2466 100644 --- a/vendor/pthreads/include/ptw32_threadStart.c +++ b/vendor/pthreads/include/ptw32_threadStart.c @@ -7,43 +7,45 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" #include -#if defined(__CLEANUP_C) +#if defined(__PTW32_CLEANUP_C) # include #endif -#if defined(__CLEANUP_SEH) +#if defined(__PTW32_CLEANUP_SEH) static DWORD ExceptionFilter (EXCEPTION_POINTERS * ep, DWORD * ei) @@ -59,7 +61,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; @@ -74,7 +76,7 @@ ExceptionFilter (EXCEPTION_POINTERS * ep, DWORD * ei) */ pthread_t self = pthread_self (); - ptw32_callUserDestroyRoutines (self); + __ptw32_callUserDestroyRoutines (self); return EXCEPTION_CONTINUE_SEARCH; break; @@ -82,99 +84,91 @@ ExceptionFilter (EXCEPTION_POINTERS * ep, DWORD * ei) } } -#elif defined(__CLEANUP_CXX) +#elif defined(__PTW32_CLEANUP_CXX) #if defined(_MSC_VER) # include #elif defined(__WATCOMC__) # include # include -typedef terminate_handler - terminate_function; #else # if defined(__GNUC__) && __GNUC__ < 3 # include # else # include -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 /* __PTW32_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 (__MINGW32__) || (defined (__MSVCRT__) && ! defined (__DMC__)) unsigned __stdcall #else void #endif -ptw32_threadStart (void *vthreadParms) +__ptw32_threadStart (void *vthreadParms) { ThreadParms * threadParms = (ThreadParms *) vthreadParms; pthread_t self; - ptw32_thread_t * sp; - void * (PTW32_CDECL *start) (void *); + __ptw32_thread_t * sp; + void * (__PTW32_CDECL *start) (void *); void * arg; -#if defined(__CLEANUP_SEH) +#if defined(__PTW32_CLEANUP_SEH) DWORD ei[] = { 0, 0, 0 }; #endif -#if defined(__CLEANUP_C) +#if defined(__PTW32_CLEANUP_C) int setjmp_rc; #endif - ptw32_mcs_local_node_t stateLock; + __ptw32_mcs_local_node_t stateLock; void * status = (void *) 0; self = threadParms->tid; - sp = (ptw32_thread_t *) self.p; + sp = (__ptw32_thread_t *) self.p; start = threadParms->start; arg = threadParms->arg; free (threadParms); -#if (defined(__MINGW64__) || defined(__MINGW32__)) && ! defined (__MSVCRT__) +#if ! defined (__MINGW32__) || defined (__MSVCRT__) || defined (__DMC__) +#else /* - * beginthread does not return the thread id and is running + * _beginthread does not return the thread id and is running * before it returns us the thread handle, and so we do it here. */ sp->thread = GetCurrentThreadId (); +#endif + + pthread_setspecific (__ptw32_selfThreadKey, sp); /* * Here we're using stateLock as a general-purpose lock * to make the new thread wait until the creating thread * has the new handle. */ - ptw32_mcs_lock_acquire (&sp->stateLock, &stateLock); - pthread_setspecific (ptw32_selfThreadKey, sp); -#else - pthread_setspecific (ptw32_selfThreadKey, sp); - ptw32_mcs_lock_acquire (&sp->stateLock, &stateLock); -#endif - + __ptw32_mcs_lock_acquire (&sp->stateLock, &stateLock); sp->state = PThreadStateRunning; - ptw32_mcs_lock_release (&stateLock); + __ptw32_mcs_lock_release (&stateLock); -#if defined(__CLEANUP_SEH) +#if defined(__PTW32_CLEANUP_SEH) __try { @@ -194,31 +188,30 @@ 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; } } -#else /* __CLEANUP_SEH */ +#else /* __PTW32_CLEANUP_SEH */ -#if defined(__CLEANUP_C) +#if defined(__PTW32_CLEANUP_C) setjmp_rc = setjmp (sp->start_mark); if (0 == setjmp_rc) { - /* * Run the caller's routine; */ @@ -228,73 +221,36 @@ 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) +#else /* __PTW32_CLEANUP_C */ - ptw32_oldTerminate = set_terminate (&ptw32_terminate); +#if defined(__PTW32_CLEANUP_CXX) 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 &) + catch (__ptw32_exception_cancel &) { /* * Thread was canceled. */ status = sp->exitStatus = PTHREAD_CANCELED; } - catch (ptw32_exception_exit &) + catch (__ptw32_exception_exit &) { /* * Thread was exited via pthread_exit(). @@ -304,29 +260,26 @@ 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. -#endif /* __CLEANUP_CXX */ -#endif /* __CLEANUP_C */ -#endif /* __CLEANUP_SEH */ +#endif /* __PTW32_CLEANUP_CXX */ +#endif /* __PTW32_CLEANUP_C */ +#endif /* __PTW32_CLEANUP_SEH */ -#if defined(PTW32_STATIC_LIB) +#if defined (__PTW32_STATIC_LIB) /* * 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 +287,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 (__MINGW32__) || defined (__MSVCRT__) || defined (__DMC__) _endthreadex ((unsigned)(size_t) status); #else _endthread (); @@ -350,8 +303,23 @@ ptw32_threadStart (void *vthreadParms) * Never reached. */ -#if ! (defined(__MINGW64__) || defined(__MINGW32__)) || defined (__MSVCRT__) || defined (__DMC__) +#if ! defined (__MINGW32__) || defined (__MSVCRT__) || defined (__DMC__) return (unsigned)(size_t) status; #endif -} /* ptw32_threadStart */ +} /* __ptw32_threadStart */ + +/* + * Reset optimization + */ +#ifdef _MSC_VER +# pragma optimize("", on) +#endif + +#if defined (__PTW32_USES_SEPARATE_CRT) && (defined(__PTW32_CLEANUP_CXX) || defined(__PTW32_CLEANUP_SEH)) +__ptw32_terminate_handler +pthread_win32_set_terminate_np(__ptw32_terminate_handler termFunction) +{ + return set_terminate(termFunction); +} +#endif diff --git a/vendor/pthreads/include/ptw32_throw.c b/vendor/pthreads/include/ptw32_throw.c index 1404e940f5..45337d25a4 100644 --- a/vendor/pthreads/include/ptw32_throw.c +++ b/vendor/pthreads/include/ptw32_throw.c @@ -7,76 +7,67 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" -#if defined(__CLEANUP_C) +#if defined(__PTW32_CLEANUP_C) # include #endif /* - * ptw32_throw + * __ptw32_throw * - * All canceled and explicitly exited POSIX threads go through + * All cancelled and explicitly exited POSIX threads go through * here. This routine knows how to exit both POSIX initiated threads and * 'implicit' POSIX threads for each of the possible language modes (C, * C++, and SEH). */ -#if defined(_MSC_VER) -/* - * Ignore the warning: - * "C++ exception specification ignored except to indicate that - * the function is not __declspec(nothrow)." - */ -#pragma warning(disable:4290) -#endif void -ptw32_throw (DWORD exception) -#if defined(__CLEANUP_CXX) - throw(ptw32_exception_cancel,ptw32_exception_exit) -#endif +__ptw32_throw (DWORD exception) { /* * Don't use pthread_self() to avoid creating an implicit POSIX thread handle * unnecessarily. */ - ptw32_thread_t * sp = (ptw32_thread_t *) pthread_getspecific (ptw32_selfThreadKey); + __ptw32_thread_t * sp = (__ptw32_thread_t *) pthread_getspecific (__ptw32_selfThreadKey); -#if defined(__CLEANUP_SEH) +#if defined(__PTW32_CLEANUP_SEH) DWORD exceptionInformation[3]; #endif sp->state = PThreadStateExiting; - if (exception != PTW32_EPS_CANCEL && exception != PTW32_EPS_EXIT) + if (exception != __PTW32_EPS_CANCEL && exception != __PTW32_EPS_EXIT) { /* Should never enter here */ exit (1); @@ -90,30 +81,30 @@ 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 (__MINGW32__) || 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) +#if defined (__PTW32_STATIC_LIB) pthread_win32_thread_detach_np (); #endif -#if ! (defined(__MINGW64__) || defined(__MINGW32__)) || defined (__MSVCRT__) || defined (__DMC__) +#if ! defined (__MINGW32__) || defined (__MSVCRT__) || defined (__DMC__) _endthreadex (exitCode); #else _endthread (); @@ -121,33 +112,33 @@ ptw32_throw (DWORD exception) } -#if defined(__CLEANUP_SEH) +#if defined(__PTW32_CLEANUP_SEH) exceptionInformation[0] = (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 */ +#else /* __PTW32_CLEANUP_SEH */ -#if defined(__CLEANUP_C) +#if defined(__PTW32_CLEANUP_C) - ptw32_pop_cleanup_all (1); + __ptw32_pop_cleanup_all (1); longjmp (sp->start_mark, exception); -#else /* __CLEANUP_C */ +#else /* __PTW32_CLEANUP_C */ -#if defined(__CLEANUP_CXX) +#if defined(__PTW32_CLEANUP_CXX) switch (exception) { - case PTW32_EPS_CANCEL: - throw ptw32_exception_cancel (); + case __PTW32_EPS_CANCEL: + throw __ptw32_exception_cancel (); break; - case PTW32_EPS_EXIT: - throw ptw32_exception_exit (); + case __PTW32_EPS_EXIT: + throw __ptw32_exception_exit (); break; } @@ -155,29 +146,29 @@ ptw32_throw (DWORD exception) #error ERROR [__FILE__, line __LINE__]: Cleanup type undefined. -#endif /* __CLEANUP_CXX */ +#endif /* __PTW32_CLEANUP_CXX */ -#endif /* __CLEANUP_C */ +#endif /* __PTW32_CLEANUP_C */ -#endif /* __CLEANUP_SEH */ +#endif /* __PTW32_CLEANUP_SEH */ /* Never reached */ } void -ptw32_pop_cleanup_all (int execute) +__ptw32_pop_cleanup_all (int execute) { - while (NULL != ptw32_pop_cleanup (execute)) + while (NULL != __ptw32_pop_cleanup (execute)) { } } DWORD -ptw32_get_exception_services_code (void) +__ptw32_get_exception_services_code (void) { -#if defined(__CLEANUP_SEH) +#if defined(__PTW32_CLEANUP_SEH) return EXCEPTION_PTW32_SERVICES; diff --git a/vendor/pthreads/include/ptw32_timespec.c b/vendor/pthreads/include/ptw32_timespec.c index 6318957a89..a57a6c572d 100644 --- a/vendor/pthreads/include/ptw32_timespec.c +++ b/vendor/pthreads/include/ptw32_timespec.c @@ -7,48 +7,47 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" - -#if defined(NEED_FTIME) - /* * time between jan 1, 1601 and jan 1, 1970 in units of 100 nanoseconds */ -#define PTW32_TIMESPEC_TO_FILETIME_OFFSET \ - ( ((int64_t) 27111902 << 32) + (int64_t) 3577643008 ) +#define __PTW32_TIMESPEC_TO_FILETIME_OFFSET \ + ( ((uint64_t) 27111902UL << 32) + (uint64_t) 3577643008UL ) INLINE void -ptw32_timespec_to_filetime (const struct timespec *ts, FILETIME * ft) +__ptw32_timespec_to_filetime (const struct timespec *ts, FILETIME * ft) /* * ------------------------------------------------------------------- * converts struct timespec @@ -58,12 +57,12 @@ ptw32_timespec_to_filetime (const struct timespec *ts, FILETIME * ft) * ------------------------------------------------------------------- */ { - *(int64_t *) ft = ts->tv_sec * 10000000 - + (ts->tv_nsec + 50) / 100 + PTW32_TIMESPEC_TO_FILETIME_OFFSET; + *(uint64_t *) ft = ts->tv_sec * 10000000UL + + (ts->tv_nsec + 50) / 100 + __PTW32_TIMESPEC_TO_FILETIME_OFFSET; } INLINE void -ptw32_filetime_to_timespec (const FILETIME * ft, struct timespec *ts) +__ptw32_filetime_to_timespec (const FILETIME * ft, struct timespec *ts) /* * ------------------------------------------------------------------- * converts FILETIME (as set by GetSystemTimeAsFileTime), where the time is @@ -74,10 +73,8 @@ ptw32_filetime_to_timespec (const FILETIME * ft, struct timespec *ts) */ { ts->tv_sec = - (int) ((*(int64_t *) ft - PTW32_TIMESPEC_TO_FILETIME_OFFSET) / 10000000); + (int) ((*(uint64_t *) ft - __PTW32_TIMESPEC_TO_FILETIME_OFFSET) / 10000000UL); ts->tv_nsec = - (int) ((*(int64_t *) ft - PTW32_TIMESPEC_TO_FILETIME_OFFSET - - ((int64_t) ts->tv_sec * (int64_t) 10000000)) * 100); + (int) ((*(uint64_t *) ft - __PTW32_TIMESPEC_TO_FILETIME_OFFSET - + ((uint64_t) ts->tv_sec * (uint64_t) 10000000UL)) * 100); } - -#endif /* NEED_FTIME */ diff --git a/vendor/pthreads/include/ptw32_tkAssocCreate.c b/vendor/pthreads/include/ptw32_tkAssocCreate.c index 50d6c500c3..d860a0acce 100644 --- a/vendor/pthreads/include/ptw32_tkAssocCreate.c +++ b/vendor/pthreads/include/ptw32_tkAssocCreate.c @@ -7,40 +7,42 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" int -ptw32_tkAssocCreate (ptw32_thread_t * sp, pthread_key_t key) +__ptw32_tkAssocCreate (__ptw32_thread_t * sp, pthread_key_t key) /* * ------------------------------------------------------------------- * This routine creates an association that @@ -54,7 +56,7 @@ ptw32_tkAssocCreate (ptw32_thread_t * sp, pthread_key_t key) * * Notes: * 1) New associations are pushed to the beginning of the - * chain so that the internal ptw32_selfThreadKey association + * chain so that the internal __ptw32_selfThreadKey association * is always last, thus allowing selfThreadExit to * be implicitly called last by pthread_exit. * 2) @@ -115,4 +117,4 @@ ptw32_tkAssocCreate (ptw32_thread_t * sp, pthread_key_t key) return (0); -} /* ptw32_tkAssocCreate */ +} /* __ptw32_tkAssocCreate */ diff --git a/vendor/pthreads/include/ptw32_tkAssocDestroy.c b/vendor/pthreads/include/ptw32_tkAssocDestroy.c index fedebf5935..63839ea742 100644 --- a/vendor/pthreads/include/ptw32_tkAssocDestroy.c +++ b/vendor/pthreads/include/ptw32_tkAssocDestroy.c @@ -7,40 +7,42 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" void -ptw32_tkAssocDestroy (ThreadKeyAssoc * assoc) +__ptw32_tkAssocDestroy (ThreadKeyAssoc * assoc) /* * ------------------------------------------------------------------- * This routine releases all resources for the given ThreadKeyAssoc @@ -111,4 +113,4 @@ ptw32_tkAssocDestroy (ThreadKeyAssoc * assoc) free (assoc); } -} /* ptw32_tkAssocDestroy */ +} /* __ptw32_tkAssocDestroy */ diff --git a/vendor/pthreads/include/rwlock.c b/vendor/pthreads/include/rwlock.c deleted file mode 100644 index 4a3cd2594c..0000000000 --- a/vendor/pthreads/include/rwlock.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - * rwlock.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 "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" -#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" diff --git a/vendor/pthreads/include/sched.c b/vendor/pthreads/include/sched.c deleted file mode 100644 index ed30ea7b24..0000000000 --- a/vendor/pthreads/include/sched.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - * sched.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" - -#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" diff --git a/vendor/pthreads/include/sched.h b/vendor/pthreads/include/sched.h index f36a97a66b..81630d94bc 100644 --- a/vendor/pthreads/include/sched.h +++ b/vendor/pthreads/include/sched.h @@ -3,181 +3,233 @@ * * Purpose: * Provides an implementation of POSIX realtime extensions - * as defined in + * as defined in * * POSIX 1003.1b-1993 (POSIX.1b) * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #if !defined(_SCHED_H) #define _SCHED_H +#define __SCHED_H_SOURCED__ -#undef PTW32_SCHED_LEVEL - -#if defined(_POSIX_SOURCE) -#define PTW32_SCHED_LEVEL 0 -/* Early POSIX */ -#endif +#include <_ptw32.h> -#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309 -#undef PTW32_SCHED_LEVEL -#define PTW32_SCHED_LEVEL 1 -/* Include 1b, 1c and 1d */ -#endif +/* We need a typedef for pid_t, (and POSIX requires to + * define it, as it is defined in , but it does NOT + * sanction exposure of everything from ); there is + * no pid_t in Windows anyway, (except that MinGW does define it + * in their ), so just provide a suitable typedef, + * but note that we must do so cautiously, to avoid a typedef + * conflict if MinGW's is also #included: + */ +#if ! defined __MINGW32__ || ! defined __have_typedef_pid_t -#if defined(INCLUDE_NP) -#undef PTW32_SCHED_LEVEL -#define PTW32_SCHED_LEVEL 2 -/* Include Non-Portable extensions */ +# if defined __MINGW64__ + typedef __int64 pid_t; +# else + typedef int pid_t; #endif -#define PTW32_SCHED_LEVEL_MAX 3 - -#if ( defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112 ) || !defined(PTW32_SCHED_LEVEL) -#define PTW32_SCHED_LEVEL PTW32_SCHED_LEVEL_MAX -/* Include everything */ +#if __GNUC__ < 4 +/* GCC v4.0 and later, (as used by MinGW), allows us to repeat a + * typedef, provided every duplicate is consistent; only set this + * multiple definition guard when we cannot be certain that it is + * permissable to repeat typedefs. + */ +#define __have_typedef_pid_t 1 #endif - - -#if defined(__GNUC__) && !defined(__declspec) -# error Please upgrade your GNU compiler to one that supports __declspec. #endif -/* - * When building the library, you should define PTW32_BUILD so that - * the variables/functions are exported correctly. When using the library, - * do NOT define PTW32_BUILD, and then the variables/functions will - * be imported correctly. +/* POSIX.1-1993 says that WILL expose all of */ -#if !defined(PTW32_STATIC_LIB) -# if defined(PTW32_BUILD) -# define PTW32_DLLPORT __declspec (dllexport) -# else -# define PTW32_DLLPORT __declspec (dllimport) -# endif -#else -# define PTW32_DLLPORT +#undef __SCHED_H_SOURCED__ +#if _POSIX_C_SOURCE >= 200112L +/* POSIX.1-2001 and later revises this to say only that it MAY do so; + * only struct timespec, and associated time_t are actually required, + * so prefer to be selective; (MinGW.org's offers an option + * for selective #inclusion, when __SCHED_H_SOURCED__ is defined): + */ +#define __SCHED_H_SOURCED__ +#define __need_struct_timespec +#define __need_time_t #endif - -/* - * This is a duplicate of what is in the autoconf config.h, - * which is only used when building the pthread-win32 libraries. +#include + +#if defined __MINGW64__ || _MSC_VER >= 1900 +/* These are known to define struct timespec, when has been + * #included, but may not, (probably don't), follow the convention of + * defining __struct_timespec_defined, as adopted by MinGW.org; for + * these cases, we unconditionally assume that struct timespec has + * been defined, otherwise, if MinGW.org's criterion has not been + * satisfied... */ - -#if !defined(PTW32_CONFIG_H) -# if defined(WINCE) -# define NEED_ERRNO -# define NEED_SEM -# endif -# if defined(__MINGW64__) -# define HAVE_STRUCT_TIMESPEC -# define HAVE_MODE_T -# elif defined(_UWIN) || defined(__MINGW32__) -# define HAVE_MODE_T +#elif ! defined __struct_timespec_defined +# ifndef _TIMESPEC_DEFINED +# define _TIMESPEC_DEFINED +struct timespec +{ /* ...we fall back on this explicit definition. + */ + time_t tv_sec; + int tv_nsec; +}; # endif #endif /* - * + * Microsoft VC++6.0 lacks these *_PTR types */ - -#if PTW32_SCHED_LEVEL >= PTW32_SCHED_LEVEL_MAX -#if defined(NEED_ERRNO) -#include "need_errno.h" -#else -#include -#endif -#endif /* PTW32_SCHED_LEVEL >= PTW32_SCHED_LEVEL_MAX */ - -#if (defined(__MINGW64__) || defined(__MINGW32__)) || defined(_UWIN) -# if PTW32_SCHED_LEVEL >= PTW32_SCHED_LEVEL_MAX -/* For pid_t */ -# include -/* Required by Unix 98 */ -# include -# else - typedef int pid_t; -# endif -#else - typedef int pid_t; +#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 { - SCHED_OTHER = 0, +enum +{ SCHED_OTHER = 0, SCHED_FIFO, SCHED_RR, SCHED_MIN = SCHED_OTHER, SCHED_MAX = SCHED_RR }; -struct sched_param { - int sched_priority; +struct sched_param +{ int sched_priority; }; -#if defined(__cplusplus) -extern "C" -{ -#endif /* __cplusplus */ +/* + * 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)". + * + * FIXME: These are GNU, and NOT specified by POSIX; maybe consider + * occluding them within a _GNU_SOURCE (or similar) feature test. + */ + +#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))) -PTW32_DLLPORT int __cdecl sched_yield (void); +#define CPU_XOR(destsetptr, srcset1ptr, srcset2ptr) \ + (_sched_affinitycpuxor((destsetptr),(srcset1ptr),(srcset2ptr))) -PTW32_DLLPORT int __cdecl sched_get_priority_min (int policy); +#define CPU_EQUAL(set1ptr, set2ptr) (_sched_affinitycpuequal((set1ptr),(set2ptr))) -PTW32_DLLPORT int __cdecl sched_get_priority_max (int policy); +typedef union +{ char cpuset[CPU_SETSIZE/8]; + size_t _align; +} cpu_set_t; -PTW32_DLLPORT int __cdecl sched_setscheduler (pid_t pid, int policy); +__PTW32_BEGIN_C_DECLS -PTW32_DLLPORT int __cdecl sched_getscheduler (pid_t pid); +__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); + +/* FIXME: this declaration of sched_setscheduler() is NOT as prescribed + * by POSIX; it lacks const struct sched_param * as third argument. + */ +__PTW32_DLLPORT int __PTW32_CDECL sched_setscheduler (pid_t pid, int policy); + +/* FIXME: In addition to the above five functions, POSIX also requires: + * + * int sched_getparam (pid_t, struct sched_param *); + * int sched_setparam (pid_t, const struct sched_param *); + * + * both of which are conspicuous by their absence here! + */ + +/* Compatibility with Linux - not standard in POSIX + * FIXME: consider occluding within a _GNU_SOURCE (or similar) feature test. + */ +__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); /* - * Note that this macro returns ENOTSUP rather than - * ENOSYS as might be expected. However, returning ENOSYS - * should mean that sched_get_priority_{min,max} are - * not implemented as well as sched_rr_get_interval. - * This is not the case, since we just don't support - * round-robin scheduling. Therefore I have chosen to - * return the same value as sched_setscheduler when - * SCHED_RR is passed to it. + * Support routines and macros for cpu_set_t */ -#define sched_rr_get_interval(_pid, _interval) \ - ( errno = ENOTSUP, (int) -1 ) +__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); -#if defined(__cplusplus) -} /* End of extern "C" */ -#endif /* __cplusplus */ +__PTW32_DLLPORT void __PTW32_CDECL _sched_affinitycpuand(cpu_set_t *pdestset, const cpu_set_t *psrcset1, const cpu_set_t *psrcset2); -#undef PTW32_SCHED_LEVEL -#undef PTW32_SCHED_LEVEL_MAX +__PTW32_DLLPORT void __PTW32_CDECL _sched_affinitycpuor(cpu_set_t *pdestset, const cpu_set_t *psrcset1, const cpu_set_t *psrcset2); + +__PTW32_DLLPORT void __PTW32_CDECL _sched_affinitycpuxor(cpu_set_t *pdestset, const cpu_set_t *psrcset1, const cpu_set_t *psrcset2); + +__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 ENOSYS, as + * might be expected. However, returning ENOSYS should mean that + * sched_get_priority_{min,max} are not implemented as well as + * sched_rr_get_interval. This is not the case, since we just + * don't support round-robin scheduling. Therefore I have chosen + * to return the same value as sched_setscheduler when SCHED_RR + * is passed to it. + * + * FIXME: POSIX requires this to be defined as a function; this + * macro implementation is permitted IN ADDITION to the function, + * but the macro alone is not POSIX compliant! Worse still, it + * imposes a requirement on the caller, to ensure that both the + * declaration of errno, and the definition of ENOTSUP, are in + * scope at point of call, (which it may wish to do anyway, but + * POSIX imposes no such constraint)! + */ +#define sched_rr_get_interval(_pid, _interval) \ + ( errno = ENOTSUP, (int) -1 ) -#endif /* !_SCHED_H */ +__PTW32_END_C_DECLS +#undef __SCHED_H_SOURCED__ +#endif /* !_SCHED_H */ diff --git a/vendor/pthreads/include/sched_get_priority_max.c b/vendor/pthreads/include/sched_get_priority_max.c index cabf2320a7..10c6b3ba86 100644 --- a/vendor/pthreads/include/sched_get_priority_max.c +++ b/vendor/pthreads/include/sched_get_priority_max.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" #include "sched.h" @@ -120,15 +122,15 @@ sched_get_priority_max (int policy) { if (policy < SCHED_MIN || policy > SCHED_MAX) { - errno = EINVAL; + __PTW32_SET_ERRNO(EINVAL); return -1; } #if (THREAD_PRIORITY_LOWEST > THREAD_PRIORITY_NORMAL) /* WinCE? */ - return PTW32_MAX (THREAD_PRIORITY_IDLE, THREAD_PRIORITY_TIME_CRITICAL); + return __PTW32_MAX (THREAD_PRIORITY_IDLE, THREAD_PRIORITY_TIME_CRITICAL); #else /* This is independent of scheduling policy in Win32. */ - return PTW32_MAX (THREAD_PRIORITY_IDLE, THREAD_PRIORITY_TIME_CRITICAL); + return __PTW32_MAX (THREAD_PRIORITY_IDLE, THREAD_PRIORITY_TIME_CRITICAL); #endif } diff --git a/vendor/pthreads/include/sched_get_priority_min.c b/vendor/pthreads/include/sched_get_priority_min.c index 9c4f8591e5..24eb5af68f 100644 --- a/vendor/pthreads/include/sched_get_priority_min.c +++ b/vendor/pthreads/include/sched_get_priority_min.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" #include "sched.h" @@ -121,15 +123,15 @@ sched_get_priority_min (int policy) { if (policy < SCHED_MIN || policy > SCHED_MAX) { - errno = EINVAL; + __PTW32_SET_ERRNO(EINVAL); return -1; } #if (THREAD_PRIORITY_LOWEST > THREAD_PRIORITY_NORMAL) /* WinCE? */ - return PTW32_MIN (THREAD_PRIORITY_IDLE, THREAD_PRIORITY_TIME_CRITICAL); + return __PTW32_MIN (THREAD_PRIORITY_IDLE, THREAD_PRIORITY_TIME_CRITICAL); #else /* This is independent of scheduling policy in Win32. */ - return PTW32_MIN (THREAD_PRIORITY_IDLE, THREAD_PRIORITY_TIME_CRITICAL); + return __PTW32_MIN (THREAD_PRIORITY_IDLE, THREAD_PRIORITY_TIME_CRITICAL); #endif } diff --git a/vendor/pthreads/include/sched_getscheduler.c b/vendor/pthreads/include/sched_getscheduler.c index 8769c15e5a..28995d98fe 100644 --- a/vendor/pthreads/include/sched_getscheduler.c +++ b/vendor/pthreads/include/sched_getscheduler.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" #include "sched.h" @@ -53,13 +55,11 @@ sched_getscheduler (pid_t pid) if (pid != selfPid) { HANDLE h = - OpenProcess (PROCESS_QUERY_INFORMATION, PTW32_FALSE, (DWORD) pid); + OpenProcess (PROCESS_QUERY_INFORMATION, __PTW32_FALSE, (DWORD) 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/vendor/pthreads/include/sched_setaffinity.c b/vendor/pthreads/include/sched_setaffinity.c new file mode 100644 index 0000000000..39c4c0ea07 --- /dev/null +++ b/vendor/pthreads/include/sched_setaffinity.c @@ -0,0 +1,349 @@ +/* + * sched_setaffinity.c + * + * Description: + * POSIX scheduling functions that deal with CPU affinity. + * + * -------------------------------------------------------------------------- + * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * + * The 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: + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifdef HAVE_CONFIG_H +# include +#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/vendor/pthreads/include/sched_setscheduler.c b/vendor/pthreads/include/sched_setscheduler.c index 8691316371..8d9cf72f21 100644 --- a/vendor/pthreads/include/sched_setscheduler.c +++ b/vendor/pthreads/include/sched_setscheduler.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" #include "sched.h" @@ -55,13 +57,11 @@ sched_setscheduler (pid_t pid, int policy) if (pid != selfPid) { HANDLE h = - OpenProcess (PROCESS_SET_INFORMATION, PTW32_FALSE, (DWORD) pid); + OpenProcess (PROCESS_SET_INFORMATION, __PTW32_FALSE, (DWORD) pid); 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 +71,7 @@ sched_setscheduler (pid_t pid, int policy) if (SCHED_OTHER != policy) { - errno = ENOSYS; + __PTW32_SET_ERRNO(ENOSYS); return -1; } diff --git a/vendor/pthreads/include/sched_yield.c b/vendor/pthreads/include/sched_yield.c index 6ac5ed9263..dd42272581 100644 --- a/vendor/pthreads/include/sched_yield.c +++ b/vendor/pthreads/include/sched_yield.c @@ -6,34 +6,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" #include "sched.h" diff --git a/vendor/pthreads/include/sem_close.c b/vendor/pthreads/include/sem_close.c index 6d7280f299..eef4c675b9 100644 --- a/vendor/pthreads/include/sem_close.c +++ b/vendor/pthreads/include/sem_close.c @@ -13,34 +13,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "semaphore.h" #include "implement.h" @@ -53,6 +55,6 @@ int sem_close (sem_t * sem) { - errno = ENOSYS; + __PTW32_SET_ERRNO(ENOSYS); return -1; } /* sem_close */ diff --git a/vendor/pthreads/include/sem_destroy.c b/vendor/pthreads/include/sem_destroy.c index 6c98e80b93..471741b2f3 100644 --- a/vendor/pthreads/include/sem_destroy.c +++ b/vendor/pthreads/include/sem_destroy.c @@ -13,34 +13,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "semaphore.h" #include "implement.h" @@ -48,29 +50,29 @@ int sem_destroy (sem_t * sem) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function destroys an unnamed semaphore. - * - * PARAMETERS - * sem - * pointer to an instance of sem_t - * - * DESCRIPTION - * This function destroys an unnamed semaphore. - * - * RESULTS - * 0 successfully destroyed semaphore, - * -1 failed, error in errno - * ERRNO - * EINVAL 'sem' is not a valid semaphore, - * ENOSYS semaphores are not supported, - * EBUSY threads (or processes) are currently - * blocked on 'sem' - * - * ------------------------------------------------------ - */ +/* + * ------------------------------------------------------ + * DOCPUBLIC + * This function destroys an unnamed semaphore. + * + * PARAMETERS + * sem + * pointer to an instance of sem_t + * + * DESCRIPTION + * This function destroys an unnamed semaphore. + * + * RESULTS + * 0 successfully destroyed semaphore, + * -1 failed, error in errno + * ERRNO + * EINVAL 'sem' is not a valid semaphore, + * ENOSYS semaphores are not supported, + * EBUSY threads (or processes) are currently + * blocked on 'sem' + * + * ------------------------------------------------------ + */ { int result = 0; sem_t s = NULL; @@ -81,59 +83,34 @@ sem_destroy (sem_t * sem) } else { + __ptw32_mcs_local_node_t node; s = *sem; - if ((result = pthread_mutex_lock (&s->lock)) == 0) + if ((result = __ptw32_mcs_lock_try_acquire(&s->lock, &node)) == 0) { if (s->value < 0) { - (void) pthread_mutex_unlock (&s->lock); result = EBUSY; } else { - /* There are no threads currently blocked on this semaphore. */ - + /* + * There are no threads currently blocked on this semaphore + * however there could be threads about to wait behind us. + * It is up to the application to ensure this is not the case. + */ if (!CloseHandle (s->sem)) - { - (void) pthread_mutex_unlock (&s->lock); - result = EINVAL; - } - else - { - /* - * Invalidate the semaphore handle when we have the lock. - * Other sema operations should test this after acquiring the lock - * to check that the sema is still valid, i.e. before performing any - * operations. This may only be necessary before the sema op routine - * returns so that the routine can return EINVAL - e.g. if setting - * s->value to SEM_VALUE_MAX below does force a fall-through. - */ - *sem = NULL; - - /* Prevent anyone else actually waiting on or posting this sema. - */ - s->value = SEM_VALUE_MAX; - - (void) pthread_mutex_unlock (&s->lock); - - do - { - /* Give other threads a chance to run and exit any sema op - * routines. Due to the SEM_VALUE_MAX value, if sem_post or - * sem_wait were blocked by us they should fall through. - */ - Sleep(0); - } - while (pthread_mutex_destroy (&s->lock) == EBUSY); + { + result = EINVAL; } } + __ptw32_mcs_lock_release(&node); } } if (result != 0) { - errno = result; + __PTW32_SET_ERRNO(result); return -1; } diff --git a/vendor/pthreads/include/sem_getvalue.c b/vendor/pthreads/include/sem_getvalue.c index baafb02cf0..2e043db524 100644 --- a/vendor/pthreads/include/sem_getvalue.c +++ b/vendor/pthreads/include/sem_getvalue.c @@ -13,34 +13,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "semaphore.h" #include "implement.h" @@ -48,63 +50,49 @@ int sem_getvalue (sem_t * sem, int *sval) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function stores the current count value of the - * semaphore. - * RESULTS - * - * Return value - * - * 0 sval has been set. - * -1 failed, error in errno - * - * in global errno - * - * EINVAL 'sem' is not a valid semaphore, - * ENOSYS this function is not supported, - * - * - * PARAMETERS - * - * sem pointer to an instance of sem_t - * - * sval pointer to int. - * - * DESCRIPTION - * This function stores the current count value of the semaphore - * pointed to by sem in the int pointed to by sval. - */ +/* + * ------------------------------------------------------ + * DOCPUBLIC + * This function stores the current count value of the + * semaphore. + * RESULTS + * + * Return value + * + * 0 sval has been set. + * -1 failed, error in errno + * + * in global errno + * + * EINVAL 'sem' is not a valid semaphore, + * ENOSYS this function is not supported, + * + * + * PARAMETERS + * + * sem pointer to an instance of sem_t + * + * sval pointer to int. + * + * DESCRIPTION + * This function stores the current count value of the semaphore + * pointed to by sem in the int pointed to by sval. + */ { - if (sem == NULL || *sem == NULL || sval == NULL) - { - errno = EINVAL; - return -1; - } - else - { - long value; - register sem_t s = *sem; - int result = 0; + 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; - } + __ptw32_mcs_local_node_t node; + register sem_t s = *sem; - value = s->value; - (void) pthread_mutex_unlock(&s->lock); - *sval = value; - } + __ptw32_mcs_lock_acquire(&s->lock, &node); + *sval = s->value; + __ptw32_mcs_lock_release(&node); - return result; + if (result != 0) + { + __PTW32_SET_ERRNO(result); + return -1; } + return 0; } /* sem_getvalue */ diff --git a/vendor/pthreads/include/sem_init.c b/vendor/pthreads/include/sem_init.c index f682f4b204..bd9ec30538 100644 --- a/vendor/pthreads/include/sem_init.c +++ b/vendor/pthreads/include/sem_init.c @@ -11,76 +11,78 @@ * * ------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "semaphore.h" #include "implement.h" int sem_init (sem_t * sem, int pshared, unsigned int value) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function initializes a semaphore. The - * initial value of the semaphore is 'value' - * - * PARAMETERS - * sem - * pointer to an instance of sem_t - * - * pshared - * if zero, this semaphore may only be shared between - * threads in the same process. - * if nonzero, the semaphore can be shared between - * processes - * - * value - * initial value of the semaphore counter - * - * DESCRIPTION - * This function initializes a semaphore. The - * initial value of the semaphore is set to 'value'. - * - * RESULTS - * 0 successfully created semaphore, - * -1 failed, error in errno - * ERRNO - * EINVAL 'sem' is not a valid semaphore, or - * 'value' >= SEM_VALUE_MAX - * ENOMEM out of memory, - * ENOSPC a required resource has been exhausted, - * ENOSYS semaphores are not supported, - * EPERM the process lacks appropriate privilege - * - * ------------------------------------------------------ - */ +/* + * ------------------------------------------------------ + * DOCPUBLIC + * This function initializes a semaphore. The + * initial value of the semaphore is 'value' + * + * PARAMETERS + * sem + * pointer to an instance of sem_t + * + * pshared + * if zero, this semaphore may only be shared between + * threads in the same process. + * if nonzero, the semaphore can be shared between + * processes + * + * value + * initial value of the semaphore counter + * + * DESCRIPTION + * This function initializes a semaphore. The + * initial value of the semaphore is set to 'value'. + * + * RESULTS + * 0 successfully created semaphore, + * -1 failed, error in errno + * ERRNO + * EINVAL 'sem' is not a valid semaphore, or + * 'value' >= SEM_VALUE_MAX + * ENOMEM out of memory, + * ENOSPC a required resource has been exhausted, + * ENOSYS semaphores are not supported, + * EPERM the process lacks appropriate privilege + * + * ------------------------------------------------------ + */ { int result = 0; sem_t s = NULL; @@ -102,63 +104,53 @@ sem_init (sem_t * sem, int pshared, unsigned int value) s = (sem_t) calloc (1, sizeof (*s)); if (NULL == s) - { - result = ENOMEM; - } + { + result = ENOMEM; + } else - { + { - s->value = value; - if (pthread_mutex_init(&s->lock, NULL) == 0) - { + s->value = value; + s->lock = NULL; #if defined(NEED_SEM) - s->sem = CreateEvent (NULL, - PTW32_FALSE, /* auto (not manual) reset */ - PTW32_FALSE, /* initial state is unset */ - NULL); - - if (0 == s->sem) - { - free (s); - (void) pthread_mutex_destroy(&s->lock); - result = ENOSPC; - } - else - { - s->leftToUnblock = 0; - } + s->sem = CreateEvent (NULL, + __PTW32_FALSE, /* auto (not manual) reset */ + __PTW32_FALSE, /* initial state is unset */ + NULL); + + if (0 == s->sem) + { + result = ENOSPC; + } + else + { + s->leftToUnblock = 0; + } #else /* NEED_SEM */ - if ((s->sem = CreateSemaphore (NULL, /* Always NULL */ - (long) 0, /* Force threads to wait */ - (long) SEM_VALUE_MAX, /* Maximum value */ - NULL)) == 0) /* Name */ - { - (void) pthread_mutex_destroy(&s->lock); - result = ENOSPC; - } + if ((s->sem = CreateSemaphore (NULL, /* Always NULL */ + (long) 0, /* Force threads to wait */ + (long) SEM_VALUE_MAX, /* Maximum value */ + NULL)) == 0) /* Name */ + { + result = ENOSPC; + } #endif /* NEED_SEM */ - } - else - { - result = ENOSPC; - } - - if (result != 0) - { - free(s); - } - } + if (result != 0) + { + free(s); + } + } } if (result != 0) { - errno = result; + __PTW32_SET_ERRNO(result); return -1; } diff --git a/vendor/pthreads/include/sem_open.c b/vendor/pthreads/include/sem_open.c index fb1cc541f8..68021eb54d 100644 --- a/vendor/pthreads/include/sem_open.c +++ b/vendor/pthreads/include/sem_open.c @@ -13,34 +13,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "semaphore.h" #include "implement.h" @@ -50,9 +52,14 @@ #pragma warning( disable : 4100 ) #endif -int -sem_open (const char *name, int oflag, mode_t mode, unsigned int value) +sem_t +*sem_open (const char *name, int oflag, ...) { - errno = ENOSYS; - return -1; + /* Note: this is a POSIX.1b-1993 conforming stub; POSIX.1-2001 removed + * the requirement to provide this stub, and also removed the validity + * of ENOSYS as a resultant errno state; nevertheless, it makes sense + * to retain the POSIX.1b-1993 conforming behaviour here. + */ + __PTW32_SET_ERRNO(ENOSYS); + return SEM_FAILED; } /* sem_open */ diff --git a/vendor/pthreads/include/sem_post.c b/vendor/pthreads/include/sem_post.c index 34832527b8..786c5dd544 100644 --- a/vendor/pthreads/include/sem_post.c +++ b/vendor/pthreads/include/sem_post.c @@ -13,34 +13,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "semaphore.h" #include "implement.h" @@ -48,81 +50,66 @@ int sem_post (sem_t * sem) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function posts a wakeup to a semaphore. - * - * PARAMETERS - * sem - * pointer to an instance of sem_t - * - * DESCRIPTION - * This function posts a wakeup to a semaphore. If there - * are waiting threads (or processes), one is awakened; - * otherwise, the semaphore value is incremented by one. - * - * RESULTS - * 0 successfully posted semaphore, - * -1 failed, error in errno - * ERRNO - * EINVAL 'sem' is not a valid semaphore, - * ENOSYS semaphores are not supported, - * ERANGE semaphore count is too big - * - * ------------------------------------------------------ - */ +/* + * ------------------------------------------------------ + * DOCPUBLIC + * This function posts a wakeup to a semaphore. + * + * PARAMETERS + * sem + * pointer to an instance of sem_t + * + * DESCRIPTION + * This function posts a wakeup to a semaphore. If there + * are waiting threads (or processes), one is awakened; + * otherwise, the semaphore value is incremented by one. + * + * RESULTS + * 0 successfully posted semaphore, + * -1 failed, error in errno + * ERRNO + * EINVAL 'sem' is not a valid semaphore, + * ENOSYS semaphores are not supported, + * ERANGE semaphore count is too big + * + * ------------------------------------------------------ + */ { int result = 0; + + __ptw32_mcs_local_node_t node; sem_t s = *sem; - if (s == NULL) - { - result = EINVAL; - } - else if ((result = pthread_mutex_lock (&s->lock)) == 0) + __ptw32_mcs_lock_acquire(&s->lock, &node); + if (s->value < SEM_VALUE_MAX) { - /* See sem_destroy.c - */ - if (*sem == NULL) +#if defined(NEED_SEM) + if (++s->value <= 0 + && !SetEvent(s->sem)) { - (void) pthread_mutex_unlock (&s->lock); + s->value--; result = EINVAL; - return -1; } - - 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; + } + __ptw32_mcs_lock_release(&node); if (result != 0) { - errno = result; + __PTW32_SET_ERRNO(result); return -1; } return 0; - -} /* sem_post */ +} diff --git a/vendor/pthreads/include/sem_post_multiple.c b/vendor/pthreads/include/sem_post_multiple.c index 44c168c6cf..a7a78df636 100644 --- a/vendor/pthreads/include/sem_post_multiple.c +++ b/vendor/pthreads/include/sem_post_multiple.c @@ -13,34 +13,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "semaphore.h" #include "implement.h" @@ -48,95 +50,81 @@ int sem_post_multiple (sem_t * sem, int count) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function posts multiple wakeups to a semaphore. - * - * PARAMETERS - * sem - * pointer to an instance of sem_t - * - * count - * counter, must be greater than zero. - * - * DESCRIPTION - * This function posts multiple wakeups to a semaphore. If there - * are waiting threads (or processes), n <= count are awakened; - * the semaphore value is incremented by count - n. - * - * RESULTS - * 0 successfully posted semaphore, - * -1 failed, error in errno - * ERRNO - * EINVAL 'sem' is not a valid semaphore - * or count is less than or equal to zero. - * ERANGE semaphore count is too big - * - * ------------------------------------------------------ - */ +/* + * ------------------------------------------------------ + * DOCPUBLIC + * This function posts multiple wakeups to a semaphore. + * + * PARAMETERS + * sem + * pointer to an instance of sem_t + * + * count + * counter, must be greater than zero. + * + * DESCRIPTION + * This function posts multiple wakeups to a semaphore. If there + * are waiting threads (or processes), n <= count are awakened; + * the semaphore value is incremented by count - n. + * + * RESULTS + * 0 successfully posted semaphore, + * -1 failed, error in errno + * ERRNO + * EINVAL 'sem' is not a valid semaphore + * or count is less than or equal to zero. + * ERANGE semaphore count is too big + * + * ------------------------------------------------------ + */ { + __ptw32_mcs_local_node_t node; int result = 0; long waiters; sem_t s = *sem; - if (s == NULL || count <= 0) - { - result = EINVAL; - } - else if ((result = pthread_mutex_lock (&s->lock)) == 0) + __ptw32_mcs_lock_acquire(&s->lock, &node); + + if (s->value <= (SEM_VALUE_MAX - count)) { - /* See sem_destroy.c - */ - if (*sem == NULL) + waiters = -s->value; + s->value += count; + if (waiters > 0) { - (void) pthread_mutex_unlock (&s->lock); - result = EINVAL; - return -1; - } - - if (s->value <= (SEM_VALUE_MAX - count)) - { - waiters = -s->value; - s->value += count; - if (waiters > 0) - { #if defined(NEED_SEM) - if (SetEvent(s->sem)) - { - waiters--; - s->leftToUnblock += count - 1; - if (s->leftToUnblock > waiters) - { - s->leftToUnblock = waiters; - } - } + if (SetEvent(s->sem)) + { + waiters--; + s->leftToUnblock += count - 1; + if (s->leftToUnblock > waiters) + { + s->leftToUnblock = waiters; + } + } #else - if (ReleaseSemaphore (s->sem, (waiters<=count)?waiters:count, 0)) - { - /* No action */ - } + if (ReleaseSemaphore (s->sem, (waiters<=count)?waiters:count, 0)) + { + /* No action */ + } #endif - else - { - s->value -= count; - result = EINVAL; - } - } - } - else - { - result = ERANGE; - } - (void) pthread_mutex_unlock (&s->lock); + else + { + s->value -= count; + result = EINVAL; + } + } } + else + { + result = ERANGE; + } + __ptw32_mcs_lock_release(&node); if (result != 0) { - errno = result; + __PTW32_SET_ERRNO(result); return -1; } return 0; - -} /* sem_post_multiple */ +} diff --git a/vendor/pthreads/include/sem_timedwait.c b/vendor/pthreads/include/sem_timedwait.c index 638431cf1f..5b22e8639b 100644 --- a/vendor/pthreads/include/sem_timedwait.c +++ b/vendor/pthreads/include/sem_timedwait.c @@ -13,34 +13,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "semaphore.h" #include "implement.h" @@ -52,183 +54,156 @@ typedef struct { } sem_timedwait_cleanup_args_t; -static void PTW32_CDECL -ptw32_sem_timedwait_cleanup (void * args) +static void __PTW32_CDECL +__ptw32_sem_timedwait_cleanup (void * args) { + __ptw32_mcs_local_node_t node; sem_timedwait_cleanup_args_t * a = (sem_timedwait_cleanup_args_t *)args; sem_t s = a->sem; - if (pthread_mutex_lock (&s->lock) == 0) + __ptw32_mcs_lock_acquire(&s->lock, &node); + /* + * We either timed out or were cancelled. + * If someone has posted between then and now we try to take the semaphore. + * Otherwise the semaphore count may be wrong after we + * return. In the case of a cancellation, it is as if we + * were cancelled just before we return (after taking the semaphore) + * which is ok. + */ + if (WaitForSingleObject(s->sem, 0) == WAIT_OBJECT_0) { - /* - * We either timed out or were cancelled. - * If someone has posted between then and now we try to take the semaphore. - * Otherwise the semaphore count may be wrong after we - * return. In the case of a cancellation, it is as if we - * were cancelled just before we return (after taking the semaphore) - * which is ok. - */ - if (WaitForSingleObject(s->sem, 0) == WAIT_OBJECT_0) - { - /* We got the semaphore on the second attempt */ - *(a->resultPtr) = 0; - } - else - { - /* Indicate we're no longer waiting */ - s->value++; + /* We got the semaphore on the second attempt */ + *(a->resultPtr) = 0; + } + else + { + /* Indicate we're no longer waiting */ + s->value++; #if defined(NEED_SEM) - if (s->value > 0) - { - s->leftToUnblock = 0; - } + if (s->value > 0) + { + s->leftToUnblock = 0; + } #else - /* - * Don't release the W32 sema, it doesn't need adjustment - * because it doesn't record the number of waiters. - */ + /* + * Don't release the W32 sema, it doesn't need adjustment + * because it doesn't record the number of waiters. + */ #endif - } - (void) pthread_mutex_unlock (&s->lock); } + __ptw32_mcs_lock_release(&node); } int sem_timedwait (sem_t * sem, const struct timespec *abstime) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function waits on a semaphore possibly until - * 'abstime' time. - * - * PARAMETERS - * sem - * pointer to an instance of sem_t - * - * abstime - * pointer to an instance of struct timespec - * - * DESCRIPTION - * This function waits on a semaphore. If the - * semaphore value is greater than zero, it decreases - * its value by one. If the semaphore value is zero, then - * the calling thread (or process) is blocked until it can - * successfully decrease the value or until interrupted by - * a signal. - * - * If 'abstime' is a NULL pointer then this function will - * block until it can successfully decrease the value or - * until interrupted by a signal. - * - * RESULTS - * 0 successfully decreased semaphore, - * -1 failed, error in errno - * ERRNO - * EINVAL 'sem' is not a valid semaphore, - * ENOSYS semaphores are not supported, - * EINTR the function was interrupted by a signal, - * EDEADLK a deadlock condition was detected. - * ETIMEDOUT abstime elapsed before success. - * - * ------------------------------------------------------ - */ +/* + * ------------------------------------------------------ + * DOCPUBLIC + * This function waits on a semaphore possibly until + * 'abstime' time. + * + * PARAMETERS + * sem + * pointer to an instance of sem_t + * + * abstime + * pointer to an instance of struct timespec + * + * DESCRIPTION + * This function waits on a semaphore. If the + * semaphore value is greater than zero, it decreases + * its value by one. If the semaphore value is zero, then + * the calling thread (or process) is blocked until it can + * successfully decrease the value or until interrupted by + * a signal. + * + * If 'abstime' is a NULL pointer then this function will + * block until it can successfully decrease the value or + * until interrupted by a signal. + * + * RESULTS + * 0 successfully decreased semaphore, + * -1 failed, error in errno + * ERRNO + * EINVAL 'sem' is not a valid semaphore, + * ENOSYS semaphores are not supported, + * EINTR the function was interrupted by a signal, + * EDEADLK a deadlock condition was detected. + * ETIMEDOUT abstime elapsed before success. + * + * ------------------------------------------------------ + */ { + __ptw32_mcs_local_node_t node; + DWORD milliseconds; + int v; int result = 0; sem_t s = *sem; pthread_testcancel(); - if (sem == NULL) + if (abstime == NULL) { - result = EINVAL; + milliseconds = INFINITE; } else { - DWORD milliseconds; - - if (abstime == NULL) - { - milliseconds = INFINITE; - } - else - { - /* - * Calculate timeout as milliseconds from current system time. - */ - milliseconds = ptw32_relmillisecs (abstime); - } - - if ((result = pthread_mutex_lock (&s->lock)) == 0) - { - int v; - - /* See sem_destroy.c - */ - if (*sem == NULL) - { - (void) pthread_mutex_unlock (&s->lock); - errno = EINVAL; - return -1; - } - - v = --s->value; - (void) pthread_mutex_unlock (&s->lock); - - if (v < 0) - { + /* + * Calculate timeout as milliseconds from current system time. + */ + milliseconds = __ptw32_relmillisecs (abstime); + } + + __ptw32_mcs_lock_acquire(&s->lock, &node); + v = --s->value; + __ptw32_mcs_lock_release(&node); + + if (v < 0) + { #if defined(NEED_SEM) - int timedout; + int timedout; #endif - sem_timedwait_cleanup_args_t cleanup_args; + sem_timedwait_cleanup_args_t cleanup_args; - cleanup_args.sem = s; - cleanup_args.resultPtr = &result; + 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 */ - pthread_cleanup_push(ptw32_sem_timedwait_cleanup, (void *) &cleanup_args); + /* Must wait */ + pthread_cleanup_push(__ptw32_sem_timedwait_cleanup, (void *) &cleanup_args); #if defined(NEED_SEM) - timedout = + timedout = #endif - result = pthreadCancelableTimedWait (s->sem, milliseconds); - pthread_cleanup_pop(result); -#if defined(_MSC_VER) && _MSC_VER < 1400 + result = pthreadCancelableTimedWait (s->sem, milliseconds); + pthread_cleanup_pop(result); +#if defined (__PTW32_CONFIG_MSVC7) #pragma inline_depth() #endif #if defined(NEED_SEM) - if (!timedout && pthread_mutex_lock (&s->lock) == 0) - { - if (*sem == NULL) - { - (void) pthread_mutex_unlock (&s->lock); - errno = EINVAL; - return -1; - } - - if (s->leftToUnblock > 0) - { - --s->leftToUnblock; - SetEvent(s->sem); - } - (void) pthread_mutex_unlock (&s->lock); - } + if (!timedout) + { + __ptw32_mcs_lock_acquire(&s->lock, &node); + if (s->leftToUnblock > 0) + { + --s->leftToUnblock; + SetEvent(s->sem); + } + __ptw32_mcs_lock_release(&node); + } #endif /* NEED_SEM */ - } - } - } if (result != 0) { - errno = result; + __PTW32_SET_ERRNO(result); return -1; } diff --git a/vendor/pthreads/include/sem_trywait.c b/vendor/pthreads/include/sem_trywait.c index 63614ba2b8..a0e1cd12b6 100644 --- a/vendor/pthreads/include/sem_trywait.c +++ b/vendor/pthreads/include/sem_trywait.c @@ -13,34 +13,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "semaphore.h" #include "implement.h" @@ -48,67 +50,54 @@ int sem_trywait (sem_t * sem) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function tries to wait on a semaphore. - * - * PARAMETERS - * sem - * pointer to an instance of sem_t - * - * DESCRIPTION - * This function tries to wait on a semaphore. If the - * semaphore value is greater than zero, it decreases - * its value by one. If the semaphore value is zero, then - * this function returns immediately with the error EAGAIN - * - * RESULTS - * 0 successfully decreased semaphore, - * -1 failed, error in errno - * ERRNO - * EAGAIN the semaphore was already locked, - * EINVAL 'sem' is not a valid semaphore, - * ENOTSUP sem_trywait is not supported, - * EINTR the function was interrupted by a signal, - * EDEADLK a deadlock condition was detected. - * - * ------------------------------------------------------ - */ +/* + * ------------------------------------------------------ + * DOCPUBLIC + * This function tries to wait on a semaphore. + * + * PARAMETERS + * sem + * pointer to an instance of sem_t + * + * DESCRIPTION + * This function tries to wait on a semaphore. If the + * semaphore value is greater than zero, it decreases + * its value by one. If the semaphore value is zero, then + * this function returns immediately with the error EAGAIN + * + * RESULTS + * 0 successfully decreased semaphore, + * -1 failed, error in errno + * ERRNO + * EAGAIN the semaphore was already locked, + * EINVAL 'sem' is not a valid semaphore, + * ENOTSUP sem_trywait is not supported, + * EINTR the function was interrupted by a signal, + * EDEADLK a deadlock condition was detected. + * + * ------------------------------------------------------ + */ { int result = 0; sem_t s = *sem; + __ptw32_mcs_local_node_t node; - if (s == NULL) + __ptw32_mcs_lock_acquire(&s->lock, &node); + + if (s->value > 0) { - result = EINVAL; + s->value--; } - else if ((result = pthread_mutex_lock (&s->lock)) == 0) + else { - /* See sem_destroy.c - */ - if (*sem == NULL) - { - (void) pthread_mutex_unlock (&s->lock); - errno = EINVAL; - return -1; - } - - if (s->value > 0) - { - s->value--; - } - else - { - result = EAGAIN; - } - - (void) pthread_mutex_unlock (&s->lock); + result = EAGAIN; } + __ptw32_mcs_lock_release(&node); + if (result != 0) { - errno = result; + __PTW32_SET_ERRNO(result); return -1; } diff --git a/vendor/pthreads/include/sem_unlink.c b/vendor/pthreads/include/sem_unlink.c index fb80569a0a..f14fff1bc9 100644 --- a/vendor/pthreads/include/sem_unlink.c +++ b/vendor/pthreads/include/sem_unlink.c @@ -13,34 +13,36 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "semaphore.h" #include "implement.h" @@ -53,6 +55,6 @@ int sem_unlink (const char *name) { - errno = ENOSYS; + __PTW32_SET_ERRNO(ENOSYS); return -1; } /* sem_unlink */ diff --git a/vendor/pthreads/include/sem_wait.c b/vendor/pthreads/include/sem_wait.c index 50c11d8080..bceea5ab5e 100644 --- a/vendor/pthreads/include/sem_wait.c +++ b/vendor/pthreads/include/sem_wait.c @@ -13,172 +13,148 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "semaphore.h" #include "implement.h" -static void PTW32_CDECL -ptw32_sem_wait_cleanup(void * sem) +static void __PTW32_CDECL +__ptw32_sem_wait_cleanup(void * sem) { sem_t s = (sem_t) sem; - - if (pthread_mutex_lock (&s->lock) == 0) + __ptw32_mcs_local_node_t node; + + __ptw32_mcs_lock_acquire(&s->lock, &node); + /* + * If sema is destroyed do nothing, otherwise:- + * If the sema is posted between us being canceled and us locking + * the sema again above then we need to consume that post but cancel + * anyway. If we don't get the semaphore we indicate that we're no + * longer waiting. + */ + if (*((sem_t *)sem) != NULL && !(WaitForSingleObject(s->sem, 0) == WAIT_OBJECT_0)) { - /* - * If sema is destroyed do nothing, otherwise:- - * If the sema is posted between us being cancelled and us locking - * the sema again above then we need to consume that post but cancel - * anyway. If we don't get the semaphore we indicate that we're no - * longer waiting. - */ - if (*((sem_t *)sem) != NULL && !(WaitForSingleObject(s->sem, 0) == WAIT_OBJECT_0)) - { - ++s->value; + ++s->value; #if defined(NEED_SEM) - if (s->value > 0) - { - s->leftToUnblock = 0; - } + if (s->value > 0) + { + s->leftToUnblock = 0; + } #else - /* - * Don't release the W32 sema, it doesn't need adjustment - * because it doesn't record the number of waiters. - */ + /* + * Don't release the W32 sema, it doesn't need adjustment + * because it doesn't record the number of waiters. + */ #endif /* NEED_SEM */ - } - (void) pthread_mutex_unlock (&s->lock); } + __ptw32_mcs_lock_release(&node); } int sem_wait (sem_t * sem) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function waits on a semaphore. - * - * PARAMETERS - * sem - * pointer to an instance of sem_t - * - * DESCRIPTION - * This function waits on a semaphore. If the - * semaphore value is greater than zero, it decreases - * its value by one. If the semaphore value is zero, then - * the calling thread (or process) is blocked until it can - * successfully decrease the value or until interrupted by - * a signal. - * - * RESULTS - * 0 successfully decreased semaphore, - * -1 failed, error in errno - * ERRNO - * EINVAL 'sem' is not a valid semaphore, - * ENOSYS semaphores are not supported, - * EINTR the function was interrupted by a signal, - * EDEADLK a deadlock condition was detected. - * - * ------------------------------------------------------ - */ +/* + * ------------------------------------------------------ + * DOCPUBLIC + * This function waits on a semaphore. + * + * PARAMETERS + * sem + * pointer to an instance of sem_t + * + * DESCRIPTION + * This function waits on a semaphore. If the + * semaphore value is greater than zero, it decreases + * its value by one. If the semaphore value is zero, then + * the calling thread (or process) is blocked until it can + * successfully decrease the value or until interrupted by + * a signal. + * + * RESULTS + * 0 successfully decreased semaphore, + * -1 failed, error in errno + * ERRNO + * EINVAL 'sem' is not a valid semaphore, + * ENOSYS semaphores are not supported, + * EINTR the function was interrupted by a signal, + * EDEADLK a deadlock condition was detected. + * + * ------------------------------------------------------ + */ { + __ptw32_mcs_local_node_t node; + int v; int result = 0; sem_t s = *sem; pthread_testcancel(); - if (s == NULL) - { - result = EINVAL; - } - else - { - if ((result = pthread_mutex_lock (&s->lock)) == 0) - { - int v; - - /* See sem_destroy.c - */ - if (*sem == NULL) - { - (void) pthread_mutex_unlock (&s->lock); - errno = EINVAL; - return -1; - } - - v = --s->value; - (void) pthread_mutex_unlock (&s->lock); + __ptw32_mcs_lock_acquire(&s->lock, &node); + v = --s->value; + __ptw32_mcs_lock_release(&node); - if (v < 0) - { -#if defined(_MSC_VER) && _MSC_VER < 1400 + if (v < 0) + { +#if defined (__PTW32_CONFIG_MSVC7) #pragma inline_depth(0) #endif - /* Must wait */ - pthread_cleanup_push(ptw32_sem_wait_cleanup, (void *) s); - 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 + /* Must wait */ + pthread_cleanup_push(__ptw32_sem_wait_cleanup, (void *) s); + result = pthreadCancelableWait (s->sem); + /* Cleanup if we're canceled or on any other error */ + pthread_cleanup_pop(result); +#if defined (__PTW32_CONFIG_MSVC7) #pragma inline_depth() #endif - } + } #if defined(NEED_SEM) - if (!result && pthread_mutex_lock (&s->lock) == 0) - { - if (*sem == NULL) - { - (void) pthread_mutex_unlock (&s->lock); - errno = EINVAL; - return -1; - } - - if (s->leftToUnblock > 0) - { - --s->leftToUnblock; - SetEvent(s->sem); - } - (void) pthread_mutex_unlock (&s->lock); - } + if (!result) + { + __ptw32_mcs_lock_acquire(&s->lock, &node); + + if (s->leftToUnblock > 0) + { + --s->leftToUnblock; + SetEvent(s->sem); + } + __ptw32_mcs_lock_release(&node); + } #endif /* NEED_SEM */ - } - - } - if (result != 0) { - errno = result; + __PTW32_SET_ERRNO(result); return -1; } diff --git a/vendor/pthreads/include/semaphore.c b/vendor/pthreads/include/semaphore.c deleted file mode 100644 index 64fc0e366d..0000000000 --- a/vendor/pthreads/include/semaphore.c +++ /dev/null @@ -1,69 +0,0 @@ -/* - * ------------------------------------------------------------- - * - * Module: semaphore.c - * - * Purpose: - * Concatenated version of separate modules to allow - * inlining optimisation, which it is assumed can only - * be effective within a single module. - * - * Semaphores aren't actually part of the PThreads standard. - * They are defined by the POSIX Standard: - * - * POSIX 1003.1b-1993 (POSIX.1b) - * - * ------------------------------------------------------------- - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX 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_FTIME) -# include -#endif - -#include - -#include "pthread.h" -#include "semaphore.h" -#include "implement.h" - - -#include "sem_init.c" -#include "sem_destroy.c" -#include "sem_trywait.c" -#include "sem_wait.c" -#include "sem_timedwait.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" diff --git a/vendor/pthreads/include/semaphore.h b/vendor/pthreads/include/semaphore.h index c6e9407e25..f3eaa1890c 100644 --- a/vendor/pthreads/include/semaphore.h +++ b/vendor/pthreads/include/semaphore.h @@ -9,161 +9,108 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #if !defined( SEMAPHORE_H ) #define SEMAPHORE_H -#undef PTW32_SEMAPHORE_LEVEL - -#if defined(_POSIX_SOURCE) -#define PTW32_SEMAPHORE_LEVEL 0 -/* Early POSIX */ -#endif - -#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309 -#undef PTW32_SEMAPHORE_LEVEL -#define PTW32_SEMAPHORE_LEVEL 1 -/* Include 1b, 1c and 1d */ -#endif - -#if defined(INCLUDE_NP) -#undef PTW32_SEMAPHORE_LEVEL -#define PTW32_SEMAPHORE_LEVEL 2 -/* Include Non-Portable extensions */ -#endif - -#define PTW32_SEMAPHORE_LEVEL_MAX 3 - -#if !defined(PTW32_SEMAPHORE_LEVEL) -#define PTW32_SEMAPHORE_LEVEL PTW32_SEMAPHORE_LEVEL_MAX -/* Include everything */ -#endif - -#if defined(__GNUC__) && ! defined (__declspec) -# error Please upgrade your GNU compiler to one that supports __declspec. -#endif - -/* - * When building the library, you should define PTW32_BUILD so that - * the variables/functions are exported correctly. When using the library, - * do NOT define PTW32_BUILD, and then the variables/functions will - * be imported correctly. - */ -#if !defined(PTW32_STATIC_LIB) -# if defined(PTW32_BUILD) -# define PTW32_DLLPORT __declspec (dllexport) -# else -# define PTW32_DLLPORT __declspec (dllimport) -# endif -#else -# define PTW32_DLLPORT -#endif - -/* - * This is a duplicate of what is in the autoconf config.h, - * which is only used when building the pthread-win32 libraries. - */ - -#if !defined(PTW32_CONFIG_H) -# if defined(WINCE) -# define NEED_ERRNO -# define NEED_SEM -# endif -# if defined(__MINGW64__) -# define HAVE_STRUCT_TIMESPEC -# define HAVE_MODE_T -# elif defined(_UWIN) || defined(__MINGW32__) -# define HAVE_MODE_T -# endif -#endif - -/* +/* FIXME: POSIX.1 says that _POSIX_SEMAPHORES should be defined + * in , not here; for later POSIX.1 versions, its value + * should match the corresponding _POSIX_VERSION number, but in + * the case of POSIX.1b-1993, the value is unspecified. * + * Notwithstanding the above, since POSIX semaphores, (and indeed + * having any to #include), are not a standard feature + * on MS-Windows, it is convenient to retain this definition here; + * we may consider adding a hook, to make it selectively available + * for inclusion by , in those cases (e.g. MinGW) where + * is provided. */ - -#if PTW32_SEMAPHORE_LEVEL >= PTW32_SEMAPHORE_LEVEL_MAX -#if defined(NEED_ERRNO) -#include "need_errno.h" -#else -#include -#endif -#endif /* PTW32_SEMAPHORE_LEVEL >= PTW32_SEMAPHORE_LEVEL_MAX */ - #define _POSIX_SEMAPHORES -#if defined(__cplusplus) -extern "C" -{ -#endif /* __cplusplus */ - -#if !defined(HAVE_MODE_T) -typedef unsigned int mode_t; -#endif +/* Internal macros, common to the public interfaces for various + * pthreads-win32 components, are defined in <_ptw32.h>; we must + * include them here. + */ +#include <_ptw32.h> +/* The sem_timedwait() function was added in POSIX.1-2001; it + * requires struct timespec to be defined, at least as a partial + * (a.k.a. incomplete) data type. Forward declare it as such, + * then include selectively, to acquire a complete + * definition, (if available). + */ +struct timespec; +#define __need_struct_timespec +#include +/* The data type used to represent our semaphore implementation, + * as required by POSIX.1; FIXME: consider renaming the underlying + * structure tag, to avoid possible pollution of user namespace. + */ typedef struct sem_t_ * sem_t; -PTW32_DLLPORT int __cdecl sem_init (sem_t * sem, - int pshared, - unsigned int value); +/* POSIX.1b (and later) mandates SEM_FAILED as the value to be + * returned on failure of sem_open(); (our implementation is a + * stub, which will always return this). + */ +#define SEM_FAILED (sem_t *)(-1) + +__PTW32_BEGIN_C_DECLS -PTW32_DLLPORT int __cdecl sem_destroy (sem_t * sem); +/* Function prototypes: some are implemented as stubs, which + * always fail; (FIXME: identify them). + */ +__PTW32_DLLPORT int __PTW32_CDECL sem_init (sem_t * sem, + int pshared, + unsigned int value); -PTW32_DLLPORT int __cdecl sem_trywait (sem_t * sem); +__PTW32_DLLPORT int __PTW32_CDECL sem_destroy (sem_t * sem); -PTW32_DLLPORT int __cdecl sem_wait (sem_t * sem); +__PTW32_DLLPORT int __PTW32_CDECL sem_trywait (sem_t * sem); -PTW32_DLLPORT int __cdecl sem_timedwait (sem_t * sem, - const struct timespec * abstime); +__PTW32_DLLPORT int __PTW32_CDECL sem_wait (sem_t * sem); -PTW32_DLLPORT int __cdecl sem_post (sem_t * sem); +__PTW32_DLLPORT int __PTW32_CDECL sem_timedwait (sem_t * sem, + const struct timespec * abstime); -PTW32_DLLPORT int __cdecl sem_post_multiple (sem_t * sem, - int count); +__PTW32_DLLPORT int __PTW32_CDECL sem_post (sem_t * sem); -PTW32_DLLPORT int __cdecl sem_open (const char * name, - int oflag, - mode_t mode, - unsigned int value); +__PTW32_DLLPORT int __PTW32_CDECL sem_post_multiple (sem_t * sem, + int count); -PTW32_DLLPORT int __cdecl sem_close (sem_t * sem); +__PTW32_DLLPORT sem_t * __PTW32_CDECL sem_open (const char *, int, ...); -PTW32_DLLPORT int __cdecl sem_unlink (const char * name); +__PTW32_DLLPORT int __PTW32_CDECL sem_close (sem_t * sem); -PTW32_DLLPORT int __cdecl sem_getvalue (sem_t * sem, - int * sval); +__PTW32_DLLPORT int __PTW32_CDECL sem_unlink (const char * name); -#if defined(__cplusplus) -} /* End of extern "C" */ -#endif /* __cplusplus */ +__PTW32_DLLPORT int __PTW32_CDECL sem_getvalue (sem_t * sem, + int * sval); -#undef PTW32_SEMAPHORE_LEVEL -#undef PTW32_SEMAPHORE_LEVEL_MAX +__PTW32_END_C_DECLS #endif /* !SEMAPHORE_H */ diff --git a/vendor/pthreads/include/signal.c b/vendor/pthreads/include/signal.c index eef466962b..86b6947cb2 100644 --- a/vendor/pthreads/include/signal.c +++ b/vendor/pthreads/include/signal.c @@ -6,32 +6,30 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ /* @@ -44,7 +42,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). * @@ -68,7 +66,7 @@ * structures. * * pthread_kill() eventually calls a routine similar to - * ptw32_cancel_thread() which manipulates the target + * __ptw32_cancel_thread() which manipulates the target * threads processor context to cause the thread to * run the handler launcher routine. pthread_kill() must * save the target threads current context so that the @@ -81,18 +79,22 @@ * pthread_t structure. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" #if defined(HAVE_SIGSET_T) static void -ptw32_signal_thread () +__ptw32_signal_thread () { } static void -ptw32_signal_callhandler () +__ptw32_signal_callhandler () { } diff --git a/vendor/pthreads/include/spin.c b/vendor/pthreads/include/spin.c deleted file mode 100644 index 41b5aa5251..0000000000 --- a/vendor/pthreads/include/spin.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * spin.c - * - * Description: - * This translation unit implements spin 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 "pthread.h" -#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" -#include "pthread_spin_unlock.c" -#include "pthread_spin_trylock.c" diff --git a/vendor/pthreads/include/sync.c b/vendor/pthreads/include/sync.c deleted file mode 100644 index 5e56fa9a1f..0000000000 --- a/vendor/pthreads/include/sync.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - * sync.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,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 "pthread_detach.c" -#include "pthread_join.c" diff --git a/vendor/pthreads/include/tsd.c b/vendor/pthreads/include/tsd.c deleted file mode 100644 index ed44fe6cb4..0000000000 --- a/vendor/pthreads/include/tsd.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * tsd.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" - - -#include "pthread_key_create.c" -#include "pthread_key_delete.c" -#include "pthread_setspecific.c" -#include "pthread_getspecific.c" diff --git a/vendor/pthreads/include/version.rc b/vendor/pthreads/include/version.rc deleted file mode 100644 index 02ade072fa..0000000000 --- a/vendor/pthreads/include/version.rc +++ /dev/null @@ -1,394 +0,0 @@ -/* 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 -#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(__MINGW64__) -# define PTW32_ARCH "x64 (mingw64)" -#elif defined (__MINGW32__) -# define PTW32_ARCH "x86 (mingw32)" -#endif -#if defined(PTW32_ARCHx64) -# define PTW32_ARCH "x64" -#elif defined(PTW32_ARCHx86) -# define PTW32_ARCH "x86" -#endif - -#if defined(PTW32_RC_MSC) -# 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(__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(__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(__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/vendor/pthreads/include/w32_CancelableWait.c b/vendor/pthreads/include/w32_CancelableWait.c index 070633e0f9..72a0f183ff 100644 --- a/vendor/pthreads/include/w32_CancelableWait.c +++ b/vendor/pthreads/include/w32_CancelableWait.c @@ -6,46 +6,48 @@ * * -------------------------------------------------------------------------- * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * * The 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 + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "pthread.h" #include "implement.h" static INLINE int -ptw32_cancelable_wait (HANDLE waitHandle, DWORD timeout) +__ptw32_cancelable_wait (HANDLE waitHandle, DWORD timeout) /* * ------------------------------------------------------------------- * This provides an extra hook into the pthread_cancel * mechanism that will allow you to wait on a Windows handle and make it a * cancellation point. This function blocks until the given WIN32 handle is - * signaled or pthread_cancel has been called. It is implemented using + * signalled or pthread_cancel has been called. It is implemented using * WaitForMultipleObjects on 'waitHandle' and a manually reset WIN32 * event used to implement pthread_cancel. * @@ -56,7 +58,7 @@ ptw32_cancelable_wait (HANDLE waitHandle, DWORD timeout) { int result; pthread_t self; - ptw32_thread_t * sp; + __ptw32_thread_t * sp; HANDLE handles[2]; DWORD nHandles = 1; DWORD status; @@ -64,7 +66,7 @@ ptw32_cancelable_wait (HANDLE waitHandle, DWORD timeout) handles[0] = waitHandle; self = pthread_self(); - sp = (ptw32_thread_t *) self.p; + sp = (__ptw32_thread_t *) self.p; if (sp != NULL) { @@ -85,7 +87,7 @@ ptw32_cancelable_wait (HANDLE waitHandle, DWORD timeout) handles[1] = NULL; } - status = WaitForMultipleObjects (nHandles, handles, PTW32_FALSE, timeout); + status = WaitForMultipleObjects (nHandles, handles, __PTW32_FALSE, timeout); switch (status - WAIT_OBJECT_0) { @@ -103,29 +105,29 @@ ptw32_cancelable_wait (HANDLE waitHandle, DWORD timeout) case 1: /* * Got cancel request. - * In the event that both handles are signaled, the cancel will + * In the event that both handles are signalled, the cancel will * be ignored (see case 0 comment). */ ResetEvent (handles[1]); if (sp != NULL) { - ptw32_mcs_local_node_t stateLock; + __ptw32_mcs_local_node_t stateLock; /* - * Should handle POSIX and implicit POSIX threads.. - * Make sure we haven't been async-canceled in the meantime. + * Should handle POSIX and implicit POSIX threads. + * Make sure we haven't been async-cancelled in the meantime. */ - ptw32_mcs_lock_acquire (&sp->stateLock, &stateLock); + __ptw32_mcs_lock_acquire (&sp->stateLock, &stateLock); if (sp->state < PThreadStateCanceling) { sp->state = PThreadStateCanceling; sp->cancelState = PTHREAD_CANCEL_DISABLE; - ptw32_mcs_lock_release (&stateLock); - ptw32_throw (PTW32_EPS_CANCEL); + __ptw32_mcs_lock_release (&stateLock); + __ptw32_throw (__PTW32_EPS_CANCEL); /* Never reached */ } - ptw32_mcs_lock_release (&stateLock); + __ptw32_mcs_lock_release (&stateLock); } /* Should never get to here. */ @@ -151,11 +153,11 @@ ptw32_cancelable_wait (HANDLE waitHandle, DWORD timeout) int pthreadCancelableWait (HANDLE waitHandle) { - return (ptw32_cancelable_wait (waitHandle, INFINITE)); + return (__ptw32_cancelable_wait (waitHandle, INFINITE)); } int pthreadCancelableTimedWait (HANDLE waitHandle, DWORD timeout) { - return (ptw32_cancelable_wait (waitHandle, timeout)); + return (__ptw32_cancelable_wait (waitHandle, timeout)); } diff --git a/vendor/pthreads/premake5.lua b/vendor/pthreads/premake5.lua index 4cd6a03657..db9b897eb5 100644 --- a/vendor/pthreads/premake5.lua +++ b/vendor/pthreads/premake5.lua @@ -67,6 +67,6 @@ project "pthread" filter "system:windows" defines { - "HAVE_PTW32_CONFIG_H", - "PTW32_BUILD_INLINED" + "HAVE_CONFIG_H", + "__PTW32_BUILD_INLINED" }