- libeio, located at eio/ is copyright Marc Alexander Lehmann, and
dual-licensed under the MIT license and GPL2.
-
- - deps/pthread-win32 is a POSIX threads library for
- Microsoft Windows and is used for the Windows build and statically
- linked into the Node executable. This software is freely available at
- http://sourceware.org/pthreads-win32/ It is Copyright 1998 John E.
- Bossom and 1999,2006 Pthreads-win32 contributors and licensed under the
- LGPL. See deps/pthread-win32/COPYING.LIB for more details.
-
+++ /dev/null
-CVS
-*.obj
-*.dll
-*.lib
-*.res
+++ /dev/null
- PTHREADS-WIN32 RELEASE 2.9.0 (2007-??-??)
- -----------------------------------------
- Web Site: http://sources.redhat.com/pthreads-win32/
- FTP Site: ftp://sources.redhat.com/pub/pthreads-win32
- Maintainer: Ross Johnson <rpj@callisto.canberra.edu.au>
-
-
-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 <John.Bossom@cognos.com>.
-
-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://sources.redhat.com/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
- pthread_win32_process_attach_np (Required when statically linking
- the library)
- pthread_win32_process_detach_np (Required when statically linking
- the library)
- pthread_win32_thread_attach_np (Required when statically linking
- the library)
- pthread_win32_thread_detach_np (Required when statically linking
- the library)
-
- ---------------------------
- 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
+++ /dev/null
-----------
-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.
+++ /dev/null
-# 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)
+++ /dev/null
-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.
-
+++ /dev/null
- 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.
+++ /dev/null
- 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.
-\f
- 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.
-\f
- 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.
-\f
- 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.
-\f
- 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.
-\f
- 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.
-\f
- 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.
-\f
- 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.
-\f
- 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
-\f
- 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.
-
- <one line to give the library's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- 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.
-
- <signature of Ty Coon>, 1 April 1990
- Ty Coon, President of Vice
-
-That's all there is to it!
-
-
+++ /dev/null
-2011-07-06 Ross Johnson <ross dot johnson at homemail dot com dot au>\r
-\r
- * pthread_cond_wait.c (pragma inline_depth): this is almost redundant\r
- now nevertheless fixed thei controlling MSC_VER from "< 800" to\r
- "< 1400" (i.e. any prior to VC++ 8.0).\r
- * pthread_once.ci (pragma inline_depth): Likewise.\r
- * pthread_rwlock_timedwrlock.ci (pragma inline_depth): Likewise.\r
- * pthread_rwlock_wrlock.ci (pragma inline_depth): Likewise.\r
- * sem_timedwait.ci (pragma inline_depth): Likewise.\r
- * sem_wait.ci (pragma inline_depth): Likewise.\r
-\r
-2011-07-05 Ross Johnson <ross dot johnson at homemail dot com dot au>\r
-\r
- * pthread_win32_attach_detach_np.c: Use strncat_s if available\r
- to removei a compile warning; MingW supports this routine but we\r
- continue to use strncat anyway there because it is secure if\r
- given the correct parameters; fix strncat param 3 to avoid\r
- buffer overrun exploitation potential.\r
-\r
-2011-07-03 Ross Johnson <ross dot johnson at homemail dot com dot au>\r
-\r
- * pthread_spin_unlock.c (EPERM): Return success if unlocking a lock\r
- that is not locked, because single CPU machines wrap a\r
- PTHREAD_MUTEX_NORMAL mutex, which returns success in this case.\r
- * pthread_win32_attach_detach_np.c (QUSEREX.DLL): Load from an\r
- absolute path only which must be the Windows System folder.\r
-\r
-2011-07-03 Daniel Richard G. <skunk at iskunk dot org>\r
-\r
- * Makefile (_WIN32_WINNT): Removed; duplicate definition in\r
- implement.h; more cleanup and enhancements.\r
-\r
-2011-07-02 Daniel Richard G. <skunk at iskunk dot org>\r
-\r
- * Makefile: Cleanups and implovements.\r
- * ptw32_MCS_locks.c: Casting fixes.\r
- * implement.h: Interlocked call and argument casting macro fixes\r
- to support older and newer build environments.\r
-\r
-2011-07-01 Ross Johnson <ross dot johnson at homemail dot com dot au>\r
-\r
- * *.[ch] (PTW32_INTERLOCKED_*): Redo 23 and 64 bit versions of these\r
- macros and re-apply in code to undo the incorrect changes from\r
- 2011-06-29; remove some size_t casts which should not be required\r
- and may be problematic.a\r
- There are now two sets of macros:\r
- PTW32_INTERLOCKED_*_LONG which work only on 32 bit integer variables;\r
- PTW32_INTERLOCKED_*_SIZE which work on size_t integer variables, i.e.\r
- LONG for 32 bit systems and LONGLONG for 64 bit systems.\r
- * implement.h (MCS locks): nextFlag and waitFlag are now HANDLE type.\r
- * ptw32_MCS_locks.c: Likewise.\r
- * pthread.h (#include <setjmp.h>): Removed.\r
- * ptw32_throw.c (#include <setjmp.h>): Added.\r
- * ptw32_threadStart.c (#include <setjmp.h>): Added.\r
- * implement.h (#include <setjmp.h>): Added.\r
-\r
-2011-06-30 Ross Johnson <ross dot johnson at homemail dot com dot au>\r
-\r
- * pthread_once.c: Tighten 'if' statement casting; fix interlocked\r
- pointer cast for 64 bit compatibility (missed yesterday); remove\r
- the superfluous static cleanup routine and call the release routine\r
- directly if popped.\r
- * create.c (stackSize): Now type size_t.\r
- * pthread.h (struct ptw32_thread_t_): Rearrange to fix element alignments.\r
-\r
-2011-06-29 Daniel Richard G. <skunk at iskunk dot org>\r
-\r
- * ptw32_relmillisecs.c (ftime):\r
- _ftime64_s() is only available in MSVC 2005 or later;\r
- _ftime64() is available in MinGW or MSVC 2002 or later;\r
- _ftime() is always available.\r
- * pthread.h (long long): Not defined in older MSVC 6.\r
- * implement.h (long long): Likewise.\r
- * pthread_getunique_np.c (long long): Likewise.\r
-\r
-2011-06-29 Ross Johnson <ross dot johnson at homemail dot com dot au>\r
-\r
- * *.[ch] (PTW32_INTERLOCKED_*): These macros should now work for\r
- both 32 and 64 bit builds. The MingW versions are all inlined asm\r
- while the MSVC versions expand to their Interlocked* or Interlocked*64\r
- counterparts appropriately. The argument type have also been changed\r
- to cast to the appropriate value or pointer size for the architecture.\r
-\r
-2011-05-29 Ross Johnson <ross dot johnson at homemail dot com dot au>\r
-\r
- * *.[ch] (#ifdef): Extended cleanup to whole project.\r
-\r
-2011-05-29 Daniel Richard G. <skunk at iskunk dot org>\r
-\r
- * Makefile (CC): Define CC to allow use of other compatible\r
- compilers such as the Intel compilter icl.\r
- * implement.h (#if): Fix forms like #if HAVE_SOMETHING.\r
- * pthread.h: Likewise.\r
- * sched.h: Likewise; PTW32_LEVEL_* becomes PTW32_SCHED_LEVEL_*.\r
- * semaphore.h: Likewise.\r
-\r
-2011-05-11 Ross Johnson <ross.johnson at homemail.com.au>\r
-\r
- * ptw32_callUserDestroyRoutines.c (terminate): Altered includes\r
- to match ptw32_threadStart.c.\r
- * GNUmakefile (GCE-inlined-debug, DOPT): Fixed.\r
-\r
-2011-04-31 Ross Johnson <ross.johnson at homemail.com.au>\r
-\r
- * (robust mutexes): Added this API. The API is not\r
- mandatory for implementations that don't support PROCESS_SHARED\r
- mutexes, nevertheless it was considered useful both functionally\r
- and for source-level compatibility.\r
- \r
-2011-03-26 Ross Johnson <ross.johnson at homemail.com.au>\r
-\r
- * pthread_getunique_np.c: New non-POSIX interface for compatibility\r
- with some other implementations; returns a 64 bit sequence number\r
- that is unique to each thread in the process.\r
- * pthread.h (pthread_getunique_np): Added.\r
- * global.c: Add global sequence counter for above.\r
- * implement.h: Likewise.\r
-\r
-2011-03-25 Ross Johnson <ross.johnson at homemail.com.au>\r
-\r
- * (cancelLock): Convert to an MCS lock and rename to stateLock.\r
- * (threadLock): Likewise.\r
- * (keyLock): Likewise.\r
- * pthread_mutex*.c: First working robust mutexes.\r
-\r
-2011-03-11 Ross Johnson <ross.johnson at homemail.com.au>\r
-\r
- * implement.h (PTW32_INTERLOCKED_*CREMENT macros): increment/decrement\r
- using ++/-- instead of add/subtract 1.\r
- * ptw32_MCS_lock.c: Make casts consistent.\r
-\r
-2011-03-09 Ross Johnson <ross.johnson at homemail.com.au>\r
-\r
- * implement.h (ptw32_thread_t_): Add process unique sequence number.\r
- * global.c: Replace global Critical Section objects with MCS\r
- queue locks.\r
- * implement.h: Likewise.\r
- * pthread_cond_destroy.c: Likewise.\r
- * pthread_cond_init.c: Likewise.\r
- * pthread_detach.c: Likewise.\r
- * pthread_join.c: Likewise.\r
- * pthread_kill.c: Likewise.\r
- * pthread_mutex_destroy.c: Likewise.\r
- * pthread_rwlock_destroy.c: Likewise.\r
- * pthread_spin_destroy.c: Likewise.\r
- * pthread_timechange_handler_np.c: Likewise.\r
- * ptw32_cond_check_need_init.c: Likewise.\r
- * ptw32_mutex_check_need_init.c: Likewise.\r
- * ptw32_processInitialize.c: Likewise.\r
- * ptw32_processTerminate.c: Likewise.\r
- * ptw32_reuse.c: Likewise.\r
- * ptw32_rwlock_check_need_init.c: Likewise.\r
- * ptw32_spinlock_check_need_init.c: Likewise.\r
-\r
-2011-03-06 Ross Johnson <ross.johnson at homemail.com.au>\r
-\r
- * several (MINGW64): Cast and call fixups for 64 bit compatibility;\r
- clean build via x86_64-w64-mingw32 cross toolchain on Linux i686\r
- targeting x86_64 win64.\r
- * ptw32_threadStart.c (ptw32_threadStart): Routine no longer attempts\r
- to pass [unexpected C++] exceptions out of scope but ends the thread\r
- normally setting EINTR as the exit status.\r
- * ptw32_throw.c: Fix C++ exception throwing warnings; ignore\r
- informational warning.\r
- * implement.h: Likewise with the corresponding header definition.\r
-\r
-2011-03-04 Ross Johnson <ross.johnson at homemail.com.au>\r
-\r
- * implement.h (PTW32_INTERLOCKED_*): Mingw32 does not provide\r
- the __sync_* intrinsics so implemented them here as macro\r
- assembler routines. MSVS Interlocked* are emmitted as intrinsics\r
- wherever possible, so we want mingw to match it; Extended to\r
- include all interlocked routines used by the library; implemented\r
- x86_64 versions also.\r
- * ptw32_InterlockedCompareExchange.c: No code remaining here.\r
- * ptw32_MCS_lock.c: Converted interlocked calls to use new macros.\r
- * pthread_barrier_wait.c: Likewise.\r
- * pthread_once.c: Likewise.\r
- * ptw32_MCS_lock.c (ptw32_mcs_node_substitute): Name changed to\r
- ptw32_mcs_node_transfer.\r
-\r
-2011-02-28 Ross Johnson <ross.johnson at homemail.com.au>\r
-\r
- * ptw32_relmillisecs.c: If possible, use _ftime64_s or _ftime64\r
- before resorting to _ftime.\r
-\r
-2011-02-27 Ross Johnson <ross.johnson at homemail.com.au>\r
-\r
- * sched_setscheduler.c: Ensure the handle is closed after use.\r
- * sched_getscheduler.c: Likewise.\r
- * pthread.h: Remove POSIX compatibility macros; don't define\r
- timespec if already defined.\r
- * context.h: Changes for 64 bit.\r
- * pthread_cancel.c: Likewise.\r
- * pthread_exit.c: Likewise.\r
- * pthread_spin_destroy.c: Likewise.\r
- * pthread_timechange_handler_np.c: Likewise.\r
- * ptw32_MCS_lock.c: Likewise; some of these changes may\r
- not be compatible with pre Windows 2000 systems; reverse the order of\r
- the includes.\r
- * ptw32_threadStart.c: Likewise.\r
- * ptw32_throw.c: Likewise.\r
-\r
-2011-02-13 Ross Johnson <ross.johnson at homemail.com.au>\r
-\r
- * pthread_self: Add comment re returning 'nil' value to\r
- indicate failure only to win32 threads that call us.\r
- * pthread_attr_setstackaddr: Fix comments; note this\r
- function and it's compliment are now removed from SUSv4.\r
-\r
-2011-02-12 Ross Johnson <ross.johnson at homemail.com.au>\r
-\r
- README.NONPORTABLE: Record a description of an obvious\r
- method for nulling/comparing/hashing pthread_t using a\r
- union; plus and investigation of a change of type for\r
- pthread_t (to a union) to neutralise any padding bits and\r
- bytes if they occur in pthread_t (the current pthread_t struct\r
- does not contain padding AFAIK, but porting the library to a\r
- future architecture may introduce them). Padding affects\r
- byte-by-byte copies and compare operations.\r
-\r
-2010-11-16 Ross Johnson <ross.johnson at homemail.com.au>\r
-\r
- * ChangeLog: Add this entry ;-)\r
- Restore entries from 2007 through 2009 that went missing\r
- at the last update.\r
-\r
-2010-06-19 Ross Johnson <ross.johnson at homemail.com.au>\r
-\r
- * ptw32_MCS_lock.c (ptw32_mcs_node_substitute): Fix variable\r
- names to avoid using C++ keyword ("new").\r
- * implement.h (ptw32_mcs_node_substitute): Likewise.\r
- * pthread_barrier_wait.c: Fix signed/unsigned comparison warning.\r
-\r
-2010-06-18 Ramiro Polla <ramiro.polla at gmail.com >\r
-\r
- * autostatic.c: New file; call pthread_win32_process_*()\r
- libary init/cleanup routines automatically on application start\r
- when statically linked.\r
- * pthread.c (autostatic.c): Included.\r
- * pthread.h (declspec): Remove import/export defines if compiler\r
- is MINGW.\r
- * sched.h (declspec): Likewise.\r
- * semaphore.h (declspec): Likewise.\r
- * need_errno.h (declspec): Likewise.\r
- * Makefile (autostatic.obj): Add for small static builds.\r
- * GNUmakefile (autostatic.o): Likewise.\r
- * NEWS (Version 2.9.0): Add changes.\r
- * README.NONPORTABLE (pthread_win32_process_*): Update\r
- description.\r
-\r
-2010-06-15 Ramiro Polla <ramiro.polla at gmail.com >\r
-\r
- * Makefile: Remove linkage with the winsock library by default.\r
- * GNUmakefile: Likewise.\r
- * pthread_getspecific.c: Likewise by removing calls to WSA\r
- functions.\r
- * config.h (RETAIN_WSALASTERROR): Can be defined if necessary.\r
-\r
-2010-01-26 Ross Johnson <ross.johnson at homemail.com.au>\r
-\r
- * ptw32_MCS_lock.c (ptw32_mcs_node_substitute): New routine\r
- to allow relocating the lock owners thread-local node to somewhere\r
- else, e.g. to global space so that another thread can release the\r
- lock. Used in pthread_barrier_wait.\r
- (ptw32_mcs_lock_try_acquire): New routine.\r
- * pthread_barrier_init: Only one semaphore is used now.\r
- * pthread_barrier_wait: Added an MCS guard lock with the last thread\r
- to leave the barrier releasing the lock. This removes a deadlock bug\r
- observed when there are greater than barrier-count threads\r
- attempting to cross.\r
- * pthread_barrier_destroy: Added an MCS guard lock.\r
- \r
-2009-03-03 Stephan O'Farrill <stephan dot ofarrill at gmail dot com>\r
-\r
- * pthread_attr_getschedpolicy.c: Add "const" to function parameter\r
- in accordance with SUSv3 (POSIX).\r
- * pthread_attr_getinheritsched.c: Likewise.\r
- * pthread_mutexattr_gettype.c: Likewise.\r
-\r
-2008-06-06 Robert Kindred <RKindred at SwRI dot edu>\r
-\r
- * ptw32_throw.c (ptw32_throw): Remove possible reference to NULL\r
- pointer. (At the same time made the switch block conditionally\r
- included only if exitCode is needed - RPJ.)\r
- * pthread_testcancel.c (pthread_testcancel): Remove duplicate and\r
- misplaced pthread_mutex_unlock().\r
-\r
-2008-02-21 Sebastian Gottschalk <seppig_relay at gmx dot de>\r
-\r
- * pthread_attr_getdetachstate.c (pthread_attr_getdetachstate):\r
- Remove potential and superfluous null pointer assignment.\r
-\r
-2007-11-22 Ivan Pizhenko <ivanp4 at ua dot fm>\r
-\r
- * pthread.h (gmtime_r): gmtime returns 0 if tm represents a time\r
- prior to 1/1/1970. Notice this to prevent raising an exception.\r
- * pthread.h (localtime_r): Likewise for localtime.\r
-\r
-2007-07-14 Marcel Ruff <mr at marcelruff dot info>\r
-\r
- * errno.c (_errno): Fix test for pthread_self() success.\r
- * need_errno.h: Remove unintentional line wrap from #if line.\r
-\r
-2007-07-14 Mike Romanchuk <mromanchuk at empirix dot com>\r
-\r
- * pthread.h (timespec): Fix tv_sec type.\r
-\r
-2007-01-07 Sinan Kaya <sinan.kaya at siemens dot com>\r
-\r
- * need_errno.h: Fix declaration of _errno - the local version of\r
- _errno() is used, e.g. by WinCE.\r
-\r
-2007-01-06 Ross Johnson <ross.johnson at homemail dot com dot au>\r
-\r
- * ptw32_semwait.c: Add check for invalid sem_t after acquiring the\r
- sem_t state guard mutex and before affecting changes to sema state.\r
- \r
-2007-01-06 Marcel Ruff <mr at marcelruff dot info>\r
-\r
- * error.c: Fix reference to pthread handle exitStatus member for\r
- builds that use NEED_ERRNO (i.e. WINCE).\r
- * context.h: Add support for ARM processor (WinCE).\r
- * mutex.c (process.h): Exclude for WINCE.\r
- * create.c: Likewise.\r
- * exit.c: Likewise.\r
- * implement.h: Likewise.\r
- * pthread_detach.c (signal.h): Exclude for WINCE.\r
- * pthread_join.c: Likewise.\r
- * pthread_kill.c: Likewise.\r
- * pthread_rwlock_init.c (errno.h): Remove - included by pthread.h.\r
- * pthread_rwlock_destroy.c: Likewise.\r
- * pthread_rwlock_rdlock.c: Likewise.\r
- * pthread_rwlock_timedrdlock.c: Likewise.\r
- * pthread_rwlock_timedwrlock.c: Likewise.\r
- * pthread_rwlock_tryrdlock.c: Likewise.\r
- * pthread_rwlock_trywrlock.c: likewise.\r
- * pthread_rwlock_unlock.c: Likewise.\r
- * pthread_rwlock_wrlock.c: Likewise.\r
- * pthread_rwlockattr_destroy.c: Likewise.\r
- * pthread_rwlockattr_getpshared.c: Likewise.\r
- * pthread_rwlockattr_init.c: Likewise.\r
- * pthread_rwlockattr_setpshared.c: Likewise.\r
-\r
-2007-01-06 Romano Paolo Tenca <rotenca at telvia dot it>\r
-\r
- * pthread_cond_destroy.c: Replace sem_wait() with non-cancelable\r
- ptw32_semwait() since pthread_cond_destroy() is not a cancelation\r
- point.\r
- * implement.h (ptw32_spinlock_check_need_init): Add prototype.\r
- * ptw32_MCS_lock.c: Reverse order of includes.\r
-\r
-2007-01-06 Eric Berge <eric dot berge at quantum dot com>\r
-\r
- * pthread_cond_destroy.c: Add LeaveCriticalSection before returning\r
- after errors.\r
-\r
-2007-01-04 Ross Johnson <ross.johnson at homemail dot com dot au>\r
-\r
- * ptw32_InterlockedCompareExchange.c: Conditionally skip for\r
- Win64 as not required.\r
- * pthread_win32_attach_detach_np.c (pthread_win32_process_attach_np):\r
- Test for InterlockedCompareExchange is not required for Win64.\r
- * context.h: New file. Included by pthread_cancel.h and any tests\r
- that need it (e.g. context1.c).\r
- * pthread_cancel.c: Architecture-dependent context macros moved\r
- to context.h.\r
-\r
-2007-01-04 Kip Streithorst <KSTREITH at ball dot com>\r
-\r
- * implement.h (PTW32_INTERLOCKED_COMPARE_EXCHANGE): Add Win64\r
- support.\r
-\r
-2006-12-20 Ross Johnson <ross.johnson at homemail.com.au>\r
-\r
- * sem_destroy.c: Fix the race involving invalidation of the sema;\r
- fix incorrect return of EBUSY resulting from the mutex trylock\r
- on the private mutex guard.\r
- * sem_wait.c: Add check for invalid sem_t after acquiring the\r
- sem_t state guard mutex and before affecting changes to sema state.\r
- * sem_trywait.c: Likewise.\r
- * sem_timedwait.c: Likewise.\r
- * sem_getvalue.c: Likewise.\r
- * sem_post.c: Similar.\r
- * sem_post_multiple.c: Likewise.\r
- * sem_init.c: Set max Win32 semaphore count to SEM_VALUE_MAX (was\r
- _POSIX_SEM_VALUE_MAX, which is a lower value - the minimum).\r
-\r
- * pthread_win32_attach_detach_np.c (pthread_win32_process_attach_np):\r
- Load COREDLL.DLL under WINCE to check existence of\r
- InterlockedCompareExchange() routine. This used to be done to test\r
- for TryEnterCriticalSection() but was removed when this was no\r
- longer needed.\r
-\r
-2006-01-25 Prashant Thakre <prashant.thakre at gmail.com>\r
-\r
- * pthread_cancel.c: Added _M_IA64 register context support.\r
-\r
-2005-05-13 Ross Johnson <ross at callisto.canberra.edu.au>\r
-\r
- * pthread_kill.c (pthread_kill): Remove check for Win32 thread\r
- priority (to confirm HANDLE validity). Useless since thread HANDLEs\r
- a not recycle-unique.\r
-\r
-2005-05-30 Vladimir Kliatchko <vladimir at kliatchko.com>\r
-\r
- * pthread_once.c: Re-implement using an MCS queue-based lock. The form\r
- of pthread_once is as proposed by Alexander Terekhov (see entry of\r
- 2005-03-13). The MCS lock implementation does not require a unique\r
- 'name' to identify the lock between threads. Attempts to get the Event\r
- or Semaphore based versions of pthread_once to a satisfactory level\r
- of robustness have thus far failed. The last problem (avoiding races\r
- involving non recycle-unique Win32 HANDLEs) was giving everyone\r
- grey hair trying to solve it.\r
-\r
- * ptw32_MCS_lock.c: New MCS queue-based lock implementation. These\r
- locks are efficient: they have very low overhead in the uncontended case;\r
- are efficient in contention and minimise cache-coherence updates in\r
- managing the user level FIFO queue; do not require an ABI change in the\r
- library.\r
-\r
-2005-05-27 Alexander Gottwald <alexander.gottwald at s1999.tu-chemnitz.de>\r
-\r
- * pthread.h: Some things, like HANDLE, were only defined if\r
- PTW32_LEVEL was >= 3. They should always be defined.\r
-\r
-2005-05-25 Vladimir Kliatchko <vladimir at kliatchko.com>\r
-\r
- * pthread_once.c: Eliminate all priority operations and other\r
- complexity by replacing the event with a semaphore. The advantage\r
- of the change is the ability to release just one waiter if the\r
- init_routine thread is cancelled yet still release all waiters when\r
- done. Simplify once_control state checks to improve efficiency\r
- further.\r
-\r
-2005-05-24 Mikael Magnusson <mikaelmagnusson at glocalnet.net>\r
-\r
- * GNUmakefile: Patched to allow cross-compile with mingw32 on Linux.\r
- It uses macros instead of referencing dlltool, gcc and g++ directly;\r
- added a call to ranlib. For example the GC static library can be\r
- built with:\r
- make CC=i586-mingw32msvc-gcc RC=i586-mingw32msvc-windres \\r
- RANLIB=i586-mingw32msvc-ranlib clean GC-static\r
-\r
-2005-05-13 Ross Johnson <ross at callisto.canberra.edu.au>\r
-\r
- * pthread_win32_attach_detach_np.c (pthread_win32_thread_detach_np):\r
- Move on-exit-only stuff from ptw32_threadDestroy() to here.\r
- * ptw32_threadDestroy.c: It's purpose is now only to reclaim thread\r
- resources for detached threads, or via pthread_join() or\r
- pthread_detach() on joinable threads.\r
- * ptw32_threadStart.c: Calling user destruct routines has moved to\r
- pthread_win32_thread_detach_np(); call pthread_win32_thread_detach_np()\r
- directly if statically linking, otherwise do so via dllMain; store\r
- thread return value in thread struct for all cases, including\r
- cancellation and exception exits; thread abnormal exits go via\r
- pthread_win32_thread_detach_np.\r
- * pthread_join.c (pthread_join): Don't try to get return code from\r
- Win32 thread - always get it from he thread struct.\r
- * pthread_detach.c (pthread_detach): reduce extent of the thread\r
- existence check since we now don't care if the Win32 thread HANDLE has\r
- been closed; reclaim thread resources if the thread has exited already.\r
- * ptw32_throw.c (ptw32_throw): For Win32 threads that are not implicit,\r
- only Call thread cleanup if statically linking, otherwise leave it to\r
- dllMain.\r
- * sem_post.c (_POSIX_SEM_VALUE_MAX): Change to SEM_VALUE_MAX.\r
- * sem_post_multiple.c: Likewise.\r
- * sem_init.c: Likewise.\r
-\r
-2005-05-10 Ross Johnson <ross at callisto.canberra.edu.au>\r
-\r
- * pthread_join.c (pthread_join): Add missing check for thread ID\r
- reference count in thread existence test; reduce extent of the\r
- existence test since we don't care if the Win32 thread HANDLE has\r
- been closed.\r
-\r
-2005-05-09 Ross Johnson <ross at callisto.canberra.edu.au>\r
-\r
- * ptw32_callUserDestroyRoutines.c: Run destructor process (i.e.\r
- loop over all keys calling destructors) up to\r
- PTHREAD_DESTRUCTOR_ITERATIONS times if TSD value isn't NULL yet;\r
- modify assoc management.\r
- * pthread_key_delete.c: Modify assoc management.\r
- * ptw32_tkAssocDestroy.c: Fix error in assoc removal from chains.\r
- * pthread.h\r
- (_POSIX_THREAD_DESTRUCTOR_ITERATIONS): Define to value specified by\r
- POSIX.\r
- (_POSIX_THREAD_KEYS_MAX): Define to value specified by POSIX.\r
- (PTHREAD_KEYS_MAX): Redefine [upward] to minimum required by POSIX.\r
- (SEM_NSEMS_MAX): Define to implementation value.\r
- (SEM_VALUE_MAX): Define to implementation value.\r
- (_POSIX_SEM_NSEMS_MAX): Redefine to value specified by POSIX.\r
- (_POSIX_SEM_VALUE_MAX): Redefine to value specified by POSIX.\r
-\r
-2005-05-06 Ross Johnson <ross at callisto.canberra.edu.au>\r
-\r
- * signal.c (sigwait): Add a cancellation point to this otherwise\r
- no-op.\r
- * sem_init.c (sem_init): Check for and return ERANGE error.\r
- * sem_post.c (sem_post): Likewise.\r
- * sem_post_multiple.c (sem_post_multiple): Likewise.\r
- * manual (directory): Added; see ChangeLog inside.\r
-\r
-2005-05-02 Ross Johnson <ross at callisto.canberra.edu.au>\r
-\r
- * implement.h (struct pthread_key_t_): Change threadsLock to keyLock\r
- so as not to be confused with the per thread lock 'threadlock';\r
- change all references to it.\r
- * implement.h (struct ThreadKeyAssoc): Remove lock; add prevKey\r
- and prevThread pointers; re-implemented all routines that use this\r
- struct. The effect of this is to save one handle per association,\r
- which could potentially equal the number of keys multiplied by the\r
- number of threads, accumulating over time - and to free the\r
- association memory as soon as it is no longer referenced by either\r
- the key or the thread. Previously, the handle and memory were\r
- released only after BOTH key and thread no longer referenced the\r
- association. That is, often no association resources were released\r
- until the process itself exited. In addition, at least one race\r
- condition has been removed - where two threads could attempt to\r
- release the association resources simultaneously - one via\r
- ptw32_callUserDestroyRoutines and the other via\r
- pthread_key_delete.\r
- - thanks to Richard Hughes at Aculab for discovering the problem.\r
- * pthread_key_create.c: See above.\r
- * pthread_key_delete.c: See above.\r
- * pthread_setspecific.c: See above.\r
- * ptw32_callUserDestroyRoutines.c: See above.\r
- * ptw32_tkAssocCreate.c: See above.\r
- * ptw32_tkAssocDestroy.c: See above.\r
-\r
-2005-04-27 Ross Johnson <ross at callisto.canberra.edu.au>\r
-\r
- * sem_wait.c (ptw32_sem_wait_cleanup): after cancellation re-attempt\r
- to acquire the semaphore to avoid a race with a late sem_post.\r
- * sem_timedwait.c: Modify comments.\r
-\r
-2005-04-25 Ross Johnson <ross at callisto.canberra.edu.au>\r
-\r
- * ptw32_relmillisecs.c: New module; converts future abstime to \r
- milliseconds relative to 'now'.\r
- * pthread_mutex_timedlock.c: Use new ptw32_relmillisecs routine in\r
- place of internal code; remove the NEED_SEM code - this routine is now\r
- implemented for builds that define NEED_SEM (WinCE etc)\r
- * sem_timedwait.c: Likewise; after timeout or cancellation,\r
- re-attempt to acquire the semaphore in case one has been posted since\r
- the timeout/cancel occurred. Thanks to Stefan Mueller.\r
- * Makefile: Add ptw32_relmillisecs.c module; remove\r
- ptw32_{in,de}crease_semaphore.c modules.\r
- * GNUmakefile: Likewise.\r
- * Bmakefile: Likewise.\r
-\r
- * sem_init.c: Re-write the NEED_SEM code to be consistent with the\r
- non-NEED_SEM code, but retaining use of an event in place of the w32 sema\r
- for w32 systems that don't include semaphores (WinCE);\r
- the NEED_SEM versions of semaphores has been broken for a long time but is\r
- now fixed and supports all of the same routines as the non-NEED_SEM case.\r
- * sem_destroy.c: Likewise.\r
- * sem_wait.c: Likewise.\r
- * sem_post.c: Likewise.\r
- * sem_post_multple.c: Likewise.\r
- * implement.h: Likewise.\r
- * sem_timedwait.c: Likewise; this routine is now\r
- implemented for builds that define NEED_SEM (WinCE etc).\r
- * sem_trywait.c: Likewise.\r
- * sem_getvalue.c: Likewise.\r
-\r
- * pthread_once.c: Yet more changes, reverting closer to Gottlob Frege's\r
- first design, but retaining cancellation, priority boosting, and adding\r
- preservation of W32 error codes to make pthread_once transparent to\r
- GetLastError.\r
-\r
-2005-04-11 Ross Johnson <ross at callisto.canberra.edu.au>\r
-\r
- * pthread_once.c (pthread_once): Added priority boosting to\r
- solve starvation problem after once_routine cancellation.\r
- See notes in file.\r
-\r
-2005-04-06 Kevin Lussier <Kevin at codegreennetworks.com>\r
-\r
- * Makefile: Added debug targets for all versions of the library.\r
-\r
-2005-04-01 Ross Johnson <ross at callisto.canberra.edu.au>\r
-\r
- * GNUmakefile: Add target to build libpthreadGC1.a as a static link\r
- library.\r
- * Makefile: Likewise for pthreadGC1.lib.\r
-\r
-2005-04-01 Kevin Lussier <Kevin at codegreennetworks.com>\r
-\r
- * sem_timedwait.c (sem_timedwait): Increase size of temp variables to\r
- avoid int overflows for large timeout values.\r
- * implement.h (int64_t): Include or define.\r
-\r
-2005-03-31 Dimitar Panayotov <develop at mail.bg>^M\r
-\r
- * pthread.h: Fix conditional defines for static linking.\r
- * sched.h: Liekwise.\r
- * semaphore.h: Likewise.\r
- * dll.c (PTW32_STATIC_LIB): Module is conditionally included\r
- in the build.\r
-\r
-2005-03-16 Ross Johnson <ross at callisto.canberra.edu.au>^M\r
-\r
- * pthread_setcancelstate.c: Undo the last change.\r
-\r
-2005-03-16 Ross Johnson <ross at callisto.canberra.edu.au>^M\r
-\r
- * pthread_setcancelstate.c: Don't check for an async cancel event\r
- if the library is using alertable async cancel..\r
-\r
-2005-03-14 Ross Johnson <ross at callisto.canberra.edu.au>\r
-\r
- * pthread_once.c (pthread_once): Downgrade interlocked operations to simple\r
- memory operations where these are protected by the critical section; edit\r
- comments.\r
-\r
-2005-03-13 Ross Johnson <rpj at callisto.canberra.edu.au>\r
-\r
- * pthread_once.c (pthread_once): Completely redesigned; a change was\r
- required to the ABI (pthread_once_t_), and resulting in a version\r
- compatibility index increment.\r
-\r
- NOTES:\r
- The design (based on pseudo code contributed by Gottlob Frege) avoids\r
- creating a kernel object if there is no contention. See URL for details:-\r
- http://sources.redhat.com/ml/pthreads-win32/2005/msg00029.html\r
- This uses late initialisation similar to the technique already used for\r
- pthreads-win32 mutexes and semaphores (from Alexander Terekhov).\r
-\r
- The subsequent cancelation cleanup additions (by rpj) could not be implemented\r
- without sacrificing some of the efficiency in Gottlob's design. In particular,\r
- although each once_control uses it's own event to block on, a global CS is\r
- required to manage it - since the event must be either re-usable or\r
- re-creatable under cancelation. This is not needed in the non-cancelable\r
- design because it is able to mark the event as closed (forever).\r
-\r
- When uncontested, a CS operation is equivalent to an Interlocked operation\r
- in speed. So, in the final design with cancelability, an uncontested\r
- once_control operation involves a minimum of five interlocked operations\r
- (including the LeaveCS operation).\r
- \r
- ALTERNATIVES:\r
- An alternative design from Alexander Terekhov proposed using a named mutex,\r
- as sketched below:-\r
-\r
- if (!once_control) { // May be in TLS\r
- named_mutex::guard guard(&once_control2);\r
- if (!once_control2) {\r
- <init>\r
- once_control2 = true;\r
- }\r
- once_control = true;\r
- }\r
- \r
- A more detailed description of this can be found here:-\r
- http://groups.yahoo.com/group/boost/message/15442\r
-\r
- [Although the definition of a suitable PTHREAD_ONCE_INIT precludes use of the\r
- TLS located flag, this is not critical.]\r
- \r
- There are three primary concerns though:-\r
- 1) The [named] mutex is 'created' even in the uncontended case.\r
- 2) A system wide unique name must be generated.\r
- 3) Win32 mutexes are VERY slow even in the uncontended case. An uncontested\r
- Win32 mutex lock operation can be 50 (or more) times slower than an\r
- uncontested EnterCS operation.\r
-\r
- Ultimately, the named mutex trick is making use of the global locks maintained\r
- by the kernel.\r
-\r
- * pthread.h (pthread_once_t_): One flag and an event HANDLE added.\r
- (PTHREAD_ONCE_INIT): Additional values included.\r
-\r
-2005-03-08 Ross Johnson <rpj at callisto.canberra.edu.au>\r
-\r
- * pthread_once.c (pthread_once): Redesigned to elliminate potential\r
- starvation problem.\r
- - reported by Gottlob Frege <gottlobfrege at gmail.com>\r
-\r
- * ptw32_threadDestroy.c (ptw32_threadDestroy): Implicit threads were\r
- not closing their Win32 thread duplicate handle.\r
- - reported by Dmitrii Semii <bogolt at gmail.com>\r
-\r
-2005-01-25 Ralf Kubis <RKubis at mc.com>\r
-\r
- * Attempted acquisition of recursive mutex was causing waiting\r
- threads to not be woken when the mutex is released.\r
-\r
- * GNUmakefile (GCE): Generate correct version resource comments.\r
-\r
-2005-01-01 Konstantin Voronkov <beowinkle at yahoo.com>\r
-\r
- * pthread_mutex_lock.c (pthread_mutex_lock): The new atomic exchange\r
- mutex algorithm is known to allow a thread to steal the lock off\r
- FIFO waiting threads. The next waiting FIFO thread gets a spurious\r
- wake-up and must attempt to re-acquire the lock. The woken thread\r
- was setting itself as the mutex's owner before the re-acquisition.\r
-\r
-2004-11-22 Ross Johnson <rpj at callisto.canberra.edu.au>\r
-\r
- * pthread_cond_wait.c (ptw32_cond_wait_cleanup): Undo change\r
- from 2004-11-02.\r
- * Makefile (DLL_VER): Added for DLL naming suffix - see README.\r
- * GNUmakefile (DLL_VER): Likewise.\r
- * Wmakefile (DLL_VER): Likewise.\r
- * Bmakefile (DLL_VER): Likewise.\r
- * pthread.dsw (version.rc): Added to MSVS workspace.\r
-\r
-2004-11-20 Boudewijn Dekker <b.dekker at ellipsis.nl>\r
-\r
- * pthread_getspecific.c (pthread_getspecific): Check for\r
- invalid (NULL) key argument.\r
-\r
-2004-11-19 Ross Johnson <rpj at callisto.canberra.edu.au>\r
-\r
- * config.h (PTW32_THREAD_ID_REUSE_INCREMENT): Added to allow\r
- building the library for either unique thread IDs like Solaris\r
- or non-unique thread IDs like Linux; allows application developers\r
- to override the library's default insensitivity to some apps\r
- that may not be strictly POSIX compliant.\r
- * version.rc: New resource module to encode version information\r
- within the DLL.\r
- * pthread.h: Added PTW32_VERSION* defines and grouped sections\r
- required by resource compiler together; bulk of file is skipped\r
- if RC_INVOKED. Defined some error numbers and other names for\r
- Borland compiler.\r
-\r
-2004-11-02 Ross Johnson <rpj at callisto.canberra.edu.au>\r
-\r
- * pthread_cond_wait.c (ptw32_cond_wait_cleanup): Lock CV mutex at\r
- start of cleanup handler rather than at the end.\r
- * implement.h (PTW32_THREAD_REUSE_EMPTY): Renamed from *_BOTTOM.\r
- (ptw32_threadReuseBottom): New global variable.\r
- * global.c (ptw32_threadReuseBottom): Declare new variable.\r
- * ptw32_reuse.c (ptw32_reuse): Change reuse LIFO stack to LILO queue\r
- to more evenly distribute use of reusable thread IDs; use renamed\r
- PTW32_THREAD_REUSE_EMPTY.\r
- * ptw32_processTerminate.c (ptw2_processTerminate): Use renamed\r
- PTW32_THREAD_REUSE_EMPTY.\r
-\r
-2004-10-31 Ross Johnson <rpj at callisto.canberra.edu.au>\r
-\r
- * implement.h (PThreadState): Add new state value\r
- 'PThreadStateCancelPending'.\r
- * pthread_testcancel.c (pthread_testcancel): Use new thread\r
- 'PThreadStateCancelPending' state as short cut to avoid entering\r
- kernel space via WaitForSingleObject() call. This was obviated\r
- by user space sema acquisition in sem_wait() and sem_timedwait(),\r
- which are also cancelation points. A call to pthread_testcancel()\r
- was required, which introduced a kernel call, effectively nullifying\r
- any gains made by the user space sem acquisition checks.\r
- * pthread_cancel.c (pthread_cancel): Set new thread\r
- 'PThreadStateCancelPending' state.\r
-\r
-2004-10-29 Ross Johnson <rpj at callisto.canberra.edu.au>\r
-\r
- * implement.h (pthread_t): Renamed to ptw32_thread_t; struct contains\r
- all thread state.\r
- * pthread.h (ptw32_handle_t): New general purpose struct to serve\r
- as a handle for various reusable object IDs - currently only used\r
- by pthread_t; contains a pointer to ptw32_thread_t (thread state)\r
- and a general purpose uint for use as a reuse counter or flags etc.\r
- (pthread_t): typedef'ed to ptw32_handle_t; the uint is the reuse\r
- counter that allows the library to maintain unique POSIX thread IDs.\r
- When the pthread struct reuse stack was introduced, threads would\r
- often acquire an identical ID to a previously destroyed thread. The\r
- same was true for the pre-reuse stack library, by virtue of pthread_t\r
- being the address of the thread struct. The new pthread_t retains\r
- the reuse stack but provides virtually unique thread IDs.\r
- * sem_wait.c (ptw32_sem_wait_cleanup): New routine used for\r
- cancelation cleanup.\r
- * sem_timedwait.c (ptw32_sem_timedwait_cleanup): Likewise.\r
-\r
-2004-10-22 Ross Johnson <rpj at callisto.canberra.edu.au>\r
-\r
- * sem_init.c (sem_init): Introduce a 'lock' element in order to\r
- replace the interlocked operations with conventional serialisation.\r
- This is needed in order to be able to atomically modify the sema\r
- value and perform Win32 sema release operations. Win32 semaphores are\r
- used instead of events in order to support efficient multiple posting.\r
- If the whole modify/release isn't atomic, a race between\r
- sem_timedwait() and sem_post() could result in a release when there is\r
- no waiting semaphore, which would cause too many threads to proceed.\r
- * sem_wait.c (sem_wait): Use new 'lock'element.\r
- * sem_timedwait.c (sem_timedwait): Likewise.\r
- * sem_trywait.c (sem_trywait): Likewise.\r
- * sem_post.c (sem_post): Likewise.\r
- * sem_post_multiple.c (sem_post_multiple): Likewise.\r
- * sem_getvalue.c (sem_getvalue): Likewise.\r
- * ptw32_semwait.c (ptw32_semwait): Likewise.\r
- * sem_destroy.c (sem_destroy): Likewise; also tightened the conditions\r
- for semaphore destruction; in particular, a semaphore will not be\r
- destroyed if it has waiters.\r
- * sem_timedwait.c (sem_timedwait): Added cancel cleanup handler to\r
- restore sema value when cancelled.\r
- * sem_wait.c (sem_wait): Likewise.\r
-\r
-2004-10-21 Ross Johnson <rpj at callisto.canberra.edu.au>\r
-\r
- * pthread_mutex_unlock.c (pthread_mutex_unlock): Must use PulseEvent()\r
- rather than SetEvent() to reset the event if there are no waiters.\r
-\r
-2004-10-19 Ross Johnson <rpj at callisto.canberra.edu.au>\r
-\r
- * sem_init.c (sem_init): New semaphore model based on the same idea\r
- as mutexes, i.e. user space interlocked check to avoid \r
- unnecessarily entering kernel space. Wraps the Win32 semaphore and\r
- keeps it's own counter. Although the motivation to do this has existed\r
- for a long time, credit goes to Alexander Terekhov for providing\r
- the logic. I have deviated slightly from AT's logic to add the waiters\r
- count, which has made the code more complicated by adding cancelation\r
- cleanup. This also appears to have broken the VCE (C++ EH) version of\r
- the library (the same problem as previously reported - see BUGS #2),\r
- only apparently not fixable using the usual workaround, nor by turning\r
- all optimisation off. The GCE version works fine, so it is presumed to\r
- be a bug in MSVC++ 6.0. The cancelation exception is thrown and caught\r
- correctly, but the cleanup class destructor is never called. The failing\r
- test is tests\semaphore4.c.\r
- * sem_wait.c (sem_wait): Implemented user space check model.\r
- * sem_post.c (sem_post): Likewise.\r
- * sem_trywait.c (sem_trywait): Likewise.\r
- * sem_timedwait.c (sem_timedwait): Likewise.\r
- * sem_post_multiple.c (sem_post_multiple): Likewise.\r
- * sem_getvalue.c (sem_getvalue): Likewise.\r
- * ptw32_semwait.c (ptw32_semwait): Likewise.\r
- * implement.h (sem_t_): Add counter element.\r
-\r
-2004-10-15 Ross Johnson <rpj at callisto.canberra.edu.au>\r
-\r
- * implement.h (pthread_mutex_t_): Use an event in place of\r
- the POSIX semaphore.\r
- * pthread_mutex_init.c: Create the event; remove semaphore init.\r
- * pthread_mutex_destroy.c: Delete the event.\r
- * pthread_mutex_lock.c: Replace the semaphore wait with the event wait.\r
- * pthread_mutex_trylock.c: Likewise.\r
- * pthread_mutex_timedlock.c: Likewise.\r
- * pthread_mutex_unlock.c: Set the event.\r
- \r
-2004-10-14 Ross Johnson <rpj at callisto.canberra.edu.au>\r
-\r
- * pthread_mutex_lock.c (pthread_mutex_lock): New algorithm using\r
- Terekhov's xchg based variation of Drepper's cmpxchg model.\r
- Theoretically, xchg uses fewer clock cycles than cmpxchg (using IA-32\r
- as a reference), however, in my opinion bus locking dominates the\r
- equation on smp systems, so the model with the least number of bus\r
- lock operations in the execution path should win, which is Terekhov's\r
- variant. On IA-32 uni-processor systems, it's faster to use the\r
- CMPXCHG instruction without locking the bus than to use the XCHG\r
- instruction, which always locks the bus. This makes the two variants\r
- equal for the non-contended lock (fast lane) execution path on up\r
- IA-32. Testing shows that the xchg variant is faster on up IA-32 as\r
- well if the test forces higher lock contention frequency, even though\r
- kernel calls should be dominating the times (on up IA-32, both\r
- variants used CMPXCHG instructions and neither locked the bus).\r
- * pthread_mutex_timedlock.c pthread_mutex_timedlock(): Similarly.\r
- * pthread_mutex_trylock.c (pthread_mutex_trylock): Similarly.\r
- * pthread_mutex_unlock.c (pthread_mutex_unlock): Similarly.\r
- * ptw32_InterlockedCompareExchange.c (ptw32_InterlockExchange): New\r
- function.\r
- (PTW32_INTERLOCKED_EXCHANGE): Sets up macro to use inlined\r
- ptw32_InterlockedExchange.\r
- * implement.h (PTW32_INTERLOCKED_EXCHANGE): Set default to\r
- InterlockedExchange().\r
- * Makefile: Building using /Ob2 so that asm sections within inline\r
- functions are inlined.\r
-\r
-2004-10-08 Ross Johnson <rpj at callisto.canberra.edu.au>\r
-\r
- * pthread_mutex_destroy.c (pthread_mutex_destroy): Critical Section\r
- element is no longer required.\r
- * pthread_mutex_init.c (pthread_mutex_init): Likewise.\r
- * pthread_mutex_lock.c (pthread_mutex_lock): New algorithm following\r
- Drepper's paper at http://people.redhat.com/drepper/futex.pdf, but\r
- using the existing semaphore in place of the futex described in the\r
- paper. Idea suggested by Alexander Terekhov - see:\r
- http://sources.redhat.com/ml/pthreads-win32/2003/msg00108.html\r
- * pthread_mutex_timedlock.c pthread_mutex_timedlock(): Similarly.\r
- * pthread_mutex_trylock.c (pthread_mutex_trylock): Similarly.\r
- * pthread_mutex_unlock.c (pthread_mutex_unlock): Similarly.\r
- * pthread_barrier_wait.c (pthread_barrier_wait): Use inlined version\r
- of InterlockedCompareExchange() if possible - determined at\r
- build-time.\r
- * pthread_spin_destroy.c pthread_spin_destroy(): Likewise.\r
- * pthread_spin_lock.c pthread_spin_lock():Likewise.\r
- * pthread_spin_trylock.c (pthread_spin_trylock):Likewise.\r
- * pthread_spin_unlock.c (pthread_spin_unlock):Likewise.\r
- * ptw32_InterlockedCompareExchange.c: Sets up macro for inlined use.\r
- * implement.h (pthread_mutex_t_): Remove Critical Section element.\r
- (PTW32_INTERLOCKED_COMPARE_EXCHANGE): Set to default non-inlined\r
- version of InterlockedCompareExchange().\r
- * private.c: Include ptw32_InterlockedCompareExchange.c first for\r
- inlining.\r
- * GNUmakefile: Add commandline option to use inlined\r
- InterlockedCompareExchange().\r
- * Makefile: Likewise.\r
-\r
-2004-09-27 Ross Johnson <rpj at callisto.canberra.edu.au>\r
-\r
- * pthread_mutex_lock.c (pthread_mutex_lock): Separate\r
- PTHREAD_MUTEX_NORMAL logic since we do not need to keep or check some\r
- state required by other mutex types; do not check mutex pointer arg\r
- for validity - leave this to the system since we are only checking\r
- for NULL pointers. This should improve speed of NORMAL mutexes and\r
- marginally improve speed of other type.\r
- * pthread_mutex_trylock.c (pthread_mutex_trylock): Likewise.\r
- * pthread_mutex_unlock.c (pthread_mutex_unlock): Likewise; also avoid\r
- entering the critical section for the no-waiters case, with approx.\r
- 30% reduction in lock/unlock overhead for this case.\r
- * pthread_mutex_timedlock.c (pthread_mutex_timedlock): Likewise; also\r
- no longer keeps mutex if post-timeout second attempt succeeds - this\r
- will assist applications that wish to impose strict lock deadlines,\r
- rather than simply to escape from frozen locks.\r
-\r
-2004-09-09 Tristan Savatier <tristan at mpegtv.com>\r
- * pthread.h (struct pthread_once_t_): Qualify the 'done' element\r
- as 'volatile'.\r
- * pthread_once.c: Concerned about possible race condition,\r
- specifically on MPU systems re concurrent access to multibyte types.\r
- [Maintainer's note: the race condition is harmless on SPU systems\r
- and only a problem on MPU systems if concurrent access results in an\r
- exception (presumably generated by a hardware interrupt). There are\r
- other instances of similar harmless race conditions that have not\r
- been identified as issues.]\r
-\r
-2004-09-09 Ross Johnson <rpj at callisto.canberra.edu.au>\r
-\r
- * pthread.h: Declare additional types as volatile.\r
-\r
-2004-08-27 Ross Johnson <rpj at callisto.canberra.edu.au>\r
-\r
- * pthread_barrier_wait.c (pthread_barrier_wait): Remove excessive code\r
- by substituting the internal non-cancelable version of sem_wait\r
- (ptw32_semwait).\r
-\r
-2004-08-25 Ross Johnson <rpj at callisto.canberra.edu.au>\r
-\r
- * pthread_join.c (pthread_join): Rewrite and re-order the conditional\r
- tests in an attempt to improve efficiency and remove a race\r
- condition.\r
-\r
-2004-08-23 Ross Johnson <rpj at callisto.canberra.edu.au>\r
-\r
- * create.c (pthread_create): Don't create a thread if the thread\r
- id pointer location (first arg) is inaccessible. A memory\r
- protection fault will result if the thread id arg isn't an accessible\r
- location. This is consistent with GNU/Linux but different to\r
- Solaris or MKS (and possibly others), which accept NULL as meaning\r
- 'don't return the created thread's ID'. Applications that run\r
- using pthreads-win32 will run on all other POSIX threads\r
- implementations, at least w.r.t. this feature.\r
-\r
- It was decided not to copy the Solaris et al behaviour because,\r
- although it would have simplified some application porting (but only\r
- from Solaris to Windows), the feature is not technically necessary,\r
- and the alternative segfault behaviour helps avoid buggy application\r
- code.\r
-\r
-2004-07-01 Anuj Goyal <anuj.goyal at gmail.com>\r
-\r
- * builddmc.bat: New; Windows bat file to build the library.\r
- * config.h (__DMC__): Support for Digital Mars compiler.\r
- * create.c (__DMC__): Likewise.\r
- * pthread_exit.c (__DMC__): Likewise.\r
- * pthread_join.c (__DMC__): Likewise.\r
- * ptw32_threadDestroy.c (__DMC__): Likewise.\r
- * ptw32_threadStart.c (__DMC__): Likewise.\r
- * ptw32_throw.c (__DMC__): Likewise.\r
-\r
-2004-06-29 Anuj Goyal <anuj.goyal at gmail.com>\r
-\r
- * pthread.h (__DMC__): Initial support for Digital Mars compiler.\r
-\r
-2004-06-29 Will Bryant <will.bryant at ecosm.com>\r
-\r
- * README.Borland: New; description of Borland changes.\r
- * Bmakefile: New makefile for the Borland make utility.\r
- * ptw32_InterlockedCompareExchange.c:\r
- Add Borland compatible asm code.\r
-\r
-2004-06-26 Jason Bard <BardJA at Npt.NUWC.Navy.Mil>\r
-\r
- * pthread.h (HAVE_STRUCT_TIMESPEC): If undefined, define it\r
- to avoid timespec struct redefined errors elsewhere in an\r
- application.\r
-\r
-2004-06-21 Ross Johnson <rpj at callisto.canberra.edu.au>\r
-\r
- * pthread.h (PTHREAD_RECURSIVE_MUTEX_INITIALIZER): Mutex\r
- initialiser added for compatibility with Linux threads and\r
- others; currently not included in SUSV3.\r
- * pthread.h (PTHREAD_ERRORCHECK_MUTEX_INITIALIZER): Likewise.\r
- * pthread.h (PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP): Likewise.\r
- * pthread.h (PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP): Likewise.\r
-\r
- * ptw32_mutex_check_need_init.c (ptw32_mutex_check_need_init): \r
- Add new initialisers.\r
-\r
- * pthread_mutex_lock.c (pthread_mutex_lock): Check for new\r
- initialisers.\r
- * pthread_mutex_trylock.c (pthread_mutex_trylock): Likewise.\r
- * pthread_mutex_timedlock.c (pthread_mutex_timedlock): Likewise.\r
- * pthread_mutex_unlock.c (pthread_mutex_unlock): Likewise.\r
- * pthread_mutex_destroy.c (pthread_mutex_destroy): Likewise.\r
-\r
-2004-05-20 Ross Johnson <rpj at callisto.canberra.edu.au>\r
-\r
- * README.NONPORTABLE: Document pthread_win32_test_features_np().\r
- * FAQ: Update various answers.\r
-\r
-2004-05-19 Ross Johnson <rpj at callisto.canberra.edu.au>\r
-\r
- * Makefile: Don't define _WIN32_WINNT on compiler command line.\r
- * GNUmakefile: Likewise.\r
-\r
-2004-05-16 Ross Johnson <rpj at callisto.canberra.edu.au>\r
-\r
- * pthread_cancel.c (pthread_cancel): Adapted to use auto-detected\r
- QueueUserAPCEx features at run-time.\r
- (ptw32_RegisterCancelation): Drop in replacement for QueueUserAPCEx()\r
- if it can't be used. Provides older style non-preemptive async\r
- cancelation.\r
- * pthread_win32_attach_detach_np.c (pthread_win32_attach_np):\r
- Auto-detect quserex.dll and the availability of alertdrv.sys;\r
- initialise and close on process attach/detach.\r
- * global.c (ptw32_register_cancelation): Pointer to either\r
- QueueUserAPCEx() or ptw32_RegisterCancelation() depending on\r
- availability. QueueUserAPCEx makes pre-emptive async cancelation\r
- possible.\r
- * implement.h: Add definitions and prototypes related to QueueUserAPC.\r
-\r
-2004-05-16 Panagiotis E. Hadjidoukas <peh at hpclab.ceid.upatras.gr>\r
-\r
- * QueueUserAPCEx (separate contributed package): Provides preemptive\r
- APC feature.\r
- * pthread_cancel.c (pthread_cancel): Initial integration of\r
- QueueUserAPCEx into pthreads-win32 to provide true pre-emptive\r
- async cancelation of threads, including blocked threads.\r
-\r
-2004-05-06 Makoto Kato <raven at oldskool.jp>\r
-\r
- * pthread.h (DWORD_PTR): Define typedef for older MSVC.\r
- * pthread_cancel.c (AMD64): Add architecture specific Context register.\r
- * ptw32_getprocessors.c: Use correct types (DWORD_PTR) for mask\r
- variables.\r
-\r
-2004-04-06 P. van Bruggen <pietvb at newbridges.nl>\r
-\r
- * ptw32_threadDestroy.c: Destroy threadLock mutex to\r
- close a memory leak.\r
-\r
-2004-02-13 Gustav Hallberg <gustav at virtutech.com>\r
-\r
- * pthread_equal.c: Remove redundant equality logic.\r
-\r
-2003-12-10 Philippe Di Cristo <philipped at voicebox.com>\r
-\r
- * sem_timedwait.c (sem_timedwait): Fix timeout calculations.\r
-\r
-2003-10-20 Alexander Terekhov <TEREKHOV at de.ibm.com>\r
-\r
- * pthread_mutex_timedlock.c (ptw32_semwait): Move to individual module.\r
- * ptw32_semwait.c: New module.\r
- * pthread_cond_wait.c (ptw32_cond_wait_cleanup): Replace cancelable\r
- sem_wait() call with non-cancelable ptw32_semwait() call.\r
- * pthread.c (private.c): Re-order for inlining. GNU C warned that\r
- function ptw32_semwait() was defined 'inline' after it was called.\r
- * pthread_cond_signal.c (ptw32_cond_unblock): Likewise.\r
- * pthread_delay_np.c: Disable Watcom warning with comment.\r
- * *.c (process.h): Remove include from .c files. This is conditionally\r
- included by the common project include files.\r
-\r
-2003-10-20 James Ewing <james.ewing at sveasoft.com>\r
-\r
- * ptw32_getprocessors.c: Some Win32 environments don't have\r
- GetProcessAffinityMask(), so always return CPU count = 1 for them.\r
- * config.h (NEED_PROCESSOR_AFFINITY_MASK): Define for WinCE.\r
- \r
-2003-10-15 Ross Johnson <ross at callisto.canberra.edu.au>\r
-\r
- * Re-indented all .c files using default GNU style to remove assorted\r
- editor ugliness (used GNU indent utility in default style).\r
-\r
-2003-10-15 Alex Blanco <Alex.Blanco at motorola.com>\r
-\r
- * sem_init.c (sem_init): Would call CreateSemaphore even if the sema\r
- struct calloc failed; was not freeing calloced memory if either\r
- CreateSemaphore or CreateEvent failed.\r
-\r
-2003-10-14 Ross Johnson <ross at callisto.canberra.edu.au>\r
-\r
- * pthread.h: Add Watcom compiler compatibility. Esssentially just add\r
- the cdecl attribute to all exposed function prototypes so that Watcom\r
- generates function call code compatible with non-Watcom built libraries.\r
- By default, Watcom uses registers to pass function args if possible rather\r
- than pushing to stack.\r
- * semaphore.h: Likewise.\r
- * sched.h: Likewise.\r
- * pthread_cond_wait.c (ptw32_cond_wait_cleanup): Define with cdecl attribute\r
- for Watcom compatibility. This routine is called via pthread_cleanup_push so\r
- it had to match function arg definition.\r
- * Wmakefile: New makefile for Watcom builds.\r
-\r
-2003-09-14 Ross Johnson <rpj at callisto.canberra.edu.au>\r
-\r
- * pthread_setschedparam.c (pthread_setschedparam): Attempt to map\r
- all priority levels between max and min (as returned by\r
- sched_get_priority_min/max) to reasonable Win32 priority levels - i.e.\r
- levels between THREAD_PRIORITY_LOWEST/IDLE to THREAD_PRIORITY_LOWEST and\r
- between THREAD_PRIORITY_HIGHEST/TIME_CRITICAL to THREAD_PRIORITY_HIGHEST\r
- while others remain unchanged; record specified thread priority level\r
- for return by pthread_getschedparam.\r
-\r
- Note that, previously, specified levels not matching Win32 priority levels\r
- would silently leave the current thread priority unaltered.\r
-\r
- * pthread_getschedparam.c (pthread_getschedparam): Return the priority\r
- level specified by the latest pthread_setschedparam or pthread_create rather\r
- than the actual running thread priority as returned by GetThreadPriority - as\r
- required by POSIX. I.e. temporary or adjusted actual priority levels are not\r
- returned by this routine.\r
-\r
- * pthread_create.c (pthread_create): For priority levels specified via\r
- pthread attributes, attempt to map all priority levels between max and\r
- min (as returned by sched_get_priority_min/max) to reasonable Win32\r
- priority levels; record priority level given via attributes, or\r
- inherited from parent thread, for later return by pthread_getschedparam.\r
-\r
- * ptw32_new.c (ptw32_new): Initialise pthread_t_ sched_priority element.\r
-\r
- * pthread_self.c (pthread_self): Set newly created implicit POSIX thread\r
- sched_priority to Win32 thread's current actual priority. Temporarily\r
- altered priorities can't be avoided in this case.\r
-\r
- * implement.h (struct pthread_t_): Add new sched_priority element.\r
-\r
-2003-09-12 Ross Johnson <rpj at callisto.canberra.edu.au>\r
-\r
- * sched_get_priority_min.c (sched_get_priority_min): On error should return -1\r
- with errno set.\r
- * sched_get_priority_max.c (sched_get_priority_max): Likewise.\r
-\r
-2003-09-03 Ross Johnson <rpj at callisto.canberra.edu.au>\r
-\r
- * w32_cancelableWait.c (ptw32_cancelable_wait): Allow cancelation\r
- of implicit POSIX threads as well.\r
-\r
-2003-09-02 Ross Johnson <rpj at callisto.canberra.edu.au>\r
-\r
- * pthread_win32_attach_detach_np.c (pthread_win32_thread_detach_np):\r
- Add comment.\r
-\r
- * pthread_exit.c (pthread_exit): Fix to recycle the POSIX thread handle in\r
- addition to calling user TSD destructors. Move the implicit POSIX thread exit\r
- handling to ptw32_throw to centralise the logic.\r
-\r
- * ptw32_throw.c (ptw32_throw): Implicit POSIX threads have no point\r
- to jump or throw to, so cleanup and exit the thread here in this case. For\r
- processes using the C runtime, the exit code will be set to the POSIX\r
- reason for the throw (i.e. PTHREAD_CANCEL or the value given to pthread_exit).\r
- Note that pthread_exit() already had similar logic, which has been moved to\r
- here.\r
-\r
- * ptw32_threadDestroy.c (ptw32_threadDestroy): Don't close the Win32 handle\r
- of implicit POSIX threads - expect this to be done by Win32?\r
-\r
-2003-09-01 Ross Johnson <rpj at callisto.canberra.edu.au>\r
-\r
- * pthread_self.c (pthread_self): The newly aquired pthread_t must be\r
- assigned to the reuse stack, not freed, if the routine fails somehow.\r
-\r
-2003-08-13 Ross Johnson <rpj at ise.canberra.edu.au>\r
-\r
- * pthread_getschedparam.c (pthread_getschedparam): An invalid thread ID\r
- parameter was returning an incorrect error value; now uses a more exhaustive\r
- check for validity.\r
-\r
- * pthread_setschedparam.c (pthread_setschedparam): Likewise.\r
-\r
- * pthread_join.c (pthread_join): Now uses a more exhaustive\r
- check for validity.\r
-\r
- * pthread_detach.c (pthread_detach): Likewise.\r
-\r
- * pthread_cancel.c (pthread_cancel): Likewise.\r
-\r
- * ptw32_threadDestroy.c (ptw32_threadDestroy): pthread_t structs are\r
- never freed - push them onto a stack for reuse.\r
-\r
- * ptw32_new.c (ptw32_new): Check for reusable pthread_t before dynamically\r
- allocating new memory for the struct.\r
-\r
- * pthread_kill.c (pthread_kill): New file; new routine; takes only a zero\r
- signal arg so that applications can check the thread arg for validity; checks\r
- that the underlying Win32 thread HANDLE is valid.\r
-\r
- * pthread.h (pthread_kill): Add prototype.\r
-\r
- * ptw32_reuse.c (ptw32_threadReusePop): New file; new routine; pop a\r
- pthread_t off the reuse stack. pthread_t_ structs that have been destroyed, i.e.\r
- have exited detached or have been joined, are cleaned up and put onto a reuse\r
- stack. Consequently, thread IDs are no longer freed once calloced. The library\r
- will attempt to get a struct off this stack before asking the system to alloc\r
- new memory when creating threads. The stack is guarded by a global mutex.\r
- (ptw32_threadReusePush): New routine; push a pthread_t onto the reuse stack.\r
-\r
- * implement.h (ptw32_threadReusePush): Add new prototype.\r
- (ptw32_threadReusePop): Likewise.\r
- (pthread_t): Add new element.\r
-\r
- * ptw32_processTerminate.c (ptw32_processTerminate): Delete the thread\r
- reuse lock; free all thread ID structs on the thread reuse stack.\r
-\r
- * ptw32_processInitialize.c (ptw32_processInitialize): Initialise the\r
- thread reuse lock.\r
-\r
-2003-07-19 Ross Johnson <rpj at ise.canberra.edu.au>\r
-\r
- * GNUmakefile: modified to work under MsysDTK environment.\r
- * pthread_spin_lock.c (pthread_spin_lock): Check for NULL arg.\r
- * pthread_spin_unlock.c (pthread_spin_unlock): Likewise.\r
- * pthread_spin_trylock.c (pthread_spin_trylock): Likewise;\r
- fix incorrect pointer value if lock is dynamically initialised by\r
- this function.\r
- * sem_init.c (sem_init): Initialise sem_t value to quell compiler warning.\r
- * sem_destroy.c (sem_destroy): Likewise.\r
- * ptw32_threadStart.c (non-MSVC code sections): Include <exception> rather\r
- than old-style <new.h>; fix all std:: namespace entities such as\r
- std::terminate_handler instances and associated methods.\r
- * ptw32_callUserDestroyRoutines.c (non-MSVC code sections): Likewise.\r
-\r
-2003-06-24 Piet van Bruggen <pietvb at newbridges.nl>\r
-\r
- * pthread_spin_destroy.c (pthread_spin_destroy): Was not freeing the\r
- spinlock struct.\r
-\r
-2003-06-22 Nicolas Barry <boozai at yahoo.com>\r
-\r
- * pthread_mutex_destroy.c (pthread_mutex_destroy): When called\r
- with a recursive mutex that was locked by the current thread, the\r
- function was failing with a success return code.\r
-\r
-2003-05-15 Steven Reddie <Steven.Reddie at ca.com>\r
-\r
- * pthread_win32_attach_detach_np.c (pthread_win32_process_detach_np):\r
- NULLify ptw32_selfThreadKey after the thread is destroyed, otherwise\r
- destructors calling pthreads routines might resurrect it again, creating\r
- memory leaks. Call the underlying Win32 Tls routine directly rather than\r
- pthread_setspecific().\r
- (pthread_win32_thread_detach_np): Likewise.\r
-\r
-2003-05-14 Viv <vcotirlea at hotmail.com>\r
-\r
- * pthread.dsp: Change /MT compile flag to /MD.\r
-\r
-2003-03-04 Alexander Terekhov <TEREKHOV at de.ibm.com>\r
-\r
- * pthread_mutex_timedlock.c (pthread_mutex_timedlock): Fix failure to\r
- set ownership of mutex on second grab after abstime timeout.\r
- - bug reported by Robert Strycek <strycek at posam.sk>\r
-\r
-2002-12-17 Thomas Pfaff <tpfaff at gmx.net>\r
-\r
- * pthread_mutex_lock.c (ptw32_semwait): New static routine to provide\r
- a non-cancelable sem_wait() function. This is consistent with the\r
- way that pthread_mutex_timedlock.c does it.\r
- (pthread_mutex_lock): Use ptw32_semwait() instead of sem_wait().\r
-\r
-2002-12-11 Thomas Pfaff <tpfaff at gmx.net>\r
-\r
- * pthread_mutex_trylock.c: Should return EBUSY rather than EDEADLK.\r
- * pthread_mutex_destroy.c: Remove redundant ownership test (the\r
- trylock call does this for us); do not destroy a recursively locked\r
- mutex.\r
-\r
-2002-09-20 Michael Johnson <michaelj at maine.rr.com>\r
-\r
- * pthread_cond_destroy.c (pthread_cond_destroy): \r
- When two different threads exist, and one is attempting to\r
- destroy a condition variable while the other is attempting to\r
- initialize a condition variable that was created with\r
- PTHREAD_COND_INITIALIZER, a deadlock can occur. Shrink\r
- the ptw32_cond_list_lock critical section to fix it.\r
-\r
-2002-07-31 Ross Johnson <rpj at special.ise.canberra.edu.au>\r
-\r
- * ptw32_threadStart.c (ptw32_threadStart): Thread cancelLock\r
- destruction moved to ptw32_threadDestroy().\r
-\r
- * ptw32_threadDestroy.c (ptw32_threadDestroy): Destroy\r
- the thread's cancelLock. Moved here from ptw32_threadStart.c\r
- to cleanup implicit threads as well.\r
-\r
-2002-07-30 Alexander Terekhov <TEREKHOV at de.ibm.com>\r
-\r
- * pthread_cond_wait.c (ptw32_cond_wait_cleanup): \r
- Remove code designed to avoid/prevent spurious wakeup\r
- problems. It is believed that the sem_timedwait() call\r
- is consuming a CV signal that it shouldn't and this is\r
- breaking the avoidance logic.\r
-\r
-2002-07-30 Ross Johnson <rpj at ise.canberra.edu.au>\r
-\r
- * sem_timedwait.c (sem_timedwait): Tighten checks for\r
- unreasonable abstime values - that would result in\r
- unexpected timeout values.\r
-\r
- * w32_CancelableWait.c (ptw32_cancelable_wait):\r
- Tighten up return value checking and add comments.\r
-\r
-\r
-2002-06-08 Ross Johnson <rpj at special.ise.canberra.edu.au>\r
-\r
- * sem_getvalue.c (sem_getvalue): Now returns a value for the\r
- NEED_SEM version (i.e. earlier versions of WinCE).\r
-\r
-\r
-2002-06-04 Rob Fanner <rfanner at stonethree.com>\r
-\r
- * sem_getvalue.c (sem_getvalue): The Johnson M. Hart\r
- approach didn't work - we are forced to take an\r
- intrusive approach. We try to decrement the sema\r
- and then immediately release it again to get the\r
- value. There is a small probability that this may\r
- block other threads, but only momentarily.\r
-\r
-2002-06-03 Ross Johnson <rpj at ise.canberra.edu.au>\r
-\r
- * sem_init.c (sem_init): Initialise Win32 semaphores\r
- to _POSIX_SEM_VALUE_MAX (which this implementation\r
- defines in pthread.h) so that sem_getvalue() can use\r
- the trick described in the comments in sem_getvalue().\r
- * pthread.h (_POSIX_SEM_VALUE_MAX): Defined.\r
- (_POSIX_SEM_NSEMS_MAX): Defined - not used but may be\r
- useful for source code portability.\r
-\r
-2002-06-03 Rob Fanner <rfanner at stonethree.com>\r
-\r
- * sem_getvalue.c (sem_getvalue): Did not work on NT.\r
- Use approach suggested by Johnson M. Hart in his book\r
- "Win32 System Programming".\r
-\r
-2002-02-28 Ross Johnson <rpj at setup1.ise.canberra.edu.au>\r
-\r
- * errno.c: Compiler directive was incorrectly including code.\r
- * pthread.h: Conditionally added some #defines from config.h\r
- needed when not building the library. e.g. NEED_ERRNO, NEED_SEM.\r
- (PTW32_DLLPORT): Now only defined if _DLL defined.\r
- (_errno): Compiler directive was incorrectly including prototype.\r
- * sched.h: Conditionally added some #defines from config.h\r
- needed when not building the library.\r
- * semaphore.h: Replace an instance of NEED_SEM that should\r
- have been NEED_ERRNO. This change currently has nil effect.\r
-\r
- * GNUmakefile: Correct some recent changes.\r
-\r
- * Makefile: Add rule to generate pre-processor output.\r
-\r
-2002-02-23 Ross Johnson <rpj at setup1.ise.canberra.edu.au>\r
-\r
- * pthread_rwlock_timedrdlock.c: New - untested.\r
- * pthread_rwlock_timedwrlock.c: New - untested.\r
- \r
- * Testsuite passed (except known MSVC++ problems)\r
-\r
- * pthread_cond_destroy.c: Expand the time change\r
- critical section to solve deadlock problem.\r
-\r
- * pthread.c: Add all remaining C modules.\r
- * pthread.h: Use dllexport/dllimport attributes on functions\r
- to avoid using pthread.def.\r
- * sched.h: Likewise.\r
- * semaphore.h: Likewise.\r
- * GNUmakefile: Add new targets for single translation\r
- unit build to maximise inlining potential; generate\r
- pthread.def automatically.\r
- * Makefile: Likewise, but no longer uses pthread.def.\r
-\r
-2002-02-20 Ross Johnson <rpj at setup1.ise.canberra.edu.au>\r
-\r
- * pthread_cond_destroy.c (pthread_cond_destroy):\r
- Enter the time change critical section earlier.\r
-\r
-2002-02-17 Ross Johnson <rpj at setup1.ise.canberra.edu.au\r
-\r
- * Testsuite passed.\r
-\r
- * pthread_timechange_handler_np.c: New; following\r
- a suggestion from Alexander Terekhov that CVs should\r
- be broadcast so that they all re-evaluate their\r
- condition variables and reset a new timeout if\r
- required, whenever an application receives a\r
- WM_TIMECHANGE message. This message indicates that\r
- the system time has been changed. Therefore, CVs\r
- waiting for a timeout set as an abs_time will possibly\r
- not wake up at the expected time. Some applications\r
- may not be tolerant of this.\r
- * pthread_cond_init.c: Add CV to linked list.\r
- * pthread_cond_destroy.c: Remove CV from linked list.\r
- * global.c (ptw32_cond_list_head): New variable.\r
- (ptw32_cond_list_tail): New variable.\r
- (ptw32_cond_list_cs): New critical section.\r
- * ptw32_processInitialize (ptw32_cond_list_cs): Initialize.\r
- * ptw32_processTerminate (ptw32_cond_list_cs): Delete.\r
-\r
-\r
- * Reduce executable size.\r
- -----------------------\r
- When linking with the static library, only those\r
- routines actually called, either directly or indirectly\r
- should be included.\r
-\r
- [Gcc has the -ffunction-segments option to do this but MSVC\r
- doesn't have this feature as far as I can determine. Other\r
- compilers are undetermined as well. - rpj]\r
-\r
- * spin.c: Split file into function segments.\r
- * ptw32_spinlock_check_need_init.c: Separated routine from spin.c.\r
- * pthread_spin_init.c: Likewise.\r
- * pthread_spin_destroy.c: Likewise.\r
- * pthread_spin_lock.c: Likewise.\r
- * pthread_spin_unlock.c: Likewise.\r
- * pthread_spin_trylock.c: Likewise.\r
-\r
- * sync.c: Split file into function segments.\r
- * pthread_detach.c: Separated routine from sync.c.\r
- * pthread_join.c: Likewise.\r
-\r
- * tsd.c: Split file into function segments.\r
- * pthread_key_create.c: Separated routine from tsd.c.\r
- * pthread_key_delete.c: Likewise.\r
- * pthread_setspecific.c: Likewise.\r
- * pthread_getspecific.c: Likewise.\r
-\r
- * sched.c: Split file into function segments.\r
- * pthread_attr_setschedpolicy.c: Separated routine from sched.c.\r
- * pthread_attr_getschedpolicy.c: Likewise.\r
- * pthread_attr_setschedparam.c: Likewise.\r
- * pthread_attr_getschedparam.c: Likewise.\r
- * pthread_attr_setinheritsched.c: Likewise.\r
- * pthread_attr_getinheritsched.c: Likewise.\r
- * pthread_setschedparam.c: Likewise.\r
- * pthread_getschedparam.c: Likewise.\r
- * sched_get_priority_max.c: Likewise.\r
- * sched_get_priority_min.c: Likewise.\r
- * sched_setscheduler.c: Likewise.\r
- * sched_getscheduler.c: Likewise.\r
- * sched_yield.c: Likewise.\r
-\r
-\r
-2002-02-16 Ross Johnson <rpj at setup1.ise.canberra.edu.au\r
-\r
- Reduce executable size.\r
- -----------------------\r
- When linking with the static library, only those\r
- routines actually called, either directly or indirectly\r
- should be included.\r
-\r
- [Gcc has the -ffunction-segments option to do this but MSVC\r
- doesn't have this feature as far as I can determine. Other\r
- compilers are undetermined as well. - rpj]\r
-\r
- * mutex.c: Split file into function segments.\r
- * pthread_mutexattr_destroy.c: Separated routine from mutex.c\r
- * pthread_mutexattr_getpshared.c: Likewise.\r
- * pthread_mutexattr_gettype.c: Likewise.\r
- * pthread_mutexattr_init.c: Likewise.\r
- * pthread_mutexattr_setpshared.c: Likewise.\r
- * pthread_mutexattr_settype.c: Likewise.\r
- * ptw32_mutex_check_need_init.c: Likewise.\r
- * pthread_mutex_destroy.c: Likewise.\r
- * pthread_mutex_init.c: Likewise.\r
- * pthread_mutex_lock.c: Likewise.\r
- * pthread_mutex_timedlock.c: Likewise.\r
- * pthread_mutex_trylock.c: Likewise.\r
- * pthread_mutex_unlock.c: Likewise.\r
- \r
- * private.c: Split file into function segments.\r
- * ptw32_InterlockedCompareExchange.c: Separated routine from private.c\r
- * ptw32_callUserDestroyRoutines.c: Likewise.\r
- * ptw32_getprocessors.c: Likewise.\r
- * ptw32_processInitialize.c: Likewise.\r
- * ptw32_processTerminate.c: Likewise.\r
- * ptw32_threadDestroy.c: Likewise.\r
- * ptw32_threadStart.c: Likewise.\r
- * ptw32_throw.c: Likewise.\r
- * ptw32_timespec.c: Likewise.\r
- * ptw32_tkAssocCreate.c: Likewise.\r
- * ptw32_tkAssocDestroy.c: Likewise.\r
-\r
- * rwlock.c: Split file into function segments.\r
- * pthread_rwlockattr_destroy.c: Separated routine from rwlock.c\r
- * pthread_rwlockattr_getpshared.c: Likewise.\r
- * pthread_rwlockattr_init.c: Likewise.\r
- * pthread_rwlockattr_setpshared.c: Likewise.\r
- * ptw32_rwlock_check_need_init.c: Likewise.\r
- * pthread_rwlock_destroy.c: Likewise.\r
- * pthread_rwlock_init.c: Likewise.\r
- * pthread_rwlock_rdlock.c: Likewise.\r
- * pthread_rwlock_tryrdlock.c: Likewise.\r
- * pthread_rwlock_trywrlock.c: Likewise.\r
- * pthread_rwlock_unlock.c: Likewise.\r
- * pthread_rwlock_wrlock.c: Likewise.\r
-\r
-2002-02-10 Ross Johnson <rpj at setup1.ise.canberra.edu.au\r
-\r
- Reduce executable size.\r
- -----------------------\r
- When linking with the static library, only those\r
- routines actually called, either directly or indirectly\r
- should be included.\r
-\r
- [Gcc has the -ffunction-segments option to do this but MSVC\r
- doesn't have this feature as far as I can determine. Other\r
- compilers are undetermined as well. - rpj]\r
-\r
- * nonportable.c: Split file into function segments.\r
- * np_delay.c: Separated routine from nonportable.c\r
- * np_getw32threadhandle.c: Likewise.\r
- * np_mutexattr_setkind.c: Likewise.\r
- * np_mutexattr_getkind.c: Likewise.\r
- * np_num_processors.c: Likewise.\r
- * np_win32_attach_detach.c: Likewise.\r
-\r
- * misc.c: Split file into function segments.\r
- * pthread_equal.c: Separated routine from nonportable.c.\r
- * pthread_getconcurrency.c: Likewise.\r
- * pthread_once.c: Likewise.\r
- * pthread_self.c: Likewise.\r
- * pthread_setconcurrency.c: Likewise.\r
- * ptw32_calloc.c: Likewise.\r
- * ptw32_new.c: Likewise.\r
- * w32_CancelableWait.c: Likewise.\r
- \r
-2002-02-09 Ross Johnson <rpj at setup1.ise.canberra.edu.au\r
-\r
- Reduce executable size.\r
- -----------------------\r
- When linking with the static library, only those\r
- routines actually called, either directly or indirectly\r
- should be included.\r
-\r
- [Gcc has the -ffunction-segments option to do this but MSVC\r
- doesn't have this feature as far as I can determine. Other\r
- compilers are undetermined as well. - rpj]\r
-\r
- * condvar.c: Split file into function segments.\r
- * pthread_condattr_destroy.c: Separated routine from condvar.c.\r
- * pthread_condattr_getpshared.c: Likewise.\r
- * pthread_condattr_init.c: Likewise.\r
- * pthread_condattr_setpshared.c: Likewise.\r
- * ptw32_cond_check_need_init.c: Likewise.\r
- * pthread_cond_destroy.c: Likewise.\r
- * pthread_cond_init.c: Likewise.\r
- * pthread_cond_signal.c: Likewise.\r
- * pthread_cond_wait.c: Likewise.\r
- \r
-2002-02-07 Alexander Terekhov<TEREKHOV at de.ibm.com>\r
-\r
- * nonportable.c (pthread_delay_np): Make a true\r
- cancelation point. Deferred cancels will interrupt the\r
- wait.\r
-\r
-2002-02-07 Ross Johnson <rpj at setup1.ise.canberra.edu.au\r
-\r
- * misc.c (ptw32_new): Add creation of cancelEvent so that\r
- implicit POSIX threads (Win32 threads with a POSIX face)\r
- are cancelable; mainly so that pthread_delay_np doesn't fail\r
- if called from the main thread.\r
- * create.c (pthread_create): Remove creation of cancelEvent\r
- from here; now in ptw32_new().\r
-\r
- Reduce executable size.\r
- -----------------------\r
- When linking with the static library, only those\r
- routines actually called, either directly or indirectly\r
- should be included.\r
-\r
- [Gcc has the -ffunction-segments option to do this but MSVC\r
- doesn't have this feature as far as I can determine. Other\r
- compilers are undetermined as well. - rpj]\r
-\r
- * barrier.c: All routines are now in separate compilation units;\r
- This file is used to congregate the separate modules for\r
- potential inline optimisation and backward build compatibility.\r
- * cancel.c: Likewise.\r
- * pthread_barrierattr_destroy.c: Separated routine from cancel.c.\r
- * pthread_barrierattr_getpshared.c: Likewise.\r
- * pthread_barrierattr_init.c: Likewise.\r
- * pthread_barrierattr_setpshared.c: Likewise.\r
- * pthread_barrier_destroy.c: Likewise.\r
- * pthread_barrier_init.c: Likewise.\r
- * pthread_barrier_wait.c: Likewise.\r
- * pthread_cancel.c: Likewise.\r
- * pthread_setcancelstate.c: Likewise.\r
- * pthread_setcanceltype.c: Likewise.\r
- * pthread_testcancel.c: Likewise.\r
-\r
-2002-02-04 Max Woodbury <mtew at cds.duke.edu>\r
-\r
- Reduced name space pollution.\r
- -----------------------------\r
- When the appropriate symbols are defined, the headers\r
- will restrict the definitions of new names. In particular,\r
- it must be possible to NOT include the <windows.h>\r
- header and related definitions with some combination\r
- of symbol definitions. Secondly, it should be possible\r
- that additional definitions should be limited to POSIX \r
- compliant symbols by the definition of appropriate symbols.\r
-\r
- * pthread.h: POSIX conditionals.\r
- * sched.h: POSIX conditionals.\r
- * semaphore.h: POSIX conditionals.\r
-\r
- * semaphore.c: Included <limits.h>.\r
- (sem_init): Changed magic 0x7FFFFFFFL to INT_MAX.\r
- (sem_getvalue): Trial version.\r
-\r
- Reduce executable size.\r
- -----------------------\r
- When linking with the static library, only those\r
- routines actually called, either directly or indirectly\r
- should be included.\r
-\r
- [Gcc has the -ffunction-segments option to do this but MSVC\r
- doesn't have this feature as far as I can determine. Other\r
- compilers are undetermined as well. - rpj]\r
-\r
- * semaphore.c: All routines are now in separate compilation units;\r
- This file is used to congregate the separate modules for\r
- potential inline optimisation and backward build compatibility.\r
- * sem_close.c: Separated routine from semaphore.c.\r
- * ptw32_decrease_semaphore.c: Likewise.\r
- * sem_destroy.c: Likewise.\r
- * sem_getvalue.c: Likewise.\r
- * ptw32_increase_semaphore.c: Likewise.\r
- * sem_init.c: Likewise.\r
- * sem_open.c: Likewise.\r
- * sem_post.c: Likewise.\r
- * sem_post_multiple.c: Likewise.\r
- * sem_timedwait.c: Likewise.\r
- * sem_trywait.c: Likewise.\r
- * sem_unlink.c: Likewise.\r
- * sem_wait.c: Likewise.\r
-\r
-2002-02-04 Ross Johnson <rpj at setup1.ise.canberra.edu.au>\r
-\r
- The following extends the idea above to the rest of pthreads-win32 - rpj\r
- \r
- * attr.c: All routines are now in separate compilation units;\r
- This file is used to congregate the separate modules for\r
- potential inline optimisation and backward build compatibility.\r
- * pthread_attr_destroy.c: Separated routine from attr.c.\r
- * pthread_attr_getdetachstate.c: Likewise.\r
- * pthread_attr_getscope.c: Likewise.\r
- * pthread_attr_getstackaddr.c: Likewise.\r
- * pthread_attr_getstacksize.c: Likewise.\r
- * pthread_attr_init.c: Likewise.\r
- * pthread_attr_is_attr.c: Likewise.\r
- * pthread_attr_setdetachstate.c: Likewise.\r
- * pthread_attr_setscope.c: Likewise.\r
- * pthread_attr_setstackaddr.c: Likewise.\r
- * pthread_attr_setstacksize.c: Likewise.\r
-\r
- * pthread.c: Agregation of agregate modules for super-inlineability.\r
-\r
-2002-02-02 Ross Johnson <rpj at setup1.ise.canberra.edu.au>\r
-\r
- * cancel.c: Rearranged some code and introduced checks\r
- to disable cancelation at the start of a thread's cancelation\r
- run to prevent double cancelation. The main problem\r
- arises if a thread is canceling and then receives a subsequent\r
- async cancel request.\r
- * private.c: Likewise.\r
- * condvar.c: Place pragmas around cleanup_push/pop to turn\r
- off inline optimisation (/Obn where n>0 - MSVC only). Various\r
- optimisation switches in MSVC turn this on, which interferes with\r
- the way that cleanup handlers are run in C++ EH and SEH\r
- code. Application code compiled with inline optimisation must\r
- also wrap cleanup_push/pop blocks with the pragmas, e.g.\r
- #pragma inline_depth(0)\r
- pthread_cleanup_push(...)\r
- ...\r
- pthread_cleanup_pop(...)\r
- #pragma inline_depth(8)\r
- * rwlock.c: Likewise.\r
- * mutex.c: Remove attempts to inline some functions.\r
- * signal.c: Modify misleading comment.\r
-\r
-2002-02-01 Ross Johnson <rpj at setup1.ise.canberra.edu.au>\r
-\r
- * semaphore.c (sem_trywait): Fix missing errno return\r
- for systems that define NEED_SEM (e.g. early WinCE).\r
- * mutex.c (pthread_mutex_timedlock): Return ENOTSUP\r
- for systems that define NEED_SEM since they don't\r
- have sem_trywait().\r
-\r
-2002-01-27 Ross Johnson <rpj at special.ise.canberra.edu.au>\r
-\r
- * mutex.c (pthread_mutex_timedlock): New function suggested by\r
- Alexander Terekhov. The logic required to implement this\r
- properly came from Alexander, with some collaboration\r
- with Thomas Pfaff.\r
- (pthread_mutex_unlock): Wrap the waiters check and sema\r
- post in a critical section to prevent a race with\r
- pthread_mutex_timedlock.\r
- (ptw32_timed_semwait): New function;\r
- returns a special result if the absolute timeout parameter\r
- represents a time already passed when called; used by\r
- pthread_mutex_timedwait(). Have deliberately not reused\r
- the name "ptw32_sem_timedwait" because they are not the same\r
- routine.\r
- * condvar.c (ptw32_cond_timedwait): Use the new sem_timedwait()\r
- instead of ptw32_sem_timedwait(), which now has a different\r
- function. See previous.\r
- * implement.h: Remove prototype for ptw32_sem_timedwait.\r
- See next.\r
- (pthread_mutex_t_): Add critical section element for access\r
- to lock_idx during mutex post-timeout processing.\r
- * semaphore.h (sem_timedwait): See next.\r
- * semaphore.c (sem_timedwait): See next.\r
- * private.c (ptw32_sem_timedwait): Move to semaphore.c\r
- and rename as sem_timedwait().\r
-\r
-2002-01-18 Ross Johnson <rpj at special.ise.canberra.edu.au>\r
-\r
- * sync.c (pthread_join): Was getting the exit code from the\r
- calling thread rather than the joined thread if\r
- defined(__MINGW32__) && !defined(__MSVCRT__).\r
-\r
-2002-01-15 Ross Johnson <rpj at special.ise.canberra.edu.au>\r
-\r
- * pthread.h: Unless the build explicitly defines __CLEANUP_SEH,\r
- __CLEANUP_CXX, or __CLEANUP_C, then the build defaults to\r
- __CLEANUP_C style cleanup. This style uses setjmp/longjmp\r
- in the cancelation and thread exit implementations and therefore\r
- won't do stack unwinding if linked to applications that have it\r
- (e.g. C++ apps). This is currently consistent with most/all\r
- commercial Unix POSIX threads implementations.\r
-\r
- * spin.c (pthread_spin_init): Edit renamed function call.\r
- * nonportable.c (pthread_num_processors_np): New.\r
- (pthread_getprocessors_np): Renamed to ptw32_getprocessors\r
- and moved to private.c.\r
- * private.c (pthread_getprocessors): Moved here from\r
- nonportable.c.\r
- * pthread.def (pthread_getprocessors_np): Removed\r
- from export list.\r
-\r
- * rwlock.c (pthread_rwlockattr_init): New.\r
- (pthread_rwlockattr_destroy): New.\r
- (pthread_rwlockattr_getpshared): New.\r
- (pthread_rwlockattr_setpshared): New.\r
-\r
-2002-01-14 Ross Johnson <rpj at special.ise.canberra.edu.au>\r
-\r
- * attr.c (pthread_attr_setscope): Fix struct pointer\r
- indirection error introduced 2002-01-04.\r
- (pthread_attr_getscope): Likewise.\r
-\r
-2002-01-12 Ross Johnson <rpj at special.ise.canberra.edu.au>\r
-\r
- * pthread.dsp (SOURCE): Add missing source files.\r
-\r
-2002-01-08 Ross Johnson <rpj at setup1.ise.canberra.edu.au>\r
-\r
- * mutex.c (pthread_mutex_trylock): use\r
- ptw32_interlocked_compare_exchange function pointer\r
- rather than ptw32_InterlockedCompareExchange() directly\r
- to retain portability to non-iX86 processors,\r
- e.g. WinCE etc. The pointer will point to the native\r
- OS version of InterlockedCompareExchange() if the\r
- OS supports it (see ChangeLog entry of 2001-10-17).\r
-\r
-2002-01-07 Thomas Pfaff <tpfaff at gmx.net>, Alexander Terekhov <TEREKHOV at de.ibm.com>\r
-\r
- * mutex.c (pthread_mutex_init): Remove critical\r
- section calls.\r
- (pthread_mutex_destroy): Likewise.\r
- (pthread_mutex_unlock): Likewise.\r
- (pthread_mutex_trylock): Likewise; uses\r
- ptw32_InterlockedCompareExchange() to avoid need for\r
- critical section; library is no longer i386 compatible;\r
- recursive mutexes now increment the lock count rather\r
- than return EBUSY; errorcheck mutexes return EDEADLCK\r
- rather than EBUSY. This behaviour is consistent with the\r
- Solaris pthreads implementation.\r
- * implement.h (pthread_mutex_t_): Remove critical\r
- section element - no longer needed.\r
- \r
-\r
-2002-01-04 Ross Johnson <rpj at setup1.ise.canberra.edu.au>\r
-\r
- * attr.c (pthread_attr_setscope): Add more error\r
- checking and actually store the scope value even\r
- though it's not really necessary.\r
- (pthread_attr_getscope): Return stored value.\r
- * implement.h (pthread_attr_t_): Add new scope element.\r
- * ANNOUNCE: Fix out of date comment next to\r
- pthread_attr_setscope in conformance section.\r
-\r
-2001-12-21 Alexander Terekhov <TEREKHOV at de.ibm.com>\r
-\r
- * mutex.c (pthread_mutex_lock): Decrementing lock_idx was\r
- not thread-safe.\r
- (pthread_mutex_trylock): Likewise.\r
-\r
-2001-10-26 prionx@juno.com\r
-\r
- * semaphore.c (sem_init): Fix typo and missing bracket\r
- in conditionally compiled code. Only older versions of\r
- WinCE require this code, hence it doesn't normally get\r
- tested; somehow when sem_t reverted to an opaque struct\r
- the calloc NULL check was left in the conditionally included\r
- section.\r
- (sem_destroy): Likewise, the calloced sem_t wasn't being freed.\r
-\r
-2001-10-25 Ross Johnson <rpj at setup1.ise.canberra.edu.au>\r
-\r
- * GNUmakefile (libwsock32): Add to linker flags for\r
- WSAGetLastError() and WSASetLastError().\r
- * Makefile (wsock32.lib): Likewise.\r
- * create.c: Minor mostly inert changes.\r
- * implement.h (PTW32_MAX): Move into here and renamed\r
- from sched.h.\r
- (PTW32_MIN): Likewise.\r
- * GNUmakefile (TEST_ICE): Define if testing internal\r
- implementation of InterlockedCompareExchange.\r
- * Makefile (TEST_ICE): Likewise.\r
- * private.c (TEST_ICE): Likewise.\r
- \r
-2001-10-24 Ross Johnson <rpj at setup1.ise.canberra.edu.au>\r
-\r
- * attr.c (pthread_attr_setstacksize): Quell warning\r
- from LCC by conditionally compiling the stacksize\r
- validity check. LCC correctly warns that the condition\r
- (stacksize < PTHREAD_STACK_MIN) is suspicious\r
- because STACK_MIN is 0 and stacksize is of type\r
- size_t (or unsigned int).\r
-\r
-2001-10-17 Ross Johnson <rpj at setup1.ise.canberra.edu.au>\r
-\r
- * barrier.c: Move _LONG and _LPLONG defines into\r
- implement.h; rename to PTW32_INTERLOCKED_LONG and\r
- PTW32_INTERLOCKED_LPLONG respectively.\r
- * spin.c: Likewise; ptw32_interlocked_compare_exchange used\r
- in place of InterlockedCompareExchange directly.\r
- * global.c (ptw32_interlocked_compare_exchange): Add\r
- prototype for this new routine pointer to be used when\r
- InterlockedCompareExchange isn't supported by Windows.\r
- * nonportable.c (pthread_win32_process_attach_np): Check for\r
- support of InterlockedCompareExchange in kernel32 and assign its\r
- address to ptw32_interlocked_compare_exchange if it exists, or\r
- our own ix86 specific implementation ptw32_InterlockedCompareExchange.\r
- *private.c (ptw32_InterlockedCompareExchange): An\r
- implementation of InterlockedCompareExchange() which is\r
- specific to ix86; written directly in assembler for either\r
- MSVC or GNU C; needed because Windows 95 doesn't support\r
- InterlockedCompareExchange().\r
-\r
- * sched.c (sched_get_priority_min): Extend to return\r
- THREAD_PRIORITY_IDLE.\r
- (sched_get_priority_max): Extend to return\r
- THREAD_PRIORITY_CRITICAL.\r
-\r
-2001-10-15 Ross Johnson <rpj at setup1.ise.canberra.edu.au>\r
-\r
- * spin.c (pthread_spin_lock): PTHREAD_SPINLOCK_INITIALIZER\r
- was causing a program fault.\r
- (pthread_spin_init): Could have alloced memory\r
- without freeing under some error conditions.\r
-\r
- * mutex.c (pthread_mutex_init): Move memory\r
- allocation of mutex struct after checking for\r
- PROCESS_SHARED.\r
-\r
-2001-10-12 Ross Johnson <rpj at setup1.ise.canberra.edu.au>\r
-\r
- * spin.c (pthread_spin_unlock): Was not returning\r
- EPERM if the spinlock was not locked, for multi CPU\r
- machines.\r
-\r
-2001-10-08 Ross Johnson <rpj at setup1.ise.canberra.edu.au>\r
-\r
- * spin.c (pthread_spin_trylock): Was not returning\r
- EBUSY for multi CPU machines.\r
-\r
-2001-08-24 Ross Johnson <rpj at setup1.ise.canberra.edu.au>\r
-\r
- * condvar.c (pthread_cond_destroy): Remove cv element\r
- that is no longer used.\r
- * implement.h: Likewise.\r
-\r
-2001-08-23 Alexander Terekhov <TEREKHOV at de.ibm.com>\r
-\r
- * condvar.c (pthread_cond_destroy): fix bug with\r
- respect to deadlock in the case of concurrent\r
- _destroy/_unblock; a condition variable can be destroyed\r
- immediately after all the threads that are blocked on\r
- it are awakened.\r
-\r
-2001-08-23 Phil Frisbie, Jr. <phil at hawksoft.com>\r
-\r
- * tsd.c (pthread_getspecific): Preserve the last\r
- winsock error [from WSAGetLastError()].\r
-\r
-2001-07-18 Scott McCaskill <scott at magruder.org>\r
-\r
- * mutex.c (pthread_mutexattr_init): Return ENOMEM\r
- immediately and don't dereference the NULL pointer\r
- if calloc fails.\r
- (pthread_mutexattr_getpshared): Don't dereference\r
- a pointer that is possibly NULL.\r
- * barrier.c (pthread_barrierattr_init): Likewise\r
- (pthread_barrierattr_getpshared): Don't dereference\r
- a pointer that is possibly NULL.\r
- * condvar.c (pthread_condattr_getpshared): Don't dereference\r
- a pointer that is possibly NULL.\r
-\r
-2001-07-15 Ross Johnson <rpj at setup1.ise.canberra.edu.au>\r
-\r
- * rwlock.c (pthread_rwlock_wrlock): Is allowed to be\r
- a cancelation point; re-enable deferred cancelability\r
- around the CV call.\r
-\r
-2001-07-10 Ross Johnson <rpj at setup1.ise.canberra.edu.au>\r
-\r
- * barrier.c: Still more revamping. The exclusive access\r
- mutex isn't really needed so it has been removed and replaced\r
- by an InterlockedDecrement(). nSerial has been removed.\r
- iStep is now dual-purpose. The process shared attribute\r
- is now stored in the barrier struct.\r
- * implement.h (pthread_barrier_t_): Lost some/gained one\r
- elements.\r
- * private.c (ptw32_threadStart): Removed some comments.\r
-\r
-2001-07-10 Ross Johnson <rpj at setup1.ise.canberra.edu.au>\r
-\r
- * barrier.c: Revamped to fix the race condition. Two alternating\r
- semaphores are used instead of the PulseEvent. Also improved\r
- overall throughput by returning PTHREAD_BARRIER_SERIAL_THREAD\r
- to the first waking thread.\r
- * implement.h (pthread_barrier_t_): Revamped.\r
-\r
-2001-07-09 Ross Johnson <rpj at setup1.ise.canberra.edu.au>\r
-\r
- * barrier.c: Fix several bugs in all routines. Now passes\r
- tests/barrier5.c which is fairly rigorous. There is still\r
- a non-optimal work-around for a race condition between\r
- the barrier breeched event signal and event wait. Basically\r
- the last (signalling) thread to hit the barrier yields\r
- to allow any other threads, which may have lost the race,\r
- to complete.\r
-\r
-2001-07-07 Ross Johnson <rpj at setup1.ise.canberra.edu.au>\r
-\r
- * barrier.c: Changed synchronisation mechanism to a\r
- Win32 manual reset Event and use PulseEvent to signal\r
- waiting threads. If the implementation continued to use\r
- a semaphore it would require a second semaphore and\r
- some management to use them alternately as barriers. A\r
- single semaphore allows threads to cascade from one barrier\r
- through the next, leaving some threads blocked at the first.\r
- * implement.h (pthread_barrier_t_): As per above.\r
- * general: Made a number of other routines inlinable.\r
-\r
-2001-07-07 Ross Johnson <rpj at setup1.ise.canberra.edu.au>\r
-\r
- * spin.c: Revamped and working; included static initialiser.\r
- Now beta level.\r
- * barrier.c: Likewise.\r
- * condvar.c: Macro constant change; inline auto init routine.\r
- * mutex.c: Likewise.\r
- * rwlock.c: Likewise.\r
- * private.c: Add support for spinlock initialiser.\r
- * global.c: Likewise.\r
- * implement.h: Likewise.\r
- * pthread.h (PTHREAD_SPINLOCK_INITIALIZER): Fix typo.\r
-\r
-2001-07-05 Ross Johnson <rpj at setup1.ise.canberra.edu.au>\r
-\r
- * barrier.c: Remove static initialisation - irrelevent\r
- for this object.\r
- * pthread.h (PTHREAD_BARRIER_INITIALIZER): Removed.\r
- * rwlock.c (pthread_rwlock_wrlock): This routine is\r
- not a cancelation point - disable deferred\r
- cancelation around call to pthread_cond_wait().\r
-\r
-2001-07-05 Ross Johnson <rpj at setup1.ise.canberra.edu.au>\r
-\r
- * spin.c: New module implementing spin locks.\r
- * barrier.c: New module implementing barriers.\r
- * pthread.h (_POSIX_SPIN_LOCKS): defined.\r
- (_POSIX_BARRIERS): Defined.\r
- (pthread_spin_*): Defined.\r
- (pthread_barrier*): Defined.\r
- (PTHREAD_BARRIER_SERIAL_THREAD): Defined.\r
- * implement.h (pthread_spinlock_t_): Defined.\r
- (pthread_barrier_t_): Defined.\r
- (pthread_barrierattr_t_): Defined.\r
-\r
- * mutex.c (pthread_mutex_lock): Return with the error\r
- if an auto-initialiser initialisation fails.\r
-\r
- * nonportable.c (pthread_getprocessors_np): New; gets the\r
- number of available processors for the current process.\r
-\r
-2001-07-03 Ross Johnson <rpj at setup1.ise.canberra.edu.au>\r
-\r
- * pthread.h (_POSIX_READER_WRITER_LOCKS): Define it\r
- if not already defined.\r
-\r
-2001-07-01 Alexander Terekhov <TEREKHOV at de.ibm.com>\r
-\r
- * condvar.c: Fixed lost signal bug reported by Timur Aydin\r
- (taydin@snet.net).\r
- [RPJ (me) didn't translate the original algorithm\r
- correctly.]\r
- * semaphore.c: Added sem_post_multiple; this is a useful\r
- routine, but it doesn't appear to be standard. For now it's\r
- not an exported function.\r
- \r
-2001-06-25 Ross Johnson <rpj at setup1.ise.canberra.edu.au>\r
-\r
- * create.c (pthread_create): Add priority inheritance\r
- attributes.\r
- * mutex.c (pthread_mutex_lock): Remove some overhead for\r
- PTHREAD_MUTEX_NORMAL mutex types. Specifically, avoid\r
- calling pthread_self() and pthread_equal() to check/set\r
- the mutex owner. Introduce a new pseudo owner for this\r
- type. Test results suggest increases in speed of up to\r
- 90% for non-blocking locks.\r
- This is the default type of mutex used internally by other\r
- synchronising objects, ie. condition variables and\r
- read-write locks. The test rwlock7.c shows about a\r
- 30-35% speed increase over snapshot 2001-06-06. The\r
- price of this is that the application developer\r
- must ensure correct behaviour, or explicitly set the\r
- mutex to a safer type such as PTHREAD_MUTEX_ERRORCHECK.\r
- For example, PTHREAD_MUTEX_NORMAL (or PTHREAD_MUTEX_DEFAULT)\r
- type mutexes will not return an error if a thread which is not\r
- the owner calls pthread_mutex_unlock. The call will succeed\r
- in unlocking the mutex if it is currently locked, but a\r
- subsequent unlock by the true owner will then fail with EPERM.\r
- This is however consistent with some other implementations.\r
- (pthread_mutex_unlock): Likewise.\r
- (pthread_mutex_trylock): Likewise.\r
- (pthread_mutex_destroy): Likewise.\r
- * attr.c (pthread_attr_init): PTHREAD_EXPLICIT_SCHED is the\r
- default inheritance attribute; THREAD_PRIORITY_NORMAL is\r
- the default priority for new threads.\r
- * sched.c (pthread_attr_setschedpolicy): Added routine.\r
- (pthread_attr_getschedpolicy): Added routine.\r
- (pthread_attr_setinheritsched): Added routine.\r
- (pthread_attr_getinheritsched): Added routine.\r
- * pthread.h (sched_rr_set_interval): Added as a macro;\r
- returns -1 with errno set to ENOSYS.\r
-\r
-2001-06-23 Ross Johnson <rpj at setup1.ise.canberra.edu.au>\r
-\r
- *sched.c (pthread_attr_setschedparam): Add priority range\r
- check.\r
- (sched_setscheduler): New function; checks for a valid\r
- pid and policy; checks for permission to set information\r
- in the target process; expects pid to be a Win32 process ID,\r
- not a process handle; the only scheduler policy allowed is\r
- SCHED_OTHER.\r
- (sched_getscheduler): Likewise, but checks for permission\r
- to query.\r
- * pthread.h (SCHED_*): Moved to sched.h as defined in the\r
- POSIX standard.\r
- * sched.h (SCHED_*): Moved from pthread.h.\r
- (pid_t): Defined if necessary.\r
- (sched_setscheduler): Defined.\r
- (sched_getscheduler): Defined.\r
- * pthread.def (sched_setscheduler): Exported.\r
- (sched_getscheduler): Likewise.\r
-\r
-2001-06-23 Ralf Brese <Ralf.Brese at pdb4.siemens.de>\r
-\r
- * create.c (pthread_create): Set thread priority from\r
- thread attributes.\r
-\r
-2001-06-18 Ross Johnson <rpj at setup1.ise.canberra.edu.au>\r
-\r
- * Made organisational-only changes to UWIN additions.\r
- * dll.c (dllMain): Moved UWIN process attach code\r
- to pthread_win32_process_attach_np(); moved\r
- instance of pthread_count to global.c.\r
- * global.c (pthread_count): Moved from dll.c.\r
- * nonportable.c (pthread_win32_process_attach_np):\r
- Moved _UWIN code to here from dll.c.\r
- * implement.h (pthread_count): Define extern int.\r
- * create.c (pthread_count): Remove extern int.\r
- * private.c (pthread_count): Likewise.\r
- * exit.c (pthread_count): Likewise.\r
-\r
-2001-06-18 David Korn <dgk at research.att.com>\r
-\r
- * dll.c: Added changes necessary to work with UWIN.\r
- * create.c: Likewise.\r
- * pthread.h: Likewise.\r
- * misc.c: Likewise.\r
- * exit.c: Likewise.\r
- * private.c: Likewise.\r
- * implement.h: Likewise.\r
- There is some room at the start of struct pthread_t_\r
- to implement the signal semantics in UWIN's posix.dll\r
- although this is not yet complete.\r
- * Nmakefile: Compatible with UWIN's Nmake utility.\r
- * Nmakefile.tests: Likewise - for running the tests.\r
-\r
-2001-06-08 Ross Johnson <rpj at setup1.ise.canberra.edu.au>\r
-\r
- * semaphore.h (sem_t): Fixed for compile and test.\r
- * implement.h (sem_t_): Likewise.\r
- * semaphore.c: Likewise.\r
- * private.c (ptw32_sem_timedwait): Updated to use new\r
- opaque sem_t.\r
-\r
-2001-06-06 Ross Johnson <rpj at setup1.ise.canberra.edu.au>\r
-\r
- * semaphore.h (sem_t): Is now an opaque pointer;\r
- moved actual definition to implement.h.\r
- * implement.h (sem_t_): Move here from semaphore.h;\r
- was the definition of sem_t.\r
- * semaphore.c: Wherever necessary, changed use of sem\r
- from that of a pointer to a pointer-pointer; added\r
- extra checks for a valid sem_t; NULL sem_t when\r
- it is destroyed; added extra checks when creating\r
- and destroying sem_t elements in the NEED_SEM\r
- code branches; changed from using a pthread_mutex_t\r
- ((*sem)->mutex) to CRITICAL_SECTION ((*sem)->sem_lock_cs)\r
- in NEED_SEM branches for access serialisation.\r
-\r
-2001-06-06 Ross Johnson <rpj at setup1.ise.canberra.edu.au>\r
-\r
- * mutex.c (pthread_mutexattr_init): Remove \r
- ptw32_mutex_default_kind.\r
- \r
-2001-06-05 Ross Johnson <rpj at setup1.ise.canberra.edu.au>\r
-\r
- * nonportable.c (pthread_mutex_setdefaultkind_np):\r
- Remove - should not have been included in the first place.\r
- (pthread_mutex_getdefaultkind_np): Likewise.\r
- * global.c (ptw32_mutex_default_kind): Likewise.\r
- * mutex.c (pthread_mutex_init): Remove use of\r
- ptw32_mutex_default_kind.\r
- * pthread.h (pthread_mutex_setdefaultkind_np): Likewise.\r
- (pthread_mutex_getdefaultkind_np): Likewise.\r
- * pthread.def (pthread_mutexattr_setkind_np): Added.\r
- (pthread_mutexattr_getkind_np): Likewise.\r
-\r
- * README: Many changes that should have gone in before\r
- the last snapshot.\r
- * README.NONPORTABLE: New - referred to by ANNOUNCE\r
- but never created; documents the non-portable routines\r
- included in the library - moved from README with new\r
- routines added.\r
- * ANNOUNCE (pthread_mutexattr_setkind_np): Added to\r
- compliance list.\r
- (pthread_mutexattr_getkind_np): Likewise.\r
-\r
-2001-06-04 Ross Johnson <rpj at setup1.ise.canberra.edu.au>\r
-\r
- * condvar.c: Add original description of the algorithm as\r
- developed by Terekhov and Thomas, plus reference to\r
- README.CV.\r
-\r
-2001-06-03 Alexander Terekhov <TEREKHOV at de.ibm.com>, Louis Thomas <lthomas at arbitrade.com>\r
-\r
- * condvar.c (pthread_cond_init): Completely revamped.\r
- (pthread_cond_destroy): Likewise.\r
- (ptw32_cond_wait_cleanup): Likewise.\r
- (ptw32_cond_timedwait): Likewise.\r
- (ptw32_cond_unblock): New general signaling routine.\r
- (pthread_cond_signal): Now calls ptw32_cond_unblock.\r
- (pthread_cond_broadcast): Likewise.\r
- * implement.h (pthread_cond_t_): Revamped.\r
- * README.CV: New; explanation of the above changes.\r
-\r
-2001-05-30 Ross Johnson <rpj at setup1.ise.canberra.edu.au>\r
-\r
- * pthread.h (rand_r): Fake using _seed argument to quell\r
- compiler warning (compiler should optimise this away later).\r
-\r
- * GNUmakefile (OPT): Leave symbolic information out of the library\r
- and increase optimisation level - for smaller faster prebuilt\r
- dlls.\r
- \r
-2001-05-29 Milan Gardian <Milan.Gardian at LEIBINGER.com>\r
-\r
- * Makefile: fix typo.\r
- * pthreads.h: Fix problems with stdcall/cdecl conventions, in particular\r
- remove the need for PT_STDCALL everywhere; remove warning supression.\r
- * (errno): Fix the longstanding "inconsistent dll linkage" problem\r
- with errno; now also works with /MD debugging libs - \r
- warnings emerged when compiling pthreads library with /MD (or /MDd)\r
- compiler switch, instead of /MT (or /MTd) (i.e. when compiling pthreads\r
- using Multithreaded DLL CRT instead of Multithreaded statically linked\r
- CRT).\r
- * create.c (pthread_create): Likewise; fix typo.\r
- * private.c (ptw32_threadStart): Eliminate use of terminate() which doesn't\r
- throw exceptions.\r
- * Remove unnecessary #includes from a number of modules -\r
- [I had to #include malloc.h in implement.h for gcc - rpj].\r
-\r
-2001-05-29 Thomas Pfaff <tpfaff at gmx.net>\r
-\r
- * pthread.h (PTHREAD_MUTEX_DEFAULT): New; equivalent to\r
- PTHREAD_MUTEX_DEFAULT_NP.\r
- * (PTHREAD_MUTEX_NORMAL): Similarly.\r
- * (PTHREAD_MUTEX_ERRORCHECK): Similarly.\r
- * (PTHREAD_MUTEX_RECURSIVE): Similarly.\r
- * (pthread_mutex_setdefaultkind_np): New; Linux compatibility stub\r
- for pthread_mutexattr_settype.\r
- * (pthread_mutexattr_getkind_np): New; Linux compatibility stub\r
- for pthread_mutexattr_gettype.\r
- * mutex.c (pthread_mutexattr_settype): New; allow\r
- the following types of mutex:\r
- PTHREAD_MUTEX_DEFAULT_NP\r
- PTHREAD_MUTEX_NORMAL_NP\r
- PTHREAD_MUTEX_ERRORCHECK_NP\r
- PTHREAD_MUTEX_RECURSIVE_NP\r
- * Note that PTHREAD_MUTEX_DEFAULT is equivalent to\r
- PTHREAD_MUTEX_NORMAL - ie. mutexes should no longer\r
- be recursive by default, and a thread will deadlock if it\r
- tries to relock a mutex it already owns. This is inline with\r
- other pthreads implementations.\r
- * (pthread_mutex_lock): Process the lock request\r
- according to the mutex type.\r
- * (pthread_mutex_init): Eliminate use of Win32 mutexes as the\r
- basis of POSIX mutexes - instead, a combination of one critical section\r
- and one semaphore are used in conjunction with Win32 Interlocked* routines.\r
- * (pthread_mutex_destroy): Likewise.\r
- * (pthread_mutex_lock): Likewise.\r
- * (pthread_mutex_trylock): Likewise.\r
- * (pthread_mutex_unlock): Likewise.\r
- * Use longjmp/setjmp to implement cancelation when building the library\r
- using a C compiler which doesn't support exceptions, e.g. gcc -x c (note\r
- that gcc -x c++ uses exceptions).\r
- * Also fixed some of the same typos and eliminated PT_STDCALL as\r
- Milan Gardian's patches above.\r
-\r
-2001-02-07 Alexander Terekhov <TEREKHOV at de.ibm.com>\r
-\r
- * rwlock.c: Revamped.\r
- * implement.h (pthread_rwlock_t_): Redefined.\r
- This implementation does not have reader/writer starvation problem.\r
- Rwlock attempts to behave more like a normal mutex with\r
- races and scheduling policy determining who is more important;\r
- It also supports recursive locking,\r
- has less synchronization overhead (no broadcasts at all,\r
- readers are not blocked on any condition variable) and seem to\r
- be faster than the current implementation [W98 appears to be\r
- approximately 15 percent faster at least - on top of speed increase\r
- from Thomas Pfaff's changes to mutex.c - rpj].\r
-\r
-2000-12-29 Ross Johnson <rpj at special.ise.canberra.edu.au>\r
-\r
- * Makefile: Back-out "for" loops which don't work.\r
-\r
- * GNUmakefile: Remove the fake.a target; add the "realclean"\r
- target; don't remove built libs under the "clean" target.\r
-\r
- * config.h: Add a guard against multiple inclusion.\r
-\r
- * semaphore.h: Add some defines from config.h to make\r
- semaphore.h independent of config.h when building apps.\r
-\r
- * pthread.h (_errno): Back-out previous fix until we know how to\r
- fix it properly.\r
-\r
- * implement.h (lockCount): Add missing element to pthread_mutex_t_.\r
-\r
- * sync.c (pthread_join): Spelling fix in comment.\r
-\r
- * private.c (ptw32_threadStart): Reset original termination\r
- function (C++).\r
- (ptw32_threadStart): Cleanup detached threads early in case\r
- the library is statically linked.\r
- (ptw32_callUserDestroyRoutines): Remove [SEH] __try block from\r
- destructor call so that unhandled exceptions will be passed through\r
- to the system; call terminate() from [C++] try block for the same\r
- reason.\r
-\r
- * tsd.c (pthread_getspecific): Add comment.\r
-\r
- * mutex.c (pthread_mutex_init): Initialise new elements in\r
- pthread_mutex_t.\r
- (pthread_mutex_unlock): Invert "pthread_equal()" test.\r
-\r
-2000-12-28 Ross Johnson <rpj at special.ise.canberra.edu.au>\r
-\r
- * semaphore.c (mode_t): Use ifndef HAVE_MODE_T to include definition.\r
-\r
- * config.h.in (HAVE_MODE_T): Added.\r
- (_UWIN): Start adding defines for the UWIN package.\r
-\r
- * private.c (ptw32_threadStart): Unhandled exceptions are\r
- now passed through to the system to deal with. This is consistent\r
- with normal Windows behaviour. C++ applications may use\r
- set_terminate() to override the default behaviour which is\r
- to call ptw32_terminate(). Ptw32_terminate() cleans up some\r
- POSIX thread stuff before calling the system default function\r
- which calls abort(). The users termination function should conform\r
- to standard C++ semantics which is to not return. It should\r
- exit the thread (call pthread_exit()) or exit the application.\r
- * private.c (ptw32_terminate): Added as the default set_terminate()\r
- function. It calls the system default function after cleaning up\r
- some POSIX thread stuff.\r
-\r
- * implement.h (ptw32_try_enter_critical_section): Move\r
- declaration.\r
- * global.c (ptw32_try_enter_critical_section): Moved\r
- from dll.c.\r
- * dll.c: Move process and thread attach/detach code into\r
- functions in nonportable.c.\r
- * nonportable.c (pthread_win32_process_attach_np): Process\r
- attach code from dll.c is now available to static linked\r
- applications.\r
- * nonportable.c (pthread_win32_process_detach_np): Likewise.\r
- * nonportable.c (pthread_win32_thread_attach_np): Likewise.\r
- * nonportable.c (pthread_win32_thread_detach_np): Likewise.\r
-\r
- * pthread.h: Add new non-portable prototypes for static\r
- linked applications.\r
-\r
- * GNUmakefile (OPT): Increase optimisation flag and remove\r
- debug info flag.\r
-\r
- * pthread.def: Add new non-portable exports for static\r
- linked applications.\r
-\r
-2000-12-11 Ross Johnson <rpj at special.ise.canberra.edu.au>\r
-\r
- * FAQ: Update Answer 6 re getting a fully working\r
- Mingw32 built library.\r
-\r
-2000-10-10 Steven Reddie <smr at essemer.com.au>\r
- \r
- * misc.c (pthread_self): Restore Win32 "last error"\r
- cleared by TlsGetValue() call in\r
- pthread_getspecific()\r
- \r
-2000-09-20 Arthur Kantor <akantor at bexusa.com>\r
- \r
- * mutex.c (pthread_mutex_lock): Record the owner\r
- of the mutex. This requires also keeping count of\r
- recursive locks ourselves rather than leaving it\r
- to Win32 since we need to know when to NULL the\r
- thread owner when the mutex is unlocked.\r
- (pthread_mutex_trylock): Likewise.\r
- (pthread_mutex_unlock): Check that the calling\r
- thread owns the mutex, decrement the recursive\r
- lock count, and NULL the owner if zero. Return\r
- EPERM if the mutex is owned by another thread.\r
- * implement.h (pthread_mutex_t_): Add ownerThread\r
- and lockCount members.\r
-\r
-2000-09-13 Jef Gearhart <jgearhart at tpssys.com>\r
-\r
- * mutex.c (pthread_mutex_init): Call\r
- TryEnterCriticalSection through the pointer\r
- rather than directly so that the dll can load\r
- on Windows versions that can't resolve the\r
- function, eg. Windows 95\r
-\r
-2000-09-09 Ross Johnson <rpj at special.ise.canberra.edu.au>\r
-\r
- * pthread.h (ctime_r): Fix arg.\r
-\r
-2000-09-08 Ross Johnson <rpj at special.ise.canberra.edu.au>\r
-\r
- * GNUmakefile(_WIN32_WINNT=0x400): Define in CFLAGS;\r
- doesn't seem to be needed though.\r
-\r
- * cancel.c (pthread_cancel): Must get "self" through\r
- calling pthread_self() which will ensure a POSIX thread\r
- struct is built for non-POSIX threads; return an error\r
- if this fails\r
- - Ollie Leahy <ollie at mpt.ie>\r
- (pthread_setcancelstate): Likewise.\r
- (pthread_setcanceltype): Likewise.\r
- * misc.c (ptw32_cancelable_wait): Likewise.\r
-\r
- * private.c (ptw32_tkAssocCreate): Remove unused #if 0\r
- wrapped code.\r
-\r
- * pthread.h (ptw32_get_exception_services_code):\r
- Needed to be forward declared unconditionally.\r
-\r
-2000-09-06 Ross Johnson <rpj at special.ise.canberra.edu.au>\r
-\r
- * cancel.c (pthread_cancel): If called from the main\r
- thread "self" would be NULL; get "self" via pthread_self()\r
- instead of directly from TLS so that an implicit\r
- pthread object is created.\r
-\r
- * misc.c (pthread_equal): Strengthen test for NULLs.\r
-\r
-2000-09-02 Ross Johnson <rpj at special.ise.canberra.edu.au>\r
-\r
- * condvar.c (ptw32_cond_wait_cleanup): Ensure that all\r
- waking threads check if they are the last, and notify\r
- the broadcaster if so - even if an error occurs in the\r
- waiter.\r
-\r
- * semaphore.c (_decrease_semaphore): Should be\r
- a call to ptw32_decrease_semaphore.\r
- (_increase_semaphore): Should be a call to\r
- ptw32_increase_semaphore.\r
-\r
- * misc.c (ptw32_cancelable_wait): Renamed from\r
- CancelableWait.\r
- * rwlock.c (_rwlock_check*): Renamed to\r
- ptw32_rwlock_check*.\r
- * mutex.c (_mutex_check*): Renamed to ptw32_mutex_check*.\r
- * condvar.c (cond_timed*): Renamed to ptw32_cond_timed*.\r
- (_cond_check*): Renamed to ptw32_cond_check*.\r
- (cond_wait_cleanup*): Rename to ptw32_cond_wait_cleanup*.\r
- (ptw32_cond_timedwait): Add comments.\r
-\r
-2000-08-22 Ross Johnson <rpj at setup1.ise.canberra.edu.au>\r
-\r
- * private.c (ptw32_throw): Fix exception test;\r
- move exceptionInformation declaration.\r
-\r
- * tsd.c (pthread_key_create): newkey wrongly declared.\r
-\r
- * pthread.h: Fix comment block.\r
-\r
-2000-08-18 Ross Johnson <rpj at setup1.ise.canberra.edu.au>\r
-\r
- * mutex.c (pthread_mutex_destroy): Check that the mutex isn't\r
- held; invalidate the mutex as early as possible to avoid\r
- contention; not perfect - FIXME!\r
-\r
- * rwlock.c (pthread_rwlock_init): Remove redundant assignment\r
- to "rw".\r
- (pthread_rwlock_destroy): Invalidate the rwlock before\r
- freeing up any of it's resources - to avoid contention.\r
-\r
- * private.c (ptw32_tkAssocCreate): Change assoc->lock\r
- to use a dynamically initialised mutex - only consumes\r
- a W32 mutex or critical section when first used,\r
- not before.\r
-\r
- * mutex.c (pthread_mutex_init): Remove redundant assignment\r
- to "mx".\r
- (pthread_mutexattr_destroy): Set attribute to NULL\r
- before freeing it's memory - to avoid contention.\r
-\r
- * implement.h (PTW32_EPS_CANCEL/PTW32_EPS_EXIT):\r
- Must be defined for all compilers - used as generic\r
- exception selectors by ptw32_throw().\r
-\r
- * Several: Fix typos from scripted edit session\r
- yesterday.\r
-\r
- * nonportable.c (pthread_mutexattr_setforcecs_np):\r
- Moved this function from mutex.c.\r
- (pthread_getw32threadhandle_np): New function to\r
- return the win32 thread handle that the POSIX\r
- thread is using.\r
- * mutex.c (pthread_mutexattr_setforcecs_np):\r
- Moved to new file "nonportable.c".\r
-\r
- * pthread.h (PTW32_BUILD): Only redefine __except\r
- and catch compiler keywords if we aren't building\r
- the library (ie. PTW32_BUILD is not defined) - \r
- this is safer than defining and then undefining\r
- if not building the library.\r
- * implement.h: Remove __except and catch undefines.\r
- * Makefile (CFLAGS): Define PTW32_BUILD.\r
- * GNUmakefile (CFLAGS): Define PTW32_BUILD.\r
-\r
- * All appropriate: Change Pthread_exception* to\r
- ptw32_exception* to be consistent with internal\r
- identifier naming.\r
-\r
- * private.c (ptw32_throw): New function to provide\r
- a generic exception throw for all internal\r
- exceptions and EH schemes.\r
- (ptw32_threadStart): pthread_exit() value is now\r
- returned via the thread structure exitStatus\r
- element.\r
- * exit.c (pthread_exit): pthread_exit() value is now\r
- returned via the thread structure exitStatus\r
- element.\r
- * cancel.c (ptw32_cancel_self): Now uses ptw32_throw.\r
- (pthread_setcancelstate): Ditto.\r
- (pthread_setcanceltype): Ditto.\r
- (pthread_testcancel): Ditto.\r
- (pthread_cancel): Ditto.\r
- * misc.c (CancelableWait): Ditto.\r
- * exit.c (pthread_exit): Ditto.\r
- * All applicable: Change PTW32_ prefix to\r
- PTW32_ prefix to remove leading underscores\r
- from private library identifiers.\r
-\r
-2000-08-17 Ross Johnson <rpj at special.ise.canberra.edu.au>\r
-\r
- * All applicable: Change _pthread_ prefix to\r
- ptw32_ prefix to remove leading underscores\r
- from private library identifiers (single\r
- and double leading underscores are reserved in the\r
- ANSI C standard for compiler implementations).\r
-\r
- * tsd.c (pthread_create_key): Initialise temporary\r
- key before returning it's address to avoid race\r
- conditions.\r
-\r
-2000-08-13 Ross Johnson <rpj at special.ise.canberra.edu.au>\r
-\r
- * errno.c: Add _MD precompile condition; thus far\r
- had no effect when using /MD compile option but I\r
- thnk it should be there.\r
-\r
- * exit.c: Add __cplusplus to various #if lines;\r
- was compiling SEH code even when VC++ had\r
- C++ compile options.\r
-\r
- * private.c: ditto.\r
-\r
- * create.c (pthread_create): Add PT_STDCALL macro to\r
- function pointer arg in _beginthread().\r
-\r
- * pthread.h: PT_STDCALL really does need to be defined\r
- in both this and impliment.h; don't set it to __cdecl\r
- - this macro is only used to extend function pointer\r
- casting for functions that will be passed as parameters.\r
- (~PThreadCleanup): add cast and group expression.\r
- (_errno): Add _MD compile conditional.\r
- (PtW32NoCatchWarn): Change pragma message.\r
-\r
- * implement.h: Move and change PT_STDCALL define.\r
-\r
- * need_errno.h: Add _MD to compilation conditional.\r
-\r
- * GNUmakefile: Substantial rewrite for new naming\r
- convention; set for nil optimisation (turn it up\r
- when we have a working library build; add target\r
- "fake.a" to build a libpthreadw32.a from the VC++\r
- built DLL pthreadVCE.dll.\r
-\r
- * pthread.def (LIBRARY): Don't specify in the .def\r
- file - it is specified on the linker command line\r
- since we now use the same .def file for variously\r
- named .dlls.\r
-\r
- * Makefile: Substantial rewrite for new naming\r
- convention; default nmake target only issues a\r
- help message; run nmake with specific target\r
- corresponding to the EH scheme being used.\r
-\r
- * README: Update information; add naming convention\r
- explanation.\r
-\r
- * ANNOUNCE: Update information.\r
-\r
-2000-08-12 Ross Johnson <rpj at special.ise.canberra.edu.au>\r
-\r
- * pthread.h: Add compile-time message when using\r
- MSC_VER compiler and C++ EH to warn application\r
- programmers to use PtW32Catch instead of catch(...)\r
- if they want cancelation and pthread_exit to work.\r
-\r
- * implement.h: Remove #include <semaphore.h>; we\r
- use our own local semaphore.h.\r
-\r
-2000-08-10 Ross Johnson <rpj at special.ise.canberra.edu.au>\r
-\r
- * cleanup.c (pthread_pop_cleanup): Remove _pthread\r
- prefix from __except and catch keywords; implement.h\r
- now simply undefines ptw32__except and\r
- ptw32_catch if defined; VC++ was not textually\r
- substituting ptw32_catch etc back to catch as\r
- it was redefined; the reason for using the prefixed\r
- version was to make it clear that it was not using\r
- the pthread.h redefined catch keyword.\r
-\r
- * private.c (ptw32_threadStart): Ditto.\r
- (ptw32_callUserDestroyRoutines): Ditto.\r
-\r
- * implement.h (ptw32__except): Remove #define.\r
- (ptw32_catch): Remove #define.\r
-\r
- * GNUmakefile (pthread.a): New target to build\r
- libpthread32.a from pthread.dll using dlltool.\r
-\r
- * buildlib.bat: Duplicate cl commands with args to\r
- build C++ EH version of pthread.dll; use of .bat\r
- files is redundant now that nmake compatible\r
- Makefile is included; used as a kludge only now.\r
-\r
- * Makefile: Localise some macros and fix up the clean:\r
- target to extend it and work properly.\r
-\r
- * CONTRIBUTORS: Add contributors.\r
-\r
- * ANNOUNCE: Updated.\r
-\r
- * README: Updated.\r
-\r
-2000-08-06 Ross Johnson <rpj at special.ise.canberra.edu.au>\r
-\r
- * pthread.h: Remove #warning - VC++ doesn't accept it.\r
-\r
-2000-08-05 Ross Johnson <rpj at special.ise.canberra.edu.au>\r
-\r
- * pthread.h (PtW32CatchAll): Add macro. When compiling\r
- applications using VC++ with C++ EH rather than SEH\r
- 'PtW32CatchAll' must be used in place of any 'catch( ... )'\r
- if the application wants pthread cancelation or\r
- pthread_exit() to work.\r
-\r
-2000-08-03 Ross Johnson <rpj at special.ise.canberra.edu.au>\r
-\r
- * pthread.h: Add a base class ptw32_exception for\r
- library internal exceptions and change the "catch"\r
- re-define macro to use it.\r
-\r
-2000-08-02 Ross Johnson <rpj at special.ise.canberra.edu.au>\r
-\r
- * GNUmakefile (CFLAGS): Add -mthreads.\r
- Add new targets to generate cpp and asm output.\r
-\r
- * sync.c (pthread_join): Remove dead code.\r
-\r
-2000-07-25 Tristan Savatier <tristan at mpegtv.com>\r
-\r
- * sched.c (sched_get_priority_max): Handle different WinCE and\r
- Win32 priority values together.\r
- (sched_get_priority_min): Ditto.\r
-\r
-2000-07-25 Ross Johnson <rpj at special.ise.canberra.edu.au>\r
-\r
- * create.c (pthread_create): Force new threads to wait until\r
- pthread_create has the new thread's handle; we also retain\r
- a local copy of the handle for internal use until\r
- pthread_create returns.\r
-\r
- * private.c (ptw32_threadStart): Initialise ei[].\r
- (ptw32_threadStart): When beginthread is used to start the\r
- thread, force waiting until the creator thread had the \r
- thread handle.\r
-\r
- * cancel.c (ptw32_cancel_thread): Include context switch\r
- code for defined(_X86_) environments in addition to _M_IX86.\r
-\r
- * rwlock.c (pthread_rwlock_destroy): Assignment changed\r
- to avoid compiler warning.\r
-\r
- * private.c (ptw32_get_exception_services_code): Cast\r
- NULL return value to avoid compiler warning.\r
-\r
- * cleanup.c (pthread_pop_cleanup): Initialise "cleanup" variable\r
- to avoid compiler warnings.\r
-\r
- * misc.c (ptw32_new): Change "new" variable to "t" to avoid\r
- confusion with the C++ keyword of the same name.\r
-\r
- * condvar.c (cond_wait_cleanup): Initialise lastWaiter variable.\r
- (cond_timedwait): Remove unused local variables. to avoid\r
- compiler warnings.\r
-\r
- * dll.c (dllMain): Remove 2000-07-21 change - problem\r
- appears to be in pthread_create().\r
-\r
-2000-07-22 Ross Johnson <rpj at special.ise.canberra.edu.au>\r
-\r
- * tsd.c (pthread_key_create): If a destructor was given\r
- and the pthread_mutex_init failed, then would try to\r
- reference a NULL pointer (*key); eliminate this section of\r
- code by using a dynamically initialised mutex\r
- (PTHREAD_MUTEX_INITIALIZER).\r
-\r
- * tsd.c (pthread_setspecific): Return an error if\r
- unable to set the value; simplify cryptic conditional.\r
-\r
- * tsd.c (pthread_key_delete): Locking threadsLock relied\r
- on mutex_lock returning an error if the key has no destructor.\r
- ThreadsLock is only initialised if the key has a destructor.\r
- Making this mutex a static could reduce the number of mutexes\r
- used by an application since it is actually created only at\r
- first use and it's often destroyed soon after.\r
- \r
-2000-07-22 Ross Johnson <rpj at special.ise.canberra.edu.au>\r
-\r
- * FAQ: Added Q5 and Q6.\r
-\r
-2000-07-21 David Baggett <dmb at itasoftware.com>\r
-\r
- * dll.c: Include resource leakage work-around. This is a\r
- partial FIXME which doesn't stop all leakage. The real\r
- problem needs to be found and fixed.\r
-\r
-2000-07-21 Ross Johnson <rpj at setup1.ise.canberra.edu.au>\r
-\r
- * create.c (pthread_create): Set threadH to 0 (zero)\r
- everywhere. Some assignments were using NULL. Maybe\r
- it should be NULL everywhere - need to check. (I know\r
- they are nearly always the same thing - but not by\r
- definition.)\r
-\r
- * misc.c (pthread_self): Try to catch NULL thread handles\r
- at the point where they might be generated, even though\r
- they should always be valid at this point.\r
-\r
- * tsd.c (pthread_setspecific): return an error value if\r
- pthread_self() returns NULL.\r
-\r
- * sync.c (pthread_join): return an error value if\r
- pthread_self() returns NULL.\r
-\r
- * signal.c (pthread_sigmask): return an error value if\r
- pthread_self() returns NULL.\r
-\r
-2000-03-02 Ross Johnson <rpj at special.ise.canberra.edu.au>\r
-\r
- * attr.c (pthread_attr_init): Set default stacksize to zero (0)\r
- rather than PTHREAD_STACK_MIN even though these are now the same.\r
-\r
- * pthread.h (PTHREAD_STACK_MIN): Lowered to 0.\r
-\r
-2000-01-28 Ross Johnson <rpj at special.ise.canberra.edu.au>\r
-\r
- * mutex.c (pthread_mutex_init): Free mutex if it has been alloced;\r
- if critical sections can be used instead of Win32 mutexes, test\r
- that the critical section works and return an error if not.\r
-\r
-2000-01-07 Ross Johnson <rpj at special.ise.canberra.edu.au>\r
-\r
- * cleanup.c (pthread_pop_cleanup): Include SEH code only if MSC is not\r
- compiling as C++.\r
- (pthread_push_cleanup): Include SEH code only if MSC is not\r
- compiling as C++.\r
-\r
- * pthread.h: Include SEH code only if MSC is not\r
- compiling as C++.\r
-\r
- * implement.h: Include SEH code only if MSC is not\r
- compiling as C++.\r
-\r
- * cancel.c (ptw32_cancel_thread): Add _M_IX86 check.\r
- (pthread_testcancel): Include SEH code only if MSC is not\r
- compiling as C++.\r
- (ptw32_cancel_self): Include SEH code only if MSC is not\r
- compiling as C++.\r
-\r
-2000-01-06 Erik Hensema <erik.hensema at group2000.nl>\r
-\r
- * Makefile: Remove inconsistencies in 'cl' args\r
-\r
-2000-01-04 Ross Johnson <rpj at special.ise.canberra.edu.au>\r
-\r
- * private.c (ptw32_get_exception_services_code): New; returns\r
- value of EXCEPTION_PTW32_SERVICES.\r
- (ptw32_processInitialize): Remove initialisation of\r
- ptw32_exception_services which is no longer needed.\r
-\r
- * pthread.h (ptw32_exception_services): Remove extern.\r
- (ptw32_get_exception_services_code): Add function prototype;\r
- use this to return EXCEPTION_PTW32_SERVICES value instead of\r
- using the ptw32_exception_services variable which I had\r
- trouble exporting through pthread.def.\r
-\r
- * global.c (ptw32_exception_services): Remove declaration.\r
-\r
-1999-11-22 Ross Johnson <rpj at special.ise.canberra.edu.au>\r
-\r
- * implement.h: Forward declare ptw32_new();\r
-\r
- * misc.c (ptw32_new): New; alloc and initialise a new pthread_t.\r
- (pthread_self): New thread struct is generated by new routine\r
- ptw32_new().\r
-\r
- * create.c (pthread_create): New thread struct is generated\r
- by new routine ptw32_new().\r
-\r
-1999-11-21 Ross Johnson <rpj at special.ise.canberra.edu.au>\r
-\r
- * global.c (ptw32_exception_services): Declare new variable. \r
-\r
- * private.c (ptw32_threadStart): Destroy thread's\r
- cancelLock mutex; make 'catch' and '__except' usageimmune to\r
- redfinitions in pthread.h.\r
- (ptw32_processInitialize): Init new constant ptw32_exception_services.\r
-\r
- * create.c (pthread_create): Initialise thread's cancelLock\r
- mutex.\r
-\r
- * cleanup.c (pthread_pop_cleanup): Make 'catch' and '__except'\r
- usage immune to redfinition s in pthread.h.\r
-\r
- * private.c: Ditto.\r
-\r
- * pthread.h (catch): Redefine 'catch' so that C++ applications\r
- won't catch our internal exceptions.\r
- (__except): ditto for __except.\r
-\r
- * implement.h (ptw32_catch): Define internal version\r
- of 'catch' because 'catch' is redefined by pthread.h.\r
- (__except): ditto for __except.\r
- (struct pthread_t_): Add cancelLock mutex for async cancel\r
- safety.\r
-\r
-1999-11-21 Jason Nye <jnye at nbnet.nb.ca>, Erik Hensema <erik.hensema at group2000.nl>\r
-\r
- * cancel.c (ptw32_cancel_self): New; part of the async\r
- cancellation implementation.\r
- (ptw32_cancel_thread): Ditto; this function is X86\r
- processor specific.\r
- (pthread_setcancelstate): Add check for pending async\r
- cancel request and cancel the calling thread if\r
- required; add async-cancel safety lock.\r
- (pthread_setcanceltype): Ditto.\r
-\r
-1999-11-13 Erik Hensema <erik.hensema at group2000.nl>\r
-\r
- * configure.in (AC_OUTPUT): Put generated output into GNUmakefile\r
- rather than Makefile. Makefile will become the MSC nmake compatible\r
- version\r
-\r
-1999-11-13 John Bossom (John.Bossom@cognos.com>\r
-\r
- * misc.c (pthread_self): Add a note about GetCurrentThread\r
- returning a pseudo-handle\r
-\r
-1999-11-10 Todd Owen <towen at lucidcalm.dropbear.id.au>\r
-\r
- * dll.c (dllMain): Free kernel32 ASAP.\r
- If TryEnterCriticalSection is not being used, then free\r
- the kernel32.dll handle now, rather than leaving it until\r
- DLL_PROCESS_DETACH.\r
-\r
- Note: this is not a pedantic exercise in freeing unused\r
- resources! It is a work-around for a bug in Windows 95\r
- (see microsoft knowledge base article, Q187684) which\r
- does Bad Things when FreeLibrary is called within\r
- the DLL_PROCESS_DETACH code, in certain situations.\r
- Since w95 just happens to be a platform which does not\r
- provide TryEnterCriticalSection, the bug will be\r
- effortlessly avoided.\r
-\r
-1999-11-10 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * sync.c (pthread_join): Make it a deferred cancelation point.\r
-\r
- * misc.c (pthread_self): Explicitly initialise implicitly\r
- created thread state to default values.\r
-\r
-1999-11-05 Tristan Savatier <tristan at mpegtv.com>\r
-\r
- * pthread.h (winsock.h): Include unconditionally.\r
- (ETIMEDOUT): Change fallback value to that defined by winsock.h.\r
- \r
- * general: Patched for portability to WinCE. The details are\r
- described in the file WinCE-PORT. Follow the instructions\r
- in README.WinCE to make the appropriate changes in config.h.\r
-\r
-1999-10-30 Erik Hensema <erik.hensema at group2000.nl>\r
-\r
- * create.c (pthread_create): Explicitly initialise thread state to\r
- default values.\r
-\r
- * cancel.c (pthread_setcancelstate): Check for NULL 'oldstate'\r
- for compatibility with Solaris pthreads;\r
- (pthread_setcanceltype): ditto:\r
-\r
-1999-10-23 Erik Hensema <erik.hensema at group2000.nl>\r
-\r
- * pthread.h (ctime_r): Fix incorrect argument "_tm"\r
-\r
-1999-10-21 Aurelio Medina <aureliom at crt.com>\r
-\r
- * pthread.h (_POSIX_THREADS): Only define it if it isn't\r
- already defined. Projects may need to define this on\r
- the CC command line under Win32 as it doesn't have unistd.h\r
-\r
-1999-10-17 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * rwlock.c (pthread_rwlock_destroy): Add cast to remove compile\r
- warning.\r
-\r
- * condvar.c (pthread_cond_broadcast): Only release semaphores\r
- if there are waiting threads.\r
-\r
-1999-10-15 Lorin Hochstein <lmh at xiphos.ca>, Peter Slacik <Peter.Slacik at tatramed.sk>\r
-\r
- * condvar.c (cond_wait_cleanup): New static cleanup handler for\r
- cond_timedwait;\r
- (cond_timedwait): pthread_cleanup_push args changed;\r
- canceling a thread while it's in pthread_cond_wait\r
- will now decrement the waiters count and cleanup if it's the\r
- last waiter.\r
-\r
-1999-10-15 Graham Dumpleton <Graham.Dumpleton at ra.pad.otc.telstra.com.au>\r
-\r
- * condvar.c (cond_wait_cleanup): the last waiter will now reset the CV's\r
- wasBroadcast flag\r
-\r
-Thu Sep 16 1999 Ross Johnson <rpj at swan.canberra.edu.au>\r
-\r
- * rwlock.c (pthread_rwlock_destroy): Add serialisation.\r
- (_rwlock_check_need_init): Check for detroyed rwlock.\r
- * rwlock.c: Check return codes from _rwlock_check_need_init();\r
- modify comments; serialise access to rwlock objects during\r
- operations; rename rw_mutex to rw_lock.\r
- * implement.h: Rename rw_mutex to rw_lock.\r
- * mutex.c (pthread_mutex_destroy): Add serialisation.\r
- (_mutex_check_need_init): Check for detroyed mutex.\r
- * condvar.c (pthread_cond_destroy): Add serialisation.\r
- (_cond_check_need_init): Check for detroyed condvar.\r
- * mutex.c: Modify comments.\r
- * condvar.c: Modify comments.\r
-\r
-1999-08-10 Aurelio Medina <aureliom at crt.com>\r
-\r
- * implement.h (pthread_rwlock_t_): Add.\r
- * pthread.h (pthread_rwlock_t): Add.\r
- (PTHREAD_RWLOCK_INITIALIZER): Add.\r
- Add rwlock function prototypes.\r
- * rwlock.c: New module.\r
- * pthread.def: Add new rwlock functions.\r
- * private.c (ptw32_processInitialize): initialise\r
- ptw32_rwlock_test_init_lock critical section.\r
- * global.c (ptw32_rwlock_test_init_lock): Add.\r
-\r
- * mutex.c (pthread_mutex_destroy): Don't free mutex memory\r
- if mutex is PTHREAD_MUTEX_INITIALIZER and has not been\r
- initialised yet.\r
-\r
-1999-08-08 Milan Gardian <mg at tatramed.sk>\r
-\r
- * mutex.c (pthread_mutex_destroy): Free mutex memory.\r
-\r
-1999-08-22 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * exit.c (pthread_exit): Fix reference to potentially\r
- uninitialised pointer.\r
-\r
-1999-08-21 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * private.c (ptw32_threadStart): Apply fix of 1999-08-19\r
- this time to C++ and non-trapped C versions. Ommitted to\r
- do this the first time through.\r
-\r
-1999-08-19 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * private.c (ptw32_threadStart): Return exit status from\r
- the application thread startup routine.\r
- - Milan Gardian <mg at tatramed.sk>\r
-\r
-1999-08-18 John Bossom <john.Bossom at cognos.com>\r
-\r
- * exit.c (pthread_exit): Put status into pthread_t->exitStatus\r
- * private.c (ptw32_threadStart): Set pthread->exitStatus\r
- on exit of try{} block.\r
- * sync.c (pthread_join): use pthread_exitStatus value if the\r
- thread exit doesn't return a value (for Mingw32 CRTDLL\r
- which uses endthread instead of _endthreadex).\r
-\r
-Tue Aug 17 20:17:58 CDT 1999 Mumit Khan <khan at xraylith.wisc.edu>\r
-\r
- * create.c (pthread_create): Add CRTDLL suppport.\r
- * exit.c (pthread_exit): Likewise.\r
- * private.c (ptw32_threadStart): Likewise.\r
- (ptw32_threadDestroy): Likewise.\r
- * sync.c (pthread_join): Likewise.\r
- * tests/join1.c (main): Warn about partial support for CRTDLL.\r
-\r
-Tue Aug 17 20:00:08 1999 Mumit Khan <khan at xraylith.wisc.edu>\r
-\r
- * Makefile.in (LD): Delete entry point.\r
- * acconfig.h (STDCALL): Delete unused macro.\r
- * configure.in: Remove test for STDCALL.\r
- * config.h.in: Regenerate.\r
- * errno.c (_errno): Fix self type.\r
- * pthread.h (PT_STDCALL): Move from here to\r
- * implement.h (PT_STDCALL): here.\r
- (ptw32_threadStart): Fix prototype.\r
- * private.c (ptw32_threadStart): Likewise.\r
-\r
-1999-08-14 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * exit.c (pthread_exit): Don't call pthread_self() but\r
- get thread handle directly from TSD for efficiency.\r
- \r
-1999-08-12 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * private.c (ptw32_threadStart): ei[] only declared if _MSC_VER.\r
-\r
- * exit.c (pthread_exit): Check for implicitly created threads\r
- to avoid raising an unhandled exception.\r
- \r
-1999-07-12 Peter Slacik <Peter.Slacik at tatramed.sk>\r
-\r
- * condvar.c (pthread_cond_destroy): Add critical section.\r
- (cond_timedwait): Add critical section; check for timeout\r
- waiting on semaphore.\r
- (pthread_cond_broadcast): Add critical section.\r
-\r
-1999-07-09 Lorin Hochstein <lmh at xiphos.ca>, John Bossom <John.Bossom at Cognos.COM>\r
-\r
- The problem was that cleanup handlers were not executed when\r
- pthread_exit() was called.\r
-\r
- * implement.h (pthread_t_): Add exceptionInformation element for\r
- C++ per-thread exception information.\r
- (general): Define and rename exceptions.\r
-\r
-1999-07-09 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * misc.c (CancelableWait): PTW32_EPS_CANCEL (SEH) and\r
- ptw32_exception_cancel (C++) used to identify the exception.\r
-\r
- * cancel.c (pthread_testcancel): PTW32_EPS_CANCEL (SEH) and\r
- ptw32_exception_cancel (C++) used to identify the exception.\r
-\r
- * exit.c (pthread_exit): throw/raise an exception to return to\r
- ptw32_threadStart() to exit the thread. PTW32_EPS_EXIT (SEH)\r
- and ptw32_exception_exit (C++) used to identify the exception.\r
-\r
- * private.c (ptw32_threadStart): Add pthread_exit exception trap;\r
- clean up and exit the thread directly rather than via pthread_exit().\r
-\r
-Sun May 30 00:25:02 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * semaphore.h (mode_t): Conditionally typedef it.\r
-\r
-Fri May 28 13:33:05 1999 Mark E. Armstrong <avail at pacbell.net>\r
-\r
- * condvar.c (pthread_cond_broadcast): Fix possible memory fault\r
- \r
-Thu May 27 13:08:46 1999 Peter Slacik <Peter.Slacik at tatramed.sk>\r
-\r
- * condvar.c (pthread_cond_broadcast): Fix logic bug\r
-\r
-Thu May 27 13:08:46 1999 Bossom, John <John.Bossom at Cognos.COM>\r
-\r
- * condvar.c (pthread_cond_broadcast): optimise sem_post loop\r
-\r
-Fri May 14 12:13:18 1999 Mike Russo <miker at eai.com>\r
-\r
- * attr.c (pthread_attr_setdetachstate): Fix logic bug\r
-\r
-Sat May 8 09:42:30 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * pthread.def (sem_open): Add.\r
- (sem_close): Add.\r
- (sem_unlink): Add.\r
- (sem_getvalue): Add.\r
-\r
- * FAQ (Question 3): Add.\r
-\r
-Thu Apr 8 01:16:23 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * semaphore.c (sem_open): New function; returns an error (ENOSYS).\r
- (sem_close): ditto.\r
- (sem_unlink): ditto.\r
- (sem_getvalue): ditto.\r
-\r
- * semaphore.h (_POSIX_SEMAPHORES): define.\r
- \r
-Wed Apr 7 14:09:52 1999 Ross Johnson <rpj at swan.canberra.edu.au>\r
-\r
- * errno.c (_REENTRANT || _MT): Invert condition.\r
-\r
- * pthread.h (_errno): Conditionally include prototype.\r
-\r
-Wed Apr 7 09:37:00 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * *.c (comments): Remove individual attributions - these are\r
- documented sufficiently elsewhere.\r
-\r
- * implement.h (pthread.h): Remove extraneous include.\r
-\r
-Sun Apr 4 11:05:57 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * sched.c (sched.h): Include.\r
-\r
- * sched.h: New file for POSIX 1b scheduling.\r
-\r
- * pthread.h: Move opaque structures to implement.h; move sched_*\r
- prototypes out and into sched.h.\r
-\r
- * implement.h: Add opaque structures from pthread.h.\r
-\r
- * sched.c (sched_yield): New function.\r
-\r
- * condvar.c (ptw32_sem_*): Rename to sem_*; except for\r
- ptw32_sem_timedwait which is an private function.\r
-\r
-Sat Apr 3 23:28:00 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * Makefile.in (OBJS): Add errno.o.\r
-\r
-Fri Apr 2 11:08:50 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * implement.h (ptw32_sem_*): Remove prototypes now defined in\r
- semaphore.h.\r
-\r
- * pthread.h (sempahore.h): Include.\r
-\r
- * semaphore.h: New file for POSIX 1b semaphores.\r
-\r
- * semaphore.c (ptw32_sem_timedwait): Moved to private.c.\r
-\r
- * pthread.h (ptw32_sem_t): Change to sem_t. \r
-\r
- * private.c (ptw32_sem_timedwait): Moved from semaphore.c;\r
- set errno on error.\r
-\r
- * pthread.h (pthread_t_): Add per-thread errno element.\r
-\r
-Fri Apr 2 11:08:50 1999 John Bossom <jebossom at cognos.com>\r
-\r
- * semaphore.c (ptw32_sem_*): Change to sem_*; these functions\r
- will be exported from the library; set errno on error.\r
-\r
- * errno.c (_errno): New file. New function.\r
-\r
-Fri Mar 26 14:11:45 1999 Tor Lillqvist <tml at iki.fi>\r
-\r
- * semaphore.c (ptw32_sem_timedwait): Check for negative\r
- milliseconds.\r
-\r
-Wed Mar 24 11:32:07 1999 John Bossom <jebossom at cognos.com>\r
-\r
- * misc.c (CancelableWait): Initialise exceptionInformation[2].\r
- (pthread_self): Get a real Win32 thread handle for implicit threads.\r
-\r
- * cancel.c (pthread_testcancel): Initialise exceptionInformation[2].\r
-\r
- * implement.h (SE_INFORMATION): Fix values.\r
-\r
- * private.c (ptw32_threadDestroy): Close the thread handle.\r
-\r
-Fri Mar 19 12:57:27 1999 Ross Johnson <rpj at swan.canberra.edu.au>\r
-\r
- * cancel.c (comments): Update and cleanup.\r
-\r
-Fri Mar 19 09:12:59 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * private.c (ptw32_threadStart): status returns PTHREAD_CANCELED.\r
-\r
- * pthread.h (PTHREAD_CANCELED): defined.\r
-\r
-Tue Mar 16 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * all: Add GNU LGPL and Copyright and Warranty.\r
- \r
-Mon Mar 15 00:20:13 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * condvar.c (pthread_cond_init): fix possible uninitialised use\r
- of cv.\r
-\r
-Sun Mar 14 21:01:59 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * condvar.c (pthread_cond_destroy): don't do full cleanup if\r
- static initialised cv has never been used.\r
- (cond_timedwait): check result of auto-initialisation.\r
-\r
-Thu Mar 11 09:01:48 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * pthread.h (pthread_mutex_t): revert to (pthread_mutex_t *);\r
- define a value to serve as PTHREAD_MUTEX_INITIALIZER.\r
- (pthread_mutex_t_): remove staticinit and valid elements.\r
- (pthread_cond_t): revert to (pthread_cond_t_ *);\r
- define a value to serve as PTHREAD_COND_INITIALIZER.\r
- (pthread_cond_t_): remove staticinit and valid elements.\r
-\r
- * mutex.c (pthread_mutex_t args): adjust indirection of references.\r
- (all functions): check for PTHREAD_MUTEX_INITIALIZER value;\r
- check for NULL (invalid).\r
-\r
- * condvar.c (pthread_cond_t args): adjust indirection of references.\r
- (all functions): check for PTHREAD_COND_INITIALIZER value;\r
- check for NULL (invalid).\r
-\r
-Wed Mar 10 17:18:12 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * misc.c (CancelableWait): Undo changes from Mar 8 and 7.\r
-\r
-Mon Mar 8 11:18:59 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * misc.c (CancelableWait): Ensure cancelEvent handle is the lowest\r
- indexed element in the handles array. Enhance test for abandoned\r
- objects.\r
-\r
- * pthread.h (PTHREAD_MUTEX_INITIALIZER): Trailing elements not\r
- initialised are set to zero by the compiler. This avoids the\r
- problem of initialising the opaque critical section element in it.\r
- (PTHREAD_COND_INITIALIZER): Ditto.\r
-\r
- * semaphore.c (ptw32_sem_timedwait): Check sem == NULL earlier.\r
-\r
-Sun Mar 7 12:31:14 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * condvar.c (pthread_cond_init): set semaphore initial value\r
- to 0, not 1. cond_timedwait was returning signaled immediately.\r
-\r
- * misc.c (CancelableWait): Place the cancel event handle first\r
- in the handle table for WaitForMultipleObjects. This ensures that\r
- the cancel event is recognised and acted apon if both objects\r
- happen to be signaled together.\r
-\r
- * private.c (ptw32_cond_test_init_lock): Initialise and destroy.\r
-\r
- * implement.h (ptw32_cond_test_init_lock): Add extern.\r
-\r
- * global.c (ptw32_cond_test_init_lock): Add declaration. \r
-\r
- * condvar.c (pthread_cond_destroy): check for valid initialised CV;\r
- flag destroyed CVs as invalid.\r
- (pthread_cond_init): pthread_cond_t is no longer just a pointer.\r
- This is because PTHREAD_COND_INITIALIZER needs state info to reside\r
- in pthread_cond_t so that it can initialise on first use. Will work on\r
- making pthread_cond_t (and other objects like it) opaque again, if\r
- possible, later.\r
- (cond_timedwait): add check for statically initialisation of\r
- CV; initialise on first use.\r
- (pthread_cond_signal): check for valid CV.\r
- (pthread_cond_broadcast): check for valid CV.\r
- (_cond_check_need_init): Add.\r
-\r
- * pthread.h (PTHREAD_COND_INITIALIZER): Fix.\r
- (pthread_cond_t): no longer a pointer to pthread_cond_t_.\r
- (pthread_cond_t_): add 'staticinit' and 'valid' elements.\r
-\r
-Sat Mar 6 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * implement.h: Undate comments.\r
-\r
-Sun Feb 21 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * pthread.h (PTHREAD_MUTEX_INITIALIZER): missing braces around\r
- cs element initialiser.\r
-\r
-1999-02-21 Ben Elliston <bje at cygnus.com>\r
-\r
- * pthread.h (pthread_exit): The return type of this function is\r
- void, not int.\r
-\r
- * exit.c (pthread_exit): Do not return 0.\r
-\r
-Sat Feb 20 16:03:30 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * dll.c (DLLMain): Expand TryEnterCriticalSection support test.\r
-\r
- * mutex.c (pthread_mutex_trylock): The check for\r
- ptw32_try_enter_critical_section == NULL should have been\r
- removed long ago.\r
-\r
-Fri Feb 19 16:03:30 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * sync.c (pthread_join): Fix pthread_equal() test.\r
-\r
- * mutex.c (pthread_mutex_trylock): Check mutex != NULL before\r
- using it.\r
-\r
-Thu Feb 18 16:17:30 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * misc.c (pthread_equal): Fix inverted result.\r
-\r
- * Makefile.in: Use libpthread32.a as the name of the DLL export\r
- library instead of pthread.lib.\r
-\r
- * condvar.c (pthread_cond_init): cv could have been used unitialised;\r
- initialise.\r
-\r
- * create.c (pthread_create): parms could have been used unitialised;\r
- initialise.\r
-\r
- * pthread.h (struct pthread_once_t_): Remove redefinition.\r
-\r
-Sat Feb 13 03:03:30 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * pthread.h (struct pthread_once_t_): Replaced.\r
-\r
- * misc.c (pthread_once): Replace with John Bossom's version;\r
- has lighter weight serialisation; fixes problem of not holding\r
- competing threads until after the init_routine completes.\r
-\r
-Thu Feb 11 13:34:14 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * misc.c (CancelableWait): Change C++ exception throw.\r
-\r
- * sync.c (pthread_join): Change FIXME comment - issue resolved.\r
-\r
-Wed Feb 10 12:49:11 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * configure: Various temporary changes.\r
- - Kevin Ruland <Kevin.Ruland at anheuser-busch.com>\r
-\r
- * README: Update.\r
-\r
- * pthread.def (pthread_attr_getstackaddr): uncomment\r
- (pthread_attr_setstackaddr): uncomment\r
-\r
-Fri Feb 5 13:42:30 1999 Ross Johnson <rpj at swan.canberra.edu.au>\r
-\r
- * semaphore.c: Comment format changes.\r
-\r
-Thu Feb 4 10:07:28 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * global.c: Remove ptw32_exception instantiation.\r
-\r
- * cancel.c (pthread_testcancel): Change C++ exception throw.\r
-\r
- * implement.h: Remove extern declaration.\r
-\r
-Wed Feb 3 13:04:44 1999 Ross Johnson <rpj at swan.canberra.edu.au>\r
-\r
- * cleanup.c: Rename ptw32_*_cleanup() to pthread_*_cleanup().\r
-\r
- * pthread.def: Ditto.\r
- \r
- * pthread.h: Ditto.\r
-\r
- * pthread.def (pthread_cleanup_push): Remove from export list;\r
- the function is defined as a macro under all compilers.\r
- (pthread_cleanup_pop): Ditto.\r
-\r
- * pthread.h: Remove #if defined().\r
-\r
-Wed Feb 3 10:13:48 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * sync.c (pthread_join): Check for NULL value_ptr arg;\r
- check for detached threads.\r
-\r
-Tue Feb 2 18:07:43 1999 Ross Johnson <rpj at swan.canberra.edu.au>\r
-\r
- * implement.h: Add #include <pthread.h>.\r
- Change sem_t to ptw32_sem_t.\r
-\r
-Tue Feb 2 18:07:43 1999 Kevin Ruland <Kevin.Ruland at anheuser-busch.com>\r
-\r
- * signal.c (pthread_sigmask): Add and modify casts.\r
- Reverse LHS/RHS bitwise assignments.\r
-\r
- * pthread.h: Remove #include <semaphore.h>.\r
- (PTW32_ATTR_VALID): Add cast.\r
- (struct pthread_t_): Add sigmask element.\r
-\r
- * dll.c: Add "extern C" for DLLMain.\r
- (DllMain): Add cast.\r
-\r
- * create.c (pthread_create): Set sigmask in thread.\r
-\r
- * condvar.c: Remove #include. Change sem_* to ptw32_sem_*.\r
-\r
- * attr.c: Changed #include.\r
-\r
- * Makefile.in: Additional targets and changes to build the library\r
- as a DLL.\r
-\r
-Fri Jan 29 11:56:28 1999 Ross Johnson <rpj at swan.canberra.edu.au>\r
-\r
- * Makefile.in (OBJS): Add semaphore.o to list.\r
-\r
- * semaphore.c (ptw32_sem_timedwait): Move from private.c.\r
- Rename sem_* to ptw32_sem_*.\r
-\r
- * pthread.h (pthread_cond_t): Change type of sem_t.\r
- _POSIX_SEMAPHORES no longer defined.\r
-\r
- * semaphore.h: Contents moved to implement.h.\r
- Removed from source tree.\r
-\r
- * implement.h: Add semaphore function prototypes and rename all\r
- functions to prepend 'ptw32_'. They are\r
- now private to the pthreads-win32 implementation.\r
-\r
- * private.c: Change #warning.\r
- Move ptw32_sem_timedwait() to semaphore.c.\r
-\r
- * cleanup.c: Change #warning.\r
-\r
- * misc.c: Remove #include <errno.h>\r
-\r
- * pthread.def: Cleanup CVS merge conflicts.\r
-\r
- * global.c: Ditto.\r
-\r
- * ChangeLog: Ditto.\r
-\r
- * cleanup.c: Ditto.\r
-\r
-Sun Jan 24 01:34:52 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * semaphore.c (sem_wait): Remove second arg to \r
- pthreadCancelableWait() call.\r
-\r
-Sat Jan 23 17:36:40 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * pthread.def: Add new functions to export list.\r
-\r
- * pthread.h (PTHREAD_MUTEX_AUTO_CS_NP): New.\r
- (PTHREAD_MUTEX_FORCE_CS_NP): New.\r
-\r
- * README: Updated.\r
-\r
-Fri Jan 22 14:31:59 1999 Ross Johnson <rpj at swan.canberra.edu.au>\r
-\r
- * Makefile.in (CFLAGS): Remove -fhandle-exceptions. Not needed\r
- with egcs. Add -g for debugging.\r
-\r
- * create.c (pthread_create): Replace __stdcall with PT_STDCALL\r
- macro. This is a hack and must be fixed.\r
-\r
- * misc.c (CancelableWait): Remove redundant statement.\r
-\r
- * mutex.c (pthread_mutexattr_init): Cast calloc return value.\r
-\r
- * misc.c (CancelableWait): Add cast.\r
- (pthread_self): Add cast.\r
-\r
- * exit.c (pthread_exit): Add cast.\r
-\r
- * condvar.c (pthread_condattr_init): Cast calloc return value.\r
-\r
- * cleanup.c: Reorganise conditional compilation.\r
-\r
- * attr.c (pthread_attr_init): Remove unused 'result'.\r
- Cast malloc return value.\r
-\r
- * private.c (ptw32_callUserDestroyRoutines): Redo conditional\r
- compilation.\r
-\r
- * misc.c (CancelableWait): C++ version uses 'throw'.\r
-\r
- * cancel.c (pthread_testcancel): Ditto.\r
-\r
- * implement.h (class ptw32_exception): Define for C++.\r
-\r
- * pthread.h: Fix C, C++, and Win32 SEH condition compilation\r
- mayhem around pthread_cleanup_* defines. C++ version now uses John\r
- Bossom's cleanup handlers.\r
- (pthread_attr_t): Make 'valid' unsigned.\r
- Define '_timeb' as 'timeb' for Ming32.\r
- Define PT_STDCALL as nothing for Mingw32. May be temporary.\r
-\r
- * cancel.c (pthread_testcancel): Cast return value.\r
-\r
-Wed Jan 20 09:31:28 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * pthread.h (pthread_mutexattr_t): Changed to a pointer.\r
-\r
- * mutex.c (pthread_mutex_init): Conditionally create Win32 mutex\r
- - from John Bossom's implementation.\r
- (pthread_mutex_destroy): Conditionally close Win32 mutex\r
- - from John Bossom's implementation.\r
- (pthread_mutexattr_init): Replaced by John Bossom's version.\r
- (pthread_mutexattr_destroy): Ditto.\r
- (pthread_mutexattr_getpshared): New function from John Bossom's\r
- implementation.\r
- (pthread_mutexattr_setpshared): New function from John Bossom's\r
- implementation.\r
-\r
-Tue Jan 19 18:27:42 1999 Ross Johnson <rpj at swan.canberra.edu.au>\r
-\r
- * pthread.h (pthreadCancelableTimedWait): New prototype.\r
- (pthreadCancelableWait): Remove second argument.\r
-\r
- * misc.c (CancelableWait): New static function is \r
- pthreadCancelableWait() renamed.\r
- (pthreadCancelableWait): Now just calls CancelableWait() with\r
- INFINITE timeout.\r
- (pthreadCancelableTimedWait): Just calls CancelableWait()\r
- with passed in timeout.\r
-\r
-Tue Jan 19 18:27:42 1999 Scott Lightner <scott at curriculum.com>\r
-\r
- * private.c (ptw32_sem_timedwait): 'abstime' arg really is\r
- absolute time. Calculate relative time to wait from current\r
- time before passing timeout to new routine \r
- pthreadCancelableTimedWait().\r
-\r
-Tue Jan 19 10:27:39 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * pthread.h (pthread_mutexattr_setforcecs_np): New prototype.\r
- \r
- * mutex.c (pthread_mutexattr_init): Init 'pshared' and 'forcecs'\r
- attributes to 0.\r
- (pthread_mutexattr_setforcecs_np): New function (not portable).\r
-\r
- * pthread.h (pthread_mutex_t): \r
- Add 'mutex' element. Set to NULL in PTHREAD_MUTEX_INITIALIZER.\r
- The pthread_mutex_*() routines will try to optimise performance\r
- by choosing either mutexes or critical sections as the basis\r
- for pthread mutexes for each indevidual mutex.\r
- (pthread_mutexattr_t_): Add 'forcecs' element.\r
- Some applications may choose to force use of critical sections\r
- if they know that:-\r
- the mutex is PROCESS_PRIVATE and, \r
- either the OS supports TryEnterCriticalSection() or\r
- pthread_mutex_trylock() will never be called on the mutex.\r
- This attribute will be setable via a non-portable routine.\r
-\r
- Note: We don't yet support PROCESS_SHARED mutexes, so the\r
- implementation as it stands will default to Win32 mutexes only if\r
- the OS doesn't support TryEnterCriticalSection. On Win9x, and early\r
- versions of NT 'forcecs' will need to be set in order to get\r
- critical section based mutexes.\r
-\r
-Sun Jan 17 12:01:26 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * pthread.h (PTHREAD_MUTEX_INITIALIZER): Init new 'staticinit'\r
- value to '1' and existing 'valid' value to '1'.\r
-\r
- * global.c (ptw32_mutex_test_init_lock): Add.\r
-\r
- * implement.h (ptw32_mutex_test_init_lock.): Add extern.\r
-\r
- * private.c (ptw32_processInitialize): Init critical section for\r
- global lock used by _mutex_check_need_init().\r
- (ptw32_processTerminate): Ditto (:s/Init/Destroy/).\r
-\r
- * dll.c (dllMain): Move call to FreeLibrary() so that it is only\r
- called once when the process detaches.\r
-\r
- * mutex.c (_mutex_check_need_init): New static function to test\r
- and init PTHREAD_MUTEX_INITIALIZER mutexes. Provides serialised\r
- access to the internal state of the uninitialised static mutex. \r
- Called from pthread_mutex_trylock() and pthread_mutex_lock() which\r
- do a quick unguarded test to check if _mutex_check_need_init()\r
- needs to be called. This is safe as the test is conservative\r
- and is repeated inside the guarded section of \r
- _mutex_check_need_init(). Thus in all calls except the first\r
- calls to lock static mutexes, the additional overhead to lock any\r
- mutex is a single memory fetch and test for zero.\r
-\r
- * pthread.h (pthread_mutex_t_): Add 'staticinit' member. Mutexes\r
- initialised by PTHREAD_MUTEX_INITIALIZER aren't really initialised\r
- until the first attempt to lock it. Using the 'valid'\r
- flag (which flags the mutex as destroyed or not) to record this\r
- information would be messy. It is possible for a statically\r
- initialised mutex such as this to be destroyed before ever being\r
- used.\r
-\r
- * mutex.c (pthread_mutex_trylock): Call _mutex_check_need_init()\r
- to test/init PTHREAD_MUTEX_INITIALIZER mutexes.\r
- (pthread_mutex_lock): Ditto.\r
- (pthread_mutex_unlock): Add check to ensure we don't try to unlock\r
- an unitialised static mutex.\r
- (pthread_mutex_destroy): Add check to ensure we don't try to delete\r
- a critical section that we never created. Allows us to destroy\r
- a static mutex that has never been locked (and hence initialised).\r
- (pthread_mutex_init): Set 'staticinit' flag to 0 for the new mutex.\r
-\r
-Sun Jan 17 12:01:26 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * private.c (ptw32_sem_timedwait): Move from semaphore.c.\r
-\r
- * semaphore.c : Remove redundant #includes.\r
- (ptw32_sem_timedwait): Move to private.c.\r
- (sem_wait): Add missing abstime arg to pthreadCancelableWait() call.\r
-\r
-Fri Jan 15 23:38:05 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * condvar.c (cond_timedwait): Remove comment.\r
-\r
-Fri Jan 15 15:41:28 1999 Ross Johnson <rpj at swan.canberra.edu.au>\r
-\r
- * pthread.h: Add new 'abstime' arg to pthreadCancelableWait()\r
- prototype.\r
-\r
- * condvar.c (cond_timedwait): New generalised function called by\r
- both pthread_cond_wait() and pthread_cond_timedwait(). This is\r
- essentially pthread_cond_wait() renamed and modified to add the\r
- 'abstime' arg and call the new ptw32_sem_timedwait() instead of\r
- sem_wait().\r
- (pthread_cond_wait): Now just calls the internal static\r
- function cond_timedwait() with an INFINITE wait.\r
- (pthread_cond_timedwait): Now implemented. Calls the internal\r
- static function cond_timedwait().\r
-\r
- * implement.h (ptw32_sem_timedwait): New internal function\r
- prototype.\r
-\r
- * misc.c (pthreadCancelableWait): Added new 'abstime' argument\r
- to allow shorter than INFINITE wait.\r
-\r
- * semaphore.c (ptw32_sem_timedwait): New function for internal\r
- use. This is essentially sem_wait() modified to add the\r
- 'abstime' arg and call the modified (see above)\r
- pthreadCancelableWait().\r
-\r
-Thu Jan 14 14:27:13 1999 Ross Johnson <rpj at swan.canberra.edu.au>\r
-\r
- * cleanup.c: Correct _cplusplus to __cplusplus wherever used.\r
-\r
- * Makefile.in: Add CC=g++ and add -fhandle-exceptions to CFLAGS.\r
- The derived Makefile will compile all units of the package as C++\r
- so that those which include try/catch exception handling should work\r
- properly. The package should compile ok if CC=gcc, however, exception\r
- handling will not be included and thus thread cancellation, for\r
- example, will not work.\r
-\r
- * cleanup.c (ptw32_pop_cleanup): Add #warning to compile this\r
- file as C++ if using a cygwin32 environment. Perhaps the whole package\r
- should be compiled using g++ under cygwin.\r
-\r
- * private.c (ptw32_threadStart): Change #error directive\r
- into #warning and bracket for __CYGWIN__ and derivative compilers.\r
-\r
-Wed Jan 13 09:34:52 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * build.bat: Delete old binaries before compiling/linking.\r
-\r
-Tue Jan 12 09:58:38 1999 Tor Lillqvist <tml at iki.fi>\r
-\r
- * dll.c: The Microsoft compiler pragmas probably are more\r
- appropriately protected by _MSC_VER than by _WIN32.\r
-\r
- * pthread.h: Define ETIMEDOUT. This should be returned by\r
- pthread_cond_timedwait which is not implemented yet as of\r
- snapshot-1999-01-04-1305. It was implemented in the older version.\r
- The Microsoft compiler pragmas probably are more appropriately\r
- protected by _MSC_VER than by _WIN32.\r
-\r
- * pthread.def: pthread_mutex_destroy was missing from the def file\r
-\r
- * condvar.c (pthread_cond_broadcast): Ensure we only wait on threads\r
- if there were any waiting on the condition.\r
- I think pthread_cond_broadcast should do the WaitForSingleObject\r
- only if cv->waiters > 0? Otherwise it seems to hang, at least in the\r
- testg thread program from glib.\r
-\r
-Tue Jan 12 09:58:38 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * condvar.c (pthread_cond_timedwait): Fix function description\r
- comments.\r
-\r
- * semaphore.c (sem_post): Correct typo in comment.\r
-\r
-Mon Jan 11 20:33:19 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * pthread.h: Re-arrange conditional compile of pthread_cleanup-*\r
- macros.\r
-\r
- * cleanup.c (ptw32_push_cleanup): Provide conditional \r
- compile of cleanup->prev.\r
-\r
-1999-01-11 Tor Lillqvist <tml at iki.fi>\r
-\r
- * condvar.c (pthread_cond_init): Invert logic when testing the\r
- return value from calloc().\r
-\r
-Sat Jan 9 14:32:08 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * implement.h: Compile-time switch for CYGWIN derived environments\r
- to use CreateThread instead of _beginthreadex. Ditto for ExitThread.\r
- Patch provided by Anders Norlander <anorland at hem2.passagen.se>.\r
-\r
-Tue Jan 5 16:33:04 1999 Ross Johnson <rpj at swan.canberra.edu.au>\r
-\r
- * cleanup.c (ptw32_pop_cleanup): Add C++ version of __try/__except\r
- block. Move trailing "}" out of #ifdef _WIN32 block left there by\r
- (rpj's) mistake.\r
-\r
- * private.c: Remove #include <errno.h> which is included by pthread.h.\r
-\r
-1998-12-11 Ben Elliston <bje at toilet.to.cygnus.com>\r
-\r
- * README: Update info about subscribing to the mailing list.\r
-\r
-Mon Jan 4 11:23:40 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * all: No code changes, just cleanup.\r
- - remove #if 0 /* Pre Bossom */ enclosed code.\r
- - Remove some redundant #includes.\r
- * pthread.h: Update implemented/unimplemented routines list.\r
- * Tag the bossom merge branch getting ready to merge back to main\r
- trunk.\r
-\r
-Tue Dec 29 13:11:16 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * implement.h: Move the following struct definitions to pthread.h:\r
- pthread_t_, pthread_attr_t_, pthread_mutex_t_, pthread_mutex_t_,\r
- pthread_mutexattr_t_, pthread_key_t_, pthread_cond_t_,\r
- pthread_condattr_t_, pthread_once_t_.\r
-\r
- * pthread.h: Add "_" prefix to pthread_push_cleanup and \r
- pthread_pop_cleanup internal routines, and associated struct and\r
- typedefs.\r
-\r
- * buildlib.bat: Add compile command for semaphore.c\r
-\r
- * pthread.def: Comment out pthread_atfork routine name. \r
- Now unimplemented.\r
-\r
- * tsd.c (pthread_setspecific): Rename tkAssocCreate to\r
- ptw32_tkAssocCreate.\r
- (pthread_key_delete): Rename tkAssocDestroy to\r
- ptw32_tkAssocDestroy.\r
-\r
- * sync.c (pthread_join): Rename threadDestroy to ptw32_threadDestroy\r
-\r
- * sched.c (is_attr): attr is now **attr (was *attr), so add extra\r
- NULL pointer test.\r
- (pthread_attr_setschedparam): Increase redirection for attr which is\r
- now a **.\r
- (pthread_attr_getschedparam): Ditto.\r
- (pthread_setschedparam): Change thread validation and rename "thread"\r
- Win32 thread Handle element name to match John Bossom's version.\r
- (pthread_getschedparam): Ditto.\r
-\r
- * private.c (ptw32_threadDestroy): Rename call to\r
- callUserDestroyRoutines() as ptw32_callUserDestroyRoutines()\r
-\r
- * misc.c: Add #include "implement.h".\r
-\r
- * dll.c: Remove defined(KLUDGE) wrapped code.\r
-\r
- * fork.c: Remove redefinition of ENOMEM.\r
- Remove pthread_atfork() and fork() with #if 0/#endif.\r
-\r
- * create.c (pthread_create): Rename threadStart and threadDestroy calls\r
- to ptw32_threadStart and ptw32_threadDestroy.\r
-\r
- * implement.h: Rename "detachedstate" to "detachstate".\r
-\r
- * attr.c: Rename "detachedstate" to "detachstate".\r
-\r
-Mon Dec 28 09:54:39 1998 John Bossom\r
-\r
- * semaphore.c: Initial version.\r
- * semaphore.h: Initial version.\r
-\r
-Mon Dec 28 09:54:39 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * pthread.h (pthread_attr_t_): Change to *pthread_attr_t.\r
-\r
-Mon Dec 28 09:54:39 1998 John Bossom, Ben Elliston\r
-\r
- * attr.c (pthread_attr_setstacksize): Merge with John's version.\r
- (pthread_attr_getstacksize): Merge with John's version.\r
- (pthread_attr_setstackaddr): Merge with John's version.\r
- (pthread_attr_getstackaddr): Merge with John's version.\r
- (pthread_attr_init): Merge with John's version.\r
- (pthread_attr_destroy): Merge with John's version.\r
- (pthread_attr_getdetachstate): Merge with John's version.\r
- (pthread_attr_setdetachstate): Merge with John's version.\r
- (is_attr): attr is now **attr (was *attr), so add extra NULL pointer\r
- test.\r
-\r
-Mon Dec 28 09:54:39 1998 Ross Johnson\r
-\r
- * implement.h (pthread_attr_t_): Add and rename elements in JEB's\r
- version to correspond to original, so that it can be used with\r
- original attr routines.\r
-\r
- * pthread.h: Add #endif at end which was truncated in merging.\r
-\r
-Sun Dec 20 14:51:58 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * misc.c (pthreadCancelableWait): New function by John Bossom. Non-standard\r
- but provides a hook that can be used to implement cancellation points in\r
- applications that use this library.\r
-\r
- * pthread.h (pthread_cleanup_pop): C++ (non-WIN32) version uses\r
- try/catch to emulate John Bossom's WIN32 __try/__finally behaviour.\r
- In the WIN32 version __finally block, add a test for AbnormalTermination otherwise\r
- cleanup is only run if the cleanup_pop execute arg is non-zero. Cancellation\r
- should cause the cleanup to run irrespective of the execute arg.\r
-\r
- * condvar.c (pthread_condattr_init): Replaced by John Bossom's version.\r
- (pthread_condattr_destroy): Replaced by John Bossom's version.\r
- (pthread_condattr_getpshared): Replaced by John Bossom's version.\r
- (pthread_condattr_setpshared): Replaced by John Bossom's version.\r
- (pthread_cond_init): Replaced by John Bossom's version.\r
- Fix comment (refered to mutex rather than condition variable).\r
- (pthread_cond_destroy): Replaced by John Bossom's version.\r
- (pthread_cond_wait): Replaced by John Bossom's version.\r
- (pthread_cond_timedwait): Replaced by John Bossom's version.\r
- (pthread_cond_signal): Replaced by John Bossom's version.\r
- (pthread_cond_broadcast): Replaced by John Bossom's version.\r
-\r
-Thu Dec 17 19:10:46 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * tsd.c (pthread_key_create): Replaced by John Bossom's version.\r
- (pthread_key_delete): Replaced by John Bossom's version.\r
- (pthread_setspecific): Replaced by John Bossom's version.\r
- (pthread_getspecific): Replaced by John Bossom's version.\r
-\r
-Mon Dec 7 09:44:40 1998 John Bossom\r
-\r
- * cancel.c (pthread_setcancelstate): Replaced.\r
- (pthread_setcanceltype): Replaced.\r
- (pthread_testcancel): Replaced.\r
- (pthread_cancel): Replaced.\r
- \r
- * exit.c (pthread_exit): Replaced.\r
-\r
- * misc.c (pthread_self): Replaced.\r
- (pthread_equal): Replaced.\r
-\r
- * sync.c (pthread_detach): Replaced.\r
- (pthread_join): Replaced.\r
-\r
- * create.c (pthread_create): Replaced.\r
-\r
- * private.c (ptw32_processInitialize): New.\r
- (ptw32_processTerminate): New.\r
- (ptw32_threadStart): New.\r
- (ptw32_threadDestroy): New.\r
- (ptw32_cleanupStack): New.\r
- (ptw32_tkAssocCreate): New.\r
- (ptw32_tkAssocDestroy): New.\r
- (ptw32_callUserDestroyRoutines): New.\r
-\r
- * implement.h: Added non-API structures and declarations.\r
-\r
- * dll.c (PthreadsEntryPoint): Cast return value of GetProcAddress\r
- to resolve compile warning from MSVC.\r
-\r
- * dll.c (DLLmain): Replaced.\r
- * dll.c (PthreadsEntryPoint):\r
- Re-applied Anders Norlander's patch:-\r
- Initialize ptw32_try_enter_critical_section at startup\r
- and release kernel32 handle when DLL is being unloaded.\r
-\r
-Sun Dec 6 21:54:35 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * buildlib.bat: Fix args to CL when building the .DLL\r
-\r
- * cleanup.c (ptw32_destructor_run_all): Fix TSD key management.\r
- This is a tidy-up before TSD and Thread management is completely\r
- replaced by John Bossom's code.\r
-\r
- * tsd.c (pthread_key_create): Fix TSD key management.\r
-\r
- * global.c (ptw32_key_virgin_next): Initialise.\r
-\r
- * build.bat: New DOS script to compile and link a pthreads app\r
- using Microsoft's CL compiler linker.\r
- * buildlib.bat: New DOS script to compile all the object files\r
- and create pthread.lib and pthread.dll using Microsoft's CL\r
- compiler linker.\r
-\r
-1998-12-05 Anders Norlander <anorland at hem2.passagen.se>\r
-\r
- * implement.h (ptw32_try_enter_critical_section): New extern\r
- * dll.c (ptw32_try_enter_critical_section): New pointer to\r
- TryEnterCriticalSection if it exists; otherwise NULL.\r
- * dll.c (PthreadsEntryPoint):\r
- Initialize ptw32_try_enter_critical_section at startup\r
- and release kernel32 handle when DLL is being unloaded.\r
- * mutex.c (pthread_mutex_trylock): Replaced check for NT with\r
- a check if ptw32_try_enter_critical_section is valid\r
- pointer to a function. Call ptw32_try_enter_critical_section\r
- instead of TryEnterCriticalSection to avoid errors on Win95.\r
-\r
-Thu Dec 3 13:32:00 1998 Ross Johnson <rpj at ise.canberra.edu.au>\r
-\r
- * README: Correct cygwin32 compatibility statement.\r
-\r
-Sun Nov 15 21:24:06 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * cleanup.c (ptw32_destructor_run_all): Declare missing void * arg.\r
- Fixup CVS merge conflicts.\r
-\r
-1998-10-30 Ben Elliston <bje at cygnus.com>\r
-\r
- * condvar.c (cond_wait): Fix semantic error. Test for equality\r
- instead of making an assignment.\r
-\r
-Fri Oct 30 15:15:50 1998 Ross Johnson <rpj at swan.canberra.edu.au>\r
-\r
- * cleanup.c (ptw32_handler_push): Fixed bug appending new\r
- handler to list reported by Peter Slacik\r
- <Peter.Slacik at leibinger.freinet.de>.\r
- (new_thread): Rename poorly named local variable to\r
- "new_handler".\r
-\r
-Sat Oct 24 18:34:59 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * global.c: Add TSD key management array and index declarations.\r
-\r
- * implement.h: Ditto for externs.\r
-\r
-Fri Oct 23 00:08:09 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * implement.h (PTW32_TSD_KEY_REUSE): Add enum.\r
-\r
- * private.c (ptw32_delete_thread): Add call to\r
- ptw32_destructor_run_all() to clean up the threads keys.\r
-\r
- * cleanup.c (ptw32_destructor_run_all): Check for no more dirty\r
- keys to run destructors on. Assume that the destructor call always\r
- succeeds and set the key value to NULL.\r
-\r
-Thu Oct 22 21:44:44 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * tsd.c (pthread_setspecific): Add key management code.\r
- (pthread_key_create): Ditto.\r
- (pthread_key_delete): Ditto.\r
-\r
- * implement.h (struct ptw32_tsd_key): Add status member.\r
-\r
- * tsd.c: Add description of pthread_key_delete() from the\r
- standard as a comment.\r
-\r
-Fri Oct 16 17:38:47 1998 Ross Johnson <rpj at swan.canberra.edu.au>\r
-\r
- * cleanup.c (ptw32_destructor_run_all): Fix and improve\r
- stepping through the key table.\r
-\r
-Thu Oct 15 14:05:01 1998 Ross Johnson <rpj at swan.canberra.edu.au>\r
-\r
- * private.c (ptw32_new_thread): Remove init of destructorstack.\r
- No longer an element of pthread_t.\r
-\r
- * tsd.c (pthread_setspecific): Fix type declaration and cast.\r
- (pthread_getspecific): Ditto.\r
- (pthread_getspecific): Change error return value to NULL if key\r
- is not in use.\r
-\r
-Thu Oct 15 11:53:21 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * global.c (ptw32_tsd_key_table): Fix declaration.\r
-\r
- * implement.h(ptw32_TSD_keys_TlsIndex): Add missing extern.\r
- (ptw32_tsd_mutex): Ditto.\r
-\r
- * create.c (ptw32_start_call): Fix "keys" array declaration.\r
- Add comment.\r
-\r
- * tsd.c (pthread_setspecific): Fix type declaration and cast.\r
- (pthread_getspecific): Ditto.\r
-\r
- * cleanup.c (ptw32_destructor_run_all): Declare missing loop\r
- counter.\r
-\r
-Wed Oct 14 21:09:24 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * private.c (ptw32_new_thread): Increment ptw32_threads_count.\r
- (ptw32_delete_thread): Decrement ptw32_threads_count.\r
- Remove some comments.\r
-\r
- * exit.c (ptw32_exit): : Fix two pthread_mutex_lock() calls that\r
- should have been pthread_mutex_unlock() calls.\r
- (ptw32_vacuum): Remove call to ptw32_destructor_pop_all().\r
-\r
- * create.c (pthread_create): Fix two pthread_mutex_lock() calls that\r
- should have been pthread_mutex_unlock() calls.\r
-\r
- * global.c (ptw32_tsd_mutex): Add mutex for TSD operations.\r
-\r
- * tsd.c (pthread_key_create): Add critical section.\r
- (pthread_setspecific): Ditto.\r
- (pthread_getspecific): Ditto.\r
- (pthread_key_delete): Ditto.\r
-\r
- * sync.c (pthread_join): Fix two pthread_mutex_lock() calls that\r
- should have been pthread_mutex_unlock() calls.\r
-\r
-Mon Oct 12 00:00:44 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * implement.h (ptw32_tsd_key_table): New.\r
-\r
- * create.c (ptw32_start_call): Initialise per-thread TSD keys\r
- to NULL.\r
-\r
- * misc.c (pthread_once): Correct typo in comment.\r
-\r
- * implement.h (ptw32_destructor_push): Remove.\r
- (ptw32_destructor_pop): Remove.\r
- (ptw32_destructor_run_all): Rename from ptw32_destructor_pop_all.\r
- (PTW32_TSD_KEY_DELETED): Add enum.\r
- (PTW32_TSD_KEY_INUSE): Add enum.\r
-\r
- * cleanup.c (ptw32_destructor_push): Remove.\r
- (ptw32_destructor_pop): Remove.\r
- (ptw32_destructor_run_all): Totally revamped TSD.\r
-\r
- * dll.c (ptw32_TSD_keys_TlsIndex): Initialise.\r
-\r
- * tsd.c (pthread_setspecific): Totally revamped TSD.\r
- (pthread_getspecific): Ditto.\r
- (pthread_create): Ditto.\r
- (pthread_delete): Ditto.\r
-\r
-Sun Oct 11 22:44:55 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * global.c (ptw32_tsd_key_table): Add new global.\r
-\r
- * implement.h (ptw32_tsd_key_t and struct ptw32_tsd_key):\r
- Add.\r
- (struct _pthread): Remove destructorstack.\r
-\r
- * cleanup.c (ptw32_destructor_run_all): Rename from\r
- ptw32_destructor_pop_all. The key destructor stack was made\r
- global rather than per-thread. No longer removes destructor nodes\r
- from the stack. Comments updated.\r
-\r
-1998-10-06 Ben Elliston <bje at cygnus.com>\r
-\r
- * condvar.c (cond_wait): Use POSIX, not Win32 mutex calls.\r
- (pthread_cond_broadcast): Likewise.\r
- (pthread_cond_signal): Likewise.\r
-\r
-1998-10-05 Ben Elliston <bje at cygnus.com>\r
-\r
- * pthread.def: Update. Some functions aren't available yet, others\r
- are macros in <pthread.h>.\r
-\r
- * tests/join.c: Remove; useless.\r
-\r
-Mon Oct 5 14:25:08 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * pthread.def: New file for building the DLL.\r
-\r
-1998-10-05 Ben Elliston <bje at cygnus.com>\r
-\r
- * misc.c (pthread_equal): Correct inverted logic bug.\r
- (pthread_once): Use the POSIX mutex primitives, not Win32. Remove\r
- irrelevant FIXME comment.\r
-\r
- * global.c (PTHREAD_MUTEX_INITIALIZER): Move to pthread.h.\r
-\r
- * pthread.h (PTHREAD_MUTEX_INITIALIZER): Define.\r
- (pthread_mutex_t): Reimplement as a struct containing a valid\r
- flag. If the flag is ever down upon entry to a mutex operation,\r
- we call pthread_mutex_create() to initialise the object. This\r
- fixes the problem of how to handle statically initialised objects\r
- that can't call InitializeCriticalSection() due to their context.\r
- (PTHREAD_ONCE_INIT): Define.\r
-\r
- * mutex.c (pthread_mutex_init): Set valid flag.\r
- (pthread_mutex_destroy): Clear valid flag.\r
- (pthread_mutex_lock): Check and handle the valid flag.\r
- (pthread_mutex_unlock): Likewise.\r
- (pthread_mutex_trylock): Likewise.\r
-\r
- * tests/mutex3.c: New file; test for the static initialisation\r
- macro. Passes.\r
-\r
- * tests/create1.c: New file; test pthread_create(). Passes.\r
- \r
- * tests/equal.c: Poor test; remove.\r
- \r
- * tests/equal1.c New file; test pthread_equal(). Passes.\r
-\r
- * tests/once1.c: New file; test for pthread_once(). Passes.\r
-\r
- * tests/self.c: Remove; rename to self1.c.\r
-\r
- * tests/self1.c: This is the old self.c.\r
-\r
- * tests/self2.c: New file. Test pthread_self() with a single\r
- thread. Passes.\r
-\r
- * tests/self3.c: New file. Test pthread_self() with a couple of\r
- threads to ensure their thread IDs differ. Passes.\r
- \r
-1998-10-04 Ben Elliston <bje at cygnus.com>\r
-\r
- * tests/mutex2.c: Test pthread_mutex_trylock(). Passes.\r
-\r
- * tests/mutex1.c: New basic test for mutex functions (it passes).\r
- (main): Eliminate warning.\r
-\r
- * configure.in: Test for __stdcall, not _stdcall. Typo.\r
-\r
- * configure: Regenerate.\r
-\r
- * attr.c (pthread_attr_setstackaddr): Remove FIXME comment. Win32\r
- does know about ENOSYS after all.\r
- (pthread_attr_setstackaddr): Likewise.\r
-\r
-1998-10-03 Ben Elliston <bje at cygnus.com>\r
-\r
- * configure.in: Test for the `_stdcall' keyword. Define `STDCALL'\r
- to `_stdcall' if we have it, null otherwise.\r
-\r
- * configure: Regenerate.\r
-\r
- * acconfig.h (STDCALL): New define.\r
-\r
- * config.h.in: Regenerate.\r
-\r
- * create.c (ptw32_start_call): Add STDCALL prefix.\r
- \r
- * mutex.c (pthread_mutex_init): Correct function signature.\r
-\r
- * attr.c (pthread_attr_init): Only zero out the `sigmask' member\r
- if we have the sigset_t type.\r
-\r
- * pthread.h: No need to include <unistd.h>. It doesn't even exist\r
- on Win32! Again, an artifact of cross-compilation. \r
- (pthread_sigmask): Only provide if we have the sigset_t type.\r
-\r
- * process.h: Remove. This was a stand-in before we started doing\r
- native compilation under Win32.\r
-\r
- * pthread.h (pthread_mutex_init): Make `attr' argument const.\r
-\r
-1998-10-02 Ben Elliston <bje at cygnus.com>\r
-\r
- * COPYING: Remove.\r
-\r
- * COPYING.LIB: Add. This library is under the LGPL.\r
-\r
-1998-09-13 Ben Elliston <bje at cygnus.com>\r
-\r
- * configure.in: Test for required system features.\r
-\r
- * configure: Generate. \r
-\r
- * acconfig.h: New file.\r
-\r
- * config.h.in: Generate.\r
-\r
- * Makefile.in: Renamed from Makefile.\r
-\r
- * COPYING: Import from a recent GNU package.\r
-\r
- * config.guess: Likewise.\r
-\r
- * config.sub: Likewise.\r
-\r
- * install-sh: Likewise.\r
-\r
- * config.h: Remove. \r
-\r
- * Makefile: Likewise.\r
-\r
-1998-09-12 Ben Elliston <bje at cygnus.com>\r
-\r
- * windows.h: No longer needed; remove.\r
-\r
- * windows.c: Likewise.\r
-\r
-Sat Sep 12 20:09:24 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * windows.h: Remove error number definitions. These are in <errno.h>\r
- \r
- * tsd.c: Add comment explaining rationale for not building\r
- POSIX TSD on top of Win32 TLS.\r
-\r
-1998-09-12 Ben Elliston <bje at cygnus.com>\r
-\r
- * {most}.c: Include <errno.h> to get POSIX error values.\r
-\r
- * signal.c (pthread_sigmask): Only provide if HAVE_SIGSET_T is\r
- defined.\r
- \r
- * config.h: #undef features, don't #define them. This will be\r
- generated by autoconf very soon.\r
- \r
-1998-08-11 Ben Elliston <bje at cygnus.com>\r
-\r
- * Makefile (LIB): Define.\r
- (clean): Define target.\r
- (all): Build a library not just the object files.\r
-\r
- * pthread.h: Provide a definition for struct timespec if we don't\r
- already have one.\r
-\r
- * windows.c (TlsGetValue): Bug fix.\r
- \r
-Thu Aug 6 15:19:22 1998 Ross Johnson <rpj at swan.canberra.edu.au>\r
-\r
- * misc.c (pthread_once): Fix arg 1 of EnterCriticalSection()\r
- and LeaveCriticalSection() calls to pass address-of lock.\r
-\r
- * fork.c (pthread_atfork): Typecast (void (*)(void *)) funcptr\r
- in each ptw32_handler_push() call.\r
-\r
- * exit.c (ptw32_exit): Fix attr arg in \r
- pthread_attr_getdetachstate() call.\r
-\r
- * private.c (ptw32_new_thread): Typecast (HANDLE) NULL.\r
- (ptw32_delete_thread): Ditto.\r
-\r
- * implement.h: (PTW32_MAX_THREADS): Add define. This keeps\r
- changing in an attempt to make thread administration data types\r
- opaque and cleanup DLL startup.\r
-\r
- * dll.c (PthreadsEntryPoint): \r
- (ptw32_virgins): Remove malloc() and free() calls.\r
- (ptw32_reuse): Ditto.\r
- (ptw32_win32handle_map): Ditto.\r
- (ptw32_threads_mutex_table): Ditto.\r
-\r
- * global.c (_POSIX_THREAD_THREADS_MAX): Initialise with \r
- PTW32_MAX_THREADS.\r
- (ptw32_virgins): Ditto.\r
- (ptw32_reuse): Ditto.\r
- (ptw32_win32handle_map): Ditto.\r
- (ptw32_threads_mutex_table): Ditto.\r
-\r
- * create.c (pthread_create): Typecast (HANDLE) NULL.\r
- Typecast (unsigned (*)(void *)) start_routine.\r
-\r
- * condvar.c (pthread_cond_init): Add address-of operator & to\r
- arg 1 of pthread_mutex_init() call.\r
- (pthread_cond_destroy): Add address-of operator & to\r
- arg 1 of pthread_mutex_destroy() call. \r
-\r
- * cleanup.c (ptw32_destructor_pop_all): Add (int) cast to \r
- pthread_getspecific() arg.\r
- (ptw32_destructor_pop): Add (void *) cast to "if" conditional.\r
- (ptw32_destructor_push): Add (void *) cast to\r
- ptw32_handler_push() "key" arg.\r
- (malloc.h): Add include.\r
-\r
- * implement.h (ptw32_destructor_pop): Add prototype.\r
-\r
- * tsd.c (implement.h): Add include.\r
-\r
- * sync.c (pthread_join): Remove target_thread_mutex and it's\r
- initialisation. Rename getdetachedstate to getdetachstate.\r
- Remove unused variable "exitcode".\r
- (pthread_detach): Remove target_thread_mutex and it's\r
- initialisation. Rename getdetachedstate to getdetachstate.\r
- Rename setdetachedstate to setdetachstate.\r
-\r
- * signal.c (pthread_sigmask): Rename SIG_SET to SIG_SETMASK.\r
- Cast "set" to (long *) in assignment to passify compiler warning.\r
- Add address-of operator & to thread->attr.sigmask in memcpy() call\r
- and assignment.\r
- (pthread_sigmask): Add address-of operator & to thread->attr.sigmask\r
- in memcpy() call and assignment.\r
-\r
- * windows.h (THREAD_PRIORITY_ERROR_RETURN): Add.\r
- (THREAD_PRIORITY_LOWEST): Add.\r
- (THREAD_PRIORITY_HIGHEST): Add.\r
-\r
- * sched.c (is_attr): Add function.\r
- (implement.h): Add include.\r
- (pthread_setschedparam): Rename all instances of "sched_policy"\r
- to "sched_priority".\r
- (pthread_getschedparam): Ditto.\r
-\r
-Tue Aug 4 16:57:58 1998 Ross Johnson <rpj at swan.canberra.edu.au>\r
-\r
- * private.c (ptw32_delete_thread): Fix typo. Add missing ';'.\r
-\r
- * global.c (ptw32_virgins): Change types from pointer to \r
- array pointer.\r
- (ptw32_reuse): Ditto.\r
- (ptw32_win32handle_map): Ditto.\r
- (ptw32_threads_mutex_table): Ditto.\r
-\r
- * implement.h(ptw32_virgins): Change types from pointer to \r
- array pointer.\r
- (ptw32_reuse): Ditto.\r
- (ptw32_win32handle_map): Ditto.\r
- (ptw32_threads_mutex_table): Ditto.\r
-\r
- * private.c (ptw32_delete_thread): Fix "entry" should be "thread".\r
-\r
- * misc.c (pthread_self): Add extern for ptw32_threadID_TlsIndex.\r
-\r
- * global.c: Add comment.\r
-\r
- * misc.c (pthread_once): Fix member -> dereferences.\r
- Change ptw32_once_flag to once_control->flag in "if" test.\r
-\r
-Tue Aug 4 00:09:30 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * implement.h(ptw32_virgins): Add extern.\r
- (ptw32_virgin_next): Ditto.\r
- (ptw32_reuse): Ditto.\r
- (ptw32_reuse_top): Ditto.\r
- (ptw32_win32handle_map): Ditto.\r
- (ptw32_threads_mutex_table): Ditto.\r
-\r
- * global.c (ptw32_virgins): Changed from array to pointer.\r
- Storage allocation for the array moved into dll.c.\r
- (ptw32_reuse): Ditto.\r
- (ptw32_win32handle_map): Ditto.\r
- (ptw32_threads_mutex_table): Ditto.\r
-\r
- * dll.c (PthreadsEntryPoint): Set up thread admin storage when\r
- DLL is loaded.\r
-\r
- * fork.c (pthread_atfork): Fix function pointer arg to all\r
- ptw32_handler_push() calls. Change "arg" arg to NULL in child push.\r
-\r
- * exit.c: Add windows.h and process.h includes.\r
- (ptw32_exit): Add local detachstate declaration.\r
- (ptw32_exit): Fix incorrect name for pthread_attr_getdetachstate().\r
-\r
- * pthread.h (_POSIX_THREAD_ATTR_STACKSIZE): Move from global.c\r
- (_POSIX_THREAD_ATTR_STACKADDR): Ditto.\r
-\r
- * create.c (pthread_create): Fix #if should be #ifdef.\r
- (ptw32_start_call): Remove usused variables.\r
-\r
- * process.h: Create.\r
-\r
- * windows.h: Move _beginthreadex and _endthreadex into\r
- process.h\r
-\r
-Mon Aug 3 21:19:57 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * condvar.c (pthread_cond_init): Add NULL attr to\r
- pthread_mutex_init() call - default attributes will be used.\r
- (cond_wait): Fix typo.\r
- (cond_wait): Fix typo - cv was ev.\r
- (pthread_cond_broadcast): Fix two identical typos.\r
-\r
- * cleanup.c (ptw32_destructor_pop_all): Remove _ prefix from\r
- PTHREAD_DESTRUCTOR_ITERATIONS.\r
-\r
- * pthread.h: Move _POSIX_* values into posix.h\r
-\r
- * pthread.h: Fix typo in pthread_mutex_init() prototype.\r
-\r
- * attr.c (pthread_attr_init): Fix error in priority member init.\r
-\r
- * windows.h (THREAD_PRIORITY_NORMAL): Add.\r
-\r
- * pthread.h (sched_param): Add missing ';' to struct definition. \r
-\r
- * attr.c (pthread_attr_init): Remove obsolete pthread_attr_t\r
- member initialisation - cancelstate, canceltype, cancel_pending.\r
- (is_attr): Make arg "attr" a const.\r
-\r
- * implement.h (PTW32_HANDLER_POP_LIFO): Remove definition.\r
- (PTW32_HANDLER_POP_FIFO): Ditto.\r
- (PTW32_VALID): Add missing newline escape (\).\r
- (ptw32_handler_node): Make element "next" a pointer.\r
-\r
-1998-08-02 Ben Elliston <bje at cygnus.com>\r
-\r
- * windows.h: Remove duplicate TlsSetValue() prototype. Add \r
- TlsGetValue() prototype.\r
- (FALSE): Define.\r
- (TRUE): Likewise.\r
- Add forgotten errno values. Guard against multiple #includes.\r
-\r
- * windows.c: New file. Implement stubs for Win32 functions.\r
-\r
- * Makefile (SRCS): Remove. Not explicitly needed.\r
- (CFLAGS): Add -Wall for all warnings with GCC.\r
-\r
-Sun Aug 2 19:03:42 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * config.h: Create. This is a temporary stand-in for autoconf yet\r
- to be done.\r
- (HAVE_SIGNAL_H): Add.\r
-\r
- * pthread.h: Minor rearrangement for temporary config.h.\r
-\r
-Fri Jul 31 14:00:29 1998 Ross Johnson <rpj at swan.canberra.edu.au>\r
-\r
- * cleanup.c (ptw32_destructor_pop): Implement. Removes\r
- destructors associated with a key without executing them.\r
- (ptw32_destructor_pop_all): Add FIXME comment.\r
-\r
- * tsd.c (pthread_key_delete): Add call to ptw32_destructor_pop().\r
-\r
-Fri Jul 31 00:05:45 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * tsd.c (pthread_key_create): Update to properly associate\r
- the destructor routine with the key.\r
- (pthread_key_delete): Add FIXME comment.\r
-\r
- * exit.c (ptw32_vacuum): Add call to\r
- ptw32_destructor_pop_all().\r
-\r
- * implement.h (ptw32_handler_pop_all): Add prototype.\r
- (ptw32_destructor_pop_all): Ditto.\r
-\r
- * cleanup.c (ptw32_destructor_push): Implement. This is just a\r
- call to ptw32_handler_push().\r
- (ptw32_destructor_pop_all): Implement. This is significantly\r
- different to ptw32_handler_pop_all().\r
-\r
- * Makefile (SRCS): Create. Preliminary.\r
-\r
- * windows.h: Create. Contains Win32 definitions for compile\r
- testing. This is just a standin for the real one.\r
-\r
- * pthread.h (SIG_UNBLOCK): Fix typo. Was SIG_BLOCK.\r
- (windows.h): Add include. Required for CRITICAL_SECTION.\r
- (pthread_cond_t): Move enum declaration outside of struct\r
- definition.\r
- (unistd.h): Add include - may be temporary.\r
-\r
- * condvar.c (windows.h): Add include.\r
-\r
- * implement.h (PTW32_THIS): Remove - no longer required.\r
- (PTW32_STACK): Use pthread_self() instead of PTW32_THIS.\r
-\r
-Thu Jul 30 23:12:45 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * implement.h: Remove ptw32_find_entry() prototype.\r
-\r
- * private.c: Extend comments.\r
- Remove ptw32_find_entry() - no longer needed.\r
-\r
- * create.c (ptw32_start_call): Add call to TlsSetValue() to\r
- store the thread ID.\r
-\r
- * dll.c (PthreadsEntryPoint): Implement. This is called\r
- whenever a process loads the DLL. Used to initialise thread\r
- local storage.\r
-\r
- * implement.h: Add ptw32_threadID_TlsIndex.\r
- Add ()s around PTW32_VALID expression.\r
-\r
- * misc.c (pthread_self): Re-implement using Win32 TLS to store\r
- the threads own ID.\r
-\r
-Wed Jul 29 11:39:03 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * private.c: Corrections in comments.\r
- (ptw32_new_thread): Alter "if" flow to be more natural.\r
-\r
- * cleanup.c (ptw32_handler_push): Same as below.\r
-\r
- * create.c (pthread_create): Same as below.\r
-\r
- * private.c (ptw32_new_thread): Rename "new" to "new_thread".\r
- Since when has a C programmer been required to know C++?\r
-\r
-Tue Jul 28 14:04:29 1998 Ross Johnson <rpj at swan.canberra.edu.au>\r
-\r
- * implement.h: Add PTW32_VALID macro.\r
-\r
- * sync.c (pthread_join): Modify to use the new thread\r
- type and ptw32_delete_thread(). Rename "target" to "thread".\r
- Remove extra local variable "target".\r
- (pthread_detach): Ditto.\r
-\r
- * signal.c (pthread_sigmask): Move init of "us" out of inner block.\r
- Fix instance of "this" should have been "us". Rename "us" to "thread".\r
-\r
- * sched.c (pthread_setschedparam): Modify to use the new thread\r
- type.\r
- (pthread_getschedparam): Ditto.\r
-\r
- * private.c (ptw32_find_thread): Fix return type and arg.\r
-\r
- * implement.h: Remove PTW32_YES and PTW32_NO.\r
- (ptw32_new_thread): Add prototype.\r
- (ptw32_find_thread): Ditto.\r
- (ptw32_delete_thread): Ditto.\r
- (ptw32_new_thread_entry): Remove prototype.\r
- (ptw32_find_thread_entry): Ditto.\r
- (ptw32_delete_thread_entry): Ditto.\r
- ( PTW32_NEW, PTW32_INUSE, PTW32_EXITED, PTW32_REUSE):\r
- Add.\r
-\r
-\r
- * create.c (pthread_create): Minor rename "us" to "new" (I need\r
- these cues but it doesn't stop me coming out with some major bugs\r
- at times).\r
- Load start_routine and arg into the thread so the wrapper can\r
- call it.\r
-\r
- * exit.c (pthread_exit): Fix pthread_this should be pthread_self.\r
-\r
- * cancel.c (pthread_setcancelstate): Change\r
- ptw32_threads_thread_t * to pthread_t and init with\r
- pthread_this().\r
- (pthread_setcanceltype): Ditto.\r
-\r
- * exit.c (ptw32_exit): Add new pthread_t arg.\r
- Rename ptw32_delete_thread_entry to ptw32_delete_thread.\r
- Rename "us" to "thread".\r
- (pthread_exit): Call ptw32_exit with added thread arg.\r
-\r
- * create.c (ptw32_start_call): Insert missing ")".\r
- Add "us" arg to ptw32_exit() call.\r
- (pthread_create): Modify to use new thread allocation scheme.\r
-\r
- * private.c: Added detailed explanation of the new thread\r
- allocation scheme.\r
- (ptw32_new_thread): Totally rewritten to use\r
- new thread allocation scheme.\r
- (ptw32_delete_thread): Ditto.\r
- (ptw32_find_thread): Obsolete.\r
-\r
-Mon Jul 27 17:46:37 1998 Ross Johnson <rpj at swan.canberra.edu.au>\r
-\r
- * create.c (pthread_create): Start of rewrite. Not completed yet.\r
-\r
- * private.c (ptw32_new_thread_entry): Start of rewrite. Not\r
- complete.\r
-\r
- * implement.h (ptw32_threads_thread): Rename, remove thread\r
- member, add win32handle and ptstatus members.\r
- (ptw32_t): Add.\r
-\r
- * pthread.h: pthread_t is no longer mapped directly to a Win32\r
- HANDLE type. This is so we can let the Win32 thread terminate and\r
- reuse the HANDLE while pthreads holds it's own thread ID until\r
- the last waiting join exits.\r
-\r
-Mon Jul 27 00:20:37 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * private.c (ptw32_delete_thread_entry): Destroy the thread\r
- entry attribute object before deleting the thread entry itself.\r
-\r
- * attr.c (pthread_attr_init): Initialise cancel_pending = FALSE.\r
- (pthread_attr_setdetachstate): Rename "detached" to "detachedstate".\r
- (pthread_attr_getdetachstate): Ditto.\r
-\r
- * exit.c (ptw32_exit): Fix incorrect check for detachedstate.\r
-\r
- * implement.h (ptw32_call_t): Remove env member. \r
-\r
-Sun Jul 26 13:06:12 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * implement.h (ptw32_new_thread_entry): Fix prototype.\r
- (ptw32_find_thread_entry): Ditto.\r
- (ptw32_delete_thread_entry): Ditto.\r
- (ptw32_exit): Add prototype.\r
-\r
- * exit.c (ptw32_exit): New function. Called from pthread_exit()\r
- and ptw32_start_call() to exit the thread. It allows an extra\r
- argument which is the return code passed to _endthreadex().\r
- (ptw32_exit): Move thread entry delete call from ptw32_vacuum()\r
- into here. Add more explanation of thread entry deletion.\r
- (ptw32_exit): Clarify comment.\r
-\r
- * create.c (ptw32_start_call): Change pthread_exit() call to\r
- ptw32_exit() call.\r
-\r
- * exit.c (ptw32_vacuum): Add thread entry deletion code\r
- moved from ptw32_start_call(). See next item.\r
- (pthread_exit): Remove longjmp(). Add mutex lock around thread table\r
- manipulation code. This routine now calls _enthreadex().\r
-\r
- * create.c (ptw32_start_call): Remove setjmp() call and move\r
- cleanup code out. Call pthread_exit(NULL) to terminate the thread.\r
-\r
-1998-07-26 Ben Elliston <bje at cygnus.com>\r
-\r
- * tsd.c (pthread_getspecific): Update comments.\r
-\r
- * mutex.c (pthread_mutexattr_setpshared): Not supported; remove.\r
- (pthread_mutexattr_getpshared): Likewise.\r
-\r
- * pthread.h (pthread_mutexattr_setpshared): Remove prototype.\r
- (pthread_mutexattr_getpshared): Likewise.\r
-\r
-Sun Jul 26 00:09:59 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * sync.c: Rename all instances of ptw32_count_mutex to\r
- ptw32_table_mutex.\r
-\r
- * implement.h: Rename ptw32_count_mutex to\r
- ptw32_table_mutex.\r
-\r
- * global.c: Rename ptw32_count_mutex to\r
- ptw32_table_mutex.\r
-\r
- * create.c (pthread_create): Add critical sections.\r
- (ptw32_start_call): Rename ptw32_count_mutex to\r
- ptw32_table_mutex.\r
-\r
- * cancel.c (pthread_setcancelstate): Fix indirection bug and rename\r
- "this" to "us".\r
-\r
- * signal.c (pthread_sigmask): Rename "this" to "us" and fix some\r
- minor syntax errors. Declare "us" and initialise it.\r
-\r
- * sync.c (pthread_detach): Rename "this" to "target".\r
-\r
- * pthread.h: Converting PTHREAD_* defines to alias the (const int)\r
- values in global.c.\r
-\r
- * global.c: Started converting PTHREAD_* defines to (const int) as\r
- a part of making the eventual pthreads DLL binary compatible\r
- through version changes.\r
-\r
- * condvar.c (cond_wait): Add cancelation point. This applies the\r
- point to both pthread_cond_wait() and pthread_cond_timedwait().\r
-\r
- * exit.c (pthread_exit): Rename "this" to "us".\r
-\r
- * implement.h: Add comment.\r
-\r
- * sync.c (pthread_join): I've satisfied myself that pthread_detach()\r
- does set the detached attribute in the thread entry attributes\r
- to PTHREAD_CREATE_DETACHED. "if" conditions were changed to test\r
- that attribute instead of a separate flag.\r
-\r
- * create.c (pthread_create): Rename "this" to "us".\r
- (pthread_create): cancelstate and canceltype are not attributes\r
- so the copy to thread entry attribute storage was removed.\r
- Only the thread itself can change it's cancelstate or canceltype,\r
- ie. the thread must exist already.\r
-\r
- * private.c (ptw32_delete_thread_entry): Mutex locks removed.\r
- Mutexes must be applied at the caller level.\r
- (ptw32_new_thread_entry): Ditto.\r
- (ptw32_new_thread_entry): Init cancelstate, canceltype, and\r
- cancel_pending to default values.\r
- (ptw32_new_thread_entry): Rename "this" to "new".\r
- (ptw32_find_thread_entry): Rename "this" to "entry".\r
- (ptw32_delete_thread_entry): Rename "thread_entry" to "entry".\r
-\r
- * create.c (ptw32_start_call): Mutexes changed to\r
- ptw32_count_mutex. All access to the threads table entries is\r
- under the one mutex. Otherwise chaos reigns.\r
-\r
-Sat Jul 25 23:16:51 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * implement.h (ptw32_threads_thread): Move cancelstate and\r
- canceltype members out of pthread_attr_t into here.\r
-\r
- * fork.c (fork): Add comment.\r
-\r
-1998-07-25 Ben Elliston <bje at cygnus.com>\r
-\r
- * fork.c (fork): Autoconfiscate.\r
-\r
-Sat Jul 25 00:00:13 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * create.c (ptw32_start_call): Set thread priority. Ensure our\r
- thread entry is removed from the thread table but only if\r
- pthread_detach() was called and there are no waiting joins.\r
- (pthread_create): Set detach flag in thread entry if the \r
- thread is created PTHREAD_CREATE_DETACHED.\r
-\r
- * pthread.h (pthread_attr_t): Rename member "detachedstate".\r
-\r
- * attr.c (pthread_attr_init): Rename attr members.\r
-\r
- * exit.c (pthread_exit): Fix indirection mistake.\r
-\r
- * implement.h (PTW32_THREADS_TABLE_INDEX): Add.\r
-\r
- * exit.c (ptw32_vacuum): Fix incorrect args to\r
- ptw32_handler_pop_all() calls.\r
- Make thread entry removal conditional.\r
-\r
- * sync.c (pthread_join): Add multiple join and async detach handling.\r
-\r
- * implement.h (PTW32_THREADS_TABLE_INDEX): Add.\r
-\r
- * global.c (ptw32_threads_mutex_table): Add.\r
-\r
- * implement.h (ptw32_once_flag): Remove.\r
- (ptw32_once_lock): Ditto.\r
- (ptw32_threads_mutex_table): Add.\r
-\r
- * global.c (ptw32_once_flag): Remove.\r
- (ptw32_once_lock): Ditto.\r
-\r
- * sync.c (pthread_join): Fix tests involving new return value\r
- from ptw32_find_thread_entry().\r
- (pthread_detach): Ditto.\r
-\r
- * private.c (ptw32_find_thread_entry): Failure return code\r
- changed from -1 to NULL.\r
-\r
-Fri Jul 24 23:09:33 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * create.c (pthread_create): Change . to -> in sigmask memcpy() args.\r
-\r
- * pthread.h: (pthread_cancel): Add function prototype.\r
- (pthread_testcancel): Ditto.\r
-\r
-1998-07-24 Ben Elliston <bje at cygnus.com>\r
-\r
- * pthread.h (pthread_condattr_t): Rename dummy structure member.\r
- (pthread_mutexattr_t): Likewise.\r
-\r
-Fri Jul 24 21:13:55 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * cancel.c (pthread_cancel): Implement.\r
- (pthread_testcancel): Implement.\r
-\r
- * exit.c (pthread_exit): Add comment explaining the longjmp().\r
-\r
- * implement.h (ptw32_threads_thread_t): New member cancelthread.\r
- (PTW32_YES): Define.\r
- (PTW32_NO): Define.\r
- (RND_SIZEOF): Remove.\r
-\r
- * create.c (pthread_create): Rename cancelability to cancelstate.\r
-\r
- * pthread.h (pthread_attr_t): Rename cancelability to cancelstate.\r
- (PTHREAD_CANCELED): Define.\r
-\r
-1998-07-24 Ben Elliston <bje at cygnus.com>\r
-\r
- * pthread.h (SIG_BLOCK): Define if not already defined.\r
- (SIG_UNBLOCK): Likewise.\r
- (SIG_SETMASK): Likewise.\r
- (pthread_attr_t): Add signal mask member.\r
- (pthread_sigmask): Add function prototype.\r
-\r
- * signal.c (pthread_sigmask): Implement.\r
-\r
- * create.c: #include <string.h> to get a prototype for memcpy().\r
- (pthread_create): New threads inherit their creator's signal\r
- mask. Copy the signal mask to the new thread structure if we know\r
- about signals.\r
- \r
-Fri Jul 24 16:33:17 1998 Ross Johnson <rpj at swan.canberra.edu.au>\r
-\r
- * fork.c (pthread_atfork): Add all the necessary push calls.\r
- Local implementation semantics:\r
- If we get an ENOMEM at any time then ALL handlers\r
- (including those from previous pthread_atfork() calls) will be\r
- popped off each of the three atfork stacks before we return.\r
- (fork): Add all the necessary pop calls. Add the thread cancellation\r
- and join calls to the child fork.\r
- Add #includes.\r
-\r
- * implement.h: (ptw32_handler_push): Fix return type and stack arg\r
- type in prototype.\r
- (ptw32_handler_pop): Fix stack arg type in prototype.\r
- (ptw32_handler_pop_all): Fix stack arg type in prototype.\r
-\r
- * cleanup.c (ptw32_handler_push): Change return type to int and\r
- return ENOMEM if malloc() fails.\r
-\r
- * sync.c (pthread_detach): Use equality test, not assignment.\r
-\r
- * create.c (ptw32_start_call): Add call to Win32 CloseHandle()\r
- if thread is detached.\r
-\r
-1998-07-24 Ben Elliston <bje at cygnus.com>\r
-\r
- * sync.c (pthread_detach): Close the Win32 thread handle to\r
- emulate detached (or daemon) threads.\r
-\r
-Fri Jul 24 03:00:25 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * sync.c (pthread_join): Save valueptr arg in joinvalueptr for\r
- pthread_exit() to use.\r
-\r
- * private.c (ptw32_new_thread_entry): Initialise joinvalueptr to\r
- NULL.\r
-\r
- * create.c (ptw32_start_call): Rewrite to facilitate joins.\r
- pthread_exit() will do a longjmp() back to here. Does appropriate\r
- cleanup and exit/return from the thread.\r
- (pthread_create): _beginthreadex() now passes a pointer to our\r
- thread table entry instead of just the call member of that entry.\r
-\r
- * implement.h (ptw32_threads_thread): New member \r
- void ** joinvalueptr.\r
- (ptw32_call_t): New member jmpbuf env.\r
-\r
- * exit.c (pthread_exit): Major rewrite to handle joins and handing\r
- value pointer to joining thread. Uses longjmp() back to \r
- ptw32_start_call().\r
-\r
- * create.c (pthread_create): Ensure values of new attribute members\r
- are copied to the thread attribute object.\r
-\r
- * attr.c (pthread_attr_destroy): Fix merge conflicts.\r
- (pthread_attr_getdetachstate): Fix merge conflicts.\r
- (pthread_attr_setdetachstate): Fix merge conflicts.\r
-\r
- * pthread.h: Fix merge conflicts.\r
-\r
- * sync.c (pthread_join): Fix merge conflicts.\r
-\r
-Fri Jul 24 00:21:21 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * sync.c (pthread_join): Add check for valid and joinable\r
- thread.\r
- (pthread_detach): Implement. After checking for a valid and joinable\r
- thread, it's still a no-op.\r
-\r
- * private.c (ptw32_find_thread_entry): Bug prevented returning\r
- an error value in some cases.\r
-\r
- * attr.c (pthread_attr_setdetachedstate): Implement.\r
- (pthread_attr_getdetachedstate): Implement.\r
-\r
- * implement.h: Move more hidden definitions into here from\r
- pthread.h.\r
-\r
-1998-07-24 Ben Elliston <bje at cygnus.com>\r
-\r
- * pthread.h (PTHREAD_CREATE_JOINABLE): Define.\r
- (PTHREAD_CREATE_DETACHED): Likewise.\r
- (pthread_attr_t): Add new structure member `detached'.\r
- (pthread_attr_getdetachstate): Add function prototype.\r
- (pthread_attr_setdetachstate): Likewise.\r
-\r
- * sync.c (pthread_join): Return if the target thread is detached.\r
-\r
- * attr.c (pthread_attr_init): Initialise cancelability and\r
- canceltype structure members.\r
- (pthread_attr_getdetachstate): Implement.\r
- (pthread_attr_setdetachstate): Likewise.\r
-\r
- * implement.h (PTW32_CANCEL_DEFAULTS): Remove. Bit fields\r
- proved to be too cumbersome. Set the defaults in attr.c using the\r
- public PTHREAD_CANCEL_* constants.\r
-\r
- * cancel.c: New file.\r
-\r
- * pthread.h (sched_param): Define this type.\r
- (pthread_attr_getschedparam): Add function prototype.\r
- (pthread_attr_setschedparam): Likewise.\r
- (pthread_setcancelstate): Likewise.\r
- (pthread_setcanceltype): Likewise.\r
- (sched_get_priority_min): Likewise.\r
- (sched_get_priority_max): Likewise.\r
- (pthread_mutexattr_setprotocol): Remove; not supported.\r
- (pthread_mutexattr_getprotocol): Likewise.\r
- (pthread_mutexattr_setprioceiling): Likewise.\r
- (pthread_mutexattr_getprioceiling): Likewise.\r
- (pthread_attr_t): Add canceltype member. Update comments.\r
- (SCHED_OTHER): Define this scheduling policy constant.\r
- (SCHED_FIFO): Likewise.\r
- (SCHED_RR): Likewise.\r
- (SCHED_MIN): Define the lowest possible value for this constant.\r
- (SCHED_MAX): Likewise, the maximum possible value.\r
- (PTHREAD_CANCEL_ASYNCHRONOUS): Redefine.\r
- (PTHREAD_CANCEL_DEFERRED): Likewise.\r
- \r
- * sched.c: New file.\r
- (pthread_setschedparam): Implement.\r
- (pthread_getschedparam): Implement.\r
- (sched_get_priority_max): Validate policy argument.\r
- (sched_get_priority_min): Likewise.\r
-\r
- * mutex.c (pthread_mutexattr_setprotocol): Remove; not supported.\r
- (pthread_mutexattr_getprotocol): Likewise.\r
- (pthread_mutexattr_setprioceiling): Likewise.\r
- (pthread_mutexattr_getprioceiling): Likewise.\r
-\r
-Fri Jul 24 00:21:21 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * create.c (pthread_create): Arg to ptw32_new_thread_entry()\r
- changed. See next entry. Move mutex locks out. Changes made yesterday\r
- and today allow us to start the new thread running rather than\r
- temporarily suspended.\r
-\r
- * private.c (ptw32_new_thread_entry): ptw32_thread_table\r
- was changed back to a table of thread structures rather than pointers.\r
- As such we're trading storage for increaded speed. This routine\r
- was modified to work with the new table. Mutex lock put in around\r
- global data accesses.\r
- (ptw32_find_thread_entry): Ditto\r
- (ptw32_delete_thread_entry): Ditto\r
-\r
-Thu Jul 23 23:25:30 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * global.c: New. Global data objects declared here. These moved from\r
- pthread.h.\r
-\r
- * pthread.h: Move implementation hidden definitions into\r
- implement.h.\r
-\r
- * implement.h: Move implementation hidden definitions from\r
- pthread.h. Add constants to index into the different handler stacks.\r
-\r
- * cleanup.c (ptw32_handler_push): Simplify args. Restructure.\r
- (ptw32_handler_pop): Simplify args. Restructure.\r
- (ptw32_handler_pop_all): Simplify args. Restructure.\r
-\r
-Wed Jul 22 00:16:22 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * attr.c, implement.h, pthread.h, ChangeLog: Resolve CVS merge\r
- conflicts.\r
-\r
- * private.c (ptw32_find_thread_entry): Changes to return type\r
- to support leaner ptw32_threads_table[] which now only stores\r
- ptw32_thread_thread_t *.\r
- (ptw32_new_thread_entry): Internal changes.\r
- (ptw32_delete_thread_entry): Internal changes to avoid contention.\r
- Calling routines changed accordingly.\r
-\r
- * pthread.h: Modified cleanup macros to use new generic push and pop.\r
- Added destructor and atfork stacks to ptw32_threads_thread_t.\r
-\r
- * cleanup.c (ptw32_handler_push, ptw32_handler_pop,\r
- ptw32_handler_pop_all): Renamed cleanup push and pop routines\r
- and made generic to handle destructors and atfork handlers as\r
- well.\r
-\r
- * create.c (ptw32_start_call): New function is a wrapper for\r
- all new threads. It allows us to do some cleanup when the thread\r
- returns, ie. that is otherwise only done if the thread is cancelled.\r
-\r
- * exit.c (ptw32_vacuum): New function contains code from \r
- pthread_exit() that we need in the new ptw32_start_call()\r
- as well.\r
-\r
- * implement.h: Various additions and minor changes.\r
-\r
- * pthread.h: Various additions and minor changes.\r
- Change cleanup handler macros to use generic handler push and pop\r
- functions.\r
-\r
- * attr.c: Minor mods to all functions.\r
- (is_attr): Implemented missing function.\r
-\r
- * create.c (pthread_create): More clean up.\r
-\r
- * private.c (ptw32_find_thread_entry): Implement.\r
- (ptw32_delete_thread_entry): Implement.\r
- (ptw32_new_thread_entry): Implement.\r
- These functions manipulate the implementations internal thread\r
- table and are part of general code cleanup and modularisation.\r
- They replace ptw32_getthreadindex() which was removed.\r
-\r
- * exit.c (pthread_exit): Changed to use the new code above.\r
-\r
- * pthread.h: Add cancelability constants. Update comments.\r
-\r
-1998-07-22 Ben Elliston <bje at cygnus.com>\r
-\r
- * attr.c (pthread_setstacksize): Update test of attr argument.\r
- (pthread_getstacksize): Likewise.\r
- (pthread_setstackaddr): Likewise.\r
- (pthread_getstackaddr): Likewise.\r
- (pthread_attr_init): No need to allocate any storage.\r
- (pthread_attr_destroy): No need to free any storage.\r
-\r
- * mutex.c (is_attr): Not likely to be needed; remove.\r
- (remove_attr): Likewise.\r
- (insert_attr): Likewise.\r
-\r
- * implement.h (ptw32_mutexattr_t): Moved to a public definition\r
- in pthread.h. There was little gain in hiding these details.\r
- (ptw32_condattr_t): Likewise.\r
- (ptw32_attr_t): Likewise.\r
-\r
- * pthread.h (pthread_atfork): Add function prototype.\r
- (pthread_attr_t): Moved here from implement.h.\r
-\r
- * fork.c (pthread_atfork): Preliminary implementation.\r
- (ptw32_fork): Likewise.\r
-\r
-Wed Jul 22 00:16:22 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * cleanup.c (ptw32_cleanup_push): Implement.\r
- (ptw32_cleanup_pop): Implement.\r
- (ptw32_do_cancellation): Implement.\r
- These are private to the implementation. The real cleanup functions\r
- are macros. See below.\r
-\r
- * pthread.h (pthread_cleanup_push): Implement as a macro.\r
- (pthread_cleanup_pop): Implement as a macro.\r
- Because these are macros which start and end a block, the POSIX scoping\r
- requirement is observed. See the comment in the file.\r
-\r
- * exit.c (pthread_exit): Refine the code.\r
-\r
- * create.c (pthread_create): Code cleanup.\r
-\r
- * implement.h (RND_SIZEOF): Add RND_SIZEOF(T) to round sizeof(T)\r
- up to multiple of DWORD.\r
- Add function prototypes.\r
-\r
- * private.c (ptw32_getthreadindex): "*thread" should have been \r
- "thread". Detect empty slot fail condition.\r
-\r
-1998-07-20 Ben Elliston <bje at cygnus.com>\r
-\r
- * misc.c (pthread_once): Implement. Don't use a per-application\r
- flag and mutex--make `pthread_once_t' contain these elements in\r
- their structure. The earlier version had incorrect semantics.\r
- \r
- * pthread.h (ptw32_once_flag): Add new variable. Remove.\r
- (ptw32_once_lock): Add new mutex lock to ensure integrity of\r
- access to ptw32_once_flag. Remove.\r
- (pthread_once): Add function prototype.\r
- (pthread_once_t): Define this type.\r
- \r
-Mon Jul 20 02:31:05 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * private.c (ptw32_getthreadindex): Implement.\r
-\r
- * pthread.h: Add application static data dependent on\r
- _PTHREADS_BUILD_DLL define. This is needed to avoid allocating\r
- non-sharable static data within the pthread DLL.\r
-\r
- * implement.h: Add ptw32_cleanup_stack_t, ptw32_cleanup_node_t\r
- and PTW32_HASH_INDEX.\r
-\r
- * exit.c (pthread_exit): Begin work on cleanup and de-allocate\r
- thread-private storage.\r
-\r
- * create.c (pthread_create): Add thread to thread table.\r
- Keep a thread-private copy of the attributes with default values\r
- filled in when necessary. Same for the cleanup stack. Make \r
- pthread_create C run-time library friendly by using _beginthreadex()\r
- instead of CreateThread(). Fix error returns.\r
-\r
-Sun Jul 19 16:26:23 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * implement.h: Rename pthreads_thread_count to ptw32_threads_count.\r
- Create ptw32_threads_thread_t struct to keep thread specific data.\r
-\r
- * create.c: Rename pthreads_thread_count to ptw32_threads_count.\r
- (pthread_create): Handle errors from CreateThread().\r
-\r
-1998-07-19 Ben Elliston <bje at cygnus.com>\r
-\r
- * condvar.c (pthread_cond_wait): Generalise. Moved from here ..\r
- (cond_wait): To here.\r
- (pthread_cond_timedwait): Implement; use generalised cond_wait().\r
-\r
- * pthread.h (pthread_key_t): Define this type.\r
- (pthread_key_create): Add function prototype.\r
- (pthread_setspecific): Likewise.\r
- (pthread_getspecific): Likwise.\r
- (pthread_key_delete): Likewise.\r
-\r
- * tsd.c (pthread_key_create): Implement.\r
- (pthread_setspecific): Likewise.\r
- (pthread_getspecific): Likewise.\r
- (pthread_key_delete): Likewise.\r
-\r
- * mutex.c (pthread_mutex_trylock): Return ENOSYS if this function\r
- is called on a Win32 platform which is not Windows NT.\r
-\r
-1998-07-18 Ben Elliston <bje at cygnus.com>\r
-\r
- * condvar.c (pthread_condattr_init): Do not attempt to malloc any\r
- storage; none is needed now that condattr_t is an empty struct.\r
- (pthread_condattr_destory): Likewise; do not free storage.\r
- (pthread_condattr_setpshared): No longer supported; return ENOSYS.\r
- (pthread_condattr_getpshared): Likewise.\r
- (pthread_cond_init): Implement with help from Douglas Schmidt.\r
- Remember to initialise the cv's internal mutex.\r
- (pthread_cond_wait): Likewise.\r
- (pthread_cond_signal): Likewise.\r
- (pthread_cond_broadcast): Likewise.\r
- (pthread_cond_timedwait): Preliminary implementation, but I need\r
- to see some API documentation for `WaitForMultipleObject'.\r
- (pthread_destory): Implement.\r
-\r
- * pthread.h (pthread_cond_init): Add function protoype.\r
- (pthread_cond_broadcast): Likewise.\r
- (pthread_cond_signal): Likewise.\r
- (pthread_cond_timedwait): Likewise.\r
- (pthread_cond_wait): Likewise.\r
- (pthread_cond_destroy): Likewise.\r
- (pthread_cond_t): Define this type. Fix for u_int. Do not assume\r
- that the mutex contained withing the pthread_cond_t structure will\r
- be a critical section. Use our new POSIX type!\r
-\r
- * implement.h (ptw32_condattr_t): Remove shared attribute.\r
-\r
-1998-07-17 Ben Elliston <bje at cygnus.com>\r
-\r
- * pthread.h (PTHREADS_PROCESS_PRIVATE): Remove.\r
- (PTHREAD_PROCESS_SHARED): Likewise. No support for mutexes shared\r
- across processes for now.\r
- (pthread_mutex_t): Use a Win32 CRITICAL_SECTION type for better\r
- performance.\r
- \r
- * implement.h (ptw32_mutexattr_t): Remove shared attribute.\r
- \r
- * mutex.c (pthread_mutexattr_setpshared): This optional function\r
- is no longer supported, since we want to implement POSIX mutex\r
- variables using the much more efficient Win32 critical section\r
- primitives. Critical section objects in Win32 cannot be shared\r
- between processes.\r
- (pthread_mutexattr_getpshared): Likewise.\r
- (pthread_mutexattr_init): No need to malloc any storage; the\r
- attributes structure is now empty.\r
- (pthread_mutexattr_destroy): This is now a nop.\r
- (pthread_mutex_init): Use InitializeCriticalSection().\r
- (pthread_mutex_destroy): Use DeleteCriticalSection().\r
- (pthread_mutex_lock): Use EnterCriticalSection().\r
- (pthread_mutex_trylock): Use TryEnterCriticalSection(). This is\r
- not supported by Windows 9x, but trylock is a hack anyway, IMHO.\r
- (pthread_mutex_unlock): Use LeaveCriticalSection().\r
-\r
-1998-07-14 Ben Elliston <bje at cygnus.com>\r
-\r
- * attr.c (pthread_attr_setstacksize): Implement.\r
- (pthread_attr_getstacksize): Likewise.\r
- (pthread_attr_setstackaddr): Likewise.\r
- (pthread_attr_getstackaddr): Likewise.\r
- (pthread_attr_init): Likewise.\r
- (pthread_attr_destroy): Likewise.\r
- \r
- * condvar.c (pthread_condattr_init): Add `_cond' to function name.\r
-\r
- * mutex.c (pthread_mutex_lock): Add `_mutex' to function name.\r
- (pthread_mutex_trylock): Likewise.\r
- (pthread_mutex_unlock): Likewise.\r
-\r
- * pthread.h (pthread_condattr_setpshared): Fix typo.\r
- (pthread_attr_init): Add function prototype.\r
- (pthread_attr_destroy): Likewise.\r
- (pthread_attr_setstacksize): Likewise.\r
- (pthread_attr_getstacksize): Likewise.\r
- (pthread_attr_setstackaddr): Likewise.\r
- (pthread_attr_getstackaddr): Likewise.\r
- \r
-Mon Jul 13 01:09:55 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * implement.h: Wrap in #ifndef _IMPLEMENT_H\r
-\r
- * create.c (pthread_create): Map stacksize attr to Win32.\r
-\r
- * mutex.c: Include implement.h\r
-\r
-1998-07-13 Ben Elliston <bje at cygnus.com>\r
-\r
- * condvar.c (pthread_condattr_init): Implement.\r
- (pthread_condattr_destroy): Likewise.\r
- (pthread_condattr_setpshared): Likewise.\r
- (pthread_condattr_getpshared): Likewise.\r
- \r
- * implement.h (PTHREAD_THREADS_MAX): Remove trailing semicolon.\r
- (PTHREAD_STACK_MIN): Specify; needs confirming.\r
- (ptw32_attr_t): Define this type.\r
- (ptw32_condattr_t): Likewise.\r
-\r
- * pthread.h (pthread_mutex_t): Define this type.\r
- (pthread_condattr_t): Likewise.\r
- (pthread_mutex_destroy): Add function prototype.\r
- (pthread_lock): Likewise.\r
- (pthread_trylock): Likewise.\r
- (pthread_unlock): Likewise.\r
- (pthread_condattr_init): Likewise.\r
- (pthread_condattr_destroy): Likewise.\r
- (pthread_condattr_setpshared): Likewise.\r
- (pthread_condattr_getpshared): Likewise.\r
-\r
- * mutex.c (pthread_mutex_init): Implement.\r
- (pthread_mutex_destroy): Likewise.\r
- (pthread_lock): Likewise.\r
- (pthread_trylock): Likewise.\r
- (pthread_unlock): Likewise.\r
-\r
-1998-07-12 Ben Elliston <bje at cygnus.com>\r
-\r
- * implement.h (ptw32_mutexattr_t): Define this implementation\r
- internal type. Application programmers only see a mutex attribute\r
- object as a void pointer.\r
-\r
- * pthread.h (pthread_mutexattr_t): Define this type.\r
- (pthread_mutexattr_init): Add function prototype.\r
- (pthread_mutexattr_destroy): Likewise.\r
- (pthread_mutexattr_setpshared): Likewise.\r
- (pthread_mutexattr_getpshared): Likewise.\r
- (pthread_mutexattr_setprotocol): Likewise.\r
- (pthread_mutexattr_getprotocol): Likewise.\r
- (pthread_mutexattr_setprioceiling): Likewise.\r
- (pthread_mutexattr_getprioceiling): Likewise.\r
- (PTHREAD_PROCESS_PRIVATE): Define.\r
- (PTHREAD_PROCESS_SHARED): Define.\r
-\r
- * mutex.c (pthread_mutexattr_init): Implement.\r
- (pthread_mutexattr_destroy): Implement.\r
- (pthread_mutexattr_setprotocol): Implement.\r
- (pthread_mutexattr_getprotocol): Likewise.\r
- (pthread_mutexattr_setprioceiling): Likewise.\r
- (pthread_mutexattr_getprioceiling): Likewise.\r
- (pthread_mutexattr_setpshared): Likewise.\r
- (pthread_mutexattr_getpshared): Likewise.\r
- (insert_attr): New function; very preliminary implementation!\r
- (is_attr): Likewise.\r
- (remove_attr): Likewise.\r
- \r
-Sat Jul 11 14:48:54 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>\r
-\r
- * implement.h: Preliminary implementation specific defines.\r
-\r
- * create.c (pthread_create): Preliminary implementation.\r
-\r
-1998-07-11 Ben Elliston <bje at cygnus.com>\r
-\r
- * sync.c (pthread_join): Implement.\r
-\r
- * misc.c (pthread_equal): Likewise.\r
- \r
- * pthread.h (pthread_join): Add function prototype.\r
- (pthread_equal): Likewise.\r
- \r
-1998-07-10 Ben Elliston <bje at cygnus.com>\r
-\r
- * misc.c (pthread_self): Implement.\r
-\r
- * exit.c (pthread_exit): Implement.\r
-\r
- * pthread.h (pthread_exit): Add function prototype.\r
- (pthread_self): Likewise.\r
- (pthread_t): Define this type.\r
-\r
-1998-07-09 Ben Elliston <bje at cygnus.com>\r
-\r
- * create.c (pthread_create): A dummy stub right now.\r
-\r
- * pthread.h (pthread_create): Add function prototype.\r
+++ /dev/null
- =========================================
- 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.
-
+++ /dev/null
-#
-# --------------------------------------------------------------------------
-#
-# Pthreads-win32 - POSIX 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
-
-## Mingw32
-MAKE ?= make
-CFLAGS = $(OPT) $(XOPT) -I. -DHAVE_PTW32_CONFIG_H -Wall
-
-DLL_INLINED_OBJS = \
- pthread.o \
- version.o
-
-# Agregate modules for inlinability
-DLL_OBJS = \
- attr.o \
- barrier.o \
- cancel.o \
- cleanup.o \
- condvar.o \
- create.o \
- dll.o \
- errno.o \
- exit.o \
- fork.o \
- global.o \
- misc.o \
- mutex.o \
- nonportable.o \
- private.o \
- rwlock.o \
- sched.o \
- semaphore.o \
- signal.o \
- spin.o \
- sync.o \
- tsd.o \
- version.o
-
-# Separate modules for minimum size statically linked images
-SMALL_STATIC_OBJS = \
- pthread_attr_init.o \
- pthread_attr_destroy.o \
- pthread_attr_getdetachstate.o \
- pthread_attr_setdetachstate.o \
- pthread_attr_getstackaddr.o \
- pthread_attr_setstackaddr.o \
- pthread_attr_getstacksize.o \
- pthread_attr_setstacksize.o \
- pthread_attr_getscope.o \
- pthread_attr_setscope.o \
- pthread_attr_setschedpolicy.o \
- pthread_attr_getschedpolicy.o \
- pthread_attr_setschedparam.o \
- pthread_attr_getschedparam.o \
- pthread_attr_setinheritsched.o \
- pthread_attr_getinheritsched.o \
- pthread_barrier_init.o \
- pthread_barrier_destroy.o \
- pthread_barrier_wait.o \
- pthread_barrierattr_init.o \
- pthread_barrierattr_destroy.o \
- pthread_barrierattr_setpshared.o \
- pthread_barrierattr_getpshared.o \
- pthread_setcancelstate.o \
- pthread_setcanceltype.o \
- pthread_testcancel.o \
- pthread_cancel.o \
- cleanup.o \
- pthread_condattr_destroy.o \
- pthread_condattr_getpshared.o \
- pthread_condattr_init.o \
- pthread_condattr_setpshared.o \
- pthread_cond_destroy.o \
- pthread_cond_init.o \
- pthread_cond_signal.o \
- pthread_cond_wait.o \
- create.o \
- dll.o \
- autostatic.o \
- errno.o \
- pthread_exit.o \
- fork.o \
- global.o \
- pthread_mutex_init.o \
- pthread_mutex_destroy.o \
- pthread_mutexattr_init.o \
- pthread_mutexattr_destroy.o \
- pthread_mutexattr_getpshared.o \
- pthread_mutexattr_setpshared.o \
- pthread_mutexattr_settype.o \
- pthread_mutexattr_gettype.o \
- pthread_mutexattr_setrobust.o \
- pthread_mutexattr_getrobust.o \
- pthread_mutex_lock.o \
- pthread_mutex_timedlock.o \
- pthread_mutex_unlock.o \
- pthread_mutex_trylock.o \
- pthread_mutex_consistent.o \
- pthread_mutexattr_setkind_np.o \
- pthread_mutexattr_getkind_np.o \
- pthread_getw32threadhandle_np.o \
- pthread_getunique_np.o \
- pthread_delay_np.o \
- pthread_num_processors_np.o \
- pthread_win32_attach_detach_np.o \
- pthread_equal.o \
- pthread_getconcurrency.o \
- pthread_once.o \
- pthread_self.o \
- pthread_setconcurrency.o \
- pthread_rwlock_init.o \
- pthread_rwlock_destroy.o \
- pthread_rwlockattr_init.o \
- pthread_rwlockattr_destroy.o \
- pthread_rwlockattr_getpshared.o \
- pthread_rwlockattr_setpshared.o \
- pthread_rwlock_rdlock.o \
- pthread_rwlock_wrlock.o \
- pthread_rwlock_unlock.o \
- pthread_rwlock_tryrdlock.o \
- pthread_rwlock_trywrlock.o \
- pthread_setschedparam.o \
- pthread_getschedparam.o \
- pthread_timechange_handler_np.o \
- ptw32_is_attr.o \
- ptw32_cond_check_need_init.o \
- ptw32_MCS_lock.o \
- ptw32_mutex_check_need_init.o \
- ptw32_processInitialize.o \
- ptw32_processTerminate.o \
- ptw32_threadStart.o \
- ptw32_threadDestroy.o \
- ptw32_tkAssocCreate.o \
- ptw32_tkAssocDestroy.o \
- ptw32_callUserDestroyRoutines.o \
- ptw32_timespec.o \
- ptw32_throw.o \
- ptw32_getprocessors.o \
- ptw32_calloc.o \
- ptw32_new.o \
- ptw32_reuse.o \
- ptw32_semwait.o \
- ptw32_relmillisecs.o \
- ptw32_rwlock_check_need_init.o \
- sched_get_priority_max.o \
- sched_get_priority_min.o \
- sched_setscheduler.o \
- sched_getscheduler.o \
- sched_yield.o \
- sem_init.o \
- sem_destroy.o \
- sem_trywait.o \
- sem_timedwait.o \
- sem_wait.o \
- sem_post.o \
- sem_post_multiple.o \
- sem_getvalue.o \
- sem_open.o \
- sem_close.o \
- sem_unlink.o \
- signal.o \
- pthread_kill.o \
- ptw32_spinlock_check_need_init.o \
- pthread_spin_init.o \
- pthread_spin_destroy.o \
- pthread_spin_lock.o \
- pthread_spin_unlock.o \
- pthread_spin_trylock.o \
- pthread_detach.o \
- pthread_join.o \
- pthread_key_create.o \
- pthread_key_delete.o \
- pthread_setspecific.o \
- pthread_getspecific.o \
- w32_CancelableWait.o \
- version.o
-
-INCL = \
- config.h \
- implement.h \
- semaphore.h \
- pthread.h \
- need_errno.h
-
-ATTR_SRCS = \
- pthread_attr_init.c \
- pthread_attr_destroy.c \
- pthread_attr_getdetachstate.c \
- pthread_attr_setdetachstate.c \
- pthread_attr_getstackaddr.c \
- pthread_attr_setstackaddr.c \
- pthread_attr_getstacksize.c \
- pthread_attr_setstacksize.c \
- pthread_attr_getscope.c \
- pthread_attr_setscope.c
-
-BARRIER_SRCS = \
- pthread_barrier_init.c \
- pthread_barrier_destroy.c \
- pthread_barrier_wait.c \
- pthread_barrierattr_init.c \
- pthread_barrierattr_destroy.c \
- pthread_barrierattr_setpshared.c \
- pthread_barrierattr_getpshared.c
-
-CANCEL_SRCS = \
- pthread_setcancelstate.c \
- pthread_setcanceltype.c \
- pthread_testcancel.c \
- pthread_cancel.c
-
-CONDVAR_SRCS = \
- ptw32_cond_check_need_init.c \
- pthread_condattr_destroy.c \
- pthread_condattr_getpshared.c \
- pthread_condattr_init.c \
- pthread_condattr_setpshared.c \
- pthread_cond_destroy.c \
- pthread_cond_init.c \
- pthread_cond_signal.c \
- pthread_cond_wait.c
-
-EXIT_SRCS = \
- pthread_exit.c
-
-MISC_SRCS = \
- pthread_equal.c \
- pthread_getconcurrency.c \
- pthread_kill.c \
- pthread_once.c \
- pthread_self.c \
- pthread_setconcurrency.c \
- ptw32_calloc.c \
- ptw32_MCS_lock.c \
- ptw32_new.c \
- ptw32_reuse.c \
- w32_CancelableWait.c
-
-MUTEX_SRCS = \
- ptw32_mutex_check_need_init.c \
- pthread_mutex_init.c \
- pthread_mutex_destroy.c \
- pthread_mutexattr_init.c \
- pthread_mutexattr_destroy.c \
- pthread_mutexattr_getpshared.c \
- pthread_mutexattr_setpshared.c \
- pthread_mutexattr_settype.c \
- pthread_mutexattr_gettype.c \
- pthread_mutexattr_setrobust.c \
- pthread_mutexattr_getrobust.c \
- pthread_mutex_lock.c \
- pthread_mutex_timedlock.c \
- pthread_mutex_unlock.c \
- pthread_mutex_trylock.c \
- pthread_mutex_consistent.c
-
-NONPORTABLE_SRCS = \
- pthread_mutexattr_setkind_np.c \
- pthread_mutexattr_getkind_np.c \
- pthread_getw32threadhandle_np.c \
- pthread_getunique_np.c \
- pthread_delay_np.c \
- pthread_num_processors_np.c \
- pthread_win32_attach_detach_np.c \
- pthread_timechange_handler_np.c
-
-PRIVATE_SRCS = \
- ptw32_is_attr.c \
- ptw32_processInitialize.c \
- ptw32_processTerminate.c \
- ptw32_threadStart.c \
- ptw32_threadDestroy.c \
- ptw32_tkAssocCreate.c \
- ptw32_tkAssocDestroy.c \
- ptw32_callUserDestroyRoutines.c \
- ptw32_semwait.c \
- ptw32_relmillisecs.c \
- ptw32_timespec.c \
- ptw32_throw.c \
- ptw32_getprocessors.c
-
-RWLOCK_SRCS = \
- ptw32_rwlock_check_need_init.c \
- ptw32_rwlock_cancelwrwait.c \
- pthread_rwlock_init.c \
- pthread_rwlock_destroy.c \
- pthread_rwlockattr_init.c \
- pthread_rwlockattr_destroy.c \
- pthread_rwlockattr_getpshared.c \
- pthread_rwlockattr_setpshared.c \
- pthread_rwlock_rdlock.c \
- pthread_rwlock_timedrdlock.c \
- pthread_rwlock_wrlock.c \
- pthread_rwlock_timedwrlock.c \
- pthread_rwlock_unlock.c \
- pthread_rwlock_tryrdlock.c \
- pthread_rwlock_trywrlock.c
-
-SCHED_SRCS = \
- pthread_attr_setschedpolicy.c \
- pthread_attr_getschedpolicy.c \
- pthread_attr_setschedparam.c \
- pthread_attr_getschedparam.c \
- pthread_attr_setinheritsched.c \
- pthread_attr_getinheritsched.c \
- pthread_setschedparam.c \
- pthread_getschedparam.c \
- sched_get_priority_max.c \
- sched_get_priority_min.c \
- sched_setscheduler.c \
- sched_getscheduler.c \
- sched_yield.c
-
-SEMAPHORE_SRCS = \
- sem_init.c \
- sem_destroy.c \
- sem_trywait.c \
- sem_timedwait.c \
- sem_wait.c \
- sem_post.c \
- sem_post_multiple.c \
- sem_getvalue.c \
- sem_open.c \
- sem_close.c \
- sem_unlink.c
-
-SPIN_SRCS = \
- ptw32_spinlock_check_need_init.c \
- pthread_spin_init.c \
- pthread_spin_destroy.c \
- pthread_spin_lock.c \
- pthread_spin_unlock.c \
- pthread_spin_trylock.c
-
-SYNC_SRCS = \
- pthread_detach.c \
- pthread_join.c
-
-TSD_SRCS = \
- pthread_key_create.c \
- pthread_key_delete.c \
- pthread_setspecific.c \
- pthread_getspecific.c
-
-
-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 $@ $<
-
-.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)
+++ /dev/null
-CVS Repository maintainers
-
-Ross Johnson rpj@ise.canberra.edu.au
-Ben Elliston bje@cygnus.com
+++ /dev/null
-# 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
-STATICCRT = /MT
-STATICCRTD = /MTd
-DLLCRT = /MD
-DLLCRTD = /MDd
-XCFLAGS = /W3 /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) $(DLLCRT)" CLEANUP=__CLEANUP_CXX pthreadVCE$(DLL_VER).dll
-
-VCE-debug:
- @ $(MAKE) /E /nologo EHFLAGS="$(VCEFLAGSD) $(DLLCRTD)" CLEANUP=__CLEANUP_CXX pthreadVCE$(DLL_VERD).dll
-
-VSE:
- @ $(MAKE) /E /nologo EHFLAGS="$(VSEFLAGS) $(DLLCRT)" CLEANUP=__CLEANUP_SEH pthreadVSE$(DLL_VER).dll
-
-VSE-debug:
- @ $(MAKE) /E /nologo EHFLAGS="$(VSEFLAGSD) $(DLLCRTD)" CLEANUP=__CLEANUP_SEH pthreadVSE$(DLL_VERD).dll
-
-VC:
- @ $(MAKE) /E /nologo EHFLAGS="$(VCFLAGS) $(DLLCRT)" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VER).dll
-
-VC-debug:
- @ $(MAKE) /E /nologo EHFLAGS="$(VCFLAGSD) $(DLLCRTD)" 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) $(DLLCRT) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_CXX pthreadVCE$(DLL_VER).stamp
-
-VCE-inlined-debug:
- @ $(MAKE) /E /nologo EHFLAGS="$(VCEFLAGSD) $(DLLCRTD) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_CXX pthreadVCE$(DLL_VERD).stamp
-
-VSE-inlined:
- @ $(MAKE) /E /nologo EHFLAGS="$(VSEFLAGS) $(DLLCRT) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_SEH pthreadVSE$(DLL_VER).stamp
-
-VSE-inlined-debug:
- @ $(MAKE) /E /nologo EHFLAGS="$(VSEFLAGSD) $(DLLCRTD) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_SEH pthreadVSE$(DLL_VERD).stamp
-
-VC-inlined:
- @ $(MAKE) /E /nologo EHFLAGS="$(VCFLAGS) $(DLLCRT) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VER).stamp
-
-VC-inlined-debug:
- @ $(MAKE) /E /nologo EHFLAGS="$(VCFLAGSD) $(DLLCRTD) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VERD).stamp
-
-VC-static:
- @ $(MAKE) /E /nologo EHFLAGS="$(VCFLAGS) $(STATICCRT) /DPTW32_BUILD_INLINED /DPTW32_STATIC_LIB" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VER).static
-
-VC-static-debug:
- @ $(MAKE) /E /nologo EHFLAGS="$(VCFLAGSD) $(STATICCRTD) /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 $<
-
-.rc.res:
- rc /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)
+++ /dev/null
-CURRENT CVS HEAD Version
-RELEASE 2.9.0 pending
--------------
-(2011-??-??)
-
-General
--------
-New bug fixes in this release since 2.8.0 have NOT been applied to the
-1.x.x series.
-
-Version 2.8.0 may be the last release for some older Windows systems.
-Some changes post 2011-02-26 in CVS may not be compatible with pre
-Windows 2000 systems.
-
-Version 1 no longer maintained
-------------------------------
-The 1.x.x series is no longer maintained. However, if you really need a
-version 1, the differences between 1.11.0 and 2.7.0 are very small, mainly
-revolving around the pthread_once_t_ struct. Those differences applied
-as a patch to the current 2.x.x should work. Don't forget to change
-the version numbering in pthread.h before building. If you distribute
-such a version 1.x.x please bear in mind that your numbers may clash
-with those of others doing the same thing. Please consider also making
-identifying changes in version.rc to differentiate your build.
-
-Testing and verification
-------------------------
-The current CVS head version has been tested on an SMP architecture
-(AMD Phenom 9750 Quad Core) by running the MinGW32 (GCC) builds against
-the full test suite, stress tests and benchmarks.
-
-New Features
-------------
-(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 <RKubis at mc.com>
-
-* 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 <beowinkle at yahoo.com>
-
-
-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 <tristan at mpegtv.com>
-
-* 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 <anuj.goyal at gmail.com>
-
-* 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 <Alex.Blanco at motorola.com>
-
-* ptw32_getprocessors() now returns CPU count of 1 for WinCE.
-- James Ewing <james.ewing at sveasoft.com>
-
-* pthread_cond_wait() could be canceled at a point where it should not
-be cancelable. Fixed.
-- Alexander Terekhov <TEREKHOV at de.ibm.com>
-
-* sem_timedwait() had an incorrect timeout calculation.
-- Philippe Di Cristo <philipped at voicebox.com>
-
-* Fix a memory leak left behind after threads are destroyed.
-- P. van Bruggen <pietvb at newbridges.nl>
-
-New features
-------------
-* Ported to AMD64.
-- Makoto Kato <raven at oldskool.jp>
-
-* 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 <vcotirlea@hotmail.com>
-
-* pthread_win32_process_detach_np() fixed memory leak.
-- Steven Reddie <Steven.Reddie@ca.com>
-
-* pthread_mutex_destroy() fixed incorrect return code.
-- Nicolas Barry <boozai@yahoo.com>
-
-* pthread_spin_destroy() fixed memory leak.
-- Piet van Bruggen <pietvb@newbridges.nl>
-
-* 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 <boozai@yahoo.com>
-
-* 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 <tpfaff@gmx.net>
-
-* pthread_mutex_timedlock() no longer occasionally sets incorrect mutex
-ownership, causing deadlocks in some applications.
-- Robert Strycek <strycek@posam.sk> and Alexander Terekhov <TEREKHOV@de.ibm.com>
-
-
-SNAPSHOT 2002-11-04
--------------------
-
-Bug fixes
----------
-
-* sem_getvalue() now returns the correct value under Win NT and WinCE.
-- Rob Fanner <rfanner@stonethree.com>
-
-* 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 <TEREKHOV@de.ibm.com>
-
-* 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 <michaelj@maine.rr.com>
-
-
-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 <scott@magruder.org>
-
-* Removed potential race condition in pthread_mutex_trylock and
-pthread_mutex_lock;
-- Alexander Terekhov <TEREKHOV@de.ibm.com>
-
-* 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 <tpfaff@gmx.net>
-
-* 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.
-
+++ /dev/null
-/*
- * 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
-
+++ /dev/null
-/* 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
+++ /dev/null
-Please see the ANNOUNCE file "Level of Standards Conformance"
-or the web page:
-
-http://sources.redhat.com/pthreads-win32/conformance.html
+++ /dev/null
-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
-<rpj@callisto.canberra.edu.au>
-
-
-
-
-
-
-
-
+++ /dev/null
-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/
+++ /dev/null
-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 <davids@webmaster.com> 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 <davids@webmaster.com> 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 <davids@webmaster.com> 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, <N) W threads are fast enough to go thru their _wait call and
-decrement cv->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 <tpfaff@gmx.net>,
- Nanbor Wang <nanbor@cs.wustl.edu>
-
-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 <lthomas@arbitrade.com>
-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 <lthomas@arbitrade.com>
-To: "'TEREKHOV@de.ibm.com'" <TEREKHOV@de.ibm.com>
-CC: rpj@ise.canberra.edu.au, Thomas Pfaff <tpfaff@gmx.net>,
- Nanbor Wang
- <nanbor@cs.wustl.edu>
-
-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 <lthomas@arbitrade.com>
-CC: rpj@ise.canberra.edu.au, Thomas Pfaff <tpfaff@gmx.net>,
- Nanbor Wang <nanbor@cs.wustl.edu>
-
-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?
-
-<sys/sem.h>
-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 -
-<semaphore.h>)
-
-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 <lthomas@arbitrade.com> on 02/27/2001 05:20:12 AM
-
-Please respond to Louis Thomas <lthomas@arbitrade.com>
-
-To: Alexander Terekhov/Germany/IBM@IBMDE
-cc: rpj@ise.canberra.edu.au, Thomas Pfaff <tpfaff@gmx.net>, Nanbor Wang
- <nanbor@cs.wustl.edu>
-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! :)
-
+++ /dev/null
-This file documents non-portable functions and other issues.\r
-\r
-Non-portable functions included in pthreads-win32\r
--------------------------------------------------\r
-\r
-BOOL\r
-pthread_win32_test_features_np(int mask)\r
-\r
- This routine allows an application to check which\r
- run-time auto-detected features are available within\r
- the library.\r
-\r
- The possible features are:\r
-\r
- PTW32_SYSTEM_INTERLOCKED_COMPARE_EXCHANGE\r
- Return TRUE if the native version of\r
- InterlockedCompareExchange() is being used.\r
- This feature is not meaningful in recent\r
- library versions as MSVC builds only support\r
- system implemented ICE. Note that all Mingw\r
- builds use inlined asm versions of all the\r
- Interlocked routines.\r
- PTW32_ALERTABLE_ASYNC_CANCEL\r
- Return TRUE is the QueueUserAPCEx package\r
- QUSEREX.DLL is available and the AlertDrv.sys\r
- driver is loaded into Windows, providing\r
- alertable (pre-emptive) asyncronous threads\r
- cancelation. If this feature returns FALSE\r
- then the default async cancel scheme is in\r
- use, which cannot cancel blocked threads.\r
-\r
- Features may be Or'ed into the mask parameter, in which case\r
- the routine returns TRUE if any of the Or'ed features would\r
- return TRUE. At this stage it doesn't make sense to Or features\r
- but it may some day.\r
-\r
-\r
-void *\r
-pthread_timechange_handler_np(void *)\r
-\r
- To improve tolerance against operator or time service\r
- initiated system clock changes.\r
-\r
- This routine can be called by an application when it\r
- receives a WM_TIMECHANGE message from the system. At\r
- present it broadcasts all condition variables so that\r
- waiting threads can wake up and re-evaluate their\r
- conditions and restart their timed waits if required.\r
-\r
- It has the same return type and argument type as a\r
- thread routine so that it may be called directly\r
- through pthread_create(), i.e. as a separate thread.\r
-\r
- Parameters\r
-\r
- Although a parameter must be supplied, it is ignored.\r
- The value NULL can be used.\r
-\r
- Return values\r
-\r
- It can return an error EAGAIN to indicate that not\r
- all condition variables were broadcast for some reason.\r
- Otherwise, 0 is returned.\r
-\r
- If run as a thread, the return value is returned\r
- through pthread_join().\r
-\r
- The return value should be cast to an integer.\r
-\r
-\r
-HANDLE\r
-pthread_getw32threadhandle_np(pthread_t thread);\r
-\r
- Returns the win32 thread handle that the POSIX\r
- thread "thread" is running as.\r
-\r
- Applications can use the win32 handle to set\r
- win32 specific attributes of the thread.\r
-\r
-DWORD\r
-pthread_getw32threadid_np (pthread_t thread)\r
-\r
- Returns the Windows native thread ID that the POSIX\r
- thread "thread" is running as.\r
-\r
- Only valid when the library is built where\r
- ! (defined(__MINGW64__) || defined(__MINGW32__)) || defined (__MSVCRT__) || defined (__DMC__)\r
- and otherwise returns 0.\r
-\r
-\r
-int\r
-pthread_mutexattr_setkind_np(pthread_mutexattr_t * attr, int kind)\r
-\r
-int\r
-pthread_mutexattr_getkind_np(pthread_mutexattr_t * attr, int *kind)\r
-\r
- These two routines are included for Linux compatibility\r
- and are direct equivalents to the standard routines\r
- pthread_mutexattr_settype\r
- pthread_mutexattr_gettype\r
-\r
- pthread_mutexattr_setkind_np accepts the following\r
- mutex kinds:\r
- PTHREAD_MUTEX_FAST_NP\r
- PTHREAD_MUTEX_ERRORCHECK_NP\r
- PTHREAD_MUTEX_RECURSIVE_NP\r
-\r
- These are really just equivalent to (respectively):\r
- PTHREAD_MUTEX_NORMAL\r
- PTHREAD_MUTEX_ERRORCHECK\r
- PTHREAD_MUTEX_RECURSIVE\r
-\r
-int\r
-pthread_delay_np (const struct timespec *interval);\r
-\r
- This routine causes a thread to delay execution for a specific period of time.\r
- This period ends at the current time plus the specified interval. The routine\r
- will not return before the end of the period is reached, but may return an\r
- arbitrary amount of time after the period has gone by. This can be due to\r
- system load, thread priorities, and system timer granularity.\r
-\r
- Specifying an interval of zero (0) seconds and zero (0) nanoseconds is\r
- allowed and can be used to force the thread to give up the processor or to\r
- deliver a pending cancelation request.\r
-\r
- This routine is a cancelation point.\r
-\r
- The timespec structure contains the following two fields:\r
-\r
- tv_sec is an integer number of seconds.\r
- tv_nsec is an integer number of nanoseconds. \r
-\r
- Return Values\r
-\r
- If an error condition occurs, this routine returns an integer value\r
- indicating the type of error. Possible return values are as follows:\r
-\r
- 0 Successful completion. \r
- [EINVAL] The value specified by interval is invalid. \r
-\r
-int\r
-pthread_num_processors_np (void)\r
-\r
- This routine (found on HPUX systems) returns the number of processors\r
- in the system. This implementation actually returns the number of\r
- processors available to the process, which can be a lower number\r
- than the system's number, depending on the process's affinity mask.\r
-\r
-BOOL\r
-pthread_win32_process_attach_np (void);\r
-\r
-BOOL\r
-pthread_win32_process_detach_np (void);\r
-\r
-BOOL\r
-pthread_win32_thread_attach_np (void);\r
-\r
-BOOL\r
-pthread_win32_thread_detach_np (void);\r
-\r
- These functions contain the code normally run via dllMain\r
- when the library is used as a dll but which need to be\r
- called explicitly by an application when the library\r
- is statically linked. As of version 2.9.0 of the library, static\r
- builds using either MSC or GCC will call pthread_win32_process_*\r
- automatically at application startup and exit respectively.\r
-\r
- Otherwise, you will need to call pthread_win32_process_attach_np()\r
- before you can call any pthread routines when statically linking.\r
- You should call pthread_win32_process_detach_np() before\r
- exiting your application to clean up.\r
-\r
- pthread_win32_thread_attach_np() is currently a no-op, but\r
- pthread_win32_thread_detach_np() is needed to clean up\r
- the implicit pthread handle that is allocated to a Win32 thread if\r
- it calls any pthreads routines. Call this routine when the\r
- Win32 thread exits.\r
-\r
- Threads created through pthread_create() do not need to call\r
- pthread_win32_thread_detach_np().\r
-\r
- These functions invariably return TRUE except for\r
- pthread_win32_process_attach_np() which will return FALSE\r
- if pthreads-win32 initialisation fails.\r
-\r
-int\r
-pthreadCancelableWait (HANDLE waitHandle);\r
-\r
-int\r
-pthreadCancelableTimedWait (HANDLE waitHandle, DWORD timeout);\r
-\r
- These two functions provide hooks into the pthread_cancel\r
- mechanism that will allow you to wait on a Windows handle\r
- and make it a cancellation point. Both functions block\r
- until either the given w32 handle is signaled, or\r
- pthread_cancel has been called. It is implemented using\r
- WaitForMultipleObjects on 'waitHandle' and a manually\r
- reset w32 event used to implement pthread_cancel.\r
-\r
-\r
-Non-portable issues\r
--------------------\r
-\r
-Thread priority\r
-\r
- POSIX defines a single contiguous range of numbers that determine a\r
- thread's priority. Win32 defines priority classes and priority\r
- levels relative to these classes. Classes are simply priority base\r
- levels that the defined priority levels are relative to such that,\r
- changing a process's priority class will change the priority of all\r
- of it's threads, while the threads retain the same relativity to each\r
- other.\r
-\r
- A Win32 system defines a single contiguous monotonic range of values\r
- that define system priority levels, just like POSIX. However, Win32\r
- restricts individual threads to a subset of this range on a\r
- per-process basis.\r
-\r
- The following table shows the base priority levels for combinations\r
- of priority class and priority value in Win32.\r
- \r
- Process Priority Class Thread Priority Level\r
- -----------------------------------------------------------------\r
- 1 IDLE_PRIORITY_CLASS THREAD_PRIORITY_IDLE\r
- 1 BELOW_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_IDLE\r
- 1 NORMAL_PRIORITY_CLASS THREAD_PRIORITY_IDLE\r
- 1 ABOVE_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_IDLE\r
- 1 HIGH_PRIORITY_CLASS THREAD_PRIORITY_IDLE\r
- 2 IDLE_PRIORITY_CLASS THREAD_PRIORITY_LOWEST\r
- 3 IDLE_PRIORITY_CLASS THREAD_PRIORITY_BELOW_NORMAL\r
- 4 IDLE_PRIORITY_CLASS THREAD_PRIORITY_NORMAL\r
- 4 BELOW_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_LOWEST\r
- 5 IDLE_PRIORITY_CLASS THREAD_PRIORITY_ABOVE_NORMAL\r
- 5 BELOW_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_BELOW_NORMAL\r
- 5 Background NORMAL_PRIORITY_CLASS THREAD_PRIORITY_LOWEST\r
- 6 IDLE_PRIORITY_CLASS THREAD_PRIORITY_HIGHEST\r
- 6 BELOW_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_NORMAL\r
- 6 Background NORMAL_PRIORITY_CLASS THREAD_PRIORITY_BELOW_NORMAL\r
- 7 BELOW_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_ABOVE_NORMAL\r
- 7 Background NORMAL_PRIORITY_CLASS THREAD_PRIORITY_NORMAL\r
- 7 Foreground NORMAL_PRIORITY_CLASS THREAD_PRIORITY_LOWEST\r
- 8 BELOW_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_HIGHEST\r
- 8 NORMAL_PRIORITY_CLASS THREAD_PRIORITY_ABOVE_NORMAL\r
- 8 Foreground NORMAL_PRIORITY_CLASS THREAD_PRIORITY_BELOW_NORMAL\r
- 8 ABOVE_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_LOWEST\r
- 9 NORMAL_PRIORITY_CLASS THREAD_PRIORITY_HIGHEST\r
- 9 Foreground NORMAL_PRIORITY_CLASS THREAD_PRIORITY_NORMAL\r
- 9 ABOVE_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_BELOW_NORMAL\r
- 10 Foreground NORMAL_PRIORITY_CLASS THREAD_PRIORITY_ABOVE_NORMAL\r
- 10 ABOVE_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_NORMAL\r
- 11 Foreground NORMAL_PRIORITY_CLASS THREAD_PRIORITY_HIGHEST\r
- 11 ABOVE_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_ABOVE_NORMAL\r
- 11 HIGH_PRIORITY_CLASS THREAD_PRIORITY_LOWEST\r
- 12 ABOVE_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_HIGHEST\r
- 12 HIGH_PRIORITY_CLASS THREAD_PRIORITY_BELOW_NORMAL\r
- 13 HIGH_PRIORITY_CLASS THREAD_PRIORITY_NORMAL\r
- 14 HIGH_PRIORITY_CLASS THREAD_PRIORITY_ABOVE_NORMAL\r
- 15 HIGH_PRIORITY_CLASS THREAD_PRIORITY_HIGHEST\r
- 15 HIGH_PRIORITY_CLASS THREAD_PRIORITY_TIME_CRITICAL\r
- 15 IDLE_PRIORITY_CLASS THREAD_PRIORITY_TIME_CRITICAL\r
- 15 BELOW_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_TIME_CRITICAL\r
- 15 NORMAL_PRIORITY_CLASS THREAD_PRIORITY_TIME_CRITICAL\r
- 15 ABOVE_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_TIME_CRITICAL\r
- 16 REALTIME_PRIORITY_CLASS THREAD_PRIORITY_IDLE\r
- 17 REALTIME_PRIORITY_CLASS -7\r
- 18 REALTIME_PRIORITY_CLASS -6\r
- 19 REALTIME_PRIORITY_CLASS -5\r
- 20 REALTIME_PRIORITY_CLASS -4\r
- 21 REALTIME_PRIORITY_CLASS -3\r
- 22 REALTIME_PRIORITY_CLASS THREAD_PRIORITY_LOWEST\r
- 23 REALTIME_PRIORITY_CLASS THREAD_PRIORITY_BELOW_NORMAL\r
- 24 REALTIME_PRIORITY_CLASS THREAD_PRIORITY_NORMAL\r
- 25 REALTIME_PRIORITY_CLASS THREAD_PRIORITY_ABOVE_NORMAL\r
- 26 REALTIME_PRIORITY_CLASS THREAD_PRIORITY_HIGHEST\r
- 27 REALTIME_PRIORITY_CLASS 3\r
- 28 REALTIME_PRIORITY_CLASS 4\r
- 29 REALTIME_PRIORITY_CLASS 5\r
- 30 REALTIME_PRIORITY_CLASS 6\r
- 31 REALTIME_PRIORITY_CLASS THREAD_PRIORITY_TIME_CRITICAL\r
- \r
- Windows NT: Values -7, -6, -5, -4, -3, 3, 4, 5, and 6 are not supported.\r
-\r
-\r
- As you can see, the real priority levels available to any individual\r
- Win32 thread are non-contiguous.\r
-\r
- An application using pthreads-win32 should not make assumptions about\r
- the numbers used to represent thread priority levels, except that they\r
- are monotonic between the values returned by sched_get_priority_min()\r
- and sched_get_priority_max(). E.g. Windows 95, 98, NT, 2000, XP make\r
- available a non-contiguous range of numbers between -15 and 15, while\r
- at least one version of WinCE (3.0) defines the minimum priority\r
- (THREAD_PRIORITY_LOWEST) as 5, and the maximum priority\r
- (THREAD_PRIORITY_HIGHEST) as 1.\r
-\r
- Internally, pthreads-win32 maps any priority levels between\r
- THREAD_PRIORITY_IDLE and THREAD_PRIORITY_LOWEST to THREAD_PRIORITY_LOWEST,\r
- or between THREAD_PRIORITY_TIME_CRITICAL and THREAD_PRIORITY_HIGHEST to\r
- THREAD_PRIORITY_HIGHEST. Currently, this also applies to\r
- REALTIME_PRIORITY_CLASSi even if levels -7, -6, -5, -4, -3, 3, 4, 5, and 6\r
- are supported.\r
-\r
- If it wishes, a Win32 application using pthreads-win32 can use the Win32\r
- defined priority macros THREAD_PRIORITY_IDLE through\r
- THREAD_PRIORITY_TIME_CRITICAL.\r
-\r
-\r
-The opacity of the pthread_t datatype\r
--------------------------------------\r
-and possible solutions for portable null/compare/hash, etc\r
-----------------------------------------------------------\r
-\r
-Because pthread_t is an opague datatype an implementation is permitted to define\r
-pthread_t in any way it wishes. That includes defining some bits, if it is\r
-scalar, or members, if it is an aggregate, to store information that may be\r
-extra to the unique identifying value of the ID. As a result, pthread_t values\r
-may not be directly comparable.\r
-\r
-If you want your code to be portable you must adhere to the following contraints:\r
-\r
-1) Don't assume it is a scalar data type, e.g. an integer or pointer value. There\r
-are several other implementations where pthread_t is also a struct. See our FAQ\r
-Question 11 for our reasons for defining pthread_t as a struct.\r
-\r
-2) You must not compare them using relational or equality operators. You must use\r
-the API function pthread_equal() to test for equality.\r
-\r
-3) Never attempt to reference individual members.\r
-\r
-\r
-The problem\r
-\r
-Certain applications would like to be able to access only the 'pure' pthread_t\r
-id values, primarily to use as keys into data structures to manage threads or\r
-thread-related data, but this is not possible in a maximally portable and\r
-standards compliant way for current POSIX threads implementations.\r
-\r
-For implementations that define pthread_t as a scalar, programmers often employ\r
-direct relational and equality operators on pthread_t. This code will break when\r
-ported to an implementation that defines pthread_t as an aggregate type.\r
-\r
-For implementations that define pthread_t as an aggregate, e.g. a struct,\r
-programmers can use memcmp etc., but then face the prospect that the struct may\r
-include alignment padding bytes or bits as well as extra implementation-specific\r
-members that are not part of the unique identifying value.\r
-\r
-[While this is not currently the case for pthreads-win32, opacity also\r
-means that an implementation is free to change the definition, which should\r
-generally only require that applications be recompiled and relinked, not\r
-rewritten.]\r
-\r
-\r
-Doesn't the compiler take care of padding?\r
-\r
-The C89 and later standards only effectively guarrantee element-by-element\r
-equivalence following an assignment or pass by value of a struct or union,\r
-therefore undefined areas of any two otherwise equivalent pthread_t instances\r
-can still compare differently, e.g. attempting to compare two such pthread_t\r
-variables byte-by-byte, e.g. memcmp(&t1, &t2, sizeof(pthread_t) may give an\r
-incorrect result. In practice I'm reasonably confident that compilers routinely\r
-also copy the padding bytes, mainly because assignment of unions would be far\r
-too complicated otherwise. But it just isn't guarranteed by the standard.\r
-\r
-Illustration:\r
-\r
-We have two thread IDs t1 and t2\r
-\r
-pthread_t t1, t2;\r
-\r
-In an application we create the threads and intend to store the thread IDs in an\r
-ordered data structure (linked list, tree, etc) so we need to be able to compare\r
-them in order to insert them initially and also to traverse.\r
-\r
-Suppose pthread_t contains undefined padding bits and our compiler copies our\r
-pthread_t [struct] element-by-element, then for the assignment:\r
-\r
-pthread_t temp = t1;\r
-\r
-temp and t1 will be equivalent and correct but a byte-for-byte comparison such as\r
-memcmp(&temp, &t1, sizeof(pthread_t)) == 0 may not return true as we expect because\r
-the undefined bits may not have the same values in the two variable instances.\r
-\r
-Similarly if passing by value under the same conditions.\r
-\r
-If, on the other hand, the undefined bits are at least constant through every\r
-assignment and pass-by-value then the byte-for-byte comparison\r
-memcmp(&temp, &t1, sizeof(pthread_t)) == 0 will always return the expected result.\r
-How can we force the behaviour we need?\r
-\r
-\r
-Solutions\r
-\r
-Adding new functions to the standard API or as non-portable extentions is\r
-the only reliable and portable way to provide the necessary operations.\r
-Remember also that POSIX is not tied to the C language. The most common\r
-functions that have been suggested are:\r
-\r
-pthread_null()\r
-pthread_compare()\r
-pthread_hash()\r
-\r
-A single more general purpose function could also be defined as a\r
-basis for at least the last two of the above functions.\r
-\r
-First we need to list the freedoms and constraints with restpect\r
-to pthread_t so that we can be sure our solution is compatible with the\r
-standard.\r
-\r
-What is known or may be deduced from the standard:\r
-1) pthread_t must be able to be passed by value, so it must be a single object.\r
-2) from (1) it must be copyable so cannot embed thread-state information, locks\r
-or other volatile objects required to manage the thread it associates with.\r
-3) pthread_t may carry additional information, e.g. for debugging or to manage\r
-itself.\r
-4) there is an implicit requirement that the size of pthread_t is determinable\r
-at compile-time and size-invariant, because it must be able to copy the object\r
-(i.e. through assignment and pass-by-value). Such copies must be genuine\r
-duplicates, not merely a copy of a pointer to a common instance such as\r
-would be the case if pthread_t were defined as an array.\r
-\r
-\r
-Suppose we define the following function:\r
-\r
-/* This function shall return it's argument */\r
-pthread_t* pthread_normalize(pthread_t* thread);\r
-\r
-For scalar or aggregate pthread_t types this function would simply zero any bits\r
-within the pthread_t that don't uniquely identify the thread, including padding,\r
-such that client code can return consistent results from operations done on the\r
-result. If the additional bits are a pointer to an associate structure then\r
-this function would ensure that the memory used to store that associate\r
-structure does not leak. After normalization the following compare would be\r
-valid and repeatable:\r
-\r
-memcmp(pthread_normalize(&t1),pthread_normalize(&t2),sizeof(pthread_t))\r
-\r
-Note 1: such comparisons are intended merely to order and sort pthread_t values\r
-and allow them to index various data structures. They are not intended to reveal\r
-anything about the relationships between threads, like startup order.\r
-\r
-Note 2: the normalized pthread_t is also a valid pthread_t that uniquely\r
-identifies the same thread.\r
-\r
-Advantages:\r
-1) In most existing implementations this function would reduce to a no-op that\r
-emits no additional instructions, i.e after in-lining or optimisation, or if\r
-defined as a macro:\r
-#define pthread_normalise(tptr) (tptr)\r
-\r
-2) This single function allows an application to portably derive\r
-application-level versions of any of the other required functions.\r
-\r
-3) It is a generic function that could enable unanticipated uses.\r
-\r
-Disadvantages:\r
-1) Less efficient than dedicated compare or hash functions for implementations\r
-that include significant extra non-id elements in pthread_t.\r
-\r
-2) Still need to be concerned about padding if copying normalized pthread_t.\r
-See the later section on defining pthread_t to neutralise padding issues.\r
-\r
-Generally a pthread_t may need to be normalized every time it is used,\r
-which could have a significant impact. However, this is a design decision\r
-for the implementor in a competitive environment. An implementation is free\r
-to define a pthread_t in a way that minimises or eliminates padding or\r
-renders this function a no-op.\r
-\r
-Hazards:\r
-1) Pass-by-reference directly modifies 'thread' so the application must\r
-synchronise access or ensure that the pointer refers to a copy. The alternative\r
-of pass-by-value/return-by-value was considered but then this requires two copy\r
-operations, disadvantaging implementations where this function is not a no-op\r
-in terms of speed of execution. This function is intended to be used in high\r
-frequency situations and needs to be efficient, or at least not unnecessarily\r
-inefficient. The alternative also sits awkwardly with functions like memcmp.\r
-\r
-2) [Non-compliant] code that uses relational and equality operators on\r
-arithmetic or pointer style pthread_t types would need to be rewritten, but it\r
-should be rewritten anyway.\r
-\r
-\r
-C implementation of null/compare/hash functions using pthread_normalize():\r
-\r
-/* In pthread.h */\r
-pthread_t* pthread_normalize(pthread_t* thread);\r
-\r
-/* In user code */\r
-/* User-level bitclear function - clear bits in loc corresponding to mask */\r
-void* bitclear (void* loc, void* mask, size_t count);\r
-\r
-typedef unsigned int hash_t;\r
-\r
-/* User-level hash function */\r
-hash_t hash(void* ptr, size_t count);\r
-\r
-/*\r
- * User-level pthr_null function - modifies the origin thread handle.\r
- * The concept of a null pthread_t is highly implementation dependent\r
- * and this design may be far from the mark. For example, in an\r
- * implementation "null" may mean setting a special value inside one\r
- * element of pthread_t to mean "INVALID". However, if that value was zero and\r
- * formed part of the id component then we may get away with this design.\r
- */\r
-pthread_t* pthr_null(pthread_t* tp)\r
-{\r
- /* \r
- * This should have the same effect as memset(tp, 0, sizeof(pthread_t))\r
- * We're just showing that we can do it.\r
- */\r
- void* p = (void*) pthread_normalize(tp);\r
- return (pthread_t*) bitclear(p, p, sizeof(pthread_t));\r
-}\r
-\r
-/*\r
- * Safe user-level pthr_compare function - modifies temporary thread handle copies\r
- */\r
-int pthr_compare_safe(pthread_t thread1, pthread_t thread2)\r
-{\r
- return memcmp(pthread_normalize(&thread1), pthread_normalize(&thread2), sizeof(pthread_t));\r
-}\r
-\r
-/*\r
- * Fast user-level pthr_compare function - modifies origin thread handles\r
- */\r
-int pthr_compare_fast(pthread_t* thread1, pthread_t* thread2)\r
-{\r
- return memcmp(pthread_normalize(&thread1), pthread_normalize(&thread2), sizeof(pthread_t));\r
-}\r
-\r
-/*\r
- * Safe user-level pthr_hash function - modifies temporary thread handle copy\r
- */\r
-hash_t pthr_hash_safe(pthread_t thread)\r
-{\r
- return hash((void *) pthread_normalize(&thread), sizeof(pthread_t));\r
-}\r
-\r
-/*\r
- * Fast user-level pthr_hash function - modifies origin thread handle\r
- */\r
-hash_t pthr_hash_fast(pthread_t thread)\r
-{\r
- return hash((void *) pthread_normalize(&thread), sizeof(pthread_t));\r
-}\r
-\r
-/* User-level bitclear function - modifies the origin array */\r
-void* bitclear(void* loc, void* mask, size_t count)\r
-{\r
- int i;\r
- for (i=0; i < count; i++) {\r
- (unsigned char) *loc++ &= ~((unsigned char) *mask++);\r
- }\r
-}\r
-\r
-/* Donald Knuth hash */\r
-hash_t hash(void* str, size_t count)\r
-{\r
- hash_t hash = (hash_t) count;\r
- unsigned int i = 0;\r
-\r
- for(i = 0; i < len; str++, i++)\r
- {\r
- hash = ((hash << 5) ^ (hash >> 27)) ^ (*str);\r
- }\r
- return hash;\r
-}\r
-\r
-/* Example of advantage point (3) - split a thread handle into its id and non-id values */\r
-pthread_t id = thread, non-id = thread;\r
-bitclear((void*) &non-id, (void*) pthread_normalize(&id), sizeof(pthread_t));\r
-\r
-\r
-A pthread_t type change proposal to neutralise the effects of padding\r
-\r
-Even if pthread_nornalize() is available, padding is still a problem because\r
-the standard only garrantees element-by-element equivalence through\r
-copy operations (assignment and pass-by-value). So padding bit values can\r
-still change randomly after calls to pthread_normalize().\r
-\r
-[I suspect that most compilers take the easy path and always byte-copy anyway,\r
-partly because it becomes too complex to do (e.g. unions that contain sub-aggregates)\r
-but also because programmers can easily design their aggregates to minimise and\r
-often eliminate padding].\r
-\r
-How can we eliminate the problem of padding bytes in structs? Could\r
-defining pthread_t as a union rather than a struct provide a solution?\r
-\r
-In fact, the Linux pthread.h defines most of it's pthread_*_t objects (but not\r
-pthread_t itself) as unions, possibly for this and/or other reasons. We'll\r
-borrow some element naming from there but the ideas themselves are well known\r
-- the __align element used to force alignment of the union comes from K&R's\r
-storage allocator example.\r
-\r
-/* Essentially our current pthread_t renamed */\r
-typedef struct {\r
- struct thread_state_t * __p;\r
- long __x; /* sequence counter */\r
-} thread_id_t;\r
-\r
-Ensuring that the last element in the above struct is a long ensures that the\r
-overall struct size is a multiple of sizeof(long), so there should be no trailing\r
-padding in this struct or the union we define below.\r
-(Later we'll see that we can handle internal but not trailing padding.)\r
-\r
-/* New pthread_t */\r
-typedef union {\r
- char __size[sizeof(thread_id_t)]; /* array as the first element */\r
- thread_id_t __tid;\r
- long __align; /* Ensure that the union starts on long boundary */\r
-} pthread_t;\r
-\r
-This guarrantees that, during an assignment or pass-by-value, the compiler copies\r
-every byte in our thread_id_t because the compiler guarrantees that the __size\r
-array, which we have ensured is the equal-largest element in the union, retains\r
-equivalence.\r
-\r
-This means that pthread_t values stored, assigned and passed by value will at least\r
-carry the value of any undefined padding bytes along and therefore ensure that\r
-those values remain consistent. Our comparisons will return consistent results and\r
-our hashes of [zero initialised] pthread_t values will also return consistent\r
-results.\r
-\r
-We have also removed the need for a pthread_null() function; we can initialise\r
-at declaration time or easily create our own const pthread_t to use in assignments\r
-later:\r
-\r
-const pthread_t null_tid = {0}; /* braces are required */\r
-\r
-pthread_t t;\r
-...\r
-t = null_tid;\r
-\r
-\r
-Note that we don't have to explicitly make use of the __size array at all. It's\r
-there just to force the compiler behaviour we want.\r
-\r
-\r
-Partial solutions without a pthread_normalize function\r
-\r
-\r
-An application-level pthread_null and pthread_compare proposal\r
-(and pthread_hash proposal by extention)\r
-\r
-In order to deal with the problem of scalar/aggregate pthread_t type disparity in\r
-portable code I suggest using an old-fashioned union, e.g.:\r
-\r
-Contraints:\r
-- there is no padding, or padding values are preserved through assignment and\r
- pass-by-value (see above);\r
-- there are no extra non-id values in the pthread_t.\r
-\r
-\r
-Example 1: A null initialiser for pthread_t variables...\r
-\r
-typedef union {\r
- unsigned char b[sizeof(pthread_t)];\r
- pthread_t t;\r
-} init_t;\r
-\r
-const init_t initial = {0};\r
-\r
-pthread_t tid = initial.t; /* init tid to all zeroes */\r
-\r
-\r
-Example 2: A comparison function for pthread_t values\r
-\r
-typedef union {\r
- unsigned char b[sizeof(pthread_t)];\r
- pthread_t t;\r
-} pthcmp_t;\r
-\r
-int pthcmp(pthread_t left, pthread_t right)\r
-{\r
- /*\r
- * Compare two pthread handles in a way that imposes a repeatable but arbitrary\r
- * ordering on them.\r
- * I.e. given the same set of pthread_t handles the ordering should be the same\r
- * each time but the order has no particular meaning other than that. E.g.\r
- * the ordering does not imply the thread start sequence, or any other\r
- * relationship between threads.\r
- *\r
- * Return values are:\r
- * 1 : left is greater than right\r
- * 0 : left is equal to right\r
- * -1 : left is less than right\r
- */\r
- int i;\r
- pthcmp_t L, R;\r
- L.t = left;\r
- R.t = right;\r
- for (i = 0; i < sizeof(pthread_t); i++)\r
- {\r
- if (L.b[i] > R.b[i])\r
- return 1;\r
- else if (L.b[i] < R.b[i])\r
- return -1;\r
- }\r
- return 0;\r
-}\r
-\r
-It has been pointed out that the C99 standard allows for the possibility that\r
-integer types also may include padding bits, which could invalidate the above\r
-method. This addition to C99 was specifically included after it was pointed\r
-out that there was one, presumably not particularly well known, architecture\r
-that included a padding bit in it's 32 bit integer type. See section 6.2.6.2\r
-of both the standard and the rationale, specifically the paragraph starting at\r
-line 16 on page 43 of the rationale.\r
-\r
-\r
-An aside\r
-\r
-Certain compilers, e.g. gcc and one of the IBM compilers, include a feature\r
-extention: provided the union contains a member of the same type as the\r
-object then the object may be cast to the union itself.\r
-\r
-We could use this feature to speed up the pthrcmp() function from example 2\r
-above by casting rather than assigning the pthread_t arguments to the union, e.g.:\r
-\r
-int pthcmp(pthread_t left, pthread_t right)\r
-{\r
- /*\r
- * Compare two pthread handles in a way that imposes a repeatable but arbitrary\r
- * ordering on them.\r
- * I.e. given the same set of pthread_t handles the ordering should be the same\r
- * each time but the order has no particular meaning other than that. E.g.\r
- * the ordering does not imply the thread start sequence, or any other\r
- * relationship between threads.\r
- *\r
- * Return values are:\r
- * 1 : left is greater than right\r
- * 0 : left is equal to right\r
- * -1 : left is less than right\r
- */\r
- int i;\r
- for (i = 0; i < sizeof(pthread_t); i++)\r
- {\r
- if (((pthcmp_t)left).b[i] > ((pthcmp_t)right).b[i])\r
- return 1;\r
- else if (((pthcmp_t)left).b[i] < ((pthcmp_t)right).b[i])\r
- return -1;\r
- }\r
- return 0;\r
-}\r
-\r
-\r
-Result thus far\r
-\r
-We can't remove undefined bits if they are there in pthread_t already, but we have\r
-attempted to render them inert for comparison and hashing functions by making them\r
-consistent through assignment, copy and pass-by-value.\r
-\r
-Note: Hashing pthread_t values requires that all pthread_t variables be initialised\r
-to the same value (usually all zeros) before being assigned a proper thread ID, i.e.\r
-to ensure that any padding bits are zero, or at least the same value for all\r
-pthread_t. Since all pthread_t values are generated by the library in the first\r
-instance this need not be an application-level operation.\r
-\r
-\r
-Conclusion\r
-\r
-I've attempted to resolve the multiple issues of type opacity and the possible\r
-presence of undefined bits and bytes in pthread_t values, which prevent\r
-applications from comparing or hashing pthread handles.\r
-\r
-Two complimentary partial solutions have been proposed, one an application-level\r
-scheme to handle both scalar and aggregate pthread_t types equally, plus a\r
-definition of pthread_t itself that neutralises padding bits and bytes by\r
-coercing semantics out of the compiler to eliminate variations in the values of\r
-padding bits.\r
-\r
-I have not provided any solution to the problem of handling extra values embedded\r
-in pthread_t, e.g. debugging or trap information that an implementation is entitled\r
-to include. Therefore none of this replaces the portability and flexibility of API\r
-functions but what functions are needed? The threads standard is unlikely to\r
-include that can be implemented by a combination of existing features and more\r
-generic functions (several references in the threads rationale suggest this.\r
-Therefore I propose that the following function could replace the several functions\r
-that have been suggested in conversations:\r
-\r
-pthread_t * pthread_normalize(pthread_t * handle);\r
-\r
-For most existing pthreads implementations this function, or macro, would reduce to\r
-a no-op with zero call overhead.\r
+++ /dev/null
-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.
+++ /dev/null
-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.
+++ /dev/null
- Things that aren't done yet
- ---------------------------
-
-1. Implement PTHREAD_PROCESS_SHARED for semaphores, mutexes,
- condition variables, read/write locks, barriers.
-
-
+++ /dev/null
-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 <stdio.h>, <errno.h> 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 <semaphore.h> 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 <errno.h>).
-
-
--- eof
+++ /dev/null
-/*
- * 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"
+++ /dev/null
-/*
- * 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 */
+++ /dev/null
-/*
- * 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"
+++ /dev/null
-; 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
+++ /dev/null
-/*
- * 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"
+++ /dev/null
-/*
- * cleanup.c
- *
- * Description:
- * This translation unit implements routines associated
- * with cleaning up 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"
-
-
-/*
- * 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)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * This function pops the most recently pushed cleanup
- * handler. If execute is nonzero, then the cleanup handler
- * is executed if non-null.
- *
- * PARAMETERS
- * execute
- * if nonzero, execute the cleanup handler
- *
- *
- * DESCRIPTION
- * This function pops the most recently pushed cleanup
- * handler. If execute is nonzero, then the cleanup handler
- * is executed if non-null.
- * NOTE: specify 'execute' as nonzero to avoid duplication
- * of common cleanup code.
- *
- * RESULTS
- * N/A
- *
- * ------------------------------------------------------
- */
-{
- ptw32_cleanup_t *cleanup;
-
- cleanup = (ptw32_cleanup_t *) pthread_getspecific (ptw32_cleanupKey);
-
- if (cleanup != NULL)
- {
- if (execute && (cleanup->routine != NULL))
- {
-
- (*cleanup->routine) (cleanup->arg);
-
- }
-
- pthread_setspecific (ptw32_cleanupKey, (void *) cleanup->prev);
-
- }
-
- return (cleanup);
-
-} /* ptw32_pop_cleanup */
-
-
-void
-ptw32_push_cleanup (ptw32_cleanup_t * cleanup,
- ptw32_cleanup_callback_t routine, void *arg)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * This function pushes a new cleanup handler onto the thread's stack
- * of cleanup handlers. Each cleanup handler pushed onto the stack is
- * popped and invoked with the argument 'arg' when
- * a) the thread exits by calling 'pthread_exit',
- * b) when the thread acts on a cancellation request,
- * c) or when the thread calls pthread_cleanup_pop with a nonzero
- * 'execute' argument
- *
- * PARAMETERS
- * cleanup
- * a pointer to an instance of pthread_cleanup_t,
- *
- * routine
- * pointer to a cleanup handler,
- *
- * arg
- * parameter to be passed to the cleanup handler
- *
- *
- * DESCRIPTION
- * This function pushes a new cleanup handler onto the thread's stack
- * of cleanup handlers. Each cleanup handler pushed onto the stack is
- * popped and invoked with the argument 'arg' when
- * a) the thread exits by calling 'pthread_exit',
- * 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
- * in the same lexical scope.
- *
- * RESULTS
- * pthread_cleanup_t *
- * pointer to the previous cleanup
- *
- * ------------------------------------------------------
- */
-{
- cleanup->routine = routine;
- cleanup->arg = arg;
-
- cleanup->prev = (ptw32_cleanup_t *) pthread_getspecific (ptw32_cleanupKey);
-
- pthread_setspecific (ptw32_cleanupKey, (void *) cleanup);
-
-} /* ptw32_push_cleanup */
+++ /dev/null
-/*
- * 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"
+++ /dev/null
-/* 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
-
-/* Do we know about the C type sigset_t? */
-#undef HAVE_SIGSET_T
-
-/* Define if you have the <signal.h> header file. */
-#undef HAVE_SIGNAL_H
-
-/* Define if you have the Borland TASM32 or compatible assembler. */
-#undef HAVE_TASM32
-
-/* Define if you don't have Win32 DuplicateHandle. (eg. WinCE) */
-#undef NEED_DUPLICATEHANDLE
-
-/* Define if you don't have Win32 _beginthreadex. (eg. WinCE) */
-#undef NEED_CREATETHREAD
-
-/* Define if you don't have Win32 errno. (eg. WinCE) */
-#undef NEED_ERRNO
-
-/* 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
-
-/* Define if you need to convert string parameters to unicode. (eg. WinCE) */
-#undef NEED_UNICODE_CONSTS
-
-/* Define if your C (not C++) compiler supports "inline" functions. */
-#undef HAVE_C_INLINE
-
-/* 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
- * error from __sync_lock* then consider upgrading your gcc.
- */
-#undef HAVE_GCC_ATOMIC_BUILTINS
-
-/* Define if you have the timespec struct */
-#undef HAVE_STRUCT_TIMESPEC
-
-/* Define if you don't have the GetProcessAffinityMask() */
-#undef NEED_PROCESS_AFFINITY_MASK
-
-/* Define if your version of Windows TLSGetValue() clears WSALastError
- * and calling SetLastError() isn't enough restore it. You'll also need to
- * link against wsock32.lib (or libwsock32.a for MinGW).
- */
-#undef RETAIN_WSALASTERROR
-
-/*
-# ----------------------------------------------------------------------
-# The library can be built with some alternative behaviour to better
-# facilitate development of applications on Win32 that will be ported
-# to other POSIX systems.
-#
-# Nothing described here will make the library non-compliant and strictly
-# compliant applications will not be affected in any way, but
-# 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
-# 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.
-# This provides a very high but finite level of safety for applications
-# that are not meticulous in tracking thread lifecycles e.g. applications
-# that call functions which target detached threads without some form of
-# thread exit synchronisation.
-#
-# Usage:
-# Set to any value in the range: 0 <= value < 2^wordsize.
-# Set to 0 to emulate reusable thread ID behaviour like Linux or *BSD.
-# Set to 1 for unique thread IDs like Solaris (this is the default).
-# Set to some factor of 2^wordsize to emulate smaller word size types
-# (i.e. will wrap sooner). This might be useful to emulate some embedded
-# systems.
-#
-# define PTW32_THREAD_ID_REUSE_INCREMENT 0
-#
-# ----------------------------------------------------------------------
- */
-#undef PTW32_THREAD_ID_REUSE_INCREMENT
-
-
-/*********************************************************************
- * Target specific groups
- *
- * If you find that these are incorrect or incomplete please report it
- * 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
-/* This may not be needed */
-#define RETAIN_WSALASTERROR
-#endif
-
-#if defined(_UWIN)
-#define HAVE_MODE_T
-#define HAVE_STRUCT_TIMESPEC
-#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
-#endif
-
-#if defined(__BORLANDC__)
-#endif
-
-#if defined(__WATCOMC__)
-#endif
-
-#if defined(__DMC__)
-#define HAVE_SIGNAL_H
-#define HAVE_C_INLINE
-#endif
-
-
-
-#endif
+++ /dev/null
-/*
- * context.h
- *
- * Description:
- * POSIX thread macros 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
- */
-
-#ifndef PTW32_CONTEXT_H
-#define PTW32_CONTEXT_H
-
-#undef PTW32_PROGCTR
-
-#if defined(_M_IX86) || (defined(_X86_) && !defined(__amd64__))
-#define PTW32_PROGCTR(Context) ((Context).Eip)
-#endif
-
-#if defined (_M_IA64) || defined(_IA64)
-#define PTW32_PROGCTR(Context) ((Context).StIIP)
-#endif
-
-#if defined(_MIPS_) || defined(MIPS)
-#define PTW32_PROGCTR(Context) ((Context).Fir)
-#endif
-
-#if defined(_ALPHA_)
-#define PTW32_PROGCTR(Context) ((Context).Fir)
-#endif
-
-#if defined(_PPC_)
-#define PTW32_PROGCTR(Context) ((Context).Iar)
-#endif
-
-#if defined(_AMD64_) || defined(__amd64__)
-#define PTW32_PROGCTR(Context) ((Context).Rip)
-#endif
-
-#if defined(_ARM_) || defined(ARM)
-#define PTW32_PROGCTR(Context) ((Context).Pc)
-#endif
-
-#if !defined(PTW32_PROGCTR)
-#error Module contains CPU-specific code; modify and recompile.
-#endif
-
-#endif
+++ /dev/null
-/*
- * create.c
- *
- * Description:
- * This translation unit implements routines associated with spawning a new
- * thread.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-#if ! defined(_UWIN) && ! defined(WINCE)
-#include <process.h>
-#endif
-
-int
-pthread_create (pthread_t * tid,
- const pthread_attr_t * attr,
- void *(*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;
- register pthread_attr_t a;
- HANDLE threadH = 0;
- int result = EAGAIN;
- 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
- * without invoking a memory protection error (segfault).
- * Make sure that the assignment below can't be optimised out by the compiler.
- * This is assured by conditionally assigning *tid again at the end.
- */
- tid->x = 0;
-
- if (attr != NULL)
- {
- a = *attr;
- }
- else
- {
- a = NULL;
- }
-
- if ((thread = ptw32_new ()).p == NULL)
- {
- goto FAIL0;
- }
-
- tp = (ptw32_thread_t *) thread.p;
-
- priority = tp->sched_priority;
-
- if ((parms = (ThreadParms *) malloc (sizeof (*parms))) == NULL)
- {
- goto FAIL0;
- }
-
- parms->tid = thread;
- parms->start = start;
- parms->arg = arg;
-
-#if defined(HAVE_SIGSET_T)
-
- /*
- * Threads inherit their initial sigmask from their creator thread.
- */
- self = pthread_self();
- tp->sigmask = ((ptw32_thread_t *)self.p)->sigmask;
-
-#endif /* HAVE_SIGSET_T */
-
-
- if (a != NULL)
- {
- stackSize = (unsigned int)a->stacksize;
- tp->detachState = a->detachstate;
- priority = a->param.sched_priority;
-
-#if (THREAD_PRIORITY_LOWEST > THREAD_PRIORITY_NORMAL)
- /* WinCE */
-#else
- /* Everything else */
-
- /*
- * Thread priority must be set to a valid system level
- * without altering the value set by pthread_attr_setschedparam().
- */
-
- /*
- * PTHREAD_EXPLICIT_SCHED is the default because Win32 threads
- * don't inherit their creator's priority. They are started with
- * THREAD_PRIORITY_NORMAL (win32 value). The result of not supplying
- * an 'attr' arg to pthread_create() is equivalent to defaulting to
- * 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;
- }
-
-#endif
-
- }
- else
- {
- /*
- * Default stackSize
- */
- stackSize = PTHREAD_STACK_MIN;
- }
-
- tp->state = run ? PThreadStateInitial : PThreadStateSuspended;
-
- tp->keys = NULL;
-
- /*
- * Threads must be started in suspended mode and resumed if necessary
- * after _beginthreadex returns us the handle. Otherwise we set up a
- * race condition between the creating and the created threads.
- * Note that we also retain a local copy of the handle for use
- * by us in case thread.p->threadH gets NULLed later but before we've
- * finished with it here.
- */
-
-#if ! (defined (__MINGW64__) || 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));
-
- if (threadH != 0)
- {
- if (a != NULL)
- {
- (void) ptw32_setthreadpriority (thread, SCHED_OTHER, priority);
- }
-
- if (run)
- {
- ResumeThread (threadH);
- }
- }
-
-#else
-
- {
- 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);
-
- tp->threadH =
- threadH =
- (HANDLE) _beginthread (ptw32_threadStart, stackSize, /* default stack size */
- parms);
-
- /*
- * Make the return code match _beginthreadex's.
- */
- if (threadH == (HANDLE) - 1L)
- {
- tp->threadH = threadH = 0;
- }
- 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);
- }
-
- if (a != NULL)
- {
- (void) ptw32_setthreadpriority (thread, SCHED_OTHER, priority);
- }
- }
-
- ptw32_mcs_lock_release (&stateLock);
- }
-#endif
-
- result = (threadH != 0) ? 0 : EAGAIN;
-
- /*
- * Fall Through Intentionally
- */
-
- /*
- * ------------
- * Failure Code
- * ------------
- */
-
-FAIL0:
- if (result != 0)
- {
-
- ptw32_threadDestroy (thread);
- tp = NULL;
-
- if (parms != NULL)
- {
- free (parms);
- }
- }
- else
- {
- *tid = thread;
- }
-
-#if defined(_UWIN)
- if (result == 0)
- pthread_count++;
-#endif
- return (result);
-
-} /* pthread_create */
+++ /dev/null
-/*
- * dll.c
- *
- * Description:
- * This translation unit implements DLL initialisation.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX 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)
-
-#include "pthread.h"
-#include "implement.h"
-
-#if defined(_MSC_VER)
-/*
- * lpvReserved yields an unreferenced formal parameter;
- * ignore it
- */
-#pragma warning( disable : 4100 )
-#endif
-
-#if defined(__cplusplus)
-/*
- * Dear c++: Please don't mangle this name. -thanks
- */
-extern "C"
-#endif /* __cplusplus */
- BOOL WINAPI
-DllMain (HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpvReserved)
-{
- BOOL result = PTW32_TRUE;
-
- switch (fdwReason)
- {
-
- case DLL_PROCESS_ATTACH:
- result = pthread_win32_process_attach_np ();
- break;
-
- case DLL_THREAD_ATTACH:
- /*
- * A thread is being created
- */
- result = pthread_win32_thread_attach_np ();
- break;
-
- case DLL_THREAD_DETACH:
- /*
- * A thread is exiting cleanly
- */
- result = pthread_win32_thread_detach_np ();
- break;
-
- case DLL_PROCESS_DETACH:
- (void) pthread_win32_thread_detach_np ();
- result = pthread_win32_process_detach_np ();
- break;
- }
-
- return (result);
-
-} /* DllMain */
-
-#endif /* PTW32_STATIC_LIB */
+++ /dev/null
-/*
- * errno.c
- *
- * Description:
- * This translation unit implements routines associated with spawning a new
- * thread.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#if defined(NEED_ERRNO)
-
-#include "pthread.h"
-#include "implement.h"
-
-static int reallyBad = ENOMEM;
-
-/*
- * Re-entrant errno.
- *
- * Each thread has it's own errno variable in pthread_t.
- *
- * The benefit of using the pthread_t structure
- * instead of another TSD key is TSD keys are limited
- * on Win32 to 64 per process. Secondly, to implement
- * it properly without using pthread_t you'd need
- * to dynamically allocate an int on starting the thread
- * and store it manually into TLS and then ensure that you free
- * it on thread termination. We get all that for free
- * by simply storing the errno on the pthread_t structure.
- *
- * MSVC and Mingw32 already have their own thread-safe errno.
- *
- * #if defined( _REENTRANT ) || defined( _MT )
- * #define errno *_errno()
- *
- * int *_errno( void );
- * #else
- * extern int errno;
- * #endif
- *
- */
-
-int *
-_errno (void)
-{
- pthread_t self;
- int *result;
-
- if ((self = pthread_self ()).p == NULL)
- {
- /*
- * Yikes! unable to allocate a thread!
- * Throw an exception? return an error?
- */
- result = &reallyBad;
- }
- else
- {
- result = (int *)(&self.p->exitStatus);
- }
-
- return (result);
-
-} /* _errno */
-
-#endif /* (NEED_ERRNO) */
+++ /dev/null
-/*
- * 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 <process.h>
-#endif
-
-#include "pthread_exit.c"
+++ /dev/null
-/*
- * 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"
+++ /dev/null
-/*
- * global.c
- *
- * Description:
- * This translation unit instantiates data associated with the implementation
- * as a whole.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-
-int 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;
-
-/* What features have been auto-detected */
-int ptw32_features = 0;
-
-/*
- * Global [process wide] thread sequence Number
- */
-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;
-
-/*
- * Global lock for managing pthread_t struct reuse.
- */
-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;
-
-/*
- * Global lock for testing internal state of PTHREAD_COND_INITIALIZER
- * created condition variables.
- */
-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;
-
-/*
- * Global lock for testing internal state of PTHREAD_SPINLOCK_INITIALIZER
- * created spin locks.
- */
-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;
-
-#if defined(_UWIN)
-/*
- * Keep a count of the number of threads.
- */
-int pthread_count = 0;
-#endif
+++ /dev/null
-/*
- * implement.h
- *
- * Definitions that don't need to be public.
- *
- * Keeps all the internals out of pthread.h
- *
- * --------------------------------------------------------------------------
- *
- * 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
- *
- * The 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(_IMPLEMENT_H)
-#define _IMPLEMENT_H
-
-#if !defined(_WIN32_WINNT)
-#define _WIN32_WINNT 0x0400
-#endif
-
-#include <windows.h>
-
-/*
- * In case windows.h doesn't define it (e.g. WinCE perhaps)
- */
-#if defined(WINCE)
-typedef VOID (APIENTRY *PAPCFUNC)(DWORD dwParam);
-#endif
-
-/*
- * note: ETIMEDOUT is correctly defined in winsock.h
- */
-#include <winsock.h>
-
-/*
- * In case ETIMEDOUT hasn't been defined above somehow.
- */
-#if !defined(ETIMEDOUT)
-# define ETIMEDOUT 10060 /* This is the value in winsock.h. */
-#endif
-
-#if !defined(malloc)
-#include <malloc.h>
-#endif
-
-#if defined(__CLEANUP_C)
-# include <setjmp.h>
-#endif
-
-#if !defined(INT_MAX)
-#include <limits.h>
-#endif
-
-/* use local include files during development */
-#include "semaphore.h"
-#include "sched.h"
-
-#if defined(HAVE_C_INLINE) || defined(__cplusplus)
-#define INLINE inline
-#else
-#define INLINE
-#endif
-
-#if defined(_MSC_VER) && _MSC_VER < 1300
-/*
- * MSVC 6 does not use the "volatile" qualifier
- */
-#define PTW32_INTERLOCKED_VOLATILE
-#else
-#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 <stdint.h>
-#elif defined(__BORLANDC__)
-# define int64_t ULONGLONG
-#else
-# define int64_t _int64
-# if defined(_MSC_VER) && _MSC_VER < 1300
- typedef long intptr_t;
-# endif
-#endif
-
-typedef enum
-{
- /*
- * This enumeration represents the state of the thread;
- * The thread is still "alive" if the numeric value of the
- * state is greater or equal "PThreadStateRunning".
- */
- PThreadStateInitial = 0, /* Thread not running */
- PThreadStateRunning, /* Thread alive & kicking */
- PThreadStateSuspended, /* Thread alive but suspended */
- PThreadStateCancelPending, /* Thread alive but */
- /* has cancelation 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 */
- /* 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;
-
-
-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 */
- 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 */
- HANDLE cancelEvent;
- void *exitStatus;
- void *parms;
- void *keys;
- void *nextAssoc;
-#if defined(__CLEANUP_C)
- jmp_buf start_mark; /* Jump buffer follows void* so should be aligned */
-#endif /* __CLEANUP_C */
-#if defined(HAVE_SIGSET_T)
- sigset_t sigmask;
-#endif /* HAVE_SIGSET_T */
- ptw32_mcs_lock_t
- robustMxListLock; /* robustMxList lock */
- ptw32_robust_node_t*
- robustMxList; /* List of currenty held robust mutexes */
- int ptErrno;
- int detachState;
- int sched_priority; /* As set, not as currently is */
- int cancelState;
- int cancelType;
- int implicit:1;
- DWORD thread; /* Win32 thread ID */
-#if defined(_UWIN)
- DWORD dummy[5];
-#endif
- size_t align; /* Force alignment if this struct is packed */
-};
-
-
-/*
- * Special value to mark attribute objects as valid.
- */
-#define PTW32_ATTR_VALID ((unsigned long) 0xC4C0FFEE)
-
-struct pthread_attr_t_
-{
- unsigned long valid;
- void *stackaddr;
- size_t stacksize;
- int detachstate;
- struct sched_param param;
- int inheritsched;
- int contentionscope;
-#if defined(HAVE_SIGSET_T)
- sigset_t sigmask;
-#endif /* HAVE_SIGSET_T */
-};
-
-
-/*
- * ====================
- * ====================
- * Semaphores, Mutexes and Condition Variables
- * ====================
- * ====================
- */
-
-struct sem_t_
-{
- int value;
- pthread_mutex_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
-
-struct pthread_mutex_t_
-{
- LONG lock_idx; /* Provides exclusive access to mutex state
- via the Interlocked* mechanism.
- 0: unlocked/free.
- 1: locked - no other waiters.
- -1: locked - with possible other waiters.
- */
- int recursive_count; /* Number of unlocks a thread needs to perform
- before the lock is released (recursive
- mutexes only). */
- int kind; /* Mutex type. */
- pthread_t ownerThread;
- HANDLE event; /* Mutex release notification to waiting
- threads. */
- ptw32_robust_node_t*
- robustNode; /* Extra state for robust mutexes */
-};
-
-enum ptw32_robust_state_t_
-{
- PTW32_ROBUST_CONSISTENT,
- PTW32_ROBUST_INCONSISTENT,
- PTW32_ROBUST_NOTRECOVERABLE
-};
-
-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_
-{
- pthread_mutex_t mx;
- ptw32_robust_state_t stateInconsistent;
- ptw32_robust_node_t* prev;
- ptw32_robust_node_t* next;
-};
-
-struct pthread_mutexattr_t_
-{
- int pshared;
- int kind;
- int robustness;
-};
-
-/*
- * 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.
- * If the number of cpus is greater than 1 then "interlock"
- * 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.
- *
- * "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)
-
-struct pthread_spinlock_t_
-{
- long interlock; /* Locking element for multi-cpus. */
- union
- {
- int cpus; /* No. of cpus if multi cpus, or */
- pthread_mutex_t mutex; /* mutex if single cpu. */
- } u;
-};
-
-/*
- * MCS lock queue node - see ptw32_MCS_lock.c
- */
-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 */
- HANDLE readyFlag; /* set after lock is released by
- predecessor */
- HANDLE nextFlag; /* set after 'next' ptr is set by
- successor */
-};
-
-
-struct pthread_barrier_t_
-{
- unsigned int nCurrentBarrierHeight;
- unsigned int nInitialBarrierHeight;
- int pshared;
- sem_t semBarrierBreeched;
- ptw32_mcs_lock_t lock;
- ptw32_mcs_local_node_t proxynode;
-};
-
-struct pthread_barrierattr_t_
-{
- int pshared;
-};
-
-struct pthread_key_t_
-{
- DWORD key;
- void (*destructor) (void *);
- ptw32_mcs_lock_t keyLock;
- void *threads;
-};
-
-
-typedef struct ThreadParms ThreadParms;
-
-struct ThreadParms
-{
- pthread_t tid;
- void *(*start) (void *);
- void *arg;
-};
-
-
-struct pthread_cond_t_
-{
- long nWaitersBlocked; /* Number of threads blocked */
- long nWaitersGone; /* Number of threads timed out */
- long nWaitersToUnblock; /* Number of threads to unblock */
- sem_t semBlockQueue; /* Queue up threads waiting for the */
- /* condition to become signalled */
- sem_t semBlockLock; /* Semaphore that guards access to */
- /* | waiters blocked count/block queue */
- /* +-> Mandatory Sync.LEVEL-1 */
- pthread_mutex_t mtxUnblockLock; /* Mutex that guards access to */
- /* | waiters (to)unblock(ed) counts */
- /* +-> Optional* Sync.LEVEL-2 */
- pthread_cond_t next; /* Doubly linked list */
- pthread_cond_t prev;
-};
-
-
-struct pthread_condattr_t_
-{
- int pshared;
-};
-
-#define PTW32_RWLOCK_MAGIC 0xfacade2
-
-struct pthread_rwlock_t_
-{
- pthread_mutex_t mtxExclusiveAccess;
- pthread_mutex_t mtxSharedAccessCompleted;
- pthread_cond_t cndSharedAccessCompleted;
- int nSharedAccessCount;
- int nExclusiveAccessCount;
- int nCompletedSharedAccessCount;
- int nMagic;
-};
-
-struct pthread_rwlockattr_t_
-{
- int pshared;
-};
-
-typedef struct ThreadKeyAssoc ThreadKeyAssoc;
-
-struct ThreadKeyAssoc
-{
- /*
- * Purpose:
- * This structure creates an association between a thread and a key.
- * It is used to implement the implicit invocation of a user defined
- * destroy routine for thread specific data registered by a user upon
- * exiting a thread.
- *
- * Graphically, the arrangement is as follows, where:
- *
- * K - Key with destructor
- * (head of chain is key->threads)
- * T - Thread that has called pthread_setspecific(Kn)
- * (head of chain is thread->keys)
- * A - Association. Each association is a node at the
- * intersection of two doubly-linked lists.
- *
- * T1 T2 T3
- * | | |
- * | | |
- * K1 -----+-----A-----A----->
- * | | |
- * | | |
- * K2 -----A-----A-----+----->
- * | | |
- * | | |
- * K3 -----A-----+-----A----->
- * | | |
- * | | |
- * V V V
- *
- * Access to the association is guarded by two locks: the key's
- * general lock (guarding the row) and the thread's general
- * lock (guarding the column). This avoids the need for a
- * dedicated lock for each association, which not only consumes
- * more handles but requires that the lock resources persist
- * until both the key is deleted and the thread has called the
- * destructor. The two-lock arrangement allows those resources
- * to be freed as soon as either thread or key is concluded.
- *
- * To avoid deadlock, whenever both locks are required both the
- * key and thread locks are acquired consistently in the order
- * "key lock then thread lock". An exception to this exists
- * when a thread calls the destructors, however, this is done
- * carefully (but inelegantly) to avoid deadlock.
- *
- * An association is created when a thread first calls
- * pthread_setspecific() on a key that has a specified
- * destructor.
- *
- * An association is destroyed either immediately after the
- * thread calls the key destructor function on thread exit, or
- * when the key is deleted.
- *
- * Attributes:
- * thread
- * reference to the thread that owns the
- * association. This is actually the pointer to the
- * thread struct itself. Since the association is
- * destroyed before the thread exits, this can never
- * point to a different logical thread to the one that
- * created the assoc, i.e. after thread struct reuse.
- *
- * key
- * reference to the key that owns the association.
- *
- * nextKey
- * The pthread_t->keys attribute is the head of a
- * chain of associations that runs through the nextKey
- * link. This chain provides the 1 to many relationship
- * between a pthread_t and all pthread_key_t on which
- * it called pthread_setspecific.
- *
- * prevKey
- * Similarly.
- *
- * nextThread
- * 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
- * PThreads that have called pthread_setspecific for
- * this pthread_key_t.
- *
- * prevThread
- * Similarly.
- *
- * Notes:
- * 1) As soon as either the key or the thread is no longer
- * referencing the association, it can be destroyed. The
- * association will be removed from both chains.
- *
- * 2) Under WIN32, an association is only created by
- * pthread_setspecific if the user provided a
- * destroyRoutine when they created the key.
- *
- *
- */
- ptw32_thread_t * thread;
- pthread_key_t key;
- ThreadKeyAssoc *nextKey;
- ThreadKeyAssoc *nextThread;
- ThreadKeyAssoc *prevKey;
- ThreadKeyAssoc *prevThread;
-};
-
-
-#if defined(__CLEANUP_SEH)
-/*
- * --------------------------------------------------------------
- * MAKE_SOFTWARE_EXCEPTION
- * This macro constructs a software exception code following
- * the same format as the standard Win32 error codes as defined
- * in WINERROR.H
- * Values are 32 bit values laid out as follows:
- *
- * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
- * +---+-+-+-----------------------+-------------------------------+
- * |Sev|C|R| Facility | Code |
- * +---+-+-+-----------------------+-------------------------------+
- *
- * Severity Values:
- */
-#define SE_SUCCESS 0x00
-#define SE_INFORMATION 0x01
-#define SE_WARNING 0x02
-#define SE_ERROR 0x03
-
-#define MAKE_SOFTWARE_EXCEPTION( _severity, _facility, _exception ) \
-( (DWORD) ( ( (_severity) << 30 ) | /* Severity code */ \
- ( 1 << 29 ) | /* MS=0, User=1 */ \
- ( 0 << 28 ) | /* Reserved */ \
- ( (_facility) << 16 ) | /* Facility Code */ \
- ( (_exception) << 0 ) /* Exception Code */ \
- ) )
-
-/*
- * We choose one specific Facility/Error code combination to
- * identify our software exceptions vs. WIN32 exceptions.
- * We store our actual component and error code within
- * the optional information array.
- */
-#define EXCEPTION_PTW32_SERVICES \
- MAKE_SOFTWARE_EXCEPTION( SE_ERROR, \
- PTW32_SERVICES_FACILITY, \
- PTW32_SERVICES_ERROR )
-
-#define PTW32_SERVICES_FACILITY 0xBAD
-#define PTW32_SERVICES_ERROR 0xDEED
-
-#endif /* __CLEANUP_SEH */
-
-/*
- * Services available through EXCEPTION_PTW32_SERVICES
- * and also used [as parameters to ptw32_throw()] as
- * generic exception selectors.
- */
-
-#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))
-
-
-/* Declared in pthread_cancel.c */
-extern DWORD (*ptw32_register_cancelation) (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)
-
-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 unsigned __int64 ptw32_threadSeqNumber;
-
-extern int ptw32_concurrency;
-
-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;
-
-#if defined(_UWIN)
-extern int pthread_count;
-#endif
-
-#if defined(__cplusplus)
-extern "C"
-{
-#endif /* __cplusplus */
-
-/*
- * =====================
- * =====================
- * Forward Declarations
- * =====================
- * =====================
- */
-
- 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_spinlock_check_need_init (pthread_spinlock_t * lock);
-
- int ptw32_robust_mutex_inherit(pthread_mutex_t * mutex);
- void ptw32_robust_mutex_add(pthread_mutex_t* mutex, pthread_t self);
- void ptw32_robust_mutex_remove(pthread_mutex_t* mutex, ptw32_thread_t* otp);
-
- DWORD
- ptw32_RegisterCancelation (PAPCFUNC callback,
- HANDLE threadH, DWORD callback_arg);
-
- int ptw32_processInitialize (void);
-
- void ptw32_processTerminate (void);
-
- void ptw32_threadDestroy (pthread_t tid);
-
- void ptw32_pop_cleanup_all (int execute);
-
- pthread_t ptw32_new (void);
-
- pthread_t ptw32_threadReusePop (void);
-
- void ptw32_threadReusePush (pthread_t thread);
-
- int ptw32_getprocessors (int *count);
-
- int ptw32_setthreadpriority (pthread_t thread, int policy, int priority);
-
- void ptw32_rwlock_cancelwrwait (void *arg);
-
-#if ! (defined (__MINGW64__) || defined(__MINGW32__)) || (defined(__MSVCRT__) && ! defined(__DMC__))
- unsigned __stdcall
-#else
- void
-#endif
- ptw32_threadStart (void *vthreadParms);
-
- void ptw32_callUserDestroyRoutines (pthread_t thread);
-
- int ptw32_tkAssocCreate (ptw32_thread_t * thread, pthread_key_t key);
-
- void ptw32_tkAssocDestroy (ThreadKeyAssoc * assoc);
-
- int ptw32_semwait (sem_t * sem);
-
- DWORD ptw32_relmillisecs (const struct timespec * abstime);
-
- 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);
-
- 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);
-
-#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
-
-/* Declared in misc.c */
-#if defined(NEED_CALLOC)
-#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 */
-
-
-#if defined(_UWIN_)
-# if defined(_MT)
-# if defined(__cplusplus)
-extern "C"
-{
-# endif
- _CRTIMP unsigned long __cdecl _beginthread (void (__cdecl *) (void *),
- unsigned, void *);
- _CRTIMP void __cdecl _endthread (void);
- _CRTIMP unsigned long __cdecl _beginthreadex (void *, unsigned,
- unsigned (__stdcall *) (void *),
- void *, unsigned, unsigned *);
- _CRTIMP void __cdecl _endthreadex (unsigned);
-# if defined(__cplusplus)
-}
-# endif
-# endif
-#else
-# include <process.h>
-# endif
-
-
-/*
- * Use intrinsic versions wherever possible. VC will do this
- * automatically where possible and GCC define these if available:
- * __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1
- * __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2
- * __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
- * __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8
- * __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16
- *
- * The full set of Interlocked intrinsics in GCC are (check versions):
- * type __sync_fetch_and_add (type *ptr, type value, ...)
- * type __sync_fetch_and_sub (type *ptr, type value, ...)
- * type __sync_fetch_and_or (type *ptr, type value, ...)
- * type __sync_fetch_and_and (type *ptr, type value, ...)
- * type __sync_fetch_and_xor (type *ptr, type value, ...)
- * type __sync_fetch_and_nand (type *ptr, type value, ...)
- * type __sync_add_and_fetch (type *ptr, type value, ...)
- * type __sync_sub_and_fetch (type *ptr, type value, ...)
- * type __sync_or_and_fetch (type *ptr, type value, ...)
- * type __sync_and_and_fetch (type *ptr, type value, ...)
- * type __sync_xor_and_fetch (type *ptr, type value, ...)
- * type __sync_nand_and_fetch (type *ptr, type value, ...)
- * bool __sync_bool_compare_and_swap (type *ptr, type oldval type newval, ...)
- * type __sync_val_compare_and_swap (type *ptr, type oldval type newval, ...)
- * __sync_synchronize (...) // Full memory barrier
- * type __sync_lock_test_and_set (type *ptr, type value, ...) // Acquire barrier
- * void __sync_lock_release (type *ptr, ...) // Release barrier
- *
- * These are all overloaded and take 1,2,4,8 byte scalar or pointer types.
- *
- * The above aren't available in Mingw32 as of gcc 4.5.2 so define our own.
- */
-#if defined(__GNUC__)
-# if defined(_WIN64)
-# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_64(location, value, comparand) \
- ({ \
- __typeof (value) _result; \
- __asm__ __volatile__ \
- ( \
- "lock\n\t" \
- "cmpxchgq %2,(%1)" \
- :"=a" (_result) \
- :"r" (location), "r" (value), "a" (comparand) \
- :"memory", "cc"); \
- _result; \
- })
-# define PTW32_INTERLOCKED_EXCHANGE_64(location, value) \
- ({ \
- __typeof (value) _result; \
- __asm__ __volatile__ \
- ( \
- "xchgq %0,(%1)" \
- :"=r" (_result) \
- :"r" (location), "0" (value) \
- :"memory", "cc"); \
- _result; \
- })
-# define PTW32_INTERLOCKED_EXCHANGE_ADD_64(location, value) \
- ({ \
- __typeof (value) _result; \
- __asm__ __volatile__ \
- ( \
- "lock\n\t" \
- "xaddq %0,(%1)" \
- :"=r" (_result) \
- :"r" (location), "0" (value) \
- :"memory", "cc"); \
- _result; \
- })
-# define PTW32_INTERLOCKED_INCREMENT_64(location) \
- ({ \
- PTW32_INTERLOCKED_LONG _temp = 1; \
- __asm__ __volatile__ \
- ( \
- "lock\n\t" \
- "xaddq %0,(%1)" \
- :"+r" (_temp) \
- :"r" (location) \
- :"memory", "cc"); \
- ++_temp; \
- })
-# define PTW32_INTERLOCKED_DECREMENT_64(location) \
- ({ \
- PTW32_INTERLOCKED_LONG _temp = -1; \
- __asm__ __volatile__ \
- ( \
- "lock\n\t" \
- "xaddq %2,(%1)" \
- :"+r" (_temp) \
- :"r" (location) \
- :"memory", "cc"); \
- --_temp; \
- })
-#endif
-# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG(location, value, comparand) \
- ({ \
- __typeof (value) _result; \
- __asm__ __volatile__ \
- ( \
- "lock\n\t" \
- "cmpxchgl %2,(%1)" \
- :"=a" (_result) \
- :"r" (location), "r" (value), "a" (comparand) \
- :"memory", "cc"); \
- _result; \
- })
-# define PTW32_INTERLOCKED_EXCHANGE_LONG(location, value) \
- ({ \
- __typeof (value) _result; \
- __asm__ __volatile__ \
- ( \
- "xchgl %0,(%1)" \
- :"=r" (_result) \
- :"r" (location), "0" (value) \
- :"memory", "cc"); \
- _result; \
- })
-# define PTW32_INTERLOCKED_EXCHANGE_ADD_LONG(location, value) \
- ({ \
- __typeof (value) _result; \
- __asm__ __volatile__ \
- ( \
- "lock\n\t" \
- "xaddl %0,(%1)" \
- :"=r" (_result) \
- :"r" (location), "0" (value) \
- :"memory", "cc"); \
- _result; \
- })
-# define PTW32_INTERLOCKED_INCREMENT_LONG(location) \
- ({ \
- PTW32_INTERLOCKED_LONG _temp = 1; \
- __asm__ __volatile__ \
- ( \
- "lock\n\t" \
- "xaddl %0,(%1)" \
- :"+r" (_temp) \
- :"r" (location) \
- :"memory", "cc"); \
- ++_temp; \
- })
-# define PTW32_INTERLOCKED_DECREMENT_LONG(location) \
- ({ \
- PTW32_INTERLOCKED_LONG _temp = -1; \
- __asm__ __volatile__ \
- ( \
- "lock\n\t" \
- "xaddl %0,(%1)" \
- :"+r" (_temp) \
- :"r" (location) \
- :"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)
-#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
-# endif
-# if defined(_MSC_VER) && _MSC_VER < 1300 && !defined(_WIN64) /* MSVC 6 */
-# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG(location, value, comparand) \
- ((LONG)InterlockedCompareExchange((PVOID *)(location), (PVOID)(value), (PVOID)(comparand)))
-# else
-# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG InterlockedCompareExchange
-# endif
-# define PTW32_INTERLOCKED_EXCHANGE_LONG InterlockedExchange
-# define PTW32_INTERLOCKED_EXCHANGE_ADD_LONG InterlockedExchangeAdd
-# define PTW32_INTERLOCKED_INCREMENT_LONG InterlockedIncrement
-# define PTW32_INTERLOCKED_DECREMENT_LONG InterlockedDecrement
-# if defined(_MSC_VER) && _MSC_VER < 1300 && !defined(_WIN64) /* MSVC 6 */
-# define PTW32_INTERLOCKED_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
-# 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
-#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
-#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
- */
-
-#define _beginthreadex(security, \
- stack_size, \
- start_proc, \
- arg, \
- flags, \
- pid) \
- CreateThread(security, \
- stack_size, \
- (LPTHREAD_START_ROUTINE) start_proc, \
- arg, \
- flags, \
- pid)
-
-#define _endthreadex ExitThread
-
-#endif /* NEED_CREATETHREAD */
-
-
-#endif /* _IMPLEMENT_H */
+++ /dev/null
-/*
- * 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"
+++ /dev/null
-/*
- * 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 <process.h>
-#endif
-#if !defined(NEED_FTIME)
-#include <sys/timeb.h>
-#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"
+++ /dev/null
-/***
-* errno.h - system wide error numbers (set by system calls)
-*
-* Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved.
-*
-* Purpose:
-* This file defines the system-wide error numbers (set by
-* system calls). Conforms to the XENIX standard. Extended
-* for compatibility with Uniforum standard.
-* [System V]
-*
-* [Public]
-*
-****/
-
-#if _MSC_VER > 1000
-#pragma once
-#endif
-
-#if !defined(_INC_ERRNO)
-#define _INC_ERRNO
-
-#if !defined(_WIN32)
-#error ERROR: Only Win32 targets supported!
-#endif
-
-#include <winsock.h>
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-
-
-/* Define _CRTIMP */
-
-#ifndef _CRTIMP
-#if defined(_DLL)
-#define _CRTIMP __declspec(dllimport)
-#else /* ndef _DLL */
-#define _CRTIMP
-#endif /* _DLL */
-#endif /* _CRTIMP */
-
-
-/* Define __cdecl for non-Microsoft compilers */
-
-#if ( !defined(_MSC_VER) && !defined(__cdecl) )
-#define __cdecl
-#endif
-
-/* Define _CRTAPI1 (for compatibility with the NT SDK) */
-
-#if !defined(_CRTAPI1)
-#if _MSC_VER >= 800 && _M_IX86 >= 300
-#define _CRTAPI1 __cdecl
-#else
-#define _CRTAPI1
-#endif
-#endif
-
-#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
-
-/* declare reference to errno */
-
-#if (defined(_MT) || defined(_MD) || defined(_DLL)) && !defined(_MAC)
-PTW32_DLLPORT int * __cdecl _errno(void);
-#define errno (*_errno())
-#else /* ndef _MT && ndef _MD && ndef _DLL */
-_CRTIMP extern int errno;
-#endif /* _MT || _MD || _DLL */
-
-/* Error Codes */
-
-#define EPERM 1
-#define ENOENT 2
-#define ESRCH 3
-#define EINTR 4
-#define EIO 5
-#define ENXIO 6
-#define E2BIG 7
-#define ENOEXEC 8
-#define EBADF 9
-#define ECHILD 10
-#define EAGAIN 11
-#define ENOMEM 12
-#define EACCES 13
-#define EFAULT 14
-#define EBUSY 16
-#define EEXIST 17
-#define EXDEV 18
-#define ENODEV 19
-#define ENOTDIR 20
-#define EISDIR 21
-#define EINVAL 22
-#define ENFILE 23
-#define EMFILE 24
-#define ENOTTY 25
-#define EFBIG 27
-#define ENOSPC 28
-#define ESPIPE 29
-#define EROFS 30
-#define EMLINK 31
-#define EPIPE 32
-#define EDOM 33
-#define ERANGE 34
-#define EDEADLK 36
-
-/* defined differently in winsock.h on WinCE */
-#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
-
-#define EILSEQ 42
-
-/* POSIX 2008 - robust mutexes */
-#define EOWNERDEAD 43
-#define ENOTRECOVERABLE 44
-
-/*
- * Support EDEADLOCK for compatibiity with older MS-C versions.
- */
-#define EDEADLOCK EDEADLK
-
-#if defined(__cplusplus)
-}
-#endif
-
-#endif /* _INC_ERRNO */
+++ /dev/null
-/*
- * 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"
+++ /dev/null
-/*
- * 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"
+++ /dev/null
-{
- 'targets': [
- {
- 'target_name': 'pthread-win32',
- 'type': '<(library)',
- 'include_dirs': [
- '.'
- ],
- 'direct_dependent_settings': {
- 'include_dirs': [
- '.'
- ],
- },
- 'conditions': [
- ['OS=="win"', {
- 'defines': [
- 'HAVE_PTW32_CONFIG_H',
- '__CLEANUP_C'
- ],
- 'sources': [
- 'autostatic.c',
- 'cleanup.c',
- 'create.c',
- 'dll.c',
- 'errno.c',
- 'fork.c',
- 'global.c',
- 'pthread_attr_destroy.c',
- 'pthread_attr_getdetachstate.c',
- 'pthread_attr_getinheritsched.c',
- 'pthread_attr_getschedparam.c',
- 'pthread_attr_getschedpolicy.c',
- 'pthread_attr_getscope.c',
- 'pthread_attr_getstackaddr.c',
- 'pthread_attr_getstacksize.c',
- 'pthread_attr_init.c',
- 'pthread_attr_setdetachstate.c',
- 'pthread_attr_setinheritsched.c',
- 'pthread_attr_setschedparam.c',
- 'pthread_attr_setschedpolicy.c',
- 'pthread_attr_setscope.c',
- 'pthread_attr_setstackaddr.c',
- 'pthread_attr_setstacksize.c',
- 'pthread_barrierattr_destroy.c',
- 'pthread_barrierattr_getpshared.c',
- 'pthread_barrierattr_init.c',
- 'pthread_barrierattr_setpshared.c',
- 'pthread_barrier_destroy.c',
- 'pthread_barrier_init.c',
- 'pthread_barrier_wait.c',
- 'pthread_cancel.c',
- 'pthread_condattr_destroy.c',
- 'pthread_condattr_getpshared.c',
- 'pthread_condattr_init.c',
- 'pthread_condattr_setpshared.c',
- 'pthread_cond_destroy.c',
- 'pthread_cond_init.c',
- 'pthread_cond_signal.c',
- 'pthread_cond_wait.c',
- 'pthread_delay_np.c',
- 'pthread_detach.c',
- 'pthread_equal.c',
- 'pthread_exit.c',
- 'pthread_getconcurrency.c',
- 'pthread_getschedparam.c',
- 'pthread_getspecific.c',
- 'pthread_getunique_np.c',
- 'pthread_getw32threadhandle_np.c',
- 'pthread_join.c',
- 'pthread_key_create.c',
- 'pthread_key_delete.c',
- 'pthread_kill.c',
- 'pthread_mutexattr_destroy.c',
- 'pthread_mutexattr_getkind_np.c',
- 'pthread_mutexattr_getpshared.c',
- 'pthread_mutexattr_getrobust.c',
- 'pthread_mutexattr_gettype.c',
- 'pthread_mutexattr_init.c',
- 'pthread_mutexattr_setkind_np.c',
- 'pthread_mutexattr_setpshared.c',
- 'pthread_mutexattr_setrobust.c',
- 'pthread_mutexattr_settype.c',
- 'pthread_mutex_consistent.c',
- 'pthread_mutex_destroy.c',
- 'pthread_mutex_init.c',
- 'pthread_mutex_lock.c',
- 'pthread_mutex_timedlock.c',
- 'pthread_mutex_trylock.c',
- 'pthread_mutex_unlock.c',
- 'pthread_num_processors_np.c',
- 'pthread_once.c',
- 'pthread_rwlockattr_destroy.c',
- 'pthread_rwlockattr_getpshared.c',
- 'pthread_rwlockattr_init.c',
- 'pthread_rwlockattr_setpshared.c',
- 'pthread_rwlock_destroy.c',
- 'pthread_rwlock_init.c',
- 'pthread_rwlock_rdlock.c',
- 'pthread_rwlock_timedrdlock.c',
- 'pthread_rwlock_timedwrlock.c',
- 'pthread_rwlock_tryrdlock.c',
- 'pthread_rwlock_trywrlock.c',
- 'pthread_rwlock_unlock.c',
- 'pthread_rwlock_wrlock.c',
- 'pthread_self.c',
- 'pthread_setcancelstate.c',
- 'pthread_setcanceltype.c',
- 'pthread_setconcurrency.c',
- 'pthread_setschedparam.c',
- 'pthread_setspecific.c',
- 'pthread_spin_destroy.c',
- 'pthread_spin_init.c',
- 'pthread_spin_lock.c',
- 'pthread_spin_trylock.c',
- 'pthread_spin_unlock.c',
- 'pthread_testcancel.c',
- 'pthread_timechange_handler_np.c',
- 'pthread_win32_attach_detach_np.c',
- 'ptw32_calloc.c',
- 'ptw32_callUserDestroyRoutines.c',
- 'ptw32_cond_check_need_init.c',
- 'ptw32_getprocessors.c',
- 'ptw32_is_attr.c',
- 'ptw32_MCS_lock.c',
- 'ptw32_mutex_check_need_init.c',
- 'ptw32_new.c',
- 'ptw32_processInitialize.c',
- 'ptw32_processTerminate.c',
- 'ptw32_relmillisecs.c',
- 'ptw32_reuse.c',
- 'ptw32_rwlock_cancelwrwait.c',
- 'ptw32_rwlock_check_need_init.c',
- 'ptw32_semwait.c',
- 'ptw32_spinlock_check_need_init.c',
- 'ptw32_threadDestroy.c',
- 'ptw32_threadStart.c',
- 'ptw32_throw.c',
- 'ptw32_timespec.c',
- 'ptw32_tkAssocCreate.c',
- 'ptw32_tkAssocDestroy.c',
- 'sched_getscheduler.c',
- 'sched_get_priority_max.c',
- 'sched_get_priority_min.c',
- 'sched_setscheduler.c',
- 'sched_yield.c',
- 'sem_close.c',
- 'sem_destroy.c',
- 'sem_getvalue.c',
- 'sem_init.c',
- 'sem_open.c',
- 'sem_post.c',
- 'sem_post_multiple.c',
- 'sem_timedwait.c',
- 'sem_trywait.c',
- 'sem_unlink.c',
- 'sem_wait.c',
- 'signal.c',
- 'w32_CancelableWait.c',
- ],
- }]
- ],
- },
- ]
-}
-
+++ /dev/null
-/*
- * pthread.c
- *
- * Description:
- * This translation unit agregates pthreads-win32 translation units.
- * It is used for inline optimisation of the library,
- * maximising for speed at the expense of size.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-/* The following are ordered for inlining */
-
-#include "private.c"
-#include "attr.c"
-#include "barrier.c"
-#include "cancel.c"
-#include "cleanup.c"
-#include "condvar.c"
-#include "create.c"
-#include "dll.c"
-#include "autostatic.c"
-#include "errno.c"
-#include "exit.c"
-#include "fork.c"
-#include "global.c"
-#include "misc.c"
-#include "mutex.c"
-#include "nonportable.c"
-#include "rwlock.c"
-#include "sched.c"
-#include "semaphore.c"
-#include "signal.c"
-#include "spin.c"
-#include "sync.c"
-#include "tsd.c"
+++ /dev/null
-# 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
+++ /dev/null
-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>
-{{{
-}}}
-
-###############################################################################
-
+++ /dev/null
-/* 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
- */
-
-#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,0,0
-#define PTW32_VERSION_STRING "2, 9, 0, 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.
- * The code here and within the library aims to work
- * for all reasonable combinations of environments.
- *
- * The three implementations are:
- *
- * WIN32 SEH
- * C
- * C++
- *
- * Please note that exiting a push/pop block via
- * "return", "exit", "break", or "continue" will
- * lead to different behaviour amongst applications
- * depending upon whether the library was built
- * using SEH, C++, or C. For example, a library built
- * with SEH will call the cleanup routine, while both
- * C++ and C built versions will not.
- */
-
-/*
- * 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
- * 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
-#endif
-
-#if defined( __CLEANUP_SEH ) && ( !defined( _MSC_VER ) && !defined(PTW32_RC_MSC))
-#error ERROR [__FILE__, line __LINE__]: SEH is not supported for this compiler.
-#endif
-
-/*
- * Stop here if we are being included by the resource compiler.
- */
-#if !defined(RC_INVOKED)
-
-#undef PTW32_LEVEL
-
-#if defined(_POSIX_SOURCE)
-#define PTW32_LEVEL 0
-/* Early POSIX */
-#endif
-
-#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309
-#undef PTW32_LEVEL
-#define PTW32_LEVEL 1
-/* Include 1b, 1c and 1d */
-#endif
-
-#if defined(INCLUDE_NP)
-#undef PTW32_LEVEL
-#define PTW32_LEVEL 2
-/* Include Non-Portable extensions */
-#endif
-
-#define PTW32_LEVEL_MAX 3
-
-#if ( defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112 ) || !defined(PTW32_LEVEL)
-#define PTW32_LEVEL PTW32_LEVEL_MAX
-/* Include everything */
-#endif
-
-#if defined(_UWIN)
-# define HAVE_STRUCT_TIMESPEC 1
-# define HAVE_SIGNAL_H 1
-# undef HAVE_PTW32_CONFIG_H
-# pragma comment(lib, "pthread")
-#endif
-
-/*
- * -------------------------------------------------------------
- *
- *
- * Module: pthread.h
- *
- * Purpose:
- * Provides an implementation of PThreads based upon the
- * standard:
- *
- * POSIX 1003.1-2001
- * and
- * The Single Unix Specification version 3
- *
- * (these two are equivalent)
- *
- * in order to enhance code portability between Windows,
- * various commercial Unix implementations, and Linux.
- *
- * See the ANNOUNCE file for a full list of conforming
- * routines and defined constants, and a list of missing
- * routines and constants not defined in this implementation.
- *
- * Authors:
- * There have been many contributors to this library.
- * The initial implementation was contributed by
- * John Bossom, and several others have provided major
- * sections or revisions of parts of the implementation.
- * Often significant effort has been contributed to
- * find and fix important bugs and other problems to
- * improve the reliability of the library, which sometimes
- * is not reflected in the amount of code which changed as
- * result.
- * As much as possible, the contributors are acknowledged
- * in the ChangeLog file in the source code distribution
- * where their changes are noted in detail.
- *
- * Contributors are listed in the CONTRIBUTORS file.
- *
- * As usual, all bouquets go to the contributors, and all
- * brickbats go to the project maintainer.
- *
- * Maintainer:
- * The code base for this project is coordinated and
- * eventually pre-tested, packaged, and made available by
- *
- * Ross Johnson <rpj@callisto.canberra.edu.au>
- *
- * QA Testers:
- * Ultimately, the library is tested in the real world by
- * a host of competent and demanding scientists and
- * engineers who report bugs and/or provide solutions
- * which are then fixed or incorporated into subsequent
- * versions of the library. Each time a bug is fixed, a
- * test case is written to prove the fix and ensure
- * that later changes to the code don't reintroduce the
- * same error. The number of test cases is slowly growing
- * and therefore so is the code reliability.
- *
- * Compliance:
- * See the file ANNOUNCE for the list of implemented
- * and not-implemented routines and defined options.
- * Of course, these are all defined is this file as well.
- *
- * Web site:
- * The source code and other information about this library
- * are available from
- *
- * http://sources.redhat.com/pthreads-win32/
- *
- * -------------------------------------------------------------
- */
-
-/* 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 <windows.h>
-#endif
-
-#if defined(_MSC_VER) && _MSC_VER < 1300 || defined(__DMC__)
-/*
- * VC++6.0 or early compiler's header has no DWORD_PTR type.
- */
-typedef unsigned long DWORD_PTR;
-typedef unsigned long ULONG_PTR;
-#endif
-/*
- * -----------------
- * autoconf switches
- * -----------------
- */
-
-#if defined(HAVE_PTW32_CONFIG_H)
-#include "config.h"
-#endif /* HAVE_PTW32_CONFIG_H */
-
-#if !defined(NEED_FTIME)
-#include <time.h>
-#else /* NEED_FTIME */
-/* use native WIN32 time API */
-#endif /* NEED_FTIME */
-
-#if defined(HAVE_SIGNAL_H)
-#include <signal.h>
-#endif /* HAVE_SIGNAL_H */
-
-#include <limits.h>
-
-/*
- * Boolean values to make us independent of system includes.
- */
-enum {
- 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 <errno.h>
-#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 <sched.h>
-
-/*
- * 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 */
-
-/*
- * -------------------------------------------------------------
- *
- * POSIX 1003.1-2001 Options
- * =========================
- *
- * Options are normally set in <unistd.h>, which is not provided
- * with pthreads-win32.
- *
- * 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).
- *
- * 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_THREAD_ATTR_STACKSIZE (== 200112L)
- * If == 200112L, 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
- * stack. If not supported, the following functions
- * will return ENOSYS, indicating they are not
- * supported:
- * pthread_attr_getstackaddr
- * pthread_attr_setstackaddr
- *
- * _POSIX_THREAD_PRIORITY_SCHEDULING (== -1)
- * If == 200112L, you can use realtime scheduling.
- * This option indicates that the behaviour of some
- * implemented functions conforms to the additional TPS
- * requirements in the standard. E.g. rwlocks favour
- * writers over readers when threads have equal priority.
- *
- * _POSIX_THREAD_PRIO_INHERIT (== -1)
- * If == 200112L, 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
- * Indicates the availability of:
- * pthread_mutex_getprioceiling
- * pthread_mutex_setprioceiling
- * pthread_mutexattr_getprioceiling
- * pthread_mutexattr_getprotocol +
- * pthread_mutexattr_setprioceiling
- * pthread_mutexattr_setprotocol +
- *
- * _POSIX_THREAD_PROCESS_SHARED (== -1)
- * If set, you can create mutexes and condition
- * variables that can be shared with another
- * process.If set, indicates the availability
- * of:
- * pthread_mutexattr_getpshared
- * pthread_mutexattr_setpshared
- * pthread_condattr_getpshared
- * pthread_condattr_setpshared
- *
- * _POSIX_THREAD_SAFE_FUNCTIONS (== 200112L)
- * If == 200112L 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_SPIN_LOCKS (== 200112L)
- * If == 200112L, you can use spin locks
- *
- * _POSIX_BARRIERS (== 200112L)
- * If == 200112L, you can use barriers
- *
- * + These functions provide both 'inherit' and/or
- * 'protect' protocol, based upon these macro
- * settings.
- *
- * -------------------------------------------------------------
- */
-
-/*
- * POSIX Options
- */
-#undef _POSIX_THREADS
-#define _POSIX_THREADS 200809L
-
-#undef _POSIX_READER_WRITER_LOCKS
-#define _POSIX_READER_WRITER_LOCKS 200809L
-
-#undef _POSIX_SPIN_LOCKS
-#define _POSIX_SPIN_LOCKS 200809L
-
-#undef _POSIX_BARRIERS
-#define _POSIX_BARRIERS 200809L
-
-#undef _POSIX_THREAD_SAFE_FUNCTIONS
-#define _POSIX_THREAD_SAFE_FUNCTIONS 200809L
-
-#undef _POSIX_THREAD_ATTR_STACKSIZE
-#define _POSIX_THREAD_ATTR_STACKSIZE 200809L
-
-/*
- * The following options are not supported
- */
-#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_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_PROCESS_SHARED
-#define _POSIX_THREAD_PROCESS_SHARED -1
-
-
-/*
- * POSIX 1003.1-2001 Limits
- * ===========================
- *
- * These limits are normally set in <limits.h>, which is not provided with
- * pthreads-win32.
- *
- * PTHREAD_DESTRUCTOR_ITERATIONS
- * Maximum number of attempts to destroy
- * a thread's thread-specific data on
- * termination (must be at least 4)
- *
- * PTHREAD_KEYS_MAX
- * Maximum number of thread-specific data keys
- * available per process (must be at least 128)
- *
- * PTHREAD_STACK_MIN
- * Minimum supported stack size for a thread
- *
- * PTHREAD_THREADS_MAX
- * Maximum number of threads supported per
- * process (must be at least 64).
- *
- * SEM_NSEMS_MAX
- * The maximum number of semaphores a process can have.
- * (must be at least 256)
- *
- * SEM_VALUE_MAX
- * The maximum value a semaphore can have.
- * (must be at least 32767)
- *
- */
-#undef _POSIX_THREAD_DESTRUCTOR_ITERATIONS
-#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
-
-#undef PTHREAD_DESTRUCTOR_ITERATIONS
-#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
-
-#undef _POSIX_THREAD_KEYS_MAX
-#define _POSIX_THREAD_KEYS_MAX 128
-
-#undef PTHREAD_KEYS_MAX
-#define PTHREAD_KEYS_MAX _POSIX_THREAD_KEYS_MAX
-
-#undef PTHREAD_STACK_MIN
-#define PTHREAD_STACK_MIN 0
-
-#undef _POSIX_THREAD_THREADS_MAX
-#define _POSIX_THREAD_THREADS_MAX 64
-
- /* Arbitrary value */
-#undef PTHREAD_THREADS_MAX
-#define PTHREAD_THREADS_MAX 2019
-
-#undef _POSIX_SEM_NSEMS_MAX
-#define _POSIX_SEM_NSEMS_MAX 256
-
- /* Arbitrary value */
-#undef SEM_NSEMS_MAX
-#define SEM_NSEMS_MAX 1024
-
-#undef _POSIX_SEM_VALUE_MAX
-#define _POSIX_SEM_VALUE_MAX 32767
-
-#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
-#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.
- *
- * We force all calls to cdecl even though this could slow Watcom code down
- * slightly. If you know that the Watcom compiler will be used to build both
- * the DLL and application, then you can probably define this as a null string.
- * Remember that pthread.h (this file) is used for both the DLL and application builds.
- */
-#define PTW32_CDECL __cdecl
-
-#if defined(_UWIN) && PTW32_LEVEL >= PTW32_LEVEL_MAX
-# include <sys/types.h>
-#else
-/*
- * 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;
-
-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;
-typedef struct pthread_mutex_t_ * pthread_mutex_t;
-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;
-typedef struct pthread_barrier_t_ * pthread_barrier_t;
-typedef struct pthread_barrierattr_t_ * pthread_barrierattr_t;
-
-/*
- * ====================
- * ====================
- * POSIX Threads
- * ====================
- * ====================
- */
-
-enum {
-/*
- * pthread_attr_{get,set}detachstate
- */
- PTHREAD_CREATE_JOINABLE = 0, /* Default */
- PTHREAD_CREATE_DETACHED = 1,
-
-/*
- * pthread_attr_{get,set}inheritsched
- */
- PTHREAD_INHERIT_SCHED = 0,
- PTHREAD_EXPLICIT_SCHED = 1, /* Default */
-
-/*
- * pthread_{get,set}scope
- */
- PTHREAD_SCOPE_PROCESS = 0,
- PTHREAD_SCOPE_SYSTEM = 1, /* Default */
-
-/*
- * pthread_setcancelstate paramters
- */
- PTHREAD_CANCEL_ENABLE = 0, /* Default */
- PTHREAD_CANCEL_DISABLE = 1,
-
-/*
- * pthread_setcanceltype parameters
- */
- PTHREAD_CANCEL_ASYNCHRONOUS = 0,
- PTHREAD_CANCEL_DEFERRED = 1, /* Default */
-
-/*
- * pthread_mutexattr_{get,set}pshared
- * pthread_condattr_{get,set}pshared
- */
- PTHREAD_PROCESS_PRIVATE = 0,
- PTHREAD_PROCESS_SHARED = 1,
-
-/*
- * pthread_mutexattr_{get,set}robust
- */
- PTHREAD_MUTEX_STALLED = 0, /* Default */
- PTHREAD_MUTEX_ROBUST = 1,
-
-/*
- * pthread_barrier_wait
- */
- PTHREAD_BARRIER_SERIAL_THREAD = -1
-};
-
-/*
- * ====================
- * ====================
- * Cancelation
- * ====================
- * ====================
- */
-#define PTHREAD_CANCELED ((void *)(size_t) -1)
-
-
-/*
- * ====================
- * ====================
- * Once Key
- * ====================
- * ====================
- */
-#define PTHREAD_ONCE_INIT { PTW32_FALSE, 0, 0, 0}
-
-struct pthread_once_t_
-{
- int done; /* indicates if user function has been executed */
- void * lock;
- int reserved1;
- int reserved2;
-};
-
-
-/*
- * ====================
- * ====================
- * Object initialisers
- * ====================
- * ====================
- */
-#define PTHREAD_MUTEX_INITIALIZER ((pthread_mutex_t)(size_t) -1)
-#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER ((pthread_mutex_t)(size_t) -2)
-#define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER ((pthread_mutex_t)(size_t) -3)
-
-/*
- * Compatibility with LinuxThreads
- */
-#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP PTHREAD_RECURSIVE_MUTEX_INITIALIZER
-#define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP PTHREAD_ERRORCHECK_MUTEX_INITIALIZER
-
-#define PTHREAD_COND_INITIALIZER ((pthread_cond_t)(size_t) -1)
-
-#define PTHREAD_RWLOCK_INITIALIZER ((pthread_rwlock_t)(size_t) -1)
-
-#define PTHREAD_SPINLOCK_INITIALIZER ((pthread_spinlock_t)(size_t) -1)
-
-
-/*
- * Mutex types.
- */
-enum
-{
- /* Compatibility with LinuxThreads */
- PTHREAD_MUTEX_FAST_NP,
- PTHREAD_MUTEX_RECURSIVE_NP,
- PTHREAD_MUTEX_ERRORCHECK_NP,
- PTHREAD_MUTEX_TIMED_NP = PTHREAD_MUTEX_FAST_NP,
- PTHREAD_MUTEX_ADAPTIVE_NP = PTHREAD_MUTEX_FAST_NP,
- /* For compatibility with POSIX */
- PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_FAST_NP,
- PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP,
- PTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP,
- PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL
-};
-
-
-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 *);
-
-#if defined(_MSC_VER)
-#pragma warning( default : 4229 )
-#endif
-
-struct ptw32_cleanup_t
-{
- ptw32_cleanup_callback_t routine;
- void *arg;
- struct ptw32_cleanup_t *prev;
-};
-
-#if defined(__CLEANUP_SEH)
- /*
- * WIN32 SEH version of cancel cleanup.
- */
-
-#define pthread_cleanup_push( _rout, _arg ) \
- { \
- ptw32_cleanup_t _cleanup; \
- \
- _cleanup.routine = (ptw32_cleanup_callback_t)(_rout); \
- _cleanup.arg = (_arg); \
- __try \
- { \
-
-#define pthread_cleanup_pop( _execute ) \
- } \
- __finally \
- { \
- if( _execute || AbnormalTermination()) \
- { \
- (*(_cleanup.routine))( _cleanup.arg ); \
- } \
- } \
- }
-
-#else /* __CLEANUP_SEH */
-
-#if defined(__CLEANUP_C)
-
- /*
- * C implementation of PThreads cancel cleanup
- */
-
-#define pthread_cleanup_push( _rout, _arg ) \
- { \
- ptw32_cleanup_t _cleanup; \
- \
- ptw32_push_cleanup( &_cleanup, (ptw32_cleanup_callback_t) (_rout), (_arg) ); \
-
-#define pthread_cleanup_pop( _execute ) \
- (void) ptw32_pop_cleanup( _execute ); \
- }
-
-#else /* __CLEANUP_C */
-
-#if defined(__CLEANUP_CXX)
-
- /*
- * C++ version of cancel cleanup.
- * - John E. Bossom.
- */
-
- class PThreadCleanup {
- /*
- * PThreadCleanup
- *
- * Purpose
- * This class is a C++ helper class that is
- * used to implement pthread_cleanup_push/
- * pthread_cleanup_pop.
- * The destructor of this class automatically
- * pops the pushed cleanup routine regardless
- * of how the code exits the scope
- * (i.e. such as by an exception)
- */
- ptw32_cleanup_callback_t cleanUpRout;
- void * obj;
- int executeIt;
-
- public:
- PThreadCleanup() :
- cleanUpRout( 0 ),
- obj( 0 ),
- executeIt( 0 )
- /*
- * No cleanup performed
- */
- {
- }
-
- PThreadCleanup(
- ptw32_cleanup_callback_t routine,
- void * arg ) :
- cleanUpRout( routine ),
- obj( arg ),
- executeIt( 1 )
- /*
- * Registers a cleanup routine for 'arg'
- */
- {
- }
-
- ~PThreadCleanup()
- {
- if ( executeIt && ((void *) cleanUpRout != (void *) 0) )
- {
- (void) (*cleanUpRout)( obj );
- }
- }
-
- void execute( int exec )
- {
- executeIt = exec;
- }
- };
-
- /*
- * C++ implementation of PThreads cancel cleanup;
- * This implementation takes advantage of a helper
- * class who's destructor automatically calls the
- * cleanup routine if we exit our scope weirdly
- */
-#define pthread_cleanup_push( _rout, _arg ) \
- { \
- PThreadCleanup cleanup((ptw32_cleanup_callback_t)(_rout), \
- (void *) (_arg) );
-
-#define pthread_cleanup_pop( _execute ) \
- cleanup.execute( _execute ); \
- }
-
-#else
-
-#error ERROR [__FILE__, line __LINE__]: Cleanup type undefined.
-
-#endif /* __CLEANUP_CXX */
-
-#endif /* __CLEANUP_C */
-
-#endif /* __CLEANUP_SEH */
-
-/*
- * ===============
- * ===============
- * Methods
- * ===============
- * ===============
- */
-
-/*
- * PThread Attribute Functions
- */
-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_getdetachstate (const pthread_attr_t * attr,
- int *detachstate);
-
-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,
- size_t * stacksize);
-
-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,
- void *stackaddr);
-
-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,
- struct sched_param *param);
-
-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 *,
- int);
-
-PTW32_DLLPORT int PTW32_CDECL pthread_attr_getschedpolicy (const pthread_attr_t *,
- int *);
-
-PTW32_DLLPORT int PTW32_CDECL pthread_attr_setinheritsched(pthread_attr_t * attr,
- int inheritsched);
-
-PTW32_DLLPORT int PTW32_CDECL pthread_attr_getinheritsched(const pthread_attr_t * attr,
- int * inheritsched);
-
-PTW32_DLLPORT int PTW32_CDECL pthread_attr_setscope (pthread_attr_t *,
- int);
-
-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,
- const pthread_attr_t * attr,
- void *(*start) (void *),
- void *arg);
-
-PTW32_DLLPORT int PTW32_CDECL pthread_detach (pthread_t tid);
-
-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 int PTW32_CDECL pthread_join (pthread_t thread,
- void **value_ptr);
-
-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_setcancelstate (int state,
- int *oldstate);
-
-PTW32_DLLPORT int PTW32_CDECL pthread_setcanceltype (int type,
- int *oldtype);
-
-PTW32_DLLPORT void PTW32_CDECL pthread_testcancel (void);
-
-PTW32_DLLPORT int PTW32_CDECL pthread_once (pthread_once_t * once_control,
- void (*init_routine) (void));
-
-#if PTW32_LEVEL >= PTW32_LEVEL_MAX
-PTW32_DLLPORT ptw32_cleanup_t * PTW32_CDECL ptw32_pop_cleanup (int execute);
-
-PTW32_DLLPORT void PTW32_CDECL ptw32_push_cleanup (ptw32_cleanup_t * cleanup,
- void (*routine) (void *),
- void *arg);
-#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */
-
-/*
- * Thread Specific Data Functions
- */
-PTW32_DLLPORT int PTW32_CDECL pthread_key_create (pthread_key_t * key,
- void (*destructor) (void *));
-
-PTW32_DLLPORT int PTW32_CDECL pthread_key_delete (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);
-
-
-/*
- * Mutex Attribute Functions
- */
-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_getpshared (const pthread_mutexattr_t
- * attr,
- int *pshared);
-
-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_setrobust(
- pthread_mutexattr_t *attr,
- int robust);
-PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_getrobust(
- const pthread_mutexattr_t * attr,
- int * robust);
-
-/*
- * Barrier Attribute Functions
- */
-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_getpshared (const pthread_barrierattr_t
- * attr,
- int *pshared);
-
-PTW32_DLLPORT int PTW32_CDECL pthread_barrierattr_setpshared (pthread_barrierattr_t * attr,
- int pshared);
-
-/*
- * Mutex Functions
- */
-PTW32_DLLPORT int 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_lock (pthread_mutex_t * mutex);
-
-PTW32_DLLPORT int PTW32_CDECL pthread_mutex_timedlock(pthread_mutex_t * mutex,
- const struct timespec *abstime);
-
-PTW32_DLLPORT int PTW32_CDECL pthread_mutex_trylock (pthread_mutex_t * mutex);
-
-PTW32_DLLPORT int PTW32_CDECL pthread_mutex_unlock (pthread_mutex_t * mutex);
-
-PTW32_DLLPORT int PTW32_CDECL pthread_mutex_consistent (pthread_mutex_t * mutex);
-
-/*
- * Spinlock Functions
- */
-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_lock (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);
-
-/*
- * Barrier Functions
- */
-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_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_destroy (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,
- int pshared);
-
-/*
- * Condition Variable Functions
- */
-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_wait (pthread_cond_t * cond,
- pthread_mutex_t * mutex);
-
-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_broadcast (pthread_cond_t * cond);
-
-/*
- * Scheduling
- */
-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,
- int *policy,
- struct sched_param *param);
-
-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,
- const pthread_rwlockattr_t *attr);
-
-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_trywrlock(pthread_rwlock_t *);
-
-PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_rdlock(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_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_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_getpshared (const pthread_rwlockattr_t * attr,
- int *pshared);
-
-PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_setpshared (pthread_rwlockattr_t * attr,
- int pshared);
-
-#if PTW32_LEVEL >= PTW32_LEVEL_MAX - 1
-
-/*
- * Signal Functions. Should be defined in <signal.h> 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);
-
-/*
- * Non-portable functions
- */
-
-/*
- * Compatibility with Linux.
- */
-PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_setkind_np(pthread_mutexattr_t * attr,
- int kind);
-PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_getkind_np(pthread_mutexattr_t * attr,
- int *kind);
-
-/*
- * Possibly supported by other POSIX threads implementations
- */
-PTW32_DLLPORT int 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);
-
-/*
- * 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. */
-};
-
-/*
- * Register a system time change with the library.
- * Causes the library to perform various functions
- * in response to the change. Should be called whenever
- * the application's top level window receives a
- * 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 *);
-
-#endif /*PTW32_LEVEL >= PTW32_LEVEL_MAX - 1 */
-
-#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);
-/*
- * Returns the win32 thread ID for POSIX thread.
- */
-PTW32_DLLPORT DWORD PTW32_CDECL pthread_getw32threadid_np (pthread_t thread);
-
-
-/*
- * Protected Methods
- *
- * This function blocks until the given WIN32 handle
- * is signaled or pthread_cancel had been called.
- * This function allows the caller to hook into the
- * PThreads cancel mechanism. It is implemented using
- *
- * WaitForMultipleObjects
- *
- * on 'waitHandle' and a manually reset WIN32 Event
- * used to implement pthread_cancel. The 'timeout'
- * argument to TimedWait is simply passed to
- * WaitForMultipleObjects.
- */
-PTW32_DLLPORT int PTW32_CDECL pthreadCancelableWait (HANDLE waitHandle);
-PTW32_DLLPORT int PTW32_CDECL pthreadCancelableTimedWait (HANDLE waitHandle,
- DWORD timeout);
-
-#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */
-
-/*
- * Thread-Safe C Runtime Library Mappings.
- */
-#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
-# endif
-#endif
-
-/*
- * Some compiler environments don't define some things.
- */
-#if defined(__BORLANDC__)
-# define _ftime ftime
-# define _timeb timeb
-#endif
-
-#if defined(__cplusplus)
-
-/*
- * Internal exceptions
- */
-class ptw32_exception {};
-class ptw32_exception_cancel : public ptw32_exception {};
-class ptw32_exception_exit : public ptw32_exception {};
-
-#endif
-
-#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);
-
-#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */
-
-#if !defined(PTW32_BUILD)
-
-#if defined(__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() ) \
- ? EXCEPTION_CONTINUE_SEARCH : ( E ) )
-
-#endif /* __CLEANUP_SEH */
-
-#if defined(__CLEANUP_CXX)
-
-/*
- * Redefine the C++ catch keyword to ensure that applications
- * propagate our internal exceptions up to the library's internal handlers.
- */
-#if defined(_MSC_VER)
- /*
- * WARNING: Replace any 'catch( ... )' with 'PtW32CatchAll'
- * if you want Pthread-Win32 cancelation and pthread_exit to work.
- */
-
-#if !defined(PtW32NoCatchWarn)
-
-#pragma message("Specify \"/DPtW32NoCatchWarn\" 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("")
-#pragma message(" #if defined(PtW32CatchAll)")
-#pragma message(" PtW32CatchAll")
-#pragma message(" #else")
-#pragma message(" catch(...)")
-#pragma message(" #endif")
-#pragma message(" {")
-#pragma message(" /* Catchall block processing */")
-#pragma message(" }")
-#pragma message("------------------------------------------------------------------")
-
-#endif
-
-#define PtW32CatchAll \
- catch( ptw32_exception & ) { throw; } \
- catch( ... )
-
-#else /* _MSC_VER */
-
-#define catch( E ) \
- catch( ptw32_exception & ) { throw; } \
- catch( E )
-
-#endif /* _MSC_VER */
-
-#endif /* __CLEANUP_CXX */
-
-#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
-
-#undef PTW32_LEVEL
-#undef PTW32_LEVEL_MAX
-
-#endif /* ! RC_INVOKED */
-
-#endif /* PTHREAD_H */
+++ /dev/null
-/*
- * pthread_attr_destroy.c
- *
- * Description:
- * This translation unit implements operations on thread attribute objects.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-
-int
-pthread_attr_destroy (pthread_attr_t * attr)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * Destroys a thread attributes object.
- *
- * PARAMETERS
- * attr
- * pointer to an instance of pthread_attr_t
- *
- *
- * DESCRIPTION
- * Destroys a thread attributes object.
- *
- * NOTES:
- * 1) Does not affect threads created with 'attr'.
- *
- * RESULTS
- * 0 successfully destroyed attr,
- * EINVAL 'attr' is invalid.
- *
- * ------------------------------------------------------
- */
-{
- if (ptw32_is_attr (attr) != 0)
- {
- return EINVAL;
- }
-
- /*
- * Set the attribute object to a specific invalid value.
- */
- (*attr)->valid = 0;
- free (*attr);
- *attr = NULL;
-
- return 0;
-}
+++ /dev/null
-/*
- * pthread_attr_getdetachstate.c
- *
- * Description:
- * This translation unit implements operations on thread attribute objects.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-
-int
-pthread_attr_getdetachstate (const pthread_attr_t * attr, int *detachstate)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * This function determines whether threads created with
- * 'attr' will run detached.
- *
- * PARAMETERS
- * attr
- * pointer to an instance of pthread_attr_t
- *
- * detachstate
- * pointer to an integer into which is returned one
- * of:
- *
- * PTHREAD_CREATE_JOINABLE
- * Thread ID is valid, must be joined
- *
- * PTHREAD_CREATE_DETACHED
- * Thread ID is invalid, cannot be joined,
- * canceled, or modified
- *
- *
- * DESCRIPTION
- * This function determines whether threads created with
- * 'attr' will run detached.
- *
- * NOTES:
- * 1) You cannot join or cancel detached threads.
- *
- * RESULTS
- * 0 successfully retrieved detach state,
- * EINVAL 'attr' is invalid
- *
- * ------------------------------------------------------
- */
-{
- if (ptw32_is_attr (attr) != 0 || detachstate == NULL)
- {
- return EINVAL;
- }
-
- *detachstate = (*attr)->detachstate;
- return 0;
-}
+++ /dev/null
-/*
- * pthread_attr_getinheritsched.c
- *
- * Description:
- * POSIX thread functions that deal with thread scheduling.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-#include "sched.h"
-
-int
-pthread_attr_getinheritsched (const pthread_attr_t * attr, int *inheritsched)
-{
- if (ptw32_is_attr (attr) != 0 || inheritsched == NULL)
- {
- return EINVAL;
- }
-
- *inheritsched = (*attr)->inheritsched;
- return 0;
-}
+++ /dev/null
-/*
- * pthread_attr_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
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-#include "sched.h"
-
-int
-pthread_attr_getschedparam (const pthread_attr_t * attr,
- struct sched_param *param)
-{
- if (ptw32_is_attr (attr) != 0 || param == NULL)
- {
- return EINVAL;
- }
-
- memcpy (param, &(*attr)->param, sizeof (*param));
- return 0;
-}
+++ /dev/null
-/*
- * pthread_attr_getschedpolicy.c
- *
- * Description:
- * POSIX thread functions that deal with thread scheduling.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-#include "sched.h"
-
-int
-pthread_attr_getschedpolicy (const pthread_attr_t * attr, int *policy)
-{
- if (ptw32_is_attr (attr) != 0 || policy == NULL)
- {
- return EINVAL;
- }
-
- /*
- * Validate the policy arg.
- * Check that a policy constant wasn't passed rather than &policy.
- */
- if (policy <= (int *) SCHED_MAX)
- {
- return EINVAL;
- }
-
- *policy = SCHED_OTHER;
-
- return 0;
-}
+++ /dev/null
-/*
- * pthread_attr_getscope.c
- *
- * Description:
- * This translation unit implements operations on thread attribute objects.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-/* ignore warning "unreferenced formal parameter" */
-#if defined(_MSC_VER)
-#pragma warning( disable : 4100 )
-#endif
-
-int
-pthread_attr_getscope (const pthread_attr_t * attr, int *contentionscope)
-{
-#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING)
- *contentionscope = (*attr)->contentionscope;
- return 0;
-#else
- return ENOSYS;
-#endif
-}
+++ /dev/null
-/*
- * pthread_attr_getstackaddr.c
- *
- * Description:
- * This translation unit implements operations on thread attribute objects.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-/* ignore warning "unreferenced formal parameter" */
-#if defined(_MSC_VER)
-#pragma warning( disable : 4100 )
-#endif
-
-int
-pthread_attr_getstackaddr (const pthread_attr_t * attr, void **stackaddr)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * This function determines the address of the stack
- * on which threads created with 'attr' will run.
- *
- * PARAMETERS
- * attr
- * pointer to an instance of pthread_attr_t
- *
- * stackaddr
- * pointer into which is returned the stack address.
- *
- *
- * DESCRIPTION
- * This function determines the address of the stack
- * on which threads created with 'attr' will run.
- *
- * NOTES:
- * 1) Function supported only if this macro is
- * defined:
- *
- * _POSIX_THREAD_ATTR_STACKADDR
- *
- * 2) Create only one thread for each stack
- * address..
- *
- * RESULTS
- * 0 successfully retreived stack address,
- * EINVAL 'attr' is invalid
- * ENOSYS function not supported
- *
- * ------------------------------------------------------
- */
-{
-#if defined( _POSIX_THREAD_ATTR_STACKADDR )
-
- if (ptw32_is_attr (attr) != 0)
- {
- return EINVAL;
- }
-
- *stackaddr = (*attr)->stackaddr;
- return 0;
-
-#else
-
- return ENOSYS;
-
-#endif /* _POSIX_THREAD_ATTR_STACKADDR */
-}
+++ /dev/null
-/*
- * pthread_attr_getstacksize.c
- *
- * Description:
- * This translation unit implements operations on thread attribute objects.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-/* ignore warning "unreferenced formal parameter" */
-#if defined(_MSC_VER)
-#pragma warning( disable : 4100 )
-#endif
-
-int
-pthread_attr_getstacksize (const pthread_attr_t * attr, size_t * stacksize)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * This function determines the size of the stack on
- * which threads created with 'attr' will run.
- *
- * PARAMETERS
- * attr
- * pointer to an instance of pthread_attr_t
- *
- * stacksize
- * pointer to size_t into which is returned the
- * stack size, in bytes.
- *
- *
- * DESCRIPTION
- * This function determines the size of the stack on
- * which threads created with 'attr' will run.
- *
- * NOTES:
- * 1) Function supported only if this macro is
- * defined:
- *
- * _POSIX_THREAD_ATTR_STACKSIZE
- *
- * 2) Use on newly created attributes object to
- * find the default stack size.
- *
- * RESULTS
- * 0 successfully retrieved stack size,
- * EINVAL 'attr' is invalid
- * ENOSYS function not supported
- *
- * ------------------------------------------------------
- */
-{
-#if defined(_POSIX_THREAD_ATTR_STACKSIZE)
-
- if (ptw32_is_attr (attr) != 0)
- {
- return EINVAL;
- }
-
- /* Everything is okay. */
- *stacksize = (*attr)->stacksize;
- return 0;
-
-#else
-
- return ENOSYS;
-
-#endif /* _POSIX_THREAD_ATTR_STACKSIZE */
-
-}
+++ /dev/null
-/*
- * pthread_attr_init.c
- *
- * Description:
- * This translation unit implements operations on thread attribute objects.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-
-int
-pthread_attr_init (pthread_attr_t * attr)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * Initializes a thread attributes object with default
- * attributes.
- *
- * PARAMETERS
- * attr
- * pointer to an instance of pthread_attr_t
- *
- *
- * DESCRIPTION
- * Initializes a thread attributes object with default
- * attributes.
- *
- * NOTES:
- * 1) Used to define thread attributes
- *
- * RESULTS
- * 0 successfully initialized attr,
- * ENOMEM insufficient memory for attr.
- *
- * ------------------------------------------------------
- */
-{
- pthread_attr_t attr_result;
-
- if (attr == NULL)
- {
- /* This is disallowed. */
- return EINVAL;
- }
-
- attr_result = (pthread_attr_t) malloc (sizeof (*attr_result));
-
- if (attr_result == NULL)
- {
- return ENOMEM;
- }
-
-#if defined(_POSIX_THREAD_ATTR_STACKSIZE)
- /*
- * Default to zero size. Unless changed explicitly this
- * will allow Win32 to set the size to that of the
- * main thread.
- */
- attr_result->stacksize = 0;
-#endif
-
-#if defined(_POSIX_THREAD_ATTR_STACKADDR)
- /* FIXME: Set this to something sensible when we support it. */
- attr_result->stackaddr = NULL;
-#endif
-
- attr_result->detachstate = PTHREAD_CREATE_JOINABLE;
-
-#if defined(HAVE_SIGSET_T)
- memset (&(attr_result->sigmask), 0, sizeof (sigset_t));
-#endif /* HAVE_SIGSET_T */
-
- /*
- * Win32 sets new threads to THREAD_PRIORITY_NORMAL and
- * not to that of the parent thread. We choose to default to
- * this arrangement.
- */
- attr_result->param.sched_priority = THREAD_PRIORITY_NORMAL;
- attr_result->inheritsched = PTHREAD_EXPLICIT_SCHED;
- attr_result->contentionscope = PTHREAD_SCOPE_SYSTEM;
-
- attr_result->valid = PTW32_ATTR_VALID;
-
- *attr = attr_result;
-
- return 0;
-}
+++ /dev/null
-/*
- * pthread_attr_setdetachstate.c
- *
- * Description:
- * This translation unit implements operations on thread attribute objects.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-
-int
-pthread_attr_setdetachstate (pthread_attr_t * attr, int detachstate)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * This function specifies whether threads created with
- * 'attr' will run detached.
- *
- * PARAMETERS
- * attr
- * pointer to an instance of pthread_attr_t
- *
- * detachstate
- * an integer containing one of:
- *
- * PTHREAD_CREATE_JOINABLE
- * Thread ID is valid, must be joined
- *
- * PTHREAD_CREATE_DETACHED
- * Thread ID is invalid, cannot be joined,
- * canceled, or modified
- *
- *
- * DESCRIPTION
- * This function specifies whether threads created with
- * 'attr' will run detached.
- *
- * NOTES:
- * 1) You cannot join or cancel detached threads.
- *
- * RESULTS
- * 0 successfully set detach state,
- * EINVAL 'attr' or 'detachstate' is invalid
- *
- * ------------------------------------------------------
- */
-{
- if (ptw32_is_attr (attr) != 0)
- {
- return EINVAL;
- }
-
- if (detachstate != PTHREAD_CREATE_JOINABLE &&
- detachstate != PTHREAD_CREATE_DETACHED)
- {
- return EINVAL;
- }
-
- (*attr)->detachstate = detachstate;
- return 0;
-}
+++ /dev/null
-/*
- * pthread_attr_setinheritsched.c
- *
- * Description:
- * POSIX thread functions that deal with thread scheduling.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-#include "sched.h"
-
-int
-pthread_attr_setinheritsched (pthread_attr_t * attr, int inheritsched)
-{
- if (ptw32_is_attr (attr) != 0)
- {
- return EINVAL;
- }
-
- if (PTHREAD_INHERIT_SCHED != inheritsched
- && PTHREAD_EXPLICIT_SCHED != inheritsched)
- {
- return EINVAL;
- }
-
- (*attr)->inheritsched = inheritsched;
- return 0;
-}
+++ /dev/null
-/*
- * pthread_attr_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
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-#include "sched.h"
-
-int
-pthread_attr_setschedparam (pthread_attr_t * attr,
- const struct sched_param *param)
-{
- int priority;
-
- if (ptw32_is_attr (attr) != 0 || param == NULL)
- {
- return EINVAL;
- }
-
- priority = param->sched_priority;
-
- /* Validate priority level. */
- if (priority < sched_get_priority_min (SCHED_OTHER) ||
- priority > sched_get_priority_max (SCHED_OTHER))
- {
- return EINVAL;
- }
-
- memcpy (&(*attr)->param, param, sizeof (*param));
- return 0;
-}
+++ /dev/null
-/*
- * pthread_attr_setschedpolicy.c
- *
- * Description:
- * POSIX thread functions that deal with thread scheduling.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-#include "sched.h"
-
-int
-pthread_attr_setschedpolicy (pthread_attr_t * attr, int policy)
-{
- if (ptw32_is_attr (attr) != 0)
- {
- return EINVAL;
- }
-
- if (policy != SCHED_OTHER)
- {
- return ENOTSUP;
- }
-
- return 0;
-}
+++ /dev/null
-/*
- * pthread_attr_setscope.c
- *
- * Description:
- * This translation unit implements operations on thread attribute objects.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-/* ignore warning "unreferenced formal parameter" */
-#if defined(_MSC_VER)
-#pragma warning( disable : 4100 )
-#endif
-
-int
-pthread_attr_setscope (pthread_attr_t * attr, int contentionscope)
-{
-#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING)
- switch (contentionscope)
- {
- case PTHREAD_SCOPE_SYSTEM:
- (*attr)->contentionscope = contentionscope;
- return 0;
- case PTHREAD_SCOPE_PROCESS:
- return ENOTSUP;
- default:
- return EINVAL;
- }
-#else
- return ENOSYS;
-#endif
-}
+++ /dev/null
-/*
- * pthread_attr_setstackaddr.c
- *
- * Description:
- * This translation unit implements operations on thread attribute objects.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-
-int
-pthread_attr_setstackaddr (pthread_attr_t * attr, void *stackaddr)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * Threads created with 'attr' will run on the stack
- * starting at 'stackaddr'.
- * Stack must be at least PTHREAD_STACK_MIN bytes.
- *
- * PARAMETERS
- * attr
- * pointer to an instance of pthread_attr_t
- *
- * stackaddr
- * the address of the stack to use
- *
- *
- * DESCRIPTION
- * Threads created with 'attr' will run on the stack
- * starting at 'stackaddr'.
- * Stack must be at least PTHREAD_STACK_MIN bytes.
- *
- * NOTES:
- * 1) Function supported only if this macro is
- * defined:
- *
- * _POSIX_THREAD_ATTR_STACKADDR
- *
- * 2) Create only one thread for each stack
- * address..
- *
- * 3) Ensure that stackaddr is aligned.
- *
- * RESULTS
- * 0 successfully set stack address,
- * EINVAL 'attr' is invalid
- * ENOSYS function not supported
- *
- * ------------------------------------------------------
- */
-{
-#if defined( _POSIX_THREAD_ATTR_STACKADDR )
-
- if (ptw32_is_attr (attr) != 0)
- {
- return EINVAL;
- }
-
- (*attr)->stackaddr = stackaddr;
- return 0;
-
-#else
-
- return ENOSYS;
-
-#endif /* _POSIX_THREAD_ATTR_STACKADDR */
-}
+++ /dev/null
-/*
- * pthread_attr_setstacksize.c
- *
- * Description:
- * This translation unit implements operations on thread attribute objects.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-
-int
-pthread_attr_setstacksize (pthread_attr_t * attr, size_t stacksize)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * This function specifies the size of the stack on
- * which threads created with 'attr' will run.
- *
- * PARAMETERS
- * attr
- * pointer to an instance of pthread_attr_t
- *
- * stacksize
- * stack size, in bytes.
- *
- *
- * DESCRIPTION
- * This function specifies the size of the stack on
- * which threads created with 'attr' will run.
- *
- * NOTES:
- * 1) Function supported only if this macro is
- * defined:
- *
- * _POSIX_THREAD_ATTR_STACKSIZE
- *
- * 2) Find the default first (using
- * pthread_attr_getstacksize), then increase
- * by multiplying.
- *
- * 3) Only use if thread needs more than the
- * default.
- *
- * RESULTS
- * 0 successfully set stack size,
- * EINVAL 'attr' is invalid or stacksize too
- * small or too big.
- * ENOSYS function not supported
- *
- * ------------------------------------------------------
- */
-{
-#if defined(_POSIX_THREAD_ATTR_STACKSIZE)
-
-#if PTHREAD_STACK_MIN > 0
-
- /* Verify that the stack size is within range. */
- if (stacksize < PTHREAD_STACK_MIN)
- {
- return EINVAL;
- }
-
-#endif
-
- if (ptw32_is_attr (attr) != 0)
- {
- return EINVAL;
- }
-
- /* Everything is okay. */
- (*attr)->stacksize = stacksize;
- return 0;
-
-#else
-
- return ENOSYS;
-
-#endif /* _POSIX_THREAD_ATTR_STACKSIZE */
-
-}
+++ /dev/null
-/*
- * pthread_barrier_destroy.c
- *
- * Description:
- * This translation unit implements barrier primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-int
-pthread_barrier_destroy (pthread_barrier_t * barrier)
-{
- int result = 0;
- pthread_barrier_t b;
- ptw32_mcs_local_node_t node;
-
- if (barrier == NULL || *barrier == (pthread_barrier_t) PTW32_OBJECT_INVALID)
- {
- return EINVAL;
- }
-
- if (0 != ptw32_mcs_lock_try_acquire(&(*barrier)->lock, &node))
- {
- return EBUSY;
- }
-
- b = *barrier;
-
- if (b->nCurrentBarrierHeight < b->nInitialBarrierHeight)
- {
- result = EBUSY;
- }
- else
- {
- if (0 == (result = sem_destroy (&(b->semBarrierBreeched))))
- {
- *barrier = (pthread_barrier_t) PTW32_OBJECT_INVALID;
- /*
- * Release the lock before freeing b.
- *
- * FIXME: There may be successors which, when we release the lock,
- * will be linked into b->lock, which will be corrupted at some
- * point with undefined results for the application. To fix this
- * will require changing pthread_barrier_t from a pointer to
- * 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);
- (void) free (b);
- return 0;
- }
- else
- {
- /*
- * This should not ever be reached.
- * Restore the barrier to working condition before returning.
- */
- (void) sem_init (&(b->semBarrierBreeched), b->pshared, 0);
- }
-
- if (result != 0)
- {
- /*
- * The barrier still exists and is valid
- * in the event of any error above.
- */
- result = EBUSY;
- }
- }
-
- ptw32_mcs_lock_release(&node);
- return (result);
-}
+++ /dev/null
-/*
- * pthread_barrier_init.c
- *
- * Description:
- * This translation unit implements barrier primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-
-int
-pthread_barrier_init (pthread_barrier_t * barrier,
- const pthread_barrierattr_t * attr, unsigned int count)
-{
- pthread_barrier_t b;
-
- if (barrier == NULL || count == 0)
- {
- return EINVAL;
- }
-
- if (NULL != (b = (pthread_barrier_t) calloc (1, sizeof (*b))))
- {
- b->pshared = (attr != NULL && *attr != NULL
- ? (*attr)->pshared : PTHREAD_PROCESS_PRIVATE);
-
- b->nCurrentBarrierHeight = b->nInitialBarrierHeight = count;
- b->lock = 0;
-
- if (0 == sem_init (&(b->semBarrierBreeched), b->pshared, 0))
- {
- *barrier = b;
- return 0;
- }
- (void) free (b);
- }
-
- return ENOMEM;
-}
+++ /dev/null
-/*
- * pthread_barrier_wait.c
- *
- * Description:
- * This translation unit implements barrier primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-
-int
-pthread_barrier_wait (pthread_barrier_t * barrier)
-{
- int result;
- pthread_barrier_t b;
-
- ptw32_mcs_local_node_t node;
-
- if (barrier == NULL || *barrier == (pthread_barrier_t) PTW32_OBJECT_INVALID)
- {
- return EINVAL;
- }
-
- ptw32_mcs_lock_acquire(&(*barrier)->lock, &node);
-
- b = *barrier;
- if (--b->nCurrentBarrierHeight == 0)
- {
- /*
- * We are the last thread to arrive at the barrier before it releases us.
- * 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);
-
- /*
- * Any threads that have not quite entered sem_wait below when the
- * multiple_post has completed will nevertheless continue through
- * the semaphore (barrier).
- */
- result = (b->nInitialBarrierHeight > 1
- ? sem_post_multiple (&(b->semBarrierBreeched),
- b->nInitialBarrierHeight - 1) : 0);
- }
- else
- {
- ptw32_mcs_lock_release(&node);
- /*
- * Use the non-cancelable version of sem_wait().
- *
- * It is possible that all nInitialBarrierHeight-1 threads are
- * at this point when the last thread enters the barrier, resets
- * nCurrentBarrierHeight = nInitialBarrierHeight and leaves.
- * If pthread_barrier_destroy is called at that moment then the
- * barrier will be destroyed along with the semas.
- */
- result = ptw32_semwait (&(b->semBarrierBreeched));
- }
-
- 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);
- if (0 == result)
- {
- result = PTHREAD_BARRIER_SERIAL_THREAD;
- }
- }
-
- return (result);
-}
+++ /dev/null
-/*
- * pthread_barrier_attr_destroy.c
- *
- * Description:
- * This translation unit implements barrier primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-
-int
-pthread_barrierattr_destroy (pthread_barrierattr_t * attr)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * Destroys a barrier attributes object. The object can
- * no longer be used.
- *
- * PARAMETERS
- * attr
- * pointer to an instance of pthread_barrierattr_t
- *
- *
- * DESCRIPTION
- * Destroys a barrier attributes object. The object can
- * no longer be used.
- *
- * NOTES:
- * 1) Does not affect barrieres created using 'attr'
- *
- * RESULTS
- * 0 successfully released attr,
- * EINVAL 'attr' is invalid.
- *
- * ------------------------------------------------------
- */
-{
- int result = 0;
-
- if (attr == NULL || *attr == NULL)
- {
- result = EINVAL;
- }
- else
- {
- pthread_barrierattr_t ba = *attr;
-
- *attr = NULL;
- free (ba);
- }
-
- return (result);
-} /* pthread_barrierattr_destroy */
+++ /dev/null
-/*
- * pthread_barrier_attr_getpshared.c
- *
- * Description:
- * This translation unit implements barrier primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-
-int
-pthread_barrierattr_getpshared (const pthread_barrierattr_t * attr,
- int *pshared)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * Determine whether barriers created with 'attr' can be
- * shared between processes.
- *
- * PARAMETERS
- * attr
- * pointer to an instance of pthread_barrierattr_t
- *
- * pshared
- * will be set to one of:
- *
- * PTHREAD_PROCESS_SHARED
- * May be shared if in shared memory
- *
- * PTHREAD_PROCESS_PRIVATE
- * Cannot be shared.
- *
- *
- * DESCRIPTION
- * Mutexes creatd with 'attr' can be shared between
- * processes if pthread_barrier_t variable is allocated
- * in memory shared by these processes.
- * NOTES:
- * 1) pshared barriers MUST be allocated in shared
- * memory.
- * 2) The following macro is defined if shared barriers
- * are supported:
- * _POSIX_THREAD_PROCESS_SHARED
- *
- * RESULTS
- * 0 successfully retrieved attribute,
- * EINVAL 'attr' is invalid,
- *
- * ------------------------------------------------------
- */
-{
- int result;
-
- if ((attr != NULL && *attr != NULL) && (pshared != NULL))
- {
- *pshared = (*attr)->pshared;
- result = 0;
- }
- else
- {
- result = EINVAL;
- }
-
- return (result);
-} /* pthread_barrierattr_getpshared */
+++ /dev/null
-/*
- * pthread_barrier_attr_init.c
- *
- * Description:
- * This translation unit implements barrier primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-
-int
-pthread_barrierattr_init (pthread_barrierattr_t * attr)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * Initializes a barrier attributes object with default
- * attributes.
- *
- * PARAMETERS
- * attr
- * pointer to an instance of pthread_barrierattr_t
- *
- *
- * DESCRIPTION
- * Initializes a barrier attributes object with default
- * attributes.
- *
- * NOTES:
- * 1) Used to define barrier types
- *
- * RESULTS
- * 0 successfully initialized attr,
- * ENOMEM insufficient memory for attr.
- *
- * ------------------------------------------------------
- */
-{
- pthread_barrierattr_t ba;
- int result = 0;
-
- ba = (pthread_barrierattr_t) calloc (1, sizeof (*ba));
-
- if (ba == NULL)
- {
- result = ENOMEM;
- }
- else
- {
- ba->pshared = PTHREAD_PROCESS_PRIVATE;
- }
-
- *attr = ba;
-
- return (result);
-} /* pthread_barrierattr_init */
+++ /dev/null
-/*
- * pthread_barrier_attr_setpshared.c
- *
- * Description:
- * This translation unit implements barrier primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-
-int
-pthread_barrierattr_setpshared (pthread_barrierattr_t * attr, int pshared)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * Barriers created with 'attr' can be shared between
- * processes if pthread_barrier_t variable is allocated
- * in memory shared by these processes.
- *
- * PARAMETERS
- * attr
- * pointer to an instance of pthread_barrierattr_t
- *
- * pshared
- * must be one of:
- *
- * PTHREAD_PROCESS_SHARED
- * May be shared if in shared memory
- *
- * PTHREAD_PROCESS_PRIVATE
- * Cannot be shared.
- *
- * DESCRIPTION
- * Mutexes creatd with 'attr' can be shared between
- * processes if pthread_barrier_t variable is allocated
- * in memory shared by these processes.
- *
- * NOTES:
- * 1) pshared barriers MUST be allocated in shared
- * memory.
- *
- * 2) The following macro is defined if shared barriers
- * are supported:
- * _POSIX_THREAD_PROCESS_SHARED
- *
- * RESULTS
- * 0 successfully set attribute,
- * EINVAL 'attr' or pshared is invalid,
- * ENOSYS PTHREAD_PROCESS_SHARED not supported,
- *
- * ------------------------------------------------------
- */
-{
- int result;
-
- if ((attr != NULL && *attr != NULL) &&
- ((pshared == PTHREAD_PROCESS_SHARED) ||
- (pshared == PTHREAD_PROCESS_PRIVATE)))
- {
- if (pshared == PTHREAD_PROCESS_SHARED)
- {
-
-#if !defined( _POSIX_THREAD_PROCESS_SHARED )
-
- result = ENOSYS;
- pshared = PTHREAD_PROCESS_PRIVATE;
-
-#else
-
- result = 0;
-
-#endif /* _POSIX_THREAD_PROCESS_SHARED */
-
- }
- else
- {
- result = 0;
- }
-
- (*attr)->pshared = pshared;
- }
- else
- {
- result = EINVAL;
- }
-
- return (result);
-
-} /* pthread_barrierattr_setpshared */
+++ /dev/null
-/*
- * pthread_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 "context.h"
-
-static void
-ptw32_cancel_self (void)
-{
- ptw32_throw (PTW32_EPS_CANCEL);
-
- /* Never reached */
-}
-
-static void CALLBACK
-ptw32_cancel_callback (ULONG_PTR unused)
-{
- ptw32_throw (PTW32_EPS_CANCEL);
-
- /* Never reached */
-}
-
-/*
- * ptw32_RegisterCancelation() -
- * 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)
-{
- CONTEXT context;
-
- context.ContextFlags = CONTEXT_CONTROL;
- GetThreadContext (threadH, &context);
- PTW32_PROGCTR (context) = (DWORD_PTR) ptw32_cancel_self;
- SetThreadContext (threadH, &context);
- return 0;
-}
-
-int
-pthread_cancel (pthread_t thread)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * This function requests cancellation of 'thread'.
- *
- * PARAMETERS
- * thread
- * reference to an instance of pthread_t
- *
- *
- * DESCRIPTION
- * This function requests cancellation of 'thread'.
- * NOTE: cancellation is asynchronous; use pthread_join to
- * wait for termination of 'thread' if necessary.
- *
- * RESULTS
- * 0 successfully requested cancellation,
- * ESRCH no thread found corresponding to 'thread',
- * ENOMEM implicit self thread create failed.
- * ------------------------------------------------------
- */
-{
- int result;
- int cancel_self;
- pthread_t self;
- ptw32_thread_t * tp;
- ptw32_mcs_local_node_t stateLock;
-
- result = pthread_kill (thread, 0);
-
- if (0 != result)
- {
- return result;
- }
-
- if ((self = pthread_self ()).p == NULL)
- {
- return ENOMEM;
- };
-
- /*
- * For self cancellation we need to ensure that a thread can't
- * deadlock itself trying to cancel itself asynchronously
- * (pthread_cancel is required to be an async-cancel
- * safe function).
- */
- cancel_self = pthread_equal (thread, self);
-
- tp = (ptw32_thread_t *) thread.p;
-
- /*
- * Lock for async-cancel safety.
- */
- ptw32_mcs_lock_acquire (&tp->stateLock, &stateLock);
-
- if (tp->cancelType == PTHREAD_CANCEL_ASYNCHRONOUS
- && tp->cancelState == PTHREAD_CANCEL_ENABLE
- && tp->state < PThreadStateCanceling)
- {
- if (cancel_self)
- {
- tp->state = PThreadStateCanceling;
- tp->cancelState = PTHREAD_CANCEL_DISABLE;
-
- ptw32_mcs_lock_release (&stateLock);
- ptw32_throw (PTW32_EPS_CANCEL);
-
- /* Never reached */
- }
- else
- {
- HANDLE threadH = tp->threadH;
-
- SuspendThread (threadH);
-
- if (WaitForSingleObject (threadH, 0) == WAIT_TIMEOUT)
- {
- tp->state = PThreadStateCanceling;
- tp->cancelState = PTHREAD_CANCEL_DISABLE;
- /*
- * 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
- * the threadH arg will be used.
- */
- ptw32_register_cancelation ((PAPCFUNC)ptw32_cancel_callback, threadH, 0);
- ptw32_mcs_lock_release (&stateLock);
- ResumeThread (threadH);
- }
- }
- }
- else
- {
- /*
- * Set for deferred cancellation.
- */
- if (tp->state < PThreadStateCancelPending)
- {
- tp->state = PThreadStateCancelPending;
- if (!SetEvent (tp->cancelEvent))
- {
- result = ESRCH;
- }
- }
- else if (tp->state >= PThreadStateCanceling)
- {
- result = ESRCH;
- }
-
- ptw32_mcs_lock_release (&stateLock);
- }
-
- return (result);
-}
+++ /dev/null
-/*
- * pthread_cond_destroy.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"
-
-int
-pthread_cond_destroy (pthread_cond_t * cond)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * This function destroys a condition variable
- *
- *
- * PARAMETERS
- * cond
- * pointer to an instance of pthread_cond_t
- *
- *
- * DESCRIPTION
- * This function destroys a condition variable.
- *
- * NOTES:
- * 1) A condition variable can be destroyed
- * immediately after all the threads that
- * are blocked on it are awakened. e.g.
- *
- * struct list {
- * pthread_mutex_t lm;
- * ...
- * }
- *
- * struct elt {
- * key k;
- * int busy;
- * pthread_cond_t notbusy;
- * ...
- * }
- *
- *
- * struct elt *
- * list_find(struct list *lp, key k)
- * {
- * struct elt *ep;
- *
- * pthread_mutex_lock(&lp->lm);
- * while ((ep = find_elt(l,k) != NULL) && ep->busy)
- * pthread_cond_wait(&ep->notbusy, &lp->lm);
- * if (ep != NULL)
- * ep->busy = 1;
- * pthread_mutex_unlock(&lp->lm);
- * return(ep);
- * }
- *
- * delete_elt(struct list *lp, struct elt *ep)
- * {
- * pthread_mutex_lock(&lp->lm);
- * assert(ep->busy);
- * ... remove ep from list ...
- * ep->busy = 0;
- * (A) pthread_cond_broadcast(&ep->notbusy);
- * pthread_mutex_unlock(&lp->lm);
- * (B) pthread_cond_destroy(&rp->notbusy);
- * free(ep);
- * }
- *
- * In this example, the condition variable
- * and its list element may be freed (line B)
- * immediately after all threads waiting for
- * it are awakened (line A), since the mutex
- * and the code ensure that no other thread
- * can touch the element to be deleted.
- *
- * RESULTS
- * 0 successfully released condition variable,
- * EINVAL 'cond' is invalid,
- * EBUSY 'cond' is in use,
- *
- * ------------------------------------------------------
- */
-{
- pthread_cond_t cv;
- int result = 0, result1 = 0, result2 = 0;
-
- /*
- * Assuming any race condition here is harmless.
- */
- if (cond == NULL || *cond == NULL)
- {
- return EINVAL;
- }
-
- if (*cond != PTHREAD_COND_INITIALIZER)
- {
- ptw32_mcs_local_node_t node;
- ptw32_mcs_lock_acquire(&ptw32_cond_list_lock, &node);
-
- cv = *cond;
-
- /*
- * Close the gate; this will synchronize this thread with
- * all already signaled waiters to let them retract their
- * waiter status - SEE NOTE 1 ABOVE!!!
- */
- if (ptw32_semwait (&(cv->semBlockLock)) != 0) /* Non-cancelable */
- {
- result = errno;
- }
- else
- {
- /*
- * !TRY! lock mtxUnblockLock; try will detect busy condition
- * and will not cause a deadlock with respect to concurrent
- * signal/broadcast.
- */
- if ((result = pthread_mutex_trylock (&(cv->mtxUnblockLock))) != 0)
- {
- (void) sem_post (&(cv->semBlockLock));
- }
- }
-
- if (result != 0)
- {
- ptw32_mcs_lock_release(&node);
- return result;
- }
-
- /*
- * Check whether cv is still busy (still has waiters)
- */
- if (cv->nWaitersBlocked > cv->nWaitersGone)
- {
- if (sem_post (&(cv->semBlockLock)) != 0)
- {
- result = errno;
- }
- result1 = pthread_mutex_unlock (&(cv->mtxUnblockLock));
- result2 = EBUSY;
- }
- else
- {
- /*
- * Now it is safe to destroy
- */
- *cond = NULL;
-
- if (sem_destroy (&(cv->semBlockLock)) != 0)
- {
- result = errno;
- }
- if (sem_destroy (&(cv->semBlockQueue)) != 0)
- {
- result1 = errno;
- }
- if ((result2 = pthread_mutex_unlock (&(cv->mtxUnblockLock))) == 0)
- {
- result2 = pthread_mutex_destroy (&(cv->mtxUnblockLock));
- }
-
- /* Unlink the CV from the list */
-
- if (ptw32_cond_list_head == cv)
- {
- ptw32_cond_list_head = cv->next;
- }
- else
- {
- cv->prev->next = cv->next;
- }
-
- if (ptw32_cond_list_tail == cv)
- {
- ptw32_cond_list_tail = cv->prev;
- }
- else
- {
- cv->next->prev = cv->prev;
- }
-
- (void) free (cv);
- }
-
- ptw32_mcs_lock_release(&node);
- }
- else
- {
- ptw32_mcs_local_node_t node;
- /*
- * See notes in ptw32_cond_check_need_init() above also.
- */
- ptw32_mcs_lock_acquire(&ptw32_cond_test_init_lock, &node);
-
- /*
- * Check again.
- */
- if (*cond == PTHREAD_COND_INITIALIZER)
- {
- /*
- * 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. That's OK.
- */
- *cond = NULL;
- }
- else
- {
- /*
- * The cv has been initialised while we were waiting
- * so assume it's in use.
- */
- result = EBUSY;
- }
-
- ptw32_mcs_lock_release(&node);
- }
-
- return ((result != 0) ? result : ((result1 != 0) ? result1 : result2));
-}
+++ /dev/null
-/*
- * pthread_cond_init.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"
-
-
-int
-pthread_cond_init (pthread_cond_t * cond, const pthread_condattr_t * attr)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * This function initializes a condition variable.
- *
- * PARAMETERS
- * cond
- * pointer to an instance of pthread_cond_t
- *
- * attr
- * specifies optional creation attributes.
- *
- *
- * DESCRIPTION
- * This function initializes a condition variable.
- *
- * RESULTS
- * 0 successfully created condition variable,
- * EINVAL 'attr' is invalid,
- * EAGAIN insufficient resources (other than
- * memory,
- * ENOMEM insufficient memory,
- * EBUSY 'cond' is already initialized,
- *
- * ------------------------------------------------------
- */
-{
- int result;
- pthread_cond_t cv = NULL;
-
- if (cond == NULL)
- {
- return EINVAL;
- }
-
- if ((attr != NULL && *attr != NULL) &&
- ((*attr)->pshared == PTHREAD_PROCESS_SHARED))
- {
- /*
- * Creating condition variable that can be shared between
- * processes.
- */
- result = ENOSYS;
- goto DONE;
- }
-
- cv = (pthread_cond_t) calloc (1, sizeof (*cv));
-
- if (cv == NULL)
- {
- result = ENOMEM;
- goto DONE;
- }
-
- cv->nWaitersBlocked = 0;
- cv->nWaitersToUnblock = 0;
- cv->nWaitersGone = 0;
-
- if (sem_init (&(cv->semBlockLock), 0, 1) != 0)
- {
- result = errno;
- goto FAIL0;
- }
-
- if (sem_init (&(cv->semBlockQueue), 0, 0) != 0)
- {
- result = errno;
- goto FAIL1;
- }
-
- if ((result = pthread_mutex_init (&(cv->mtxUnblockLock), 0)) != 0)
- {
- goto FAIL2;
- }
-
- result = 0;
-
- goto DONE;
-
- /*
- * -------------
- * Failed...
- * -------------
- */
-FAIL2:
- (void) sem_destroy (&(cv->semBlockQueue));
-
-FAIL1:
- (void) sem_destroy (&(cv->semBlockLock));
-
-FAIL0:
- (void) free (cv);
- cv = NULL;
-
-DONE:
- if (0 == result)
- {
- ptw32_mcs_local_node_t node;
-
- ptw32_mcs_lock_acquire(&ptw32_cond_list_lock, &node);
-
- cv->next = NULL;
- cv->prev = ptw32_cond_list_tail;
-
- if (ptw32_cond_list_tail != NULL)
- {
- ptw32_cond_list_tail->next = cv;
- }
-
- ptw32_cond_list_tail = cv;
-
- if (ptw32_cond_list_head == NULL)
- {
- ptw32_cond_list_head = cv;
- }
-
- ptw32_mcs_lock_release(&node);
- }
-
- *cond = cv;
-
- return result;
-
-} /* pthread_cond_init */
+++ /dev/null
-/*
- * pthread_cond_signal.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
- *
- * -------------------------------------------------------------
- * Algorithm:
- * See the comments at the top of pthread_cond_wait.c.
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-static INLINE int
-ptw32_cond_unblock (pthread_cond_t * cond, int unblockAll)
- /*
- * Notes.
- *
- * Does not use the external mutex for synchronisation,
- * therefore semBlockLock is needed.
- * mtxUnblockLock is for LEVEL-2 synch. LEVEL-2 is the
- * state where the external mutex is not necessarily locked by
- * any thread, ie. between cond_wait unlocking and re-acquiring
- * the lock after having been signaled or a timeout or
- * cancellation.
- *
- * Uses the following CV elements:
- * nWaitersBlocked
- * nWaitersToUnblock
- * nWaitersGone
- * mtxUnblockLock
- * semBlockLock
- * semBlockQueue
- */
-{
- int result;
- pthread_cond_t cv;
- int nSignalsToIssue;
-
- if (cond == NULL || *cond == NULL)
- {
- 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_INITIALIZER)
- {
- return 0;
- }
-
- if ((result = pthread_mutex_lock (&(cv->mtxUnblockLock))) != 0)
- {
- return result;
- }
-
- if (0 != cv->nWaitersToUnblock)
- {
- if (0 == cv->nWaitersBlocked)
- {
- return pthread_mutex_unlock (&(cv->mtxUnblockLock));
- }
- if (unblockAll)
- {
- cv->nWaitersToUnblock += (nSignalsToIssue = cv->nWaitersBlocked);
- cv->nWaitersBlocked = 0;
- }
- else
- {
- nSignalsToIssue = 1;
- cv->nWaitersToUnblock++;
- cv->nWaitersBlocked--;
- }
- }
- else if (cv->nWaitersBlocked > cv->nWaitersGone)
- {
- /* Use the non-cancellable version of sem_wait() */
- if (ptw32_semwait (&(cv->semBlockLock)) != 0)
- {
- result = errno;
- (void) pthread_mutex_unlock (&(cv->mtxUnblockLock));
- return result;
- }
- if (0 != cv->nWaitersGone)
- {
- cv->nWaitersBlocked -= cv->nWaitersGone;
- cv->nWaitersGone = 0;
- }
- if (unblockAll)
- {
- nSignalsToIssue = cv->nWaitersToUnblock = cv->nWaitersBlocked;
- cv->nWaitersBlocked = 0;
- }
- else
- {
- nSignalsToIssue = cv->nWaitersToUnblock = 1;
- cv->nWaitersBlocked--;
- }
- }
- else
- {
- return pthread_mutex_unlock (&(cv->mtxUnblockLock));
- }
-
- if ((result = pthread_mutex_unlock (&(cv->mtxUnblockLock))) == 0)
- {
- if (sem_post_multiple (&(cv->semBlockQueue), nSignalsToIssue) != 0)
- {
- result = errno;
- }
- }
-
- return result;
-
-} /* ptw32_cond_unblock */
-
-int
-pthread_cond_signal (pthread_cond_t * cond)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * This function signals a condition variable, waking
- * one waiting thread.
- * If SCHED_FIFO or SCHED_RR policy threads are waiting
- * the highest priority waiter is awakened; otherwise,
- * an unspecified waiter is awakened.
- *
- * PARAMETERS
- * cond
- * pointer to an instance of pthread_cond_t
- *
- *
- * DESCRIPTION
- * This function signals a condition variable, waking
- * one waiting thread.
- * If SCHED_FIFO or SCHED_RR policy threads are waiting
- * the highest priority waiter is awakened; otherwise,
- * an unspecified waiter is awakened.
- *
- * NOTES:
- *
- * 1) Use when any waiter can respond and only one need
- * respond (all waiters being equal).
- *
- * RESULTS
- * 0 successfully signaled condition,
- * EINVAL 'cond' is invalid,
- *
- * ------------------------------------------------------
- */
-{
- /*
- * 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)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * This function broadcasts the condition variable,
- * waking all current waiters.
- *
- * PARAMETERS
- * cond
- * pointer to an instance of pthread_cond_t
- *
- *
- * DESCRIPTION
- * This function signals a condition variable, waking
- * all waiting threads.
- *
- * NOTES:
- *
- * 1) Use when more than one waiter may respond to
- * predicate change or if any waiting thread may
- * not be able to respond
- *
- * RESULTS
- * 0 successfully signalled condition to all
- * waiting threads,
- * EINVAL 'cond' is invalid
- * ENOSPC a required resource has been exhausted,
- *
- * ------------------------------------------------------
- */
-{
- /*
- * The TRUE unblockAll arg means unblock ALL waiters.
- */
- return (ptw32_cond_unblock (cond, PTW32_TRUE));
-
-} /* pthread_cond_broadcast */
+++ /dev/null
-/*
- * pthread_cond_wait.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
- *
- * -------------------------------------------------------------
- * Algorithm:
- * The algorithm used in this implementation is that developed by
- * Alexander Terekhov in colaboration with Louis Thomas. The bulk
- * of the discussion is recorded in the file README.CV, which contains
- * several generations of both colaborators original algorithms. The final
- * algorithm used here is the one referred to as
- *
- * Algorithm 8a / IMPL_SEM,UNBLOCK_STRATEGY == UNBLOCK_ALL
- *
- * presented below in pseudo-code as it appeared:
- *
- *
- * 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( semBlockQueue,-nWaitersWasGone );
- * while ( nWaitersWasGone-- ) {
- * sem_wait( semBlockQueue ); // 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 9 / IMPL_SEM,UNBLOCK_STRATEGY == UNBLOCK_ALL
- *
- * presented below in pseudo-code; basically 8a...
- * ...BUT W/O "spurious wakes" prevention:
- *
- *
- * 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 ]
- *
- * sem_wait( semBlockLock );
- * ++nWaitersBlocked;
- * sem_post( semBlockLock );
- *
- * unlock( mtxExternal );
- * bTimedOut = sem_wait( semBlockQueue,timeout );
- *
- * lock( mtxUnblockLock );
- * if ( 0 != (nSignalsWasLeft = nWaitersToUnblock) ) {
- * --nWaitersToUnblock;
- * }
- * 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 ) {
- * 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;
- * }
- * -------------------------------------------------------------
- *
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-/*
- * 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_CDECL
-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 nSignalsWasLeft;
- 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).
- */
- if ((result = pthread_mutex_lock (&(cv->mtxUnblockLock))) != 0)
- {
- *resultPtr = result;
- return;
- }
-
- if (0 != (nSignalsWasLeft = cv->nWaitersToUnblock))
- {
- --(cv->nWaitersToUnblock);
- }
- else if (INT_MAX / 2 == ++(cv->nWaitersGone))
- {
- /* Use the non-cancellable version of sem_wait() */
- if (ptw32_semwait (&(cv->semBlockLock)) != 0)
- {
- *resultPtr = errno;
- /*
- * This is a fatal error for this CV,
- * so we deliberately don't unlock
- * cv->mtxUnblockLock before returning.
- */
- return;
- }
- cv->nWaitersBlocked -= cv->nWaitersGone;
- if (sem_post (&(cv->semBlockLock)) != 0)
- {
- *resultPtr = errno;
- /*
- * This is a fatal error for this CV,
- * so we deliberately don't unlock
- * cv->mtxUnblockLock before returning.
- */
- return;
- }
- cv->nWaitersGone = 0;
- }
-
- if ((result = pthread_mutex_unlock (&(cv->mtxUnblockLock))) != 0)
- {
- *resultPtr = result;
- return;
- }
-
- if (1 == nSignalsWasLeft)
- {
- if (sem_post (&(cv->semBlockLock)) != 0)
- {
- *resultPtr = errno;
- return;
- }
- }
-
- /*
- * XSH: Upon successful return, the mutex has been locked and is owned
- * by the calling thread.
- */
- if ((result = pthread_mutex_lock (cleanup_args->mutexPtr)) != 0)
- {
- *resultPtr = result;
- }
-} /* ptw32_cond_wait_cleanup */
-
-static INLINE 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)
- {
- 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_INITIALIZER)
- {
- result = ptw32_cond_check_need_init (cond);
- }
-
- if (result != 0 && result != EBUSY)
- {
- return result;
- }
-
- cv = *cond;
-
- /* Thread can be cancelled in sem_wait() but this is OK */
- if (sem_wait (&(cv->semBlockLock)) != 0)
- {
- return errno;
- }
-
- ++(cv->nWaitersBlocked);
-
- if (sem_post (&(cv->semBlockLock)) != 0)
- {
- return errno;
- }
-
- /*
- * Setup this waiter cleanup handler
- */
- cleanup_args.mutexPtr = mutex;
- cleanup_args.cv = cv;
- cleanup_args.resultPtr = &result;
-
-#if defined(_MSC_VER) && _MSC_VER < 1400
-#pragma inline_depth(0)
-#endif
- pthread_cleanup_push (ptw32_cond_wait_cleanup, (void *) &cleanup_args);
-
- /*
- * Now we can release 'mutex' and...
- */
- if ((result = pthread_mutex_unlock (mutex)) == 0)
- {
-
- /*
- * ...wait to be awakened by
- * pthread_cond_signal, or
- * pthread_cond_broadcast, or
- * timeout, or
- * thread cancellation
- *
- * Note:
- *
- * 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 (sem_timedwait (&(cv->semBlockQueue), abstime) != 0)
- {
- result = errno;
- }
- }
-
- /*
- * Always cleanup
- */
- pthread_cleanup_pop (1);
-#if defined(_MSC_VER) && _MSC_VER < 1400
-#pragma inline_depth()
-#endif
-
- /*
- * "result" can be modified by the cleanup handler.
- */
- return result;
-
-} /* ptw32_cond_timedwait */
-
-
-int
-pthread_cond_wait (pthread_cond_t * cond, pthread_mutex_t * mutex)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * This function waits on a condition variable until
- * awakened by a signal or broadcast.
- *
- * Caller MUST be holding the mutex lock; the
- * lock is released and the caller is blocked waiting
- * on 'cond'. When 'cond' is signaled, the mutex
- * is re-acquired before returning to the caller.
- *
- * PARAMETERS
- * cond
- * pointer to an instance of pthread_cond_t
- *
- * mutex
- * pointer to an instance of pthread_mutex_t
- *
- *
- * DESCRIPTION
- * This function waits on a condition variable until
- * awakened by a signal or broadcast.
- *
- * NOTES:
- *
- * 1) The function must be called with 'mutex' LOCKED
- * by the calling thread, or undefined behaviour
- * will result.
- *
- * 2) This routine atomically releases 'mutex' and causes
- * the calling thread to block on the condition variable.
- * The blocked thread may be awakened by
- * pthread_cond_signal or
- * pthread_cond_broadcast.
- *
- * Upon successful completion, the 'mutex' has been locked and
- * is owned by the calling thread.
- *
- *
- * RESULTS
- * 0 caught condition; mutex released,
- * EINVAL 'cond' or 'mutex' is invalid,
- * EINVAL different mutexes for concurrent waits,
- * EINVAL mutex is not held by the calling thread,
- *
- * ------------------------------------------------------
- */
-{
- /*
- * 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)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * This function waits on a condition variable either until
- * awakened by a signal or broadcast; or until the time
- * specified by abstime passes.
- *
- * PARAMETERS
- * cond
- * pointer to an instance of pthread_cond_t
- *
- * mutex
- * pointer to an instance of pthread_mutex_t
- *
- * abstime
- * pointer to an instance of (const struct timespec)
- *
- *
- * DESCRIPTION
- * This function waits on a condition variable either until
- * awakened by a signal or broadcast; or until the time
- * specified by abstime passes.
- *
- * NOTES:
- * 1) The function must be called with 'mutex' LOCKED
- * by the calling thread, or undefined behaviour
- * will result.
- *
- * 2) This routine atomically releases 'mutex' and causes
- * the calling thread to block on the condition variable.
- * The blocked thread may be awakened by
- * pthread_cond_signal or
- * pthread_cond_broadcast.
- *
- *
- * RESULTS
- * 0 caught condition; mutex released,
- * EINVAL 'cond', 'mutex', or abstime is invalid,
- * EINVAL different mutexes for concurrent waits,
- * EINVAL mutex is not held by the calling thread,
- * ETIMEDOUT abstime ellapsed before cond was signaled.
- *
- * ------------------------------------------------------
- */
-{
- if (abstime == NULL)
- {
- return EINVAL;
- }
-
- return (ptw32_cond_timedwait (cond, mutex, abstime));
-
-} /* pthread_cond_timedwait */
+++ /dev/null
-/*
- * condvar_attr_destroy.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"
-
-
-int
-pthread_condattr_destroy (pthread_condattr_t * attr)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * Destroys a condition variable attributes object.
- * The object can no longer be used.
- *
- * PARAMETERS
- * attr
- * pointer to an instance of pthread_condattr_t
- *
- *
- * DESCRIPTION
- * Destroys a condition variable attributes object.
- * The object can no longer be used.
- *
- * NOTES:
- * 1) Does not affect condition variables created
- * using 'attr'
- *
- * RESULTS
- * 0 successfully released attr,
- * EINVAL 'attr' is invalid.
- *
- * ------------------------------------------------------
- */
-{
- int result = 0;
-
- if (attr == NULL || *attr == NULL)
- {
- result = EINVAL;
- }
- else
- {
- (void) free (*attr);
-
- *attr = NULL;
- result = 0;
- }
-
- return result;
-
-} /* pthread_condattr_destroy */
+++ /dev/null
-/*
- * pthread_condattr_getpshared.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"
-
-
-int
-pthread_condattr_getpshared (const pthread_condattr_t * attr, int *pshared)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * Determine whether condition variables created with 'attr'
- * can be shared between processes.
- *
- * PARAMETERS
- * attr
- * pointer to an instance of pthread_condattr_t
- *
- * pshared
- * will be set to one of:
- *
- * PTHREAD_PROCESS_SHARED
- * May be shared if in shared memory
- *
- * PTHREAD_PROCESS_PRIVATE
- * Cannot be shared.
- *
- *
- * DESCRIPTION
- * Condition Variables created with 'attr' can be shared
- * between processes if pthread_cond_t variable is allocated
- * in memory shared by these processes.
- * NOTES:
- * 1) pshared condition variables MUST be allocated in
- * shared memory.
- *
- * 2) The following macro is defined if shared mutexes
- * are supported:
- * _POSIX_THREAD_PROCESS_SHARED
- *
- * RESULTS
- * 0 successfully retrieved attribute,
- * EINVAL 'attr' or 'pshared' is invalid,
- *
- * ------------------------------------------------------
- */
-{
- int result;
-
- if ((attr != NULL && *attr != NULL) && (pshared != NULL))
- {
- *pshared = (*attr)->pshared;
- result = 0;
- }
- else
- {
- result = EINVAL;
- }
-
- return result;
-
-} /* pthread_condattr_getpshared */
+++ /dev/null
-/*
- * pthread_condattr_init.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"
-
-
-int
-pthread_condattr_init (pthread_condattr_t * attr)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * Initializes a condition variable attributes object
- * with default attributes.
- *
- * PARAMETERS
- * attr
- * pointer to an instance of pthread_condattr_t
- *
- *
- * DESCRIPTION
- * Initializes a condition variable attributes object
- * with default attributes.
- *
- * NOTES:
- * 1) Use to define condition variable types
- * 2) It is up to the application to ensure
- * that it doesn't re-init an attribute
- * without destroying it first. Otherwise
- * a memory leak is created.
- *
- * RESULTS
- * 0 successfully initialized attr,
- * ENOMEM insufficient memory for attr.
- *
- * ------------------------------------------------------
- */
-{
- pthread_condattr_t attr_result;
- int result = 0;
-
- attr_result = (pthread_condattr_t) calloc (1, sizeof (*attr_result));
-
- if (attr_result == NULL)
- {
- result = ENOMEM;
- }
-
- *attr = attr_result;
-
- return result;
-
-} /* pthread_condattr_init */
+++ /dev/null
-/*
- * pthread_condattr_setpshared.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"
-
-
-int
-pthread_condattr_setpshared (pthread_condattr_t * attr, int pshared)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * Mutexes created with 'attr' can be shared between
- * processes if pthread_mutex_t variable is allocated
- * in memory shared by these processes.
- *
- * PARAMETERS
- * attr
- * pointer to an instance of pthread_mutexattr_t
- *
- * pshared
- * must be one of:
- *
- * PTHREAD_PROCESS_SHARED
- * May be shared if in shared memory
- *
- * PTHREAD_PROCESS_PRIVATE
- * Cannot be shared.
- *
- * DESCRIPTION
- * Mutexes creatd with 'attr' can be shared between
- * processes if pthread_mutex_t variable is allocated
- * in memory shared by these processes.
- *
- * NOTES:
- * 1) pshared mutexes MUST be allocated in shared
- * memory.
- *
- * 2) The following macro is defined if shared mutexes
- * are supported:
- * _POSIX_THREAD_PROCESS_SHARED
- *
- * RESULTS
- * 0 successfully set attribute,
- * EINVAL 'attr' or pshared is invalid,
- * ENOSYS PTHREAD_PROCESS_SHARED not supported,
- *
- * ------------------------------------------------------
- */
-{
- int result;
-
- if ((attr != NULL && *attr != NULL)
- && ((pshared == PTHREAD_PROCESS_SHARED)
- || (pshared == PTHREAD_PROCESS_PRIVATE)))
- {
- if (pshared == PTHREAD_PROCESS_SHARED)
- {
-
-#if !defined( _POSIX_THREAD_PROCESS_SHARED )
- result = ENOSYS;
- pshared = PTHREAD_PROCESS_PRIVATE;
-#else
- result = 0;
-
-#endif /* _POSIX_THREAD_PROCESS_SHARED */
-
- }
- else
- {
- result = 0;
- }
-
- (*attr)->pshared = pshared;
- }
- else
- {
- result = EINVAL;
- }
-
- return result;
-
-} /* pthread_condattr_setpshared */
+++ /dev/null
-/*
- * pthreads_delay_np.c
- *
- * Description:
- * This translation unit implements non-portable thread functions.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-/*
- * pthread_delay_np
- *
- * DESCRIPTION
- *
- * 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.
- *
- * 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.
- *
- * Example
- *
- * The following code segment would wait for 5 and 1/2 seconds
- *
- * struct timespec tsWait;
- * int intRC;
- *
- * tsWait.tv_sec = 5;
- * tsWait.tv_nsec = 500000000L;
- * intRC = pthread_delay_np(&tsWait);
- */
-int
-pthread_delay_np (struct timespec *interval)
-{
- DWORD wait_time;
- DWORD secs_in_millisecs;
- DWORD millisecs;
- DWORD status;
- pthread_t self;
- ptw32_thread_t * sp;
-
- if (interval == NULL)
- {
- return EINVAL;
- }
-
- if (interval->tv_sec == 0L && interval->tv_nsec == 0L)
- {
- pthread_testcancel ();
- Sleep (0);
- pthread_testcancel ();
- return (0);
- }
-
- /* convert secs to millisecs */
- secs_in_millisecs = (DWORD)interval->tv_sec * 1000L;
-
- /* convert nanosecs to millisecs (rounding up) */
- millisecs = (interval->tv_nsec + 999999L) / 1000000L;
-
-#if defined(__WATCOMC__)
-#pragma disable_message (124)
-#endif
-
- /*
- * Most compilers will issue a warning 'comparison always 0'
- * because the variable type is unsigned, but we need to keep this
- * for some reason I can't recall now.
- */
- if (0 > (wait_time = secs_in_millisecs + millisecs))
- {
- return EINVAL;
- }
-
-#if defined(__WATCOMC__)
-#pragma enable_message (124)
-#endif
-
- if (NULL == (self = pthread_self ()).p)
- {
- return ENOMEM;
- }
-
- 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.
- */
- if (WAIT_OBJECT_0 ==
- (status = WaitForSingleObject (sp->cancelEvent, wait_time)))
- {
- ptw32_mcs_local_node_t stateLock;
- /*
- * Canceling!
- */
- 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);
- return ESRCH;
- }
- else if (status != WAIT_TIMEOUT)
- {
- return EINVAL;
- }
- }
- else
- {
- Sleep (wait_time);
- }
-
- return (0);
-}
+++ /dev/null
-/*
- * pthread_detach.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"
-
-/*
- * Not needed yet, but defining it should indicate clashes with build target
- * environment that should be fixed.
- */
-#if !defined(WINCE)
-# include <signal.h>
-#endif
-
-
-int
-pthread_detach (pthread_t thread)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * This function detaches the given thread.
- *
- * PARAMETERS
- * thread
- * an instance of a pthread_t
- *
- *
- * DESCRIPTION
- * This function detaches the given thread. You may use it to
- * detach the main thread or to detach a joinable thread.
- * NOTE: detached threads cannot be joined;
- * storage is freed immediately on termination.
- *
- * RESULTS
- * 0 successfully detached the thread,
- * EINVAL thread is not a joinable thread,
- * ENOSPC a required resource has been exhausted,
- * ESRCH no thread could be found for 'thread',
- *
- * ------------------------------------------------------
- */
-{
- int result;
- BOOL destroyIt = PTW32_FALSE;
- 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
- {
- ptw32_mcs_local_node_t stateLock;
- /*
- * 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)
- {
- tp->detachState = PTHREAD_CREATE_DETACHED;
- }
- else if (tp->detachState != PTHREAD_CREATE_DETACHED)
- {
- /*
- * Thread is joinable and has exited or is exiting.
- */
- destroyIt = PTW32_TRUE;
- }
- ptw32_mcs_lock_release (&stateLock);
- }
-
- ptw32_mcs_lock_release(&node);
-
- if (result == 0)
- {
- /* Thread is joinable */
-
- if (destroyIt)
- {
- /* The thread has exited or is exiting but has not been joined or
- * detached. Need to wait in case it's still exiting.
- */
- (void) WaitForSingleObject(tp->threadH, INFINITE);
- ptw32_threadDestroy (thread);
- }
- }
-
- return (result);
-
-} /* pthread_detach */
+++ /dev/null
-/*
- * pthread_equal.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"
-
-
-int
-pthread_equal (pthread_t t1, pthread_t t2)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * This function returns nonzero if t1 and t2 are equal, else
- * returns zero
- *
- * PARAMETERS
- * t1,
- * t2
- * thread IDs
- *
- *
- * DESCRIPTION
- * This function returns nonzero if t1 and t2 are equal, else
- * returns zero.
- *
- * RESULTS
- * non-zero if t1 and t2 refer to the same thread,
- * 0 t1 and t2 do not refer to the same thread
- *
- * ------------------------------------------------------
- */
-{
- int result;
-
- /*
- * We also accept NULL == NULL - treating NULL as a thread
- * for this special case, because there is no error that we can return.
- */
- result = ( t1.p == t2.p && t1.x == t2.x );
-
- return (result);
-
-} /* pthread_equal */
+++ /dev/null
-/*
- * pthread_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)
-/*# include <process.h> */
-#endif
-
-void
-pthread_exit (void *value_ptr)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * This function terminates the calling thread, returning
- * the value 'value_ptr' to any joining thread.
- *
- * PARAMETERS
- * value_ptr
- * a generic data value (i.e. not the address of a value)
- *
- *
- * DESCRIPTION
- * This function terminates the calling thread, returning
- * the value 'value_ptr' to any joining thread.
- * NOTE: thread should be joinable.
- *
- * RESULTS
- * N/A
- *
- * ------------------------------------------------------
- */
-{
- 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);
-
-#if defined(_UWIN)
- if (--pthread_count <= 0)
- exit ((int) value_ptr);
-#endif
-
- if (NULL == sp)
- {
- /*
- * A POSIX thread handle was never created. I.e. this is a
- * 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.
- */
-
-#if ! (defined (__MINGW64__) || defined(__MINGW32__)) || defined (__MSVCRT__) || defined (__DMC__)
- _endthreadex ((unsigned) (size_t) value_ptr);
-#else
- _endthread ();
-#endif
-
- /* Never reached */
- }
-
- sp->exitStatus = value_ptr;
-
- ptw32_throw (PTW32_EPS_EXIT);
-
- /* Never reached. */
-
-}
+++ /dev/null
-/*
- * pthread_getconcurrency.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"
-
-
-int
-pthread_getconcurrency (void)
-{
- return ptw32_concurrency;
-}
+++ /dev/null
-/*
- * 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
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-#include "sched.h"
-
-int
-pthread_getschedparam (pthread_t thread, int *policy,
- struct sched_param *param)
-{
- int result;
-
- /* Validate the thread id. */
- 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)
- {
- return EINVAL;
- }
-
- /* Fill out the policy. */
- *policy = SCHED_OTHER;
-
- /*
- * This function must return the priority value set by
- * the most recent pthread_setschedparam() or pthread_create()
- * 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;
-
- return 0;
-}
+++ /dev/null
-/*
- * pthread_getspecific.c
- *
- * Description:
- * POSIX thread functions which implement thread-specific data (TSD).
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-
-void *
-pthread_getspecific (pthread_key_t key)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * This function returns the current value of key in the
- * calling thread. If no value has been set for 'key' in
- * the thread, NULL is returned.
- *
- * PARAMETERS
- * key
- * an instance of pthread_key_t
- *
- *
- * DESCRIPTION
- * This function returns the current value of key in the
- * calling thread. If no value has been set for 'key' in
- * the thread, NULL is returned.
- *
- * RESULTS
- * key value or NULL on failure
- *
- * ------------------------------------------------------
- */
-{
- void * ptr;
-
- if (key == NULL)
- {
- ptr = NULL;
- }
- else
- {
- int lasterror = GetLastError ();
-#if defined(RETAIN_WSALASTERROR)
- int lastWSAerror = WSAGetLastError ();
-#endif
- ptr = TlsGetValue (key->key);
-
- SetLastError (lasterror);
-#if defined(RETAIN_WSALASTERROR)
- WSASetLastError (lastWSAerror);
-#endif
- }
-
- return ptr;
-}
+++ /dev/null
-/*
- * pthread_getunique_np.c
- *
- * Description:
- * This translation unit implements non-portable thread functions.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-/*
- *
- */
-unsigned __int64
-pthread_getunique_np (pthread_t thread)
-{
- return ((ptw32_thread_t*)thread.p)->seqNumber;
-}
+++ /dev/null
-/*
- * pthread_getw32threadhandle_np.c
- *
- * Description:
- * This translation unit implements non-portable thread functions.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-/*
- * pthread_getw32threadhandle_np()
- *
- * Returns the win32 thread handle that the POSIX
- * thread "thread" is running as.
- *
- * Applications can use the win32 handle to set
- * win32 specific attributes of the thread.
- */
-HANDLE
-pthread_getw32threadhandle_np (pthread_t thread)
-{
- return ((ptw32_thread_t *)thread.p)->threadH;
-}
-
-/*
- * pthread_getw32threadid_np()
- *
- * Returns the win32 thread id that the POSIX
- * thread "thread" is running as.
- */
-DWORD
-pthread_getw32threadid_np (pthread_t thread)
-{
- return ((ptw32_thread_t *)thread.p)->thread;
-}
+++ /dev/null
-/*
- * pthread_join.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"
-
-/*
- * Not needed yet, but defining it should indicate clashes with build target
- * environment that should be fixed.
- */
-#if !defined(WINCE)
-# include <signal.h>
-#endif
-
-
-int
-pthread_join (pthread_t thread, void **value_ptr)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * This function waits for 'thread' to terminate and
- * returns the thread's exit value if 'value_ptr' is not
- * NULL. This also 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 waits for 'thread' to terminate and
- * returns the thread's exit value if 'value_ptr' is not
- * NULL. This also detaches the thread on successful
- * completion.
- * NOTE: detached threads cannot be joined or canceled
- *
- * RESULTS
- * 0 'thread' has completed
- * 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 cancelation point.
- * If we are canceled then our target thread must not be
- * detached (destroyed). This is guarranteed because
- * pthreadCancelableWait will not return if we
- * are canceled.
- */
- result = pthreadCancelableWait (tp->threadH);
-
- if (0 == result)
- {
- if (value_ptr != NULL)
- {
- *value_ptr = tp->exitStatus;
- }
-
- /*
- * The result of making multiple simultaneous calls to
- * pthread_join() or pthread_detach() specifying the same
- * target is undefined.
- */
- result = pthread_detach (thread);
- }
- else
- {
- result = ESRCH;
- }
- }
- }
-
- return (result);
-
-} /* pthread_join */
+++ /dev/null
-/*
- * pthread_key_create.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"
-
-
-/* TLS_OUT_OF_INDEXES not defined on WinCE */
-#if !defined(TLS_OUT_OF_INDEXES)
-#define TLS_OUT_OF_INDEXES 0xffffffff
-#endif
-
-int
-pthread_key_create (pthread_key_t * key, void (*destructor) (void *))
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * This function creates a thread-specific data key visible
- * to all threads. All existing and new threads have a value
- * NULL for key until set using pthread_setspecific. When any
- * thread with a non-NULL value for key terminates, 'destructor'
- * is called with key's current value for that thread.
- *
- * PARAMETERS
- * key
- * pointer to an instance of pthread_key_t
- *
- *
- * DESCRIPTION
- * This function creates a thread-specific data key visible
- * to all threads. All existing and new threads have a value
- * NULL for key until set using pthread_setspecific. When any
- * thread with a non-NULL value for key terminates, 'destructor'
- * is called with key's current value for that thread.
- *
- * RESULTS
- * 0 successfully created semaphore,
- * EAGAIN insufficient resources or PTHREAD_KEYS_MAX
- * exceeded,
- * ENOMEM insufficient memory to create the key,
- *
- * ------------------------------------------------------
- */
-{
- int result = 0;
- pthread_key_t newkey;
-
- if ((newkey = (pthread_key_t) calloc (1, sizeof (*newkey))) == NULL)
- {
- result = ENOMEM;
- }
- else if ((newkey->key = TlsAlloc ()) == TLS_OUT_OF_INDEXES)
- {
- result = EAGAIN;
-
- free (newkey);
- newkey = NULL;
- }
- else if (destructor != NULL)
- {
- /*
- * Have to manage associations between thread and key;
- * Therefore, need a lock that allows competing threads
- * to gain exclusive access to the key->threads list.
- *
- * The mutex will only be created when it is first locked.
- */
- newkey->keyLock = 0;
- newkey->destructor = destructor;
- }
-
- *key = newkey;
-
- return (result);
-}
+++ /dev/null
-/*
- * pthread_key_delete.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"
-
-
-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,
- *
- * ------------------------------------------------------
- */
-{
- 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;
-
- 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);
- }
- }
-
- 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);
- }
-
-#if defined( _DEBUG )
- memset ((char *) key, 0, sizeof (*key));
-#endif
- free (key);
- }
-
- return (result);
-}
+++ /dev/null
-/*
- * pthread_kill.c
- *
- * Description:
- * This translation unit implements the pthread_kill routine.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX 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"
-
-/*
- * Not needed yet, but defining it should indicate clashes with build target
- * environment that should be fixed.
- */
-#if !defined(WINCE)
-# include <signal.h>
-#endif
-
-int
-pthread_kill (pthread_t thread, int sig)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * This function requests that a signal be delivered to the
- * specified thread. If sig is zero, error checking is
- * performed but no signal is actually sent such that this
- * function can be used to check for a valid thread ID.
- *
- * PARAMETERS
- * thread reference to an instances of pthread_t
- * sig signal. Currently only a value of 0 is supported.
- *
- *
- * DESCRIPTION
- * This function requests that a signal be delivered to the
- * specified thread. If sig is zero, error checking is
- * performed but no signal is actually sent such that this
- * function can be used to check for a valid thread ID.
- *
- * RESULTS
- * ESRCH the thread is not a valid thread ID,
- * EINVAL the value of the signal is invalid
- * or unsupported.
- * 0 the signal was successfully sent.
- *
- * ------------------------------------------------------
- */
-{
- 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)
- {
- /*
- * Currently does not support any signals.
- */
- result = EINVAL;
- }
-
- return result;
-
-} /* pthread_kill */
+++ /dev/null
-/*
- * pthread_mutex_consistent.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
- */
-
-/*
- * From the Sun Multi-threaded Programming Guide
- *
- * robustness defines the behavior when the owner of the mutex terminates without unlocking the
- * 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
- * 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
- * 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
- * a mutex initialized with the PTHREAD_MUTEX_ROBUST attribute.
- * â– 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
- * 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
- * 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
- * mutex, the next owner acquires the lock with an EOWNERDEAD return code.
- */
-#if !defined(_UWIN)
-/*# include <process.h> */
-#endif
-#include "pthread.h"
-#include "implement.h"
-
-int
-ptw32_robust_mutex_inherit(pthread_mutex_t * mutex)
-{
- int result;
- pthread_mutex_t mx = *mutex;
- 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 */))
- {
- case -1L:
- result = EOWNERDEAD;
- break;
- case (LONG)PTW32_ROBUST_NOTRECOVERABLE:
- result = ENOTRECOVERABLE;
- break;
- default:
- result = 0;
- break;
- }
-
- return result;
-}
-
-/*
- * 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.
- * 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
- * in any order, not necessarily the reverse locking order.
- * This is all possible because it is an error if a thread that
- * does not own the [robust] mutex attempts to unlock it.
- */
-
-void
-ptw32_robust_mutex_add(pthread_mutex_t* mutex, pthread_t self)
-{
- 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;
-
- list = &tp->robustMxList;
- mx->ownerThread = self;
- if (NULL == *list)
- {
- robust->prev = NULL;
- robust->next = NULL;
- *list = robust;
- }
- else
- {
- robust->prev = NULL;
- robust->next = *list;
- (*list)->prev = robust;
- *list = robust;
- }
-}
-
-void
-ptw32_robust_mutex_remove(pthread_mutex_t* mutex, ptw32_thread_t* otp)
-{
- ptw32_robust_node_t** list;
- pthread_mutex_t mx = *mutex;
- ptw32_robust_node_t* robust = mx->robustNode;
-
- list = &(((ptw32_thread_t*)mx->ownerThread.p)->robustMxList);
- mx->ownerThread.p = otp;
- if (robust->next != NULL)
- {
- robust->next->prev = robust->prev;
- }
- if (robust->prev != NULL)
- {
- robust->prev->next = robust->next;
- }
- if (*list == robust)
- {
- *list = robust->next;
- }
-}
-
-
-int
-pthread_mutex_consistent (pthread_mutex_t* mutex)
-{
- pthread_mutex_t mx = *mutex;
- int result = 0;
-
- /*
- * Let the system deal with invalid pointers.
- */
- if (mx == NULL)
- {
- return EINVAL;
- }
-
- 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))
- {
- result = EINVAL;
- }
-
- return (result);
-}
-
+++ /dev/null
-/*
- * pthread_mutex_destroy.c
- *
- * Description:
- * This translation unit implements mutual exclusion (mutex) primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-
-int
-pthread_mutex_destroy (pthread_mutex_t * mutex)
-{
- int result = 0;
- pthread_mutex_t mx;
-
- /*
- * Let the system deal with invalid pointers.
- */
-
- /*
- * Check to see if we have something to delete.
- */
- if (*mutex < PTHREAD_ERRORCHECK_MUTEX_INITIALIZER)
- {
- mx = *mutex;
-
- result = pthread_mutex_trylock (&mx);
-
- /*
- * If trylock succeeded and the mutex is not recursively locked it
- * can be destroyed.
- */
- if (0 == result || ENOTRECOVERABLE == result)
- {
- if (mx->kind != PTHREAD_MUTEX_RECURSIVE || 1 == mx->recursive_count)
- {
- /*
- * FIXME!!!
- * The mutex isn't held by another thread but we could still
- * be too late invalidating the mutex below since another thread
- * may already have entered mutex_lock and the check for a valid
- * *mutex != NULL.
- */
- *mutex = NULL;
-
- result = (0 == result)?pthread_mutex_unlock(&mx):0;
-
- if (0 == result)
- {
- if (mx->robustNode != NULL)
- {
- free(mx->robustNode);
- }
- if (!CloseHandle (mx->event))
- {
- *mutex = mx;
- result = EINVAL;
- }
- else
- {
- free (mx);
- }
- }
- else
- {
- /*
- * Restore the mutex before we return the error.
- */
- *mutex = mx;
- }
- }
- else /* mx->recursive_count > 1 */
- {
- /*
- * The mutex must be recursive and already locked by us (this thread).
- */
- mx->recursive_count--; /* Undo effect of pthread_mutex_trylock() above */
- result = EBUSY;
- }
- }
- }
- else
- {
- ptw32_mcs_local_node_t node;
-
- /*
- * See notes in ptw32_mutex_check_need_init() above also.
- */
-
- ptw32_mcs_lock_acquire(&ptw32_mutex_test_init_lock, &node);
-
- /*
- * Check again.
- */
- if (*mutex >= PTHREAD_ERRORCHECK_MUTEX_INITIALIZER)
- {
- /*
- * This is all we need to do to destroy a statically
- * initialised mutex that has not yet been used (initialised).
- * If we get to here, another thread
- * waiting to initialise this mutex will get an EINVAL.
- */
- *mutex = NULL;
- }
- else
- {
- /*
- * The mutex has been initialised while we were waiting
- * so assume it's in use.
- */
- result = EBUSY;
- }
- ptw32_mcs_lock_release(&node);
- }
-
- return (result);
-}
+++ /dev/null
-/*
- * pthread_mutex_init.c
- *
- * Description:
- * This translation unit implements mutual exclusion (mutex) primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-
-int
-pthread_mutex_init (pthread_mutex_t * mutex, const pthread_mutexattr_t * attr)
-{
- int result = 0;
- pthread_mutex_t mx;
-
- if (mutex == NULL)
- {
- return EINVAL;
- }
-
- if (attr != NULL && *attr != NULL)
- {
- if ((*attr)->pshared == PTHREAD_PROCESS_SHARED)
- {
- /*
- * Creating mutex that can be shared between
- * processes.
- */
-#if _POSIX_THREAD_PROCESS_SHARED >= 0
-
- /*
- * Not implemented yet.
- */
-
-#error ERROR [__FILE__, line __LINE__]: Process shared mutexes are not supported yet.
-
-#else
-
- return ENOSYS;
-
-#endif /* _POSIX_THREAD_PROCESS_SHARED */
- }
- }
-
- mx = (pthread_mutex_t) calloc (1, sizeof (*mx));
-
- if (mx == NULL)
- {
- result = ENOMEM;
- }
- else
- {
- mx->lock_idx = 0;
- mx->recursive_count = 0;
- mx->robustNode = NULL;
- if (attr == NULL || *attr == NULL)
- {
- mx->kind = PTHREAD_MUTEX_DEFAULT;
- }
- else
- {
- mx->kind = (*attr)->kind;
- if ((*attr)->robustness == PTHREAD_MUTEX_ROBUST)
- {
- /*
- * Use the negative range to represent robust types.
- * Replaces a memory fetch with a register negate and incr
- * in pthread_mutex_lock etc.
- *
- * Map 0,1,..,n to -1,-2,..,(-n)-1
- */
- 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->ownerThread.p = NULL;
-
- mx->event = CreateEvent (NULL, PTW32_FALSE, /* manual reset = No */
- PTW32_FALSE, /* initial state = not signaled */
- NULL); /* event name */
-
- if (0 == mx->event)
- {
- result = ENOSPC;
- free (mx);
- mx = NULL;
- }
- }
-
- *mutex = mx;
-
- return (result);
-}
+++ /dev/null
-/*
- * pthread_mutex_lock.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)
-/*# include <process.h> */
-#endif
-#include "pthread.h"
-#include "implement.h"
-
-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)
- {
- 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()
- * to avoid race conditions.
- */
- if (*mutex >= PTHREAD_ERRORCHECK_MUTEX_INITIALIZER)
- {
- if ((result = ptw32_mutex_check_need_init (mutex)) != 0)
- {
- return (result);
- }
- }
-
- mx = *mutex;
- kind = mx->kind;
-
- if (kind >= 0)
- {
- /* 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)
- {
- 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))
- {
- result = EINVAL;
- break;
- }
- }
- }
- }
- else
- {
- 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)
- {
- mx->recursive_count = 1;
- mx->ownerThread = self;
- }
- else
- {
- if (pthread_equal (mx->ownerThread, self))
- {
- if (kind == PTHREAD_MUTEX_RECURSIVE)
- {
- mx->recursive_count++;
- }
- else
- {
- result = EDEADLK;
- }
- }
- else
- {
- 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))
- {
- result = EINVAL;
- break;
- }
- }
-
- if (0 == result)
- {
- mx->recursive_count = 1;
- mx->ownerThread = self;
- }
- }
- }
- }
- }
- else
- {
- /*
- * Robust types
- * 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;
-
- if ((PTW32_INTERLOCKED_LONG)PTW32_ROBUST_NOTRECOVERABLE == PTW32_INTERLOCKED_EXCHANGE_ADD_LONG(
- (PTW32_INTERLOCKED_LONGPTR)statePtr,
- (PTW32_INTERLOCKED_LONG)0))
- {
- result = ENOTRECOVERABLE;
- }
- else
- {
- pthread_t self = pthread_self();
-
- kind = -kind - 1; /* Convert to non-robust range */
-
- if (PTHREAD_MUTEX_NORMAL == kind)
- {
- 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)
- {
- 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))
- {
- /* Unblock the next thread */
- SetEvent(mx->event);
- result = ENOTRECOVERABLE;
- break;
- }
- }
- }
- if (0 == result || EOWNERDEAD == result)
- {
- /*
- * 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);
- }
- }
- 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)
- {
- 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);
- }
- else
- {
- if (pthread_equal (mx->ownerThread, self))
- {
- if (PTHREAD_MUTEX_RECURSIVE == kind)
- {
- mx->recursive_count++;
- }
- else
- {
- result = EDEADLK;
- }
- }
- 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)
- {
- 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))
- {
- /* Unblock the next thread */
- SetEvent(mx->event);
- result = ENOTRECOVERABLE;
- break;
- }
- }
-
- if (0 == result || EOWNERDEAD == result)
- {
- 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);
- }
- }
- }
- }
- }
- }
-
- return (result);
-}
-
+++ /dev/null
-/*
- * pthread_mutex_timedlock.c
- *
- * Description:
- * This translation unit implements mutual exclusion (mutex) primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-
-static INLINE int
-ptw32_timed_eventwait (HANDLE event, const struct timespec *abstime)
- /*
- * ------------------------------------------------------
- * DESCRIPTION
- * This function waits on an event until signaled or until
- * abstime passes.
- * If abstime has passed when this routine is called then
- * it returns a result to indicate this.
- *
- * If 'abstime' is a NULL pointer then this function will
- * block until it can successfully decrease the value or
- * until interrupted by a signal.
- *
- * This routine is not a cancelation point.
- *
- * RESULTS
- * 0 successfully signaled,
- * ETIMEDOUT abstime passed
- * EINVAL 'event' is not a valid event,
- *
- * ------------------------------------------------------
- */
-{
-
- DWORD milliseconds;
- DWORD status;
-
- if (event == NULL)
- {
- return EINVAL;
- }
- else
- {
- if (abstime == NULL)
- {
- milliseconds = INFINITE;
- }
- else
- {
- /*
- * Calculate timeout as milliseconds from current system time.
- */
- 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;
- }
- }
-
- return 0;
-
-} /* 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.
- */
-
- /*
- * 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()
- * to avoid race conditions.
- */
- if (*mutex >= PTHREAD_ERRORCHECK_MUTEX_INITIALIZER)
- {
- if ((result = ptw32_mutex_check_need_init (mutex)) != 0)
- {
- return (result);
- }
- }
-
- 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)
- {
- 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)))
- {
- return result;
- }
- }
- }
- }
- else
- {
- 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)
- {
- mx->recursive_count = 1;
- mx->ownerThread = self;
- }
- else
- {
- if (pthread_equal (mx->ownerThread, self))
- {
- if (mx->kind == PTHREAD_MUTEX_RECURSIVE)
- {
- mx->recursive_count++;
- }
- else
- {
- return EDEADLK;
- }
- }
- else
- {
- 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)))
- {
- return result;
- }
- }
-
- mx->recursive_count = 1;
- mx->ownerThread = self;
- }
- }
- }
- }
- else
- {
- /*
- * Robust types
- * 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;
-
- if ((PTW32_INTERLOCKED_LONG)PTW32_ROBUST_NOTRECOVERABLE == PTW32_INTERLOCKED_EXCHANGE_ADD_LONG(
- (PTW32_INTERLOCKED_LONGPTR)statePtr,
- (PTW32_INTERLOCKED_LONG)0))
- {
- result = ENOTRECOVERABLE;
- }
- else
- {
- pthread_t self = pthread_self();
-
- kind = -kind - 1; /* Convert to non-robust range */
-
- if (PTHREAD_MUTEX_NORMAL == kind)
- {
- 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)
- {
- 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))
- {
- /* Unblock the next thread */
- SetEvent(mx->event);
- result = ENOTRECOVERABLE;
- break;
- }
- }
-
- if (0 == result || EOWNERDEAD == result)
- {
- /*
- * 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);
- }
- }
- }
- else
- {
- 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))
- {
- 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);
- }
- else
- {
- if (pthread_equal (mx->ownerThread, self))
- {
- if (PTHREAD_MUTEX_RECURSIVE == kind)
- {
- mx->recursive_count++;
- }
- else
- {
- return EDEADLK;
- }
- }
- 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)
- {
- 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))
- {
- /* Unblock the next thread */
- SetEvent(mx->event);
- result = ENOTRECOVERABLE;
- }
- else if (0 == result || EOWNERDEAD == result)
- {
- 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);
- }
- }
- }
- }
- }
- }
-
- return result;
-}
+++ /dev/null
-/*
- * pthread_mutex_trylock.c
- *
- * Description:
- * This translation unit implements mutual exclusion (mutex) primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-
-int
-pthread_mutex_trylock (pthread_mutex_t * mutex)
-{
- pthread_mutex_t mx;
- int kind;
- int result = 0;
-
- /*
- * Let the system deal with invalid pointers.
- */
-
- /*
- * 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()
- * to avoid race conditions.
- */
- if (*mutex >= PTHREAD_ERRORCHECK_MUTEX_INITIALIZER)
- {
- if ((result = ptw32_mutex_check_need_init (mutex)) != 0)
- {
- return (result);
- }
- }
-
- 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 (kind != PTHREAD_MUTEX_NORMAL)
- {
- mx->recursive_count = 1;
- mx->ownerThread = pthread_self ();
- }
- }
- else
- {
- if (kind == PTHREAD_MUTEX_RECURSIVE &&
- pthread_equal (mx->ownerThread, pthread_self ()))
- {
- mx->recursive_count++;
- }
- else
- {
- result = EBUSY;
- }
- }
- }
- else
- {
- /*
- * Robust types
- * All types record the current owner thread.
- * The mutex is added to a per thread list when ownership is acquired.
- */
- pthread_t self;
- 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))
- {
- return ENOTRECOVERABLE;
- }
-
- 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 (kind != PTHREAD_MUTEX_NORMAL)
- {
- mx->recursive_count = 1;
- }
- ptw32_robust_mutex_add(mutex, self);
- }
- else
- {
- if (PTHREAD_MUTEX_RECURSIVE == kind &&
- pthread_equal (mx->ownerThread, pthread_self ()))
- {
- mx->recursive_count++;
- }
- else
- {
- if (EOWNERDEAD == (result = ptw32_robust_mutex_inherit(mutex)))
- {
- mx->recursive_count = 1;
- ptw32_robust_mutex_add(mutex, self);
- }
- else
- {
- if (0 == result)
- {
- result = EBUSY;
- }
- }
- }
- }
- }
-
- return (result);
-}
+++ /dev/null
-/*
- * pthread_mutex_unlock.c
- *
- * Description:
- * This translation unit implements mutual exclusion (mutex) primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-
-int
-pthread_mutex_unlock (pthread_mutex_t * mutex)
-{
- int result = 0;
- int kind;
- pthread_mutex_t mx;
-
- /*
- * Let the system deal with invalid pointers.
- */
-
- mx = *mutex;
-
- /*
- * 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)
- {
- kind = mx->kind;
-
- if (kind >= 0)
- {
- if (kind == PTHREAD_MUTEX_NORMAL)
- {
- LONG idx;
-
- idx = (LONG) PTW32_INTERLOCKED_EXCHANGE_LONG ((PTW32_INTERLOCKED_LONGPTR)&mx->lock_idx,
- (PTW32_INTERLOCKED_LONG)0);
- if (idx != 0)
- {
- if (idx < 0)
- {
- /*
- * Someone may be waiting on that mutex.
- */
- if (SetEvent (mx->event) == 0)
- {
- result = EINVAL;
- }
- }
- }
- }
- else
- {
- if (pthread_equal (mx->ownerThread, pthread_self()))
- {
- if (kind != PTHREAD_MUTEX_RECURSIVE
- || 0 == --mx->recursive_count)
- {
- mx->ownerThread.p = NULL;
-
- 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)
- {
- result = EINVAL;
- }
- }
- }
- }
- else
- {
- result = EPERM;
- }
- }
- }
- else
- {
- /* Robust types */
- pthread_t self = pthread_self();
- kind = -kind - 1; /* Convert to non-robust range */
-
- /*
- * The thread must own the lock regardless of type if the mutex
- * is robust.
- */
- 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);
- if (PTHREAD_MUTEX_NORMAL == kind)
- {
- ptw32_robust_mutex_remove(mutex, NULL);
-
- if ((LONG) PTW32_INTERLOCKED_EXCHANGE_LONG((PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx,
- (PTW32_INTERLOCKED_LONG) 0) < 0)
- {
- /*
- * Someone may be waiting on that mutex.
- */
- if (SetEvent (mx->event) == 0)
- {
- result = EINVAL;
- }
- }
- }
- else
- {
- if (kind != PTHREAD_MUTEX_RECURSIVE
- || 0 == --mx->recursive_count)
- {
- ptw32_robust_mutex_remove(mutex, NULL);
-
- if ((LONG) PTW32_INTERLOCKED_EXCHANGE_LONG((PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx,
- (PTW32_INTERLOCKED_LONG) 0) < 0)
- {
- /*
- * Someone may be waiting on that mutex.
- */
- if (SetEvent (mx->event) == 0)
- {
- result = EINVAL;
- }
- }
- }
- }
- }
- else
- {
- result = EPERM;
- }
- }
- }
- else if (mx != PTHREAD_MUTEX_INITIALIZER)
- {
- result = EINVAL;
- }
-
- return (result);
-}
+++ /dev/null
-/*
- * pthread_mutexattr_destroy.c
- *
- * Description:
- * This translation unit implements mutual exclusion (mutex) primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-
-int
-pthread_mutexattr_destroy (pthread_mutexattr_t * attr)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * Destroys a mutex attributes object. The object can
- * no longer be used.
- *
- * PARAMETERS
- * attr
- * pointer to an instance of pthread_mutexattr_t
- *
- *
- * DESCRIPTION
- * Destroys a mutex attributes object. The object can
- * no longer be used.
- *
- * NOTES:
- * 1) Does not affect mutexes created using 'attr'
- *
- * RESULTS
- * 0 successfully released attr,
- * EINVAL 'attr' is invalid.
- *
- * ------------------------------------------------------
- */
-{
- int result = 0;
-
- if (attr == NULL || *attr == NULL)
- {
- result = EINVAL;
- }
- else
- {
- pthread_mutexattr_t ma = *attr;
-
- *attr = NULL;
- free (ma);
- }
-
- return (result);
-} /* pthread_mutexattr_destroy */
+++ /dev/null
-/*
- * pthread_mutexattr_getkind_np.c
- *
- * Description:
- * This translation unit implements non-portable thread functions.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-int
-pthread_mutexattr_getkind_np (pthread_mutexattr_t * attr, int *kind)
-{
- return pthread_mutexattr_gettype (attr, kind);
-}
+++ /dev/null
-/*
- * pthread_mutexattr_getpshared.c
- *
- * Description:
- * This translation unit implements mutual exclusion (mutex) primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-
-int
-pthread_mutexattr_getpshared (const pthread_mutexattr_t * attr, int *pshared)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * Determine whether mutexes created with 'attr' can be
- * shared between processes.
- *
- * PARAMETERS
- * attr
- * pointer to an instance of pthread_mutexattr_t
- *
- * pshared
- * will be set to one of:
- *
- * PTHREAD_PROCESS_SHARED
- * May be shared if in shared memory
- *
- * PTHREAD_PROCESS_PRIVATE
- * Cannot be shared.
- *
- *
- * DESCRIPTION
- * Mutexes creatd with 'attr' can be shared between
- * processes if pthread_mutex_t variable is allocated
- * in memory shared by these processes.
- * NOTES:
- * 1) pshared mutexes MUST be allocated in shared
- * memory.
- * 2) The following macro is defined if shared mutexes
- * are supported:
- * _POSIX_THREAD_PROCESS_SHARED
- *
- * RESULTS
- * 0 successfully retrieved attribute,
- * EINVAL 'attr' is invalid,
- *
- * ------------------------------------------------------
- */
-{
- int result;
-
- if ((attr != NULL && *attr != NULL) && (pshared != NULL))
- {
- *pshared = (*attr)->pshared;
- result = 0;
- }
- else
- {
- result = EINVAL;
- }
-
- return (result);
-
-} /* pthread_mutexattr_getpshared */
+++ /dev/null
-/*
- * pthread_mutexattr_getrobust.c
- *
- * Description:
- * This translation unit implements mutual exclusion (mutex) primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-
-int
-pthread_mutexattr_getrobust (const pthread_mutexattr_t * attr, int * robust)
- /*
- * ------------------------------------------------------
- *
- * DOCPUBLIC
- * The pthread_mutexattr_setrobust() and
- * pthread_mutexattr_getrobust() functions respectively set and
- * get the mutex robust attribute. This attribute is set in the
- * robust parameter to these functions.
- *
- * PARAMETERS
- * attr
- * pointer to an instance of pthread_mutexattr_t
- *
- * robust
- * must be one of:
- *
- * PTHREAD_MUTEX_STALLED
- *
- * PTHREAD_MUTEX_ROBUST
- *
- * DESCRIPTION
- * The pthread_mutexattr_setrobust() and
- * pthread_mutexattr_getrobust() functions respectively set and
- * get the mutex robust attribute. This attribute is set in the
- * robust parameter to these functions. The default value of the
- * robust attribute is PTHREAD_MUTEX_STALLED.
- *
- * The robustness of mutex is contained in the robustness attribute
- * of the mutex attributes. Valid mutex robustness values are:
- *
- * PTHREAD_MUTEX_STALLED
- * No special actions are taken if the owner of the mutex is
- * terminated while holding the mutex lock. This can lead to
- * deadlocks if no other thread can unlock the mutex.
- * This is the default value.
- *
- * PTHREAD_MUTEX_ROBUST
- * If the process containing the owning thread of a robust mutex
- * terminates while holding the mutex lock, the next thread that
- * acquires the mutex shall be notified about the termination by
- * the return value [EOWNERDEAD] from the locking function. If the
- * owning thread of a robust mutex terminates while holding the mutex
- * lock, the next thread that acquires the mutex may be notified
- * about the termination by the return value [EOWNERDEAD]. The
- * notified thread can then attempt to mark the state protected by
- * the mutex as consistent again by a call to
- * pthread_mutex_consistent(). After a subsequent successful call to
- * pthread_mutex_unlock(), the mutex lock shall be released and can
- * be used normally by other threads. If the mutex is unlocked without
- * a call to pthread_mutex_consistent(), it shall be in a permanently
- * unusable state and all attempts to lock the mutex shall fail with
- * the error [ENOTRECOVERABLE]. The only permissible operation on such
- * a mutex is pthread_mutex_destroy().
- *
- * RESULTS
- * 0 successfully set attribute,
- * EINVAL 'attr' or 'robust' is invalid,
- *
- * ------------------------------------------------------
- */
-{
- int result = EINVAL;
-
- if ((attr != NULL && *attr != NULL && robust != NULL))
- {
- *robust = (*attr)->robustness;
- result = 0;
- }
-
- return (result);
-} /* pthread_mutexattr_getrobust */
+++ /dev/null
-/*
- * pthread_mutexattr_gettype.c
- *
- * Description:
- * This translation unit implements mutual exclusion (mutex) primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-
-int
-pthread_mutexattr_gettype (const pthread_mutexattr_t * attr, int *kind)
-{
- int result = 0;
-
- if (attr != NULL && *attr != NULL && kind != NULL)
- {
- *kind = (*attr)->kind;
- }
- else
- {
- result = EINVAL;
- }
-
- return (result);
-}
+++ /dev/null
-/*
- * pthread_mutexattr_init.c
- *
- * Description:
- * This translation unit implements mutual exclusion (mutex) primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-
-int
-pthread_mutexattr_init (pthread_mutexattr_t * attr)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * Initializes a mutex attributes object with default
- * attributes.
- *
- * PARAMETERS
- * attr
- * pointer to an instance of pthread_mutexattr_t
- *
- *
- * DESCRIPTION
- * Initializes a mutex attributes object with default
- * attributes.
- *
- * NOTES:
- * 1) Used to define mutex types
- *
- * RESULTS
- * 0 successfully initialized attr,
- * ENOMEM insufficient memory for attr.
- *
- * ------------------------------------------------------
- */
-{
- int result = 0;
- pthread_mutexattr_t ma;
-
- ma = (pthread_mutexattr_t) calloc (1, sizeof (*ma));
-
- if (ma == NULL)
- {
- result = ENOMEM;
- }
- else
- {
- ma->pshared = PTHREAD_PROCESS_PRIVATE;
- ma->kind = PTHREAD_MUTEX_DEFAULT;
- }
-
- *attr = ma;
-
- return (result);
-} /* pthread_mutexattr_init */
+++ /dev/null
-/*
- * pthread_mutexattr_setkind_np.c
- *
- * Description:
- * This translation unit implements non-portable thread functions.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-int
-pthread_mutexattr_setkind_np (pthread_mutexattr_t * attr, int kind)
-{
- return pthread_mutexattr_settype (attr, kind);
-}
+++ /dev/null
-/*
- * pthread_mutexattr_setpshared.c
- *
- * Description:
- * This translation unit implements mutual exclusion (mutex) primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-
-int
-pthread_mutexattr_setpshared (pthread_mutexattr_t * attr, int pshared)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * Mutexes created with 'attr' can be shared between
- * processes if pthread_mutex_t variable is allocated
- * in memory shared by these processes.
- *
- * PARAMETERS
- * attr
- * pointer to an instance of pthread_mutexattr_t
- *
- * pshared
- * must be one of:
- *
- * PTHREAD_PROCESS_SHARED
- * May be shared if in shared memory
- *
- * PTHREAD_PROCESS_PRIVATE
- * Cannot be shared.
- *
- * DESCRIPTION
- * Mutexes creatd with 'attr' can be shared between
- * processes if pthread_mutex_t variable is allocated
- * in memory shared by these processes.
- *
- * NOTES:
- * 1) pshared mutexes MUST be allocated in shared
- * memory.
- *
- * 2) The following macro is defined if shared mutexes
- * are supported:
- * _POSIX_THREAD_PROCESS_SHARED
- *
- * RESULTS
- * 0 successfully set attribute,
- * EINVAL 'attr' or pshared is invalid,
- * ENOSYS PTHREAD_PROCESS_SHARED not supported,
- *
- * ------------------------------------------------------
- */
-{
- int result;
-
- if ((attr != NULL && *attr != NULL) &&
- ((pshared == PTHREAD_PROCESS_SHARED) ||
- (pshared == PTHREAD_PROCESS_PRIVATE)))
- {
- if (pshared == PTHREAD_PROCESS_SHARED)
- {
-
-#if !defined( _POSIX_THREAD_PROCESS_SHARED )
-
- result = ENOSYS;
- pshared = PTHREAD_PROCESS_PRIVATE;
-
-#else
-
- result = 0;
-
-#endif /* _POSIX_THREAD_PROCESS_SHARED */
-
- }
- else
- {
- result = 0;
- }
-
- (*attr)->pshared = pshared;
- }
- else
- {
- result = EINVAL;
- }
-
- return (result);
-
-} /* pthread_mutexattr_setpshared */
+++ /dev/null
-/*
- * pthread_mutexattr_setrobust.c
- *
- * Description:
- * This translation unit implements mutual exclusion (mutex) primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-
-int
-pthread_mutexattr_setrobust (pthread_mutexattr_t * attr, int robust)
- /*
- * ------------------------------------------------------
- *
- * DOCPUBLIC
- * The pthread_mutexattr_setrobust() and
- * pthread_mutexattr_getrobust() functions respectively set and
- * get the mutex robust attribute. This attribute is set in the
- * robust parameter to these functions.
- *
- * PARAMETERS
- * attr
- * pointer to an instance of pthread_mutexattr_t
- *
- * robust
- * must be one of:
- *
- * PTHREAD_MUTEX_STALLED
- *
- * PTHREAD_MUTEX_ROBUST
- *
- * DESCRIPTION
- * The pthread_mutexattr_setrobust() and
- * pthread_mutexattr_getrobust() functions respectively set and
- * get the mutex robust attribute. This attribute is set in the
- * robust parameter to these functions. The default value of the
- * robust attribute is PTHREAD_MUTEX_STALLED.
- *
- * The robustness of mutex is contained in the robustness attribute
- * of the mutex attributes. Valid mutex robustness values are:
- *
- * PTHREAD_MUTEX_STALLED
- * No special actions are taken if the owner of the mutex is
- * terminated while holding the mutex lock. This can lead to
- * deadlocks if no other thread can unlock the mutex.
- * This is the default value.
- *
- * PTHREAD_MUTEX_ROBUST
- * If the process containing the owning thread of a robust mutex
- * terminates while holding the mutex lock, the next thread that
- * acquires the mutex shall be notified about the termination by
- * the return value [EOWNERDEAD] from the locking function. If the
- * owning thread of a robust mutex terminates while holding the mutex
- * lock, the next thread that acquires the mutex may be notified
- * about the termination by the return value [EOWNERDEAD]. The
- * notified thread can then attempt to mark the state protected by
- * the mutex as consistent again by a call to
- * pthread_mutex_consistent(). After a subsequent successful call to
- * pthread_mutex_unlock(), the mutex lock shall be released and can
- * be used normally by other threads. If the mutex is unlocked without
- * a call to pthread_mutex_consistent(), it shall be in a permanently
- * unusable state and all attempts to lock the mutex shall fail with
- * the error [ENOTRECOVERABLE]. The only permissible operation on such
- * a mutex is pthread_mutex_destroy().
- *
- * RESULTS
- * 0 successfully set attribute,
- * EINVAL 'attr' or 'robust' is invalid,
- *
- * ------------------------------------------------------
- */
-{
- int result = EINVAL;
-
- if ((attr != NULL && *attr != NULL))
- {
- switch (robust)
- {
- case PTHREAD_MUTEX_STALLED:
- case PTHREAD_MUTEX_ROBUST:
- (*attr)->robustness = robust;
- result = 0;
- break;
- }
- }
-
- return (result);
-} /* pthread_mutexattr_setrobust */
+++ /dev/null
-/*
- * pthread_mutexattr_settype.c
- *
- * Description:
- * This translation unit implements mutual exclusion (mutex) primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-
-int
-pthread_mutexattr_settype (pthread_mutexattr_t * attr, int kind)
- /*
- * ------------------------------------------------------
- *
- * DOCPUBLIC
- * The pthread_mutexattr_settype() and
- * pthread_mutexattr_gettype() functions respectively set and
- * get the mutex type attribute. This attribute is set in the
- * type parameter to these functions.
- *
- * PARAMETERS
- * attr
- * pointer to an instance of pthread_mutexattr_t
- *
- * type
- * must be one of:
- *
- * PTHREAD_MUTEX_DEFAULT
- *
- * PTHREAD_MUTEX_NORMAL
- *
- * PTHREAD_MUTEX_ERRORCHECK
- *
- * PTHREAD_MUTEX_RECURSIVE
- *
- * DESCRIPTION
- * The pthread_mutexattr_settype() and
- * pthread_mutexattr_gettype() functions respectively set and
- * get the mutex type attribute. This attribute is set in the
- * type parameter to these functions. The default value of the
- * type attribute is PTHREAD_MUTEX_DEFAULT.
- *
- * The type of mutex is contained in the type attribute of the
- * mutex attributes. Valid mutex types include:
- *
- * PTHREAD_MUTEX_NORMAL
- * This type of mutex does not detect deadlock. A
- * thread attempting to relock this mutex without
- * first unlocking it will deadlock. Attempting to
- * unlock a mutex locked by a different thread
- * results in undefined behavior. Attempting to
- * unlock an unlocked mutex results in undefined
- * behavior.
- *
- * PTHREAD_MUTEX_ERRORCHECK
- * This type of mutex provides error checking. A
- * thread attempting to relock this mutex without
- * first unlocking it will return with an error. A
- * thread attempting to unlock a mutex which another
- * thread has locked will return with an error. A
- * thread attempting to unlock an unlocked mutex will
- * return with an error.
- *
- * PTHREAD_MUTEX_DEFAULT
- * Same as PTHREAD_MUTEX_NORMAL.
- *
- * PTHREAD_MUTEX_RECURSIVE
- * A thread attempting to relock this mutex without
- * first unlocking it will succeed in locking the
- * mutex. The relocking deadlock which can occur with
- * mutexes of type PTHREAD_MUTEX_NORMAL cannot occur
- * with this type of mutex. Multiple locks of this
- * mutex require the same number of unlocks to
- * release the mutex before another thread can
- * acquire the mutex. A thread attempting to unlock a
- * mutex which another thread has locked will return
- * with an error. A thread attempting to unlock an
- * unlocked mutex will return with an error. This
- * type of mutex is only supported for mutexes whose
- * process shared attribute is
- * PTHREAD_PROCESS_PRIVATE.
- *
- * RESULTS
- * 0 successfully set attribute,
- * EINVAL 'attr' or 'type' is invalid,
- *
- * ------------------------------------------------------
- */
-{
- int result = 0;
-
- if ((attr != NULL && *attr != NULL))
- {
- switch (kind)
- {
- case PTHREAD_MUTEX_FAST_NP:
- case PTHREAD_MUTEX_RECURSIVE_NP:
- case PTHREAD_MUTEX_ERRORCHECK_NP:
- (*attr)->kind = kind;
- break;
- default:
- result = EINVAL;
- break;
- }
- }
- else
- {
- result = EINVAL;
- }
-
- return (result);
-} /* pthread_mutexattr_settype */
+++ /dev/null
-/*
- * pthread_num_processors_np.c
- *
- * Description:
- * This translation unit implements non-portable thread functions.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-/*
- * pthread_num_processors_np()
- *
- * Get the number of CPUs available to the process.
- */
-int
-pthread_num_processors_np (void)
-{
- int count;
-
- if (ptw32_getprocessors (&count) != 0)
- {
- count = 1;
- }
-
- return (count);
-}
+++ /dev/null
-/*
- * pthread_once.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"
-
-int
-pthread_once (pthread_once_t * once_control, void (*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 */
- {
- ptw32_mcs_local_node_t node;
-
- ptw32_mcs_lock_acquire((ptw32_mcs_lock_t *)&once_control->lock, &node);
-
- if (!once_control->done)
- {
-
-#if defined(_MSC_VER) && _MSC_VER < 1400
-#pragma inline_depth(0)
-#endif
-
- pthread_cleanup_push(ptw32_mcs_lock_release, &node);
- (*init_routine)();
- pthread_cleanup_pop(0);
-
-#if defined(_MSC_VER) && _MSC_VER < 1400
-#pragma inline_depth()
-#endif
-
- once_control->done = PTW32_TRUE;
- }
-
- ptw32_mcs_lock_release(&node);
- }
-
- return 0;
-
-} /* pthread_once */
+++ /dev/null
-/*
- * pthread_rwlock_destroy.c
- *
- * Description:
- * This translation unit implements read/write lock primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include <limits.h>
-
-#include "pthread.h"
-#include "implement.h"
-
-int
-pthread_rwlock_destroy (pthread_rwlock_t * rwlock)
-{
- pthread_rwlock_t rwl;
- int result = 0, result1 = 0, result2 = 0;
-
- if (rwlock == NULL || *rwlock == NULL)
- {
- return EINVAL;
- }
-
- if (*rwlock != PTHREAD_RWLOCK_INITIALIZER)
- {
- rwl = *rwlock;
-
- if (rwl->nMagic != PTW32_RWLOCK_MAGIC)
- {
- return EINVAL;
- }
-
- if ((result = pthread_mutex_lock (&(rwl->mtxExclusiveAccess))) != 0)
- {
- return result;
- }
-
- if ((result =
- pthread_mutex_lock (&(rwl->mtxSharedAccessCompleted))) != 0)
- {
- (void) pthread_mutex_unlock (&(rwl->mtxExclusiveAccess));
- return result;
- }
-
- /*
- * Check whether any threads own/wait for the lock (wait for ex.access);
- * report "BUSY" if so.
- */
- if (rwl->nExclusiveAccessCount > 0
- || rwl->nSharedAccessCount > rwl->nCompletedSharedAccessCount)
- {
- result = pthread_mutex_unlock (&(rwl->mtxSharedAccessCompleted));
- result1 = pthread_mutex_unlock (&(rwl->mtxExclusiveAccess));
- result2 = EBUSY;
- }
- else
- {
- rwl->nMagic = 0;
-
- if ((result =
- pthread_mutex_unlock (&(rwl->mtxSharedAccessCompleted))) != 0)
- {
- pthread_mutex_unlock (&rwl->mtxExclusiveAccess);
- return result;
- }
-
- if ((result =
- pthread_mutex_unlock (&(rwl->mtxExclusiveAccess))) != 0)
- {
- return result;
- }
-
- *rwlock = NULL; /* Invalidate rwlock before anything else */
- result = pthread_cond_destroy (&(rwl->cndSharedAccessCompleted));
- result1 = pthread_mutex_destroy (&(rwl->mtxSharedAccessCompleted));
- result2 = pthread_mutex_destroy (&(rwl->mtxExclusiveAccess));
- (void) free (rwl);
- }
- }
- else
- {
- ptw32_mcs_local_node_t node;
- /*
- * See notes in ptw32_rwlock_check_need_init() above also.
- */
- ptw32_mcs_lock_acquire(&ptw32_rwlock_test_init_lock, &node);
-
- /*
- * Check again.
- */
- if (*rwlock == PTHREAD_RWLOCK_INITIALIZER)
- {
- /*
- * This is all we need to do to destroy a statically
- * initialised rwlock that has not yet been used (initialised).
- * If we get to here, another thread
- * waiting to initialise this rwlock will get an EINVAL.
- */
- *rwlock = NULL;
- }
- else
- {
- /*
- * The rwlock has been initialised while we were waiting
- * so assume it's in use.
- */
- result = EBUSY;
- }
-
- ptw32_mcs_lock_release(&node);
- }
-
- return ((result != 0) ? result : ((result1 != 0) ? result1 : result2));
-}
+++ /dev/null
-/*
- * pthread_rwlock_init.c
- *
- * Description:
- * This translation unit implements read/write lock primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include <limits.h>
-
-#include "pthread.h"
-#include "implement.h"
-
-int
-pthread_rwlock_init (pthread_rwlock_t * rwlock,
- const pthread_rwlockattr_t * attr)
-{
- int result;
- pthread_rwlock_t rwl = 0;
-
- if (rwlock == NULL)
- {
- return EINVAL;
- }
-
- if (attr != NULL && *attr != NULL)
- {
- result = EINVAL; /* Not supported */
- goto DONE;
- }
-
- rwl = (pthread_rwlock_t) calloc (1, sizeof (*rwl));
-
- if (rwl == NULL)
- {
- result = ENOMEM;
- goto DONE;
- }
-
- rwl->nSharedAccessCount = 0;
- rwl->nExclusiveAccessCount = 0;
- rwl->nCompletedSharedAccessCount = 0;
-
- result = pthread_mutex_init (&rwl->mtxExclusiveAccess, NULL);
- if (result != 0)
- {
- goto FAIL0;
- }
-
- result = pthread_mutex_init (&rwl->mtxSharedAccessCompleted, NULL);
- if (result != 0)
- {
- goto FAIL1;
- }
-
- result = pthread_cond_init (&rwl->cndSharedAccessCompleted, NULL);
- if (result != 0)
- {
- goto FAIL2;
- }
-
- rwl->nMagic = PTW32_RWLOCK_MAGIC;
-
- result = 0;
- goto DONE;
-
-FAIL2:
- (void) pthread_mutex_destroy (&(rwl->mtxSharedAccessCompleted));
-
-FAIL1:
- (void) pthread_mutex_destroy (&(rwl->mtxExclusiveAccess));
-
-FAIL0:
- (void) free (rwl);
- rwl = NULL;
-
-DONE:
- *rwlock = rwl;
-
- return result;
-}
+++ /dev/null
-/*
- * pthread_rwlock_rdlock.c
- *
- * Description:
- * This translation unit implements read/write lock primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include <limits.h>
-
-#include "pthread.h"
-#include "implement.h"
-
-int
-pthread_rwlock_rdlock (pthread_rwlock_t * rwlock)
-{
- int result;
- pthread_rwlock_t rwl;
-
- if (rwlock == NULL || *rwlock == NULL)
- {
- return EINVAL;
- }
-
- /*
- * We do a quick check to see if we need to do more work
- * to initialise a static rwlock. We check
- * again inside the guarded section of ptw32_rwlock_check_need_init()
- * to avoid race conditions.
- */
- if (*rwlock == PTHREAD_RWLOCK_INITIALIZER)
- {
- result = ptw32_rwlock_check_need_init (rwlock);
-
- if (result != 0 && result != EBUSY)
- {
- return result;
- }
- }
-
- rwl = *rwlock;
-
- if (rwl->nMagic != PTW32_RWLOCK_MAGIC)
- {
- return EINVAL;
- }
-
- if ((result = pthread_mutex_lock (&(rwl->mtxExclusiveAccess))) != 0)
- {
- return result;
- }
-
- if (++rwl->nSharedAccessCount == INT_MAX)
- {
- if ((result =
- pthread_mutex_lock (&(rwl->mtxSharedAccessCompleted))) != 0)
- {
- (void) pthread_mutex_unlock (&(rwl->mtxExclusiveAccess));
- return result;
- }
-
- rwl->nSharedAccessCount -= rwl->nCompletedSharedAccessCount;
- rwl->nCompletedSharedAccessCount = 0;
-
- if ((result =
- pthread_mutex_unlock (&(rwl->mtxSharedAccessCompleted))) != 0)
- {
- (void) pthread_mutex_unlock (&(rwl->mtxExclusiveAccess));
- return result;
- }
- }
-
- return (pthread_mutex_unlock (&(rwl->mtxExclusiveAccess)));
-}
+++ /dev/null
-/*
- * pthread_rwlock_timedrdlock.c
- *
- * Description:
- * This translation unit implements read/write lock primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include <limits.h>
-
-#include "pthread.h"
-#include "implement.h"
-
-int
-pthread_rwlock_timedrdlock (pthread_rwlock_t * rwlock,
- const struct timespec *abstime)
-{
- int result;
- pthread_rwlock_t rwl;
-
- if (rwlock == NULL || *rwlock == NULL)
- {
- return EINVAL;
- }
-
- /*
- * We do a quick check to see if we need to do more work
- * to initialise a static rwlock. We check
- * again inside the guarded section of ptw32_rwlock_check_need_init()
- * to avoid race conditions.
- */
- if (*rwlock == PTHREAD_RWLOCK_INITIALIZER)
- {
- result = ptw32_rwlock_check_need_init (rwlock);
-
- if (result != 0 && result != EBUSY)
- {
- return result;
- }
- }
-
- rwl = *rwlock;
-
- if (rwl->nMagic != PTW32_RWLOCK_MAGIC)
- {
- return EINVAL;
- }
-
- if ((result =
- pthread_mutex_timedlock (&(rwl->mtxExclusiveAccess), abstime)) != 0)
- {
- return result;
- }
-
- if (++rwl->nSharedAccessCount == INT_MAX)
- {
- if ((result =
- pthread_mutex_timedlock (&(rwl->mtxSharedAccessCompleted),
- abstime)) != 0)
- {
- if (result == ETIMEDOUT)
- {
- ++rwl->nCompletedSharedAccessCount;
- }
- (void) pthread_mutex_unlock (&(rwl->mtxExclusiveAccess));
- return result;
- }
-
- rwl->nSharedAccessCount -= rwl->nCompletedSharedAccessCount;
- rwl->nCompletedSharedAccessCount = 0;
-
- if ((result =
- pthread_mutex_unlock (&(rwl->mtxSharedAccessCompleted))) != 0)
- {
- (void) pthread_mutex_unlock (&(rwl->mtxExclusiveAccess));
- return result;
- }
- }
-
- return (pthread_mutex_unlock (&(rwl->mtxExclusiveAccess)));
-}
+++ /dev/null
-/*
- * pthread_rwlock_timedwrlock.c
- *
- * Description:
- * This translation unit implements read/write lock primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include <limits.h>
-
-#include "pthread.h"
-#include "implement.h"
-
-int
-pthread_rwlock_timedwrlock (pthread_rwlock_t * rwlock,
- const struct timespec *abstime)
-{
- int result;
- pthread_rwlock_t rwl;
-
- if (rwlock == NULL || *rwlock == NULL)
- {
- return EINVAL;
- }
-
- /*
- * We do a quick check to see if we need to do more work
- * to initialise a static rwlock. We check
- * again inside the guarded section of ptw32_rwlock_check_need_init()
- * to avoid race conditions.
- */
- if (*rwlock == PTHREAD_RWLOCK_INITIALIZER)
- {
- result = ptw32_rwlock_check_need_init (rwlock);
-
- if (result != 0 && result != EBUSY)
- {
- return result;
- }
- }
-
- rwl = *rwlock;
-
- if (rwl->nMagic != PTW32_RWLOCK_MAGIC)
- {
- return EINVAL;
- }
-
- if ((result =
- pthread_mutex_timedlock (&(rwl->mtxExclusiveAccess), abstime)) != 0)
- {
- return result;
- }
-
- if ((result =
- pthread_mutex_timedlock (&(rwl->mtxSharedAccessCompleted),
- abstime)) != 0)
- {
- (void) pthread_mutex_unlock (&(rwl->mtxExclusiveAccess));
- return result;
- }
-
- if (rwl->nExclusiveAccessCount == 0)
- {
- if (rwl->nCompletedSharedAccessCount > 0)
- {
- rwl->nSharedAccessCount -= rwl->nCompletedSharedAccessCount;
- rwl->nCompletedSharedAccessCount = 0;
- }
-
- if (rwl->nSharedAccessCount > 0)
- {
- rwl->nCompletedSharedAccessCount = -rwl->nSharedAccessCount;
-
- /*
- * This routine may be a cancelation point
- * according to POSIX 1003.1j section 18.1.2.
- */
-#if defined(_MSC_VER) && _MSC_VER < 1400
-#pragma inline_depth(0)
-#endif
- pthread_cleanup_push (ptw32_rwlock_cancelwrwait, (void *) rwl);
-
- do
- {
- result =
- pthread_cond_timedwait (&(rwl->cndSharedAccessCompleted),
- &(rwl->mtxSharedAccessCompleted),
- abstime);
- }
- while (result == 0 && rwl->nCompletedSharedAccessCount < 0);
-
- pthread_cleanup_pop ((result != 0) ? 1 : 0);
-#if defined(_MSC_VER) && _MSC_VER < 1400
-#pragma inline_depth()
-#endif
-
- if (result == 0)
- {
- rwl->nSharedAccessCount = 0;
- }
- }
- }
-
- if (result == 0)
- {
- rwl->nExclusiveAccessCount++;
- }
-
- return result;
-}
+++ /dev/null
-/*
- * pthread_rwlock_tryrdlock.c
- *
- * Description:
- * This translation unit implements read/write lock primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include <limits.h>
-
-#include "pthread.h"
-#include "implement.h"
-
-int
-pthread_rwlock_tryrdlock (pthread_rwlock_t * rwlock)
-{
- int result;
- pthread_rwlock_t rwl;
-
- if (rwlock == NULL || *rwlock == NULL)
- {
- return EINVAL;
- }
-
- /*
- * We do a quick check to see if we need to do more work
- * to initialise a static rwlock. We check
- * again inside the guarded section of ptw32_rwlock_check_need_init()
- * to avoid race conditions.
- */
- if (*rwlock == PTHREAD_RWLOCK_INITIALIZER)
- {
- result = ptw32_rwlock_check_need_init (rwlock);
-
- if (result != 0 && result != EBUSY)
- {
- return result;
- }
- }
-
- rwl = *rwlock;
-
- if (rwl->nMagic != PTW32_RWLOCK_MAGIC)
- {
- return EINVAL;
- }
-
- if ((result = pthread_mutex_trylock (&(rwl->mtxExclusiveAccess))) != 0)
- {
- return result;
- }
-
- if (++rwl->nSharedAccessCount == INT_MAX)
- {
- if ((result =
- pthread_mutex_lock (&(rwl->mtxSharedAccessCompleted))) != 0)
- {
- (void) pthread_mutex_unlock (&(rwl->mtxExclusiveAccess));
- return result;
- }
-
- rwl->nSharedAccessCount -= rwl->nCompletedSharedAccessCount;
- rwl->nCompletedSharedAccessCount = 0;
-
- if ((result =
- pthread_mutex_unlock (&(rwl->mtxSharedAccessCompleted))) != 0)
- {
- (void) pthread_mutex_unlock (&(rwl->mtxExclusiveAccess));
- return result;
- }
- }
-
- return (pthread_mutex_unlock (&rwl->mtxExclusiveAccess));
-}
+++ /dev/null
-/*
- * pthread_rwlock_trywrlock.c
- *
- * Description:
- * This translation unit implements read/write lock primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include <limits.h>
-
-#include "pthread.h"
-#include "implement.h"
-
-int
-pthread_rwlock_trywrlock (pthread_rwlock_t * rwlock)
-{
- int result, result1;
- pthread_rwlock_t rwl;
-
- if (rwlock == NULL || *rwlock == NULL)
- {
- return EINVAL;
- }
-
- /*
- * We do a quick check to see if we need to do more work
- * to initialise a static rwlock. We check
- * again inside the guarded section of ptw32_rwlock_check_need_init()
- * to avoid race conditions.
- */
- if (*rwlock == PTHREAD_RWLOCK_INITIALIZER)
- {
- result = ptw32_rwlock_check_need_init (rwlock);
-
- if (result != 0 && result != EBUSY)
- {
- return result;
- }
- }
-
- rwl = *rwlock;
-
- if (rwl->nMagic != PTW32_RWLOCK_MAGIC)
- {
- return EINVAL;
- }
-
- if ((result = pthread_mutex_trylock (&(rwl->mtxExclusiveAccess))) != 0)
- {
- return result;
- }
-
- if ((result =
- pthread_mutex_trylock (&(rwl->mtxSharedAccessCompleted))) != 0)
- {
- result1 = pthread_mutex_unlock (&(rwl->mtxExclusiveAccess));
- return ((result1 != 0) ? result1 : result);
- }
-
- if (rwl->nExclusiveAccessCount == 0)
- {
- if (rwl->nCompletedSharedAccessCount > 0)
- {
- rwl->nSharedAccessCount -= rwl->nCompletedSharedAccessCount;
- rwl->nCompletedSharedAccessCount = 0;
- }
-
- if (rwl->nSharedAccessCount > 0)
- {
- if ((result =
- pthread_mutex_unlock (&(rwl->mtxSharedAccessCompleted))) != 0)
- {
- (void) pthread_mutex_unlock (&(rwl->mtxExclusiveAccess));
- return result;
- }
-
- if ((result =
- pthread_mutex_unlock (&(rwl->mtxExclusiveAccess))) == 0)
- {
- result = EBUSY;
- }
- }
- else
- {
- rwl->nExclusiveAccessCount = 1;
- }
- }
- else
- {
- result = EBUSY;
- }
-
- return result;
-}
+++ /dev/null
-/*
- * pthread_rwlock_unlock.c
- *
- * Description:
- * This translation unit implements read/write lock primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include <limits.h>
-
-#include "pthread.h"
-#include "implement.h"
-
-int
-pthread_rwlock_unlock (pthread_rwlock_t * rwlock)
-{
- int result, result1;
- pthread_rwlock_t rwl;
-
- if (rwlock == NULL || *rwlock == NULL)
- {
- return (EINVAL);
- }
-
- if (*rwlock == PTHREAD_RWLOCK_INITIALIZER)
- {
- /*
- * Assume any race condition here is harmless.
- */
- return 0;
- }
-
- rwl = *rwlock;
-
- if (rwl->nMagic != PTW32_RWLOCK_MAGIC)
- {
- return EINVAL;
- }
-
- if (rwl->nExclusiveAccessCount == 0)
- {
- if ((result =
- pthread_mutex_lock (&(rwl->mtxSharedAccessCompleted))) != 0)
- {
- return result;
- }
-
- if (++rwl->nCompletedSharedAccessCount == 0)
- {
- result = pthread_cond_signal (&(rwl->cndSharedAccessCompleted));
- }
-
- result1 = pthread_mutex_unlock (&(rwl->mtxSharedAccessCompleted));
- }
- else
- {
- rwl->nExclusiveAccessCount--;
-
- result = pthread_mutex_unlock (&(rwl->mtxSharedAccessCompleted));
- result1 = pthread_mutex_unlock (&(rwl->mtxExclusiveAccess));
-
- }
-
- return ((result != 0) ? result : result1);
-}
+++ /dev/null
-/*
- * pthread_rwlock_wrlock.c
- *
- * Description:
- * This translation unit implements read/write lock primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include <limits.h>
-
-#include "pthread.h"
-#include "implement.h"
-
-int
-pthread_rwlock_wrlock (pthread_rwlock_t * rwlock)
-{
- int result;
- pthread_rwlock_t rwl;
-
- if (rwlock == NULL || *rwlock == NULL)
- {
- return EINVAL;
- }
-
- /*
- * We do a quick check to see if we need to do more work
- * to initialise a static rwlock. We check
- * again inside the guarded section of ptw32_rwlock_check_need_init()
- * to avoid race conditions.
- */
- if (*rwlock == PTHREAD_RWLOCK_INITIALIZER)
- {
- result = ptw32_rwlock_check_need_init (rwlock);
-
- if (result != 0 && result != EBUSY)
- {
- return result;
- }
- }
-
- rwl = *rwlock;
-
- if (rwl->nMagic != PTW32_RWLOCK_MAGIC)
- {
- return EINVAL;
- }
-
- if ((result = pthread_mutex_lock (&(rwl->mtxExclusiveAccess))) != 0)
- {
- return result;
- }
-
- if ((result = pthread_mutex_lock (&(rwl->mtxSharedAccessCompleted))) != 0)
- {
- (void) pthread_mutex_unlock (&(rwl->mtxExclusiveAccess));
- return result;
- }
-
- if (rwl->nExclusiveAccessCount == 0)
- {
- if (rwl->nCompletedSharedAccessCount > 0)
- {
- rwl->nSharedAccessCount -= rwl->nCompletedSharedAccessCount;
- rwl->nCompletedSharedAccessCount = 0;
- }
-
- if (rwl->nSharedAccessCount > 0)
- {
- rwl->nCompletedSharedAccessCount = -rwl->nSharedAccessCount;
-
- /*
- * This routine may be a cancelation point
- * according to POSIX 1003.1j section 18.1.2.
- */
-#if defined(_MSC_VER) && _MSC_VER < 1400
-#pragma inline_depth(0)
-#endif
- pthread_cleanup_push (ptw32_rwlock_cancelwrwait, (void *) rwl);
-
- do
- {
- result = pthread_cond_wait (&(rwl->cndSharedAccessCompleted),
- &(rwl->mtxSharedAccessCompleted));
- }
- while (result == 0 && rwl->nCompletedSharedAccessCount < 0);
-
- pthread_cleanup_pop ((result != 0) ? 1 : 0);
-#if defined(_MSC_VER) && _MSC_VER < 1400
-#pragma inline_depth()
-#endif
-
- if (result == 0)
- {
- rwl->nSharedAccessCount = 0;
- }
- }
- }
-
- if (result == 0)
- {
- rwl->nExclusiveAccessCount++;
- }
-
- return result;
-}
+++ /dev/null
-/*
- * pthread_rwlockattr_destroy.c
- *
- * Description:
- * This translation unit implements read/write lock primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include <limits.h>
-
-#include "pthread.h"
-#include "implement.h"
-
-int
-pthread_rwlockattr_destroy (pthread_rwlockattr_t * attr)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * Destroys a rwlock attributes object. The object can
- * no longer be used.
- *
- * PARAMETERS
- * attr
- * pointer to an instance of pthread_rwlockattr_t
- *
- *
- * DESCRIPTION
- * Destroys a rwlock attributes object. The object can
- * no longer be used.
- *
- * NOTES:
- * 1) Does not affect rwlockss created using 'attr'
- *
- * RESULTS
- * 0 successfully released attr,
- * EINVAL 'attr' is invalid.
- *
- * ------------------------------------------------------
- */
-{
- int result = 0;
-
- if (attr == NULL || *attr == NULL)
- {
- result = EINVAL;
- }
- else
- {
- pthread_rwlockattr_t rwa = *attr;
-
- *attr = NULL;
- free (rwa);
- }
-
- return (result);
-} /* pthread_rwlockattr_destroy */
+++ /dev/null
-/*
- * pthread_rwlockattr_getpshared.c
- *
- * Description:
- * This translation unit implements read/write lock primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include <limits.h>
-
-#include "pthread.h"
-#include "implement.h"
-
-int
-pthread_rwlockattr_getpshared (const pthread_rwlockattr_t * attr,
- int *pshared)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * Determine whether rwlocks created with 'attr' can be
- * shared between processes.
- *
- * PARAMETERS
- * attr
- * pointer to an instance of pthread_rwlockattr_t
- *
- * pshared
- * will be set to one of:
- *
- * PTHREAD_PROCESS_SHARED
- * May be shared if in shared memory
- *
- * PTHREAD_PROCESS_PRIVATE
- * Cannot be shared.
- *
- *
- * DESCRIPTION
- * Rwlocks creatd with 'attr' can be shared between
- * processes if pthread_rwlock_t variable is allocated
- * in memory shared by these processes.
- * NOTES:
- * 1) pshared rwlocks MUST be allocated in shared
- * memory.
- * 2) The following macro is defined if shared rwlocks
- * are supported:
- * _POSIX_THREAD_PROCESS_SHARED
- *
- * RESULTS
- * 0 successfully retrieved attribute,
- * EINVAL 'attr' is invalid,
- *
- * ------------------------------------------------------
- */
-{
- int result;
-
- if ((attr != NULL && *attr != NULL) && (pshared != NULL))
- {
- *pshared = (*attr)->pshared;
- result = 0;
- }
- else
- {
- result = EINVAL;
- }
-
- return (result);
-
-} /* pthread_rwlockattr_getpshared */
+++ /dev/null
-/*
- * pthread_rwlockattr_init.c
- *
- * Description:
- * This translation unit implements read/write lock primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include <limits.h>
-
-#include "pthread.h"
-#include "implement.h"
-
-int
-pthread_rwlockattr_init (pthread_rwlockattr_t * attr)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * Initializes a rwlock attributes object with default
- * attributes.
- *
- * PARAMETERS
- * attr
- * pointer to an instance of pthread_rwlockattr_t
- *
- *
- * DESCRIPTION
- * Initializes a rwlock attributes object with default
- * attributes.
- *
- * RESULTS
- * 0 successfully initialized attr,
- * ENOMEM insufficient memory for attr.
- *
- * ------------------------------------------------------
- */
-{
- int result = 0;
- pthread_rwlockattr_t rwa;
-
- rwa = (pthread_rwlockattr_t) calloc (1, sizeof (*rwa));
-
- if (rwa == NULL)
- {
- result = ENOMEM;
- }
- else
- {
- rwa->pshared = PTHREAD_PROCESS_PRIVATE;
- }
-
- *attr = rwa;
-
- return (result);
-} /* pthread_rwlockattr_init */
+++ /dev/null
-/*
- * pthread_rwlockattr_setpshared.c
- *
- * Description:
- * This translation unit implements read/write lock primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include <limits.h>
-
-#include "pthread.h"
-#include "implement.h"
-
-int
-pthread_rwlockattr_setpshared (pthread_rwlockattr_t * attr, int pshared)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * Rwlocks created with 'attr' can be shared between
- * processes if pthread_rwlock_t variable is allocated
- * in memory shared by these processes.
- *
- * PARAMETERS
- * attr
- * pointer to an instance of pthread_rwlockattr_t
- *
- * pshared
- * must be one of:
- *
- * PTHREAD_PROCESS_SHARED
- * May be shared if in shared memory
- *
- * PTHREAD_PROCESS_PRIVATE
- * Cannot be shared.
- *
- * DESCRIPTION
- * Rwlocks creatd with 'attr' can be shared between
- * processes if pthread_rwlock_t variable is allocated
- * in memory shared by these processes.
- *
- * NOTES:
- * 1) pshared rwlocks MUST be allocated in shared
- * memory.
- *
- * 2) The following macro is defined if shared rwlocks
- * are supported:
- * _POSIX_THREAD_PROCESS_SHARED
- *
- * RESULTS
- * 0 successfully set attribute,
- * EINVAL 'attr' or pshared is invalid,
- * ENOSYS PTHREAD_PROCESS_SHARED not supported,
- *
- * ------------------------------------------------------
- */
-{
- int result;
-
- if ((attr != NULL && *attr != NULL) &&
- ((pshared == PTHREAD_PROCESS_SHARED) ||
- (pshared == PTHREAD_PROCESS_PRIVATE)))
- {
- if (pshared == PTHREAD_PROCESS_SHARED)
- {
-
-#if !defined( _POSIX_THREAD_PROCESS_SHARED )
-
- result = ENOSYS;
- pshared = PTHREAD_PROCESS_PRIVATE;
-
-#else
-
- result = 0;
-
-#endif /* _POSIX_THREAD_PROCESS_SHARED */
-
- }
- else
- {
- result = 0;
- }
-
- (*attr)->pshared = pshared;
- }
- else
- {
- result = EINVAL;
- }
-
- return (result);
-
-} /* pthread_rwlockattr_setpshared */
+++ /dev/null
-/*
- * pthread_self.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"
-
-pthread_t
-pthread_self (void)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * This function returns a reference to the current running
- * thread.
- *
- * PARAMETERS
- * N/A
- *
- *
- * DESCRIPTION
- * This function returns a reference to the current running
- * thread.
- *
- * RESULTS
- * pthread_t reference to the current thread
- *
- * ------------------------------------------------------
- */
-{
- pthread_t self;
- pthread_t nil = {NULL, 0};
- ptw32_thread_t * sp;
-
-#if defined(_UWIN)
- if (!ptw32_selfThreadKey)
- return nil;
-#endif
-
- sp = (ptw32_thread_t *) pthread_getspecific (ptw32_selfThreadKey);
-
- if (sp != NULL)
- {
- self = sp->ptHandle;
- }
- else
- {
- /*
- * Need to create an implicit 'self' for the currently
- * executing thread.
- */
- 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 ();
-
-#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 ();
-#else
- 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;
- }
-#endif
-
- /*
- * No need to explicitly serialise access to sched_priority
- * because the new handle is not yet public.
- */
- sp->sched_priority = GetThreadPriority (sp->threadH);
- pthread_setspecific (ptw32_selfThreadKey, (void *) sp);
- }
- }
-
- return (self);
-
-} /* pthread_self */
+++ /dev/null
-/*
- * pthread_setcancelstate.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"
-
-
-int
-pthread_setcancelstate (int state, int *oldstate)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * This function atomically sets the calling thread's
- * cancelability state to 'state' and returns the previous
- * cancelability state at the location referenced by
- * 'oldstate'
- *
- * PARAMETERS
- * state,
- * oldstate
- * PTHREAD_CANCEL_ENABLE
- * cancellation is enabled,
- *
- * PTHREAD_CANCEL_DISABLE
- * cancellation is disabled
- *
- *
- * DESCRIPTION
- * This function atomically sets the calling thread's
- * cancelability state to 'state' and returns the previous
- * cancelability state at the location referenced by
- * 'oldstate'.
- *
- * NOTES:
- * 1) Use to disable cancellation around 'atomic' code that
- * includes cancellation points
- *
- * COMPATIBILITY ADDITIONS
- * If 'oldstate' is NULL then the previous state is not returned
- * but the function still succeeds. (Solaris)
- *
- * RESULTS
- * 0 successfully set cancelability type,
- * EINVAL 'state' is invalid
- *
- * ------------------------------------------------------
- */
-{
- ptw32_mcs_local_node_t stateLock;
- int result = 0;
- pthread_t self = pthread_self ();
- ptw32_thread_t * sp = (ptw32_thread_t *) self.p;
-
- if (sp == NULL
- || (state != PTHREAD_CANCEL_ENABLE && state != PTHREAD_CANCEL_DISABLE))
- {
- return EINVAL;
- }
-
- /*
- * Lock for async-cancel safety.
- */
- ptw32_mcs_lock_acquire (&sp->stateLock, &stateLock);
-
- if (oldstate != NULL)
- {
- *oldstate = sp->cancelState;
- }
-
- sp->cancelState = state;
-
- /*
- * Check if there is a pending asynchronous cancel
- */
- if (state == PTHREAD_CANCEL_ENABLE
- && sp->cancelType == PTHREAD_CANCEL_ASYNCHRONOUS
- && WaitForSingleObject (sp->cancelEvent, 0) == WAIT_OBJECT_0)
- {
- sp->state = PThreadStateCanceling;
- sp->cancelState = PTHREAD_CANCEL_DISABLE;
- ResetEvent (sp->cancelEvent);
- ptw32_mcs_lock_release (&stateLock);
- ptw32_throw (PTW32_EPS_CANCEL);
-
- /* Never reached */
- }
-
- ptw32_mcs_lock_release (&stateLock);
-
- return (result);
-
-} /* pthread_setcancelstate */
+++ /dev/null
-/*
- * pthread_setcanceltype.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"
-
-
-int
-pthread_setcanceltype (int type, int *oldtype)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * This function atomically sets the calling thread's
- * cancelability type to 'type' and returns the previous
- * cancelability type at the location referenced by
- * 'oldtype'
- *
- * PARAMETERS
- * type,
- * oldtype
- * PTHREAD_CANCEL_DEFERRED
- * only deferred cancelation is allowed,
- *
- * PTHREAD_CANCEL_ASYNCHRONOUS
- * Asynchronous cancellation is allowed
- *
- *
- * DESCRIPTION
- * This function atomically sets the calling thread's
- * cancelability type to 'type' and returns the previous
- * cancelability type at the location referenced by
- * 'oldtype'
- *
- * NOTES:
- * 1) Use with caution; most code is not safe for use
- * with asynchronous cancelability.
- *
- * COMPATIBILITY ADDITIONS
- * If 'oldtype' is NULL then the previous type is not returned
- * but the function still succeeds. (Solaris)
- *
- * RESULTS
- * 0 successfully set cancelability type,
- * EINVAL 'type' is invalid
- *
- * ------------------------------------------------------
- */
-{
- ptw32_mcs_local_node_t stateLock;
- int result = 0;
- pthread_t self = pthread_self ();
- ptw32_thread_t * sp = (ptw32_thread_t *) self.p;
-
- if (sp == NULL
- || (type != PTHREAD_CANCEL_DEFERRED
- && type != PTHREAD_CANCEL_ASYNCHRONOUS))
- {
- return EINVAL;
- }
-
- /*
- * Lock for async-cancel safety.
- */
- ptw32_mcs_lock_acquire (&sp->stateLock, &stateLock);
-
- if (oldtype != NULL)
- {
- *oldtype = sp->cancelType;
- }
-
- sp->cancelType = type;
-
- /*
- * Check if there is a pending asynchronous cancel
- */
- if (sp->cancelState == PTHREAD_CANCEL_ENABLE
- && type == PTHREAD_CANCEL_ASYNCHRONOUS
- && WaitForSingleObject (sp->cancelEvent, 0) == WAIT_OBJECT_0)
- {
- sp->state = PThreadStateCanceling;
- sp->cancelState = PTHREAD_CANCEL_DISABLE;
- ResetEvent (sp->cancelEvent);
- ptw32_mcs_lock_release (&stateLock);
- ptw32_throw (PTW32_EPS_CANCEL);
-
- /* Never reached */
- }
-
- ptw32_mcs_lock_release (&stateLock);
-
- return (result);
-
-} /* pthread_setcanceltype */
+++ /dev/null
-/*
- * pthread_setconcurrency.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"
-
-
-int
-pthread_setconcurrency (int level)
-{
- if (level < 0)
- {
- return EINVAL;
- }
- else
- {
- ptw32_concurrency = level;
- return 0;
- }
-}
+++ /dev/null
-/*
- * 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
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-#include "sched.h"
-
-int
-pthread_setschedparam (pthread_t thread, int policy,
- const struct sched_param *param)
-{
- int result;
-
- /* Validate the thread id. */
- result = pthread_kill (thread, 0);
- if (0 != result)
- {
- return result;
- }
-
- /* Validate the scheduling policy. */
- if (policy < SCHED_MIN || policy > SCHED_MAX)
- {
- return EINVAL;
- }
-
- /* Ensure the policy is SCHED_OTHER. */
- if (policy != SCHED_OTHER)
- {
- return ENOTSUP;
- }
-
- return (ptw32_setthreadpriority (thread, policy, param->sched_priority));
-}
-
-
-int
-ptw32_setthreadpriority (pthread_t thread, int policy, int priority)
-{
- int prio;
- ptw32_mcs_local_node_t threadLock;
- int result = 0;
- ptw32_thread_t * tp = (ptw32_thread_t *) thread.p;
-
- prio = priority;
-
- /* Validate priority level. */
- if (prio < sched_get_priority_min (policy) ||
- prio > sched_get_priority_max (policy))
- {
- return EINVAL;
- }
-
-#if (THREAD_PRIORITY_LOWEST > THREAD_PRIORITY_NORMAL)
-/* WinCE */
-#else
-/* Everything else */
-
- if (THREAD_PRIORITY_IDLE < prio && THREAD_PRIORITY_LOWEST > prio)
- {
- prio = THREAD_PRIORITY_LOWEST;
- }
- else if (THREAD_PRIORITY_TIME_CRITICAL > prio
- && THREAD_PRIORITY_HIGHEST < prio)
- {
- prio = THREAD_PRIORITY_HIGHEST;
- }
-
-#endif
-
- ptw32_mcs_lock_acquire (&tp->threadLock, &threadLock);
-
- /* If this fails, the current priority is unchanged. */
- if (0 == SetThreadPriority (tp->threadH, prio))
- {
- result = EINVAL;
- }
- else
- {
- /*
- * Must record the thread's sched_priority as given,
- * not as finally adjusted.
- */
- tp->sched_priority = priority;
- }
-
- ptw32_mcs_lock_release (&threadLock);
-
- return result;
-}
+++ /dev/null
-/*
- * pthread_setspecific.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"
-
-
-int
-pthread_setspecific (pthread_key_t key, const void *value)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * This function sets the value of the thread specific
- * key in the calling thread.
- *
- * PARAMETERS
- * key
- * an instance of pthread_key_t
- * value
- * the value to set key to
- *
- *
- * DESCRIPTION
- * This function sets the value of the thread specific
- * key in the calling thread.
- *
- * RESULTS
- * 0 successfully set value
- * EAGAIN could not set value
- * ENOENT SERIOUS!!
- *
- * ------------------------------------------------------
- */
-{
- pthread_t self;
- int result = 0;
-
- if (key != ptw32_selfThreadKey)
- {
- /*
- * Using pthread_self will implicitly create
- * an instance of pthread_t for the current
- * thread if one wasn't explicitly created
- */
- self = pthread_self ();
- if (self.p == NULL)
- {
- return ENOENT;
- }
- }
- else
- {
- /*
- * Resolve catch-22 of registering thread with selfThread
- * key
- */
- ptw32_thread_t * sp = (ptw32_thread_t *) pthread_getspecific (ptw32_selfThreadKey);
-
- if (sp == NULL)
- {
- if (value == NULL)
- {
- return ENOENT;
- }
- self = *((pthread_t *) value);
- }
- else
- {
- self = sp->ptHandle;
- }
- }
-
- result = 0;
-
- if (key != NULL)
- {
- 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;
- /*
- * Only require associations if we have to
- * call user destroy routine.
- * Don't need to locate an existing association
- * when setting data to NULL for WIN32 since the
- * data is stored with the operating system; not
- * on the association; setting assoc to NULL short
- * circuits the search.
- */
- ThreadKeyAssoc *assoc;
-
- ptw32_mcs_lock_acquire(&(key->keyLock), &keyLock);
- ptw32_mcs_lock_acquire(&(sp->threadLock), &threadLock);
-
- assoc = (ThreadKeyAssoc *) sp->keys;
- /*
- * Locate existing association
- */
- while (assoc != NULL)
- {
- if (assoc->key == key)
- {
- /*
- * Association already exists
- */
- break;
- }
- assoc = assoc->nextKey;
- }
-
- /*
- * create an association if not found
- */
- if (assoc == NULL)
- {
- result = ptw32_tkAssocCreate (sp, key);
- }
-
- ptw32_mcs_lock_release(&threadLock);
- ptw32_mcs_lock_release(&keyLock);
- }
-
- if (result == 0)
- {
- if (!TlsSetValue (key->key, (LPVOID) value))
- {
- result = EAGAIN;
- }
- }
- }
-
- return (result);
-} /* pthread_setspecific */
+++ /dev/null
-/*
- * pthread_spin_destroy.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"
-
-
-int
-pthread_spin_destroy (pthread_spinlock_t * lock)
-{
- register pthread_spinlock_t s;
- int result = 0;
-
- if (lock == NULL || *lock == NULL)
- {
- return EINVAL;
- }
-
- if ((s = *lock) != PTHREAD_SPINLOCK_INITIALIZER)
- {
- 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))
- {
- result = EINVAL;
- }
-
- if (0 == result)
- {
- /*
- * We are relying on the application to ensure that all other threads
- * have finished with the spinlock before destroying it.
- */
- *lock = NULL;
- (void) free (s);
- }
- }
- else
- {
- /*
- * See notes in ptw32_spinlock_check_need_init() above also.
- */
- ptw32_mcs_local_node_t node;
-
- ptw32_mcs_lock_acquire(&ptw32_spinlock_test_init_lock, &node);
-
- /*
- * Check again.
- */
- if (*lock == PTHREAD_SPINLOCK_INITIALIZER)
- {
- /*
- * This is all we need to do to destroy a statically
- * initialised spinlock that has not yet been used (initialised).
- * If we get to here, another thread
- * waiting to initialise this mutex will get an EINVAL.
- */
- *lock = NULL;
- }
- else
- {
- /*
- * The spinlock has been initialised while we were waiting
- * so assume it's in use.
- */
- result = EBUSY;
- }
-
- ptw32_mcs_lock_release(&node);
- }
-
- return (result);
-}
+++ /dev/null
-/*
- * pthread_spin_init.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"
-
-
-int
-pthread_spin_init (pthread_spinlock_t * lock, int pshared)
-{
- pthread_spinlock_t s;
- int cpus = 0;
- int result = 0;
-
- if (lock == NULL)
- {
- return EINVAL;
- }
-
- if (0 != ptw32_getprocessors (&cpus))
- {
- cpus = 1;
- }
-
- if (cpus > 1)
- {
- if (pshared == PTHREAD_PROCESS_SHARED)
- {
- /*
- * Creating spinlock that can be shared between
- * processes.
- */
-#if _POSIX_THREAD_PROCESS_SHARED >= 0
-
- /*
- * Not implemented yet.
- */
-
-#error ERROR [__FILE__, line __LINE__]: Process shared spin locks are not supported yet.
-
-#else
-
- return ENOSYS;
-
-#endif /* _POSIX_THREAD_PROCESS_SHARED */
-
- }
- }
-
- s = (pthread_spinlock_t) calloc (1, sizeof (*s));
-
- if (s == NULL)
- {
- return ENOMEM;
- }
-
- if (cpus > 1)
- {
- s->u.cpus = cpus;
- s->interlock = PTW32_SPIN_UNLOCKED;
- }
- else
- {
- pthread_mutexattr_t ma;
- result = pthread_mutexattr_init (&ma);
-
- if (0 == result)
- {
- ma->pshared = pshared;
- result = pthread_mutex_init (&(s->u.mutex), &ma);
- if (0 == result)
- {
- s->interlock = PTW32_SPIN_USE_MUTEX;
- }
- }
- (void) pthread_mutexattr_destroy (&ma);
- }
-
- if (0 == result)
- {
- *lock = s;
- }
- else
- {
- (void) free (s);
- *lock = NULL;
- }
-
- return (result);
-}
+++ /dev/null
-/*
- * pthread_spin_lock.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"
-
-
-int
-pthread_spin_lock (pthread_spinlock_t * lock)
-{
- register pthread_spinlock_t s;
-
- if (NULL == lock || NULL == *lock)
- {
- return (EINVAL);
- }
-
- if (*lock == PTHREAD_SPINLOCK_INITIALIZER)
- {
- int result;
-
- if ((result = ptw32_spinlock_check_need_init (lock)) != 0)
- {
- return (result);
- }
- }
-
- 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))
- {
- }
-
- if (s->interlock == PTW32_SPIN_LOCKED)
- {
- return 0;
- }
- else if (s->interlock == PTW32_SPIN_USE_MUTEX)
- {
- return pthread_mutex_lock (&(s->u.mutex));
- }
-
- return EINVAL;
-}
+++ /dev/null
-/*
- * pthread_spin_trylock.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"
-
-
-int
-pthread_spin_trylock (pthread_spinlock_t * lock)
-{
- register pthread_spinlock_t s;
-
- if (NULL == lock || NULL == *lock)
- {
- return (EINVAL);
- }
-
- if (*lock == PTHREAD_SPINLOCK_INITIALIZER)
- {
- int result;
-
- if ((result = ptw32_spinlock_check_need_init (lock)) != 0)
- {
- return (result);
- }
- }
-
- 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))
- {
- case PTW32_SPIN_UNLOCKED:
- return 0;
- case PTW32_SPIN_LOCKED:
- return EBUSY;
- case PTW32_SPIN_USE_MUTEX:
- return pthread_mutex_trylock (&(s->u.mutex));
- }
-
- return EINVAL;
-}
+++ /dev/null
-/*
- * pthread_spin_unlock.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"
-
-
-int
-pthread_spin_unlock (pthread_spinlock_t * lock)
-{
- register pthread_spinlock_t s;
-
- if (NULL == lock || NULL == *lock)
- {
- return (EINVAL);
- }
-
- s = *lock;
-
- if (s == PTHREAD_SPINLOCK_INITIALIZER)
- {
- return EPERM;
- }
-
- switch ((long)
- 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:
- return 0;
- case PTW32_SPIN_USE_MUTEX:
- return pthread_mutex_unlock (&(s->u.mutex));
- }
-
- return EINVAL;
-}
+++ /dev/null
-/*
- * pthread_testcancel.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"
-
-
-void
-pthread_testcancel (void)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * This function creates a deferred cancellation point
- * in the calling thread. The call has no effect if the
- * current cancelability state is
- * PTHREAD_CANCEL_DISABLE
- *
- * PARAMETERS
- * N/A
- *
- *
- * DESCRIPTION
- * This function creates a deferred cancellation point
- * in the calling thread. The call has no effect if the
- * current cancelability state is
- * PTHREAD_CANCEL_DISABLE
- *
- * NOTES:
- * 1) Cancellation is asynchronous. Use pthread_join
- * to wait for termination of thread if necessary
- *
- * RESULTS
- * N/A
- *
- * ------------------------------------------------------
- */
-{
- ptw32_mcs_local_node_t stateLock;
- pthread_t self = pthread_self ();
- ptw32_thread_t * sp = (ptw32_thread_t *) self.p;
-
- if (sp == NULL)
- {
- return;
- }
-
- /*
- * Pthread_cancel() will have set sp->state to PThreadStateCancelPending
- * and set an event, so no need to enter kernel space if
- * sp->state != PThreadStateCancelPending - that only slows us down.
- */
- if (sp->state != PThreadStateCancelPending)
- {
- return;
- }
-
- 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);
- /* Never returns here */
- }
-
- ptw32_mcs_lock_release (&stateLock);
-} /* pthread_testcancel */
+++ /dev/null
-/*
- * pthread_timechange_handler_np.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"
-
-/*
- * Notes on handling system time adjustments (especially negative ones).
- * ---------------------------------------------------------------------
- *
- * This solution was suggested by Alexander Terekhov, but any errors
- * in the implementation are mine - [Ross Johnson]
- *
- * 1) The problem: threads doing a timedwait on a CV may expect to timeout
- * at a specific absolute time according to a system timer. If the
- * system clock is adjusted backwards then those threads sleep longer than
- * expected. Also, pthreads-win32 converts absolute times to intervals in
- * order to make use of the underlying Win32, and so waiting threads may
- * awake before their proper abstimes.
- *
- * 2) We aren't able to distinquish between threads on timed or untimed waits,
- * so we wake them all at the time of the adjustment so that they can
- * re-evaluate their conditions and re-compute their timeouts.
- *
- * 3) We rely on correctly written applications for this to work. Specifically,
- * they must be able to deal properly with spurious wakeups. That is,
- * they must re-test their condition upon wakeup and wait again if
- * the condition is not satisfied.
- */
-
-void *
-pthread_timechange_handler_np (void *arg)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * Broadcasts all CVs to force re-evaluation and
- * new timeouts if required.
- *
- * PARAMETERS
- * NONE
- *
- *
- * DESCRIPTION
- * Broadcasts all CVs to force re-evaluation and
- * new timeouts if required.
- *
- * This routine may be passed directly to pthread_create()
- * as a new thread in order to run asynchronously.
- *
- *
- * RESULTS
- * 0 successfully broadcast all CVs
- * EAGAIN Not all CVs were broadcast
- *
- * ------------------------------------------------------
- */
-{
- int result = 0;
- pthread_cond_t cv;
- ptw32_mcs_local_node_t node;
-
- ptw32_mcs_lock_acquire(&ptw32_cond_list_lock, &node);
-
- cv = ptw32_cond_list_head;
-
- while (cv != NULL && 0 == result)
- {
- result = pthread_cond_broadcast (&cv);
- cv = cv->next;
- }
-
- ptw32_mcs_lock_release(&node);
-
- return (void *) (size_t) (result != 0 ? EAGAIN : 0);
-}
+++ /dev/null
-/*
- * pthread_win32_attach_detach_np.c
- *
- * Description:
- * This translation unit implements non-portable thread functions.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-#include <string.h>
-#include <tchar.h>
-
-/*
- * Handle to quserex.dll
- */
-static HINSTANCE ptw32_h_quserex;
-
-BOOL
-pthread_win32_process_attach_np ()
-{
- TCHAR QuserExDLLPathBuf[1024];
- BOOL result = TRUE;
-
- result = ptw32_processInitialize ();
-
-#if defined(_UWIN)
- pthread_count++;
-#endif
-
-#if defined(__GNUC__)
- ptw32_features = 0;
-#else
- /*
- * This is obsolete now.
- */
- ptw32_features = PTW32_SYSTEM_INTERLOCKED_COMPARE_EXCHANGE;
-#endif
-
- /*
- * Load QUSEREX.DLL and try to get address of QueueUserAPCEx.
- * Because QUSEREX.DLL requires a driver to be installed we will
- * assume the DLL is in the system directory.
- *
- * This should take care of any security issues.
- */
-#if defined(__GNUC__) || _MSC_VER < 1400
- if(GetSystemDirectory(QuserExDLLPathBuf, sizeof(QuserExDLLPathBuf) / sizeof(*QuserExDLLPathBuf)))
- {
- _tcsncat(QuserExDLLPathBuf,
- TEXT("\\QUSEREX.DLL"),
- (sizeof(QuserExDLLPathBuf) / sizeof(*QuserExDLLPathBuf)) - _tcslen(QuserExDLLPathBuf) - 1);
- ptw32_h_quserex = LoadLibrary(QuserExDLLPathBuf);
- }
-#else
- /* strncat is secure - this is just to avoid a warning */
- if(GetSystemDirectory(QuserExDLLPathBuf, sizeof(QuserExDLLPathBuf) / sizeof(*QuserExDLLPathBuf)) &&
- 0 == _tcsncat_s(QuserExDLLPathBuf, sizeof(QuserExDLLPathBuf) / sizeof(*QuserExDLLPathBuf), TEXT("\\QUSEREX.DLL"), 12))
- {
- ptw32_h_quserex = LoadLibrary(QuserExDLLPathBuf);
- }
-#endif
-
- if (ptw32_h_quserex != NULL)
- {
- ptw32_register_cancelation = (DWORD (*)(PAPCFUNC, HANDLE, DWORD))
-#if defined(NEED_UNICODE_CONSTS)
- GetProcAddress (ptw32_h_quserex, (const TCHAR *) TEXT ("QueueUserAPCEx"));
-#else
- GetProcAddress (ptw32_h_quserex, "QueueUserAPCEx");
-#endif
- }
-
- if (NULL == ptw32_register_cancelation)
- {
- ptw32_register_cancelation = ptw32_RegisterCancelation;
-
- if (ptw32_h_quserex != NULL)
- {
- (void) FreeLibrary (ptw32_h_quserex);
- }
- ptw32_h_quserex = 0;
- }
- else
- {
- /* Initialise QueueUserAPCEx */
- BOOL (*queue_user_apc_ex_init) (VOID);
-
- queue_user_apc_ex_init = (BOOL (*)(VOID))
-#if defined(NEED_UNICODE_CONSTS)
- GetProcAddress (ptw32_h_quserex,
- (const TCHAR *) TEXT ("QueueUserAPCEx_Init"));
-#else
- GetProcAddress (ptw32_h_quserex, "QueueUserAPCEx_Init");
-#endif
-
- if (queue_user_apc_ex_init == NULL || !queue_user_apc_ex_init ())
- {
- ptw32_register_cancelation = ptw32_RegisterCancelation;
-
- (void) FreeLibrary (ptw32_h_quserex);
- ptw32_h_quserex = 0;
- }
- }
-
- if (ptw32_h_quserex)
- {
- ptw32_features |= PTW32_ALERTABLE_ASYNC_CANCEL;
- }
-
- return result;
-}
-
-
-BOOL
-pthread_win32_process_detach_np ()
-{
- if (ptw32_processInitialized)
- {
- ptw32_thread_t * sp = (ptw32_thread_t *) pthread_getspecific (ptw32_selfThreadKey);
-
- if (sp != NULL)
- {
- /*
- * Detached threads have their resources automatically
- * cleaned up upon exit (others must be 'joined').
- */
- if (sp->detachState == PTHREAD_CREATE_DETACHED)
- {
- ptw32_threadDestroy (sp->ptHandle);
- TlsSetValue (ptw32_selfThreadKey->key, NULL);
- }
- }
-
- /*
- * The DLL is being unmapped from the process's address space
- */
- ptw32_processTerminate ();
-
- 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,
- (const TCHAR *) TEXT ("QueueUserAPCEx_Fini"));
-#else
- GetProcAddress (ptw32_h_quserex, "QueueUserAPCEx_Fini");
-#endif
-
- if (queue_user_apc_ex_fini != NULL)
- {
- (void) queue_user_apc_ex_fini ();
- }
- (void) FreeLibrary (ptw32_h_quserex);
- }
- }
-
- return TRUE;
-}
-
-BOOL
-pthread_win32_thread_attach_np ()
-{
- return TRUE;
-}
-
-BOOL
-pthread_win32_thread_detach_np ()
-{
- 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);
-
- if (sp != NULL) // otherwise Win32 thread with no implicit POSIX handle.
- {
- ptw32_mcs_local_node_t stateLock;
- ptw32_callUserDestroyRoutines (sp->ptHandle);
-
- 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);
-
- /*
- * Robust Mutexes
- */
- 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);
- /*
- * If there are no waiters then the next thread to block will
- * sleep, wakeup immediately and then go back to sleep.
- * See pthread_mutex_lock.c.
- */
- SetEvent(mx->event);
- }
-
-
- if (sp->detachState == PTHREAD_CREATE_DETACHED)
- {
- ptw32_threadDestroy (sp->ptHandle);
-
- TlsSetValue (ptw32_selfThreadKey->key, NULL);
- }
- }
- }
-
- return TRUE;
-}
-
-BOOL
-pthread_win32_test_features_np (int feature_mask)
-{
- return ((ptw32_features & feature_mask) == feature_mask);
-}
+++ /dev/null
-/*
- * ptw32_MCS_lock.c
- *
- * Description:
- * This translation unit implements 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 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
- * when there is lock contention.
- *
- * Because the queue nodes are thread-local, most of the memory read/write
- * operations required to add or remove nodes from the queue do not trigger
- * cache-coherence updates.
- *
- * Like 'named' mutexes, MCS locks consume system resources transiently -
- * they are able to acquire and free resources automatically - but MCS
- * locks do not require any unique 'name' to identify the lock to all
- * threads using it.
- *
- * 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
- * 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;
- *
- * void *mythread(void *arg)
- * {
- * ptw32_mcs_local_node_t node;
- *
- * ptw32_mcs_acquire (&lock1, &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_lock_acquire (&lock1, &node);
- * ptw32_mcs_lock_acquire (&lock2, &nodex);
- *
- * ptw32_mcs_lock_release (&nodex);
- * ptw32_mcs_lock_release (&node);
- * }
- * return (void *)0;
- * }
- */
-
-#include "pthread.h"
-#include "sched.h"
-#include "implement.h"
-
-/*
- * 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)
-{
- 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)
- {
- /* another thread has already stored an event handle in the flag */
- SetEvent(e);
- }
-}
-
-/*
- * ptw32_mcs_flag_set -- 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)
-{
- if ((PTW32_INTERLOCKED_LONG)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);
-
- 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);
- }
-
- CloseHandle(e);
- }
-}
-
-/*
- * 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)
-{
- 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);
-
- 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_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)
-{
- 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))
- {
- /* no successor, lock is free now */
- return;
- }
-
- /* 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 */
- }
-
- /* pass the lock */
- ptw32_mcs_flag_set(&next->readyFlag);
-}
-
-/*
- * 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)
-{
- 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;
-}
-
-/*
- * 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.
- *
- * Example: used in pthread_barrier_wait where we want the last thread out of
- * the barrier to release the lock owned by the last thread to enter the barrier
- * (the one that releases all threads but not necessarily the last to leave).
- *
- * 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)
-{
- 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)
- != old_node)
- {
- /*
- * A successor has queued after us, so wait for them to link to us
- */
- while (old_node->next == 0)
- {
- sched_yield();
- }
- new_node->next = old_node->next;
- }
-}
+++ /dev/null
-/*
- * ptw32_callUserDestroyRoutines.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"
-
-#if defined(__CLEANUP_CXX)
-# if defined(_MSC_VER)
-# include <eh.h>
-# elif defined(__WATCOMC__)
-# include <eh.h>
-# include <exceptio.h>
-# else
-# if defined(__GNUC__) && __GNUC__ < 3
-# include <new.h>
-# else
-# include <new>
- using
- std::terminate;
-# endif
-# endif
-#endif
-
-void
-ptw32_callUserDestroyRoutines (pthread_t thread)
- /*
- * -------------------------------------------------------------------
- * DOCPRIVATE
- *
- * This the routine runs through all thread keys and calls
- * the destroy routines on the user's data for the current thread.
- * It simulates the behaviour of POSIX Threads.
- *
- * PARAMETERS
- * thread
- * an instance of pthread_t
- *
- * RETURNS
- * N/A
- * -------------------------------------------------------------------
- */
-{
- ThreadKeyAssoc * assoc;
-
- if (thread.p != NULL)
- {
- 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;
-
- /*
- * Run through all Thread<-->Key associations
- * for the current thread.
- *
- * Do this process at most PTHREAD_DESTRUCTOR_ITERATIONS times.
- */
- do
- {
- assocsRemaining = 0;
- iterations++;
-
- 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
- * if it deletes this assoc. This can happen if we fail to acquire
- * both locks below, and are forced to release all of our locks,
- * leaving open the opportunity for pthread_key_delete to get in
- * before us.
- */
- sp->nextAssoc = sp->keys;
- ptw32_mcs_lock_release(&threadLock);
-
- for (;;)
- {
- void * value;
- pthread_key_t k;
- void (*destructor) (void *);
-
- /*
- * First we need to serialise with pthread_key_delete by locking
- * 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);
-
- if ((assoc = (ThreadKeyAssoc *)sp->nextAssoc) == NULL)
- {
- /* Finished */
- ptw32_mcs_lock_release(&threadLock);
- break;
- }
- else
- {
- /*
- * assoc->key must be valid because assoc can't change or be
- * removed from our chain while we hold at least one lock. If
- * the assoc was on our key chain then the key has not been
- * deleted yet.
- *
- * Now try to acquire the second lock without deadlocking.
- * 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)
- {
- ptw32_mcs_lock_release(&threadLock);
- Sleep(0);
- /*
- * Go around again.
- * If pthread_key_delete has removed this assoc in the meantime,
- * sp->nextAssoc will point to a new assoc.
- */
- continue;
- }
- }
-
- /* We now hold both locks */
-
- sp->nextAssoc = assoc->nextKey;
-
- /*
- * Key still active; pthread_key_delete
- * will block on these same mutexes before
- * it can release actual key; therefore,
- * key is valid and we can call the destroy
- * routine;
- */
- k = assoc->key;
- destructor = k->destructor;
- value = TlsGetValue(k->key);
- TlsSetValue (k->key, NULL);
-
- // Every assoc->key exists and has a destructor
- if (value != NULL && iterations <= PTHREAD_DESTRUCTOR_ITERATIONS)
- {
- /*
- * Unlock both locks before the destructor runs.
- * POSIX says pthread_key_delete can be run from destructors,
- * and that probably includes with this key as target.
- * 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);
-
- assocsRemaining++;
-
-#if defined(__cplusplus)
-
- try
- {
- /*
- * Run the caller's cleanup routine.
- */
- destructor (value);
- }
- catch (...)
- {
- /*
- * A system unexpected exception has occurred
- * running the user's destructor.
- * We get control back within this block in case
- * the application has set up it's own terminate
- * handler. Since we are leaving the thread we
- * should not get any internal pthreads
- * exceptions.
- */
- terminate ();
- }
-
-#else /* __cplusplus */
-
- /*
- * Run the caller's cleanup routine.
- */
- destructor (value);
-
-#endif /* __cplusplus */
-
- }
- else
- {
- /*
- * 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);
- }
- }
- }
- while (assocsRemaining);
- }
-} /* ptw32_callUserDestroyRoutines */
+++ /dev/null
-/*
- * ptw32_calloc.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"
-
-
-#if defined(NEED_CALLOC)
-void *
-ptw32_calloc (size_t n, size_t s)
-{
- unsigned int m = n * s;
- void *p;
-
- p = malloc (m);
- if (p == NULL)
- return NULL;
-
- memset (p, 0, m);
-
- return p;
-}
-#endif
+++ /dev/null
-/*
- * ptw32_cond_check_need_init.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"
-
-
-int
-ptw32_cond_check_need_init (pthread_cond_t * cond)
-{
- int result = 0;
- 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);
-
- /*
- * We got here possibly under race
- * conditions. Check again inside the critical section.
- * If a static cv has been destroyed, the application can
- * re-initialise it only by calling pthread_cond_init()
- * explicitly.
- */
- if (*cond == PTHREAD_COND_INITIALIZER)
- {
- result = pthread_cond_init (cond, NULL);
- }
- else if (*cond == NULL)
- {
- /*
- * The cv has been destroyed while we were waiting to
- * initialise it, so the operation that caused the
- * auto-initialisation should fail.
- */
- result = EINVAL;
- }
-
- ptw32_mcs_lock_release(&node);
-
- return result;
-}
+++ /dev/null
-/*
- * ptw32_getprocessors.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"
-
-
-/*
- * ptw32_getprocessors()
- *
- * Get the number of CPUs available to the process.
- *
- * If the available number of CPUs is 1 then pthread_spin_lock()
- * will block rather than spin if the lock is already owned.
- *
- * pthread_spin_init() calls this routine when initialising
- * a spinlock. If the number of available processors changes
- * (after a call to SetProcessAffinityMask()) then only
- * newly initialised spinlocks will notice.
- */
-int
-ptw32_getprocessors (int *count)
-{
- DWORD_PTR vProcessCPUs;
- DWORD_PTR vSystemCPUs;
- int result = 0;
-
-#if defined(NEED_PROCESS_AFFINITY_MASK)
-
- *count = 1;
-
-#else
-
- if (GetProcessAffinityMask (GetCurrentProcess (),
- &vProcessCPUs, &vSystemCPUs))
- {
- DWORD_PTR bit;
- int CPUs = 0;
-
- for (bit = 1; bit != 0; bit <<= 1)
- {
- if (vProcessCPUs & bit)
- {
- CPUs++;
- }
- }
- *count = CPUs;
- }
- else
- {
- result = EAGAIN;
- }
-
-#endif
-
- return (result);
-}
+++ /dev/null
-/*
- * ptw32_is_attr.c
- *
- * Description:
- * This translation unit implements operations on thread attribute objects.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-int
-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);
-}
+++ /dev/null
-/*
- * ptw32_mutex_check_need_init.c
- *
- * Description:
- * This translation unit implements mutual exclusion (mutex) primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-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;
-
-
-int
-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_lock_acquire(&ptw32_mutex_test_init_lock, &node);
-
- /*
- * We got here possibly under race
- * conditions. Check again inside the critical section
- * and only initialise if the mutex is valid (not been destroyed).
- * If a static mutex has been destroyed, the application can
- * re-initialise it only by calling pthread_mutex_init()
- * explicitly.
- */
- mtx = *mutex;
-
- if (mtx == PTHREAD_MUTEX_INITIALIZER)
- {
- result = pthread_mutex_init (mutex, NULL);
- }
- else if (mtx == PTHREAD_RECURSIVE_MUTEX_INITIALIZER)
- {
- result = pthread_mutex_init (mutex, &ptw32_recursive_mutexattr);
- }
- else if (mtx == PTHREAD_ERRORCHECK_MUTEX_INITIALIZER)
- {
- result = pthread_mutex_init (mutex, &ptw32_errorcheck_mutexattr);
- }
- else if (mtx == NULL)
- {
- /*
- * The mutex has been destroyed while we were waiting to
- * initialise it, so the operation that caused the
- * auto-initialisation should fail.
- */
- result = EINVAL;
- }
-
- ptw32_mcs_lock_release(&node);
-
- return (result);
-}
+++ /dev/null
-/*
- * ptw32_new.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"
-
-
-pthread_t
-ptw32_new (void)
-{
- pthread_t t;
- pthread_t nil = {NULL, 0};
- ptw32_thread_t * tp;
-
- /*
- * If there's a reusable pthread_t then use it.
- */
- t = ptw32_threadReusePop ();
-
- if (NULL != t.p)
- {
- tp = (ptw32_thread_t *) t.p;
- }
- else
- {
- /* No reuse threads available */
- 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. */
- t.p = tp->ptHandle.p = tp;
- t.x = tp->ptHandle.x = 0;
- }
-
- /* Set default state. */
- tp->seqNumber = ++ptw32_threadSeqNumber;
- tp->sched_priority = THREAD_PRIORITY_NORMAL;
- tp->detachState = PTHREAD_CREATE_JOINABLE;
- tp->cancelState = PTHREAD_CANCEL_ENABLE;
- tp->cancelType = PTHREAD_CANCEL_DEFERRED;
- tp->stateLock = 0;
- tp->threadLock = 0;
- tp->robustMxListLock = 0;
- tp->robustMxList = NULL;
- tp->cancelEvent = CreateEvent (0, (int) PTW32_TRUE, /* manualReset */
- (int) PTW32_FALSE, /* setSignaled */
- NULL);
-
- if (tp->cancelEvent == NULL)
- {
- ptw32_threadReusePush (tp->ptHandle);
- return nil;
- }
-
- return t;
-
-}
+++ /dev/null
-/*
- * ptw32_processInitialize.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"
-
-
-int
-ptw32_processInitialize (void)
- /*
- * ------------------------------------------------------
- * DOCPRIVATE
- * This function performs process wide initialization for
- * the pthread library.
- *
- * PARAMETERS
- * N/A
- *
- * DESCRIPTION
- * This function performs process wide initialization for
- * the pthread library.
- * If successful, this routine sets the global variable
- * ptw32_processInitialized to TRUE.
- *
- * RESULTS
- * TRUE if successful,
- * FALSE otherwise
- *
- * ------------------------------------------------------
- */
-{
- 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;
- }
-
- ptw32_processInitialized = PTW32_TRUE;
-
- /*
- * Initialize Keys
- */
- if ((pthread_key_create (&ptw32_selfThreadKey, NULL) != 0) ||
- (pthread_key_create (&ptw32_cleanupKey, NULL) != 0))
- {
-
- ptw32_processTerminate ();
- }
-
- return (ptw32_processInitialized);
-
-} /* processInitialize */
+++ /dev/null
-/*
- * ptw32_processTerminate.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"
-
-
-void
-ptw32_processTerminate (void)
- /*
- * ------------------------------------------------------
- * DOCPRIVATE
- * This function performs process wide termination for
- * the pthread library.
- *
- * PARAMETERS
- * N/A
- *
- * DESCRIPTION
- * This function performs process wide termination for
- * the pthread library.
- * This routine sets the global variable
- * ptw32_processInitialized to FALSE
- *
- * RESULTS
- * N/A
- *
- * ------------------------------------------------------
- */
-{
- if (ptw32_processInitialized)
- {
- ptw32_thread_t * tp, * tpNext;
- ptw32_mcs_local_node_t node;
-
- if (ptw32_selfThreadKey != NULL)
- {
- /*
- * Release ptw32_selfThreadKey
- */
- pthread_key_delete (ptw32_selfThreadKey);
-
- ptw32_selfThreadKey = NULL;
- }
-
- if (ptw32_cleanupKey != NULL)
- {
- /*
- * Release ptw32_cleanupKey
- */
- pthread_key_delete (ptw32_cleanupKey);
-
- ptw32_cleanupKey = NULL;
- }
-
- ptw32_mcs_lock_acquire(&ptw32_thread_reuse_lock, &node);
-
- tp = ptw32_threadReuseTop;
- while (tp != PTW32_THREAD_REUSE_EMPTY)
- {
- tpNext = tp->prevReuse;
- free (tp);
- tp = tpNext;
- }
-
- ptw32_mcs_lock_release(&node);
-
- ptw32_processInitialized = PTW32_FALSE;
- }
-
-} /* processTerminate */
+++ /dev/null
-/*
- * ptw32_relmillisecs.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"
-#if !defined(NEED_FTIME)
-#include <sys/timeb.h>
-#endif
-
-
-#if defined(PTW32_BUILD_INLINED)
-INLINE
-#endif /* PTW32_BUILD_INLINED */
-DWORD
-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)
- struct timespec currSysTime;
- FILETIME ft;
- 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.
- */
-
- /*
- * subtract current system time from abstime in a way that checks
- * that abstime is never in the past, or is never equivalent to the
- * defined INFINITE value (0xFFFFFFFF).
- *
- * 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;
-
- /* get current system time */
-
-#if defined(NEED_FTIME)
-
- GetSystemTime(&st);
- SystemTimeToFileTime(&st, &ft);
- /*
- * GetSystemTimeAsFileTime(&ft); would be faster,
- * but it does not exist on WinCE
- */
-
- ptw32_filetime_to_timespec(&ft, &currSysTime);
-
- tmpCurrMilliseconds = (int64_t)currSysTime.tv_sec * MILLISEC_PER_SEC;
- tmpCurrMilliseconds += ((int64_t)currSysTime.tv_nsec + (NANOSEC_PER_MILLISEC/2))
- / NANOSEC_PER_MILLISEC;
-
-#else /* ! NEED_FTIME */
-
-#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)
- {
- milliseconds = (DWORD) (tmpAbsMilliseconds - tmpCurrMilliseconds);
- if (milliseconds == INFINITE)
- {
- /* Timeouts must be finite */
- milliseconds--;
- }
- }
- else
- {
- /* The abstime given is in the past */
- milliseconds = 0;
- }
-
- return milliseconds;
-}
+++ /dev/null
-/*
- * ptw32_threadReuse.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"
-
-
-/*
- * How it works:
- * A pthread_t is a struct (2x32 bit scalar types on IA-32, 2x64 bit on IA-64)
- * 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 reuse stack is a simple LILO stack managed through a singly
- * linked list element in the ptw32_thread_t.
- *
- * 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,
- *
- * 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.
- *
- * threadDestroyed = (copy.x != ((ptw32_thread_t *)copy.p)->ptHandle.x)
- *
- */
-
-/*
- * Pop a clean pthread_t struct off the reuse stack.
- */
-pthread_t
-ptw32_threadReusePop (void)
-{
- pthread_t t = {NULL, 0};
- ptw32_mcs_local_node_t node;
-
- ptw32_mcs_lock_acquire(&ptw32_thread_reuse_lock, &node);
-
- if (PTW32_THREAD_REUSE_EMPTY != ptw32_threadReuseTop)
- {
- ptw32_thread_t * tp;
-
- tp = ptw32_threadReuseTop;
-
- ptw32_threadReuseTop = tp->prevReuse;
-
- if (PTW32_THREAD_REUSE_EMPTY == ptw32_threadReuseTop)
- {
- ptw32_threadReuseBottom = PTW32_THREAD_REUSE_EMPTY;
- }
-
- tp->prevReuse = NULL;
-
- t = tp->ptHandle;
- }
-
- ptw32_mcs_lock_release(&node);
-
- return t;
-
-}
-
-/*
- * 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.
- */
-void
-ptw32_threadReusePush (pthread_t thread)
-{
- ptw32_thread_t * tp = (ptw32_thread_t *) thread.p;
- pthread_t t;
- ptw32_mcs_local_node_t node;
-
- ptw32_mcs_lock_acquire(&ptw32_thread_reuse_lock, &node);
-
- t = tp->ptHandle;
- 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;
-#else
- tp->ptHandle.x++;
-#endif
-
- tp->state = PThreadStateReuse;
-
- tp->prevReuse = PTW32_THREAD_REUSE_EMPTY;
-
- if (PTW32_THREAD_REUSE_EMPTY != ptw32_threadReuseBottom)
- {
- ptw32_threadReuseBottom->prevReuse = tp;
- }
- else
- {
- ptw32_threadReuseTop = tp;
- }
-
- ptw32_threadReuseBottom = tp;
-
- ptw32_mcs_lock_release(&node);
-}
+++ /dev/null
-/*
- * ptw32_rwlock_cancelwrwait.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 "pthread.h"
-#include "implement.h"
-
-void
-ptw32_rwlock_cancelwrwait (void *arg)
-{
- pthread_rwlock_t rwl = (pthread_rwlock_t) arg;
-
- rwl->nSharedAccessCount = -rwl->nCompletedSharedAccessCount;
- rwl->nCompletedSharedAccessCount = 0;
-
- (void) pthread_mutex_unlock (&(rwl->mtxSharedAccessCompleted));
- (void) pthread_mutex_unlock (&(rwl->mtxExclusiveAccess));
-}
+++ /dev/null
-/*
- * pthread_rwlock_check_need_init.c
- *
- * Description:
- * This translation unit implements read/write lock primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-int
-ptw32_rwlock_check_need_init (pthread_rwlock_t * rwlock)
-{
- int result = 0;
- 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);
-
- /*
- * We got here possibly under race
- * conditions. Check again inside the critical section
- * and only initialise if the rwlock is valid (not been destroyed).
- * If a static rwlock has been destroyed, the application can
- * re-initialise it only by calling pthread_rwlock_init()
- * explicitly.
- */
- if (*rwlock == PTHREAD_RWLOCK_INITIALIZER)
- {
- result = pthread_rwlock_init (rwlock, NULL);
- }
- else if (*rwlock == NULL)
- {
- /*
- * The rwlock has been destroyed while we were waiting to
- * initialise it, so the operation that caused the
- * auto-initialisation should fail.
- */
- result = EINVAL;
- }
-
- ptw32_mcs_lock_release(&node);
-
- return result;
-}
+++ /dev/null
-/*
- * ptw32_semwait.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)
-/*# include <process.h> */
-#endif
-#include "pthread.h"
-#include "implement.h"
-
-
-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.
- *
- * ------------------------------------------------------
- */
-{
- int result = 0;
- sem_t s = *sem;
-
- 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);
-
- 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;
- }
- }
- else
- {
- return 0;
- }
- }
- }
-
- if (result != 0)
- {
- errno = result;
- return -1;
- }
-
- return 0;
-
-} /* ptw32_semwait */
+++ /dev/null
-/*
- * ptw32_spinlock_check_need_init.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"
-
-
-int
-ptw32_spinlock_check_need_init (pthread_spinlock_t * lock)
-{
- int result = 0;
- 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);
-
- /*
- * We got here possibly under race
- * conditions. Check again inside the critical section
- * and only initialise if the spinlock is valid (not been destroyed).
- * If a static spinlock has been destroyed, the application can
- * re-initialise it only by calling pthread_spin_init()
- * explicitly.
- */
- if (*lock == PTHREAD_SPINLOCK_INITIALIZER)
- {
- result = pthread_spin_init (lock, PTHREAD_PROCESS_PRIVATE);
- }
- else if (*lock == NULL)
- {
- /*
- * The spinlock has been destroyed while we were waiting to
- * initialise it, so the operation that caused the
- * auto-initialisation should fail.
- */
- result = EINVAL;
- }
-
- ptw32_mcs_lock_release(&node);
-
- return (result);
-}
+++ /dev/null
-/*
- * ptw32_threadDestroy.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"
-
-
-void
-ptw32_threadDestroy (pthread_t thread)
-{
- ptw32_thread_t * tp = (ptw32_thread_t *) thread.p;
- ptw32_thread_t threadCopy;
-
- if (tp != NULL)
- {
- /*
- * Copy thread state so that the thread can be atomically NULLed.
- */
- memcpy (&threadCopy, tp, sizeof (threadCopy));
-
- /*
- * Thread ID structs are never freed. They're NULLed and reused.
- * This also sets the thread to PThreadStateInitial (invalid).
- */
- ptw32_threadReusePush (thread);
-
- /* Now work on the copy. */
- if (threadCopy.cancelEvent != NULL)
- {
- CloseHandle (threadCopy.cancelEvent);
- }
-
-#if ! (defined(__MINGW64__) || defined(__MINGW32__)) || defined (__MSVCRT__) || defined (__DMC__)
- /*
- * See documentation for endthread vs endthreadex.
- */
- if (threadCopy.threadH != 0)
- {
- CloseHandle (threadCopy.threadH);
- }
-#endif
-
- }
-} /* ptw32_threadDestroy */
-
+++ /dev/null
-/*
- * ptw32_threadStart.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 <stdio.h>
-
-#if defined(__CLEANUP_C)
-# include <setjmp.h>
-#endif
-
-#if defined(__CLEANUP_SEH)
-
-static DWORD
-ExceptionFilter (EXCEPTION_POINTERS * ep, DWORD * ei)
-{
- switch (ep->ExceptionRecord->ExceptionCode)
- {
- case EXCEPTION_PTW32_SERVICES:
- {
- DWORD param;
- DWORD numParams = ep->ExceptionRecord->NumberParameters;
-
- numParams = (numParams > 3) ? 3 : numParams;
-
- for (param = 0; param < numParams; param++)
- {
- ei[param] = ep->ExceptionRecord->ExceptionInformation[param];
- }
-
- return EXCEPTION_EXECUTE_HANDLER;
- break;
- }
- default:
- {
- /*
- * A system unexpected exception has occurred running the user's
- * routine. We need to cleanup before letting the exception
- * out of thread scope.
- */
- pthread_t self = pthread_self ();
-
- ptw32_callUserDestroyRoutines (self);
-
- return EXCEPTION_CONTINUE_SEARCH;
- break;
- }
- }
-}
-
-#elif defined(__CLEANUP_CXX)
-
-#if defined(_MSC_VER)
-# include <eh.h>
-#elif defined(__WATCOMC__)
-# include <eh.h>
-# include <exceptio.h>
-typedef terminate_handler
- terminate_function;
-#else
-# if defined(__GNUC__) && __GNUC__ < 3
-# include <new.h>
-# else
-# include <new>
-using
- std::terminate_handler;
-using
- std::terminate;
-using
- std::set_terminate;
-# endif
-typedef terminate_handler
- terminate_function;
-#endif
-
-static terminate_function
- ptw32_oldTerminate;
-
-void
-ptw32_terminate ()
-{
- set_terminate (ptw32_oldTerminate);
- (void) pthread_win32_thread_detach_np ();
- terminate ();
-}
-
-#endif
-
-#if ! (defined(__MINGW64__) || defined(__MINGW32__)) || (defined (__MSVCRT__) && ! defined (__DMC__))
-unsigned
- __stdcall
-#else
-void
-#endif
-ptw32_threadStart (void *vthreadParms)
-{
- ThreadParms * threadParms = (ThreadParms *) vthreadParms;
- pthread_t self;
- ptw32_thread_t * sp;
- void *(*start) (void *);
- void * arg;
-
-#if defined(__CLEANUP_SEH)
- DWORD
- ei[] = { 0, 0, 0 };
-#endif
-
-#if defined(__CLEANUP_C)
- int setjmp_rc;
-#endif
-
- ptw32_mcs_local_node_t stateLock;
- void * status = (void *) 0;
-
- self = threadParms->tid;
- sp = (ptw32_thread_t *) self.p;
- start = threadParms->start;
- arg = threadParms->arg;
-
- free (threadParms);
-
-#if (defined(__MINGW64__) || defined(__MINGW32__)) && ! defined (__MSVCRT__)
- /*
- * beginthread does not return the thread id and is running
- * before it returns us the thread handle, and so we do it here.
- */
- sp->thread = GetCurrentThreadId ();
- /*
- * 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
-
- sp->state = PThreadStateRunning;
- ptw32_mcs_lock_release (&stateLock);
-
-#if defined(__CLEANUP_SEH)
-
- __try
- {
- /*
- * Run the caller's routine;
- */
- status = sp->exitStatus = (*start) (arg);
- sp->state = PThreadStateExiting;
-
-#if defined(_UWIN)
- if (--pthread_count <= 0)
- exit (0);
-#endif
-
- }
- __except (ExceptionFilter (GetExceptionInformation (), ei))
- {
- switch (ei[0])
- {
- case PTW32_EPS_CANCEL:
- status = sp->exitStatus = PTHREAD_CANCELED;
-#if defined(_UWIN)
- if (--pthread_count <= 0)
- exit (0);
-#endif
- break;
- case PTW32_EPS_EXIT:
- status = sp->exitStatus;
- break;
- default:
- status = sp->exitStatus = PTHREAD_CANCELED;
- break;
- }
- }
-
-#else /* __CLEANUP_SEH */
-
-#if defined(__CLEANUP_C)
-
- setjmp_rc = setjmp (sp->start_mark);
-
- if (0 == setjmp_rc)
- {
-
- /*
- * Run the caller's routine;
- */
- status = sp->exitStatus = (*start) (arg);
- sp->state = PThreadStateExiting;
- }
- 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;
- }
- }
-
-#else /* __CLEANUP_C */
-
-#if defined(__CLEANUP_CXX)
-
- ptw32_oldTerminate = set_terminate (&ptw32_terminate);
-
- try
- {
- /*
- * Run the caller's routine in a nested try block so that we
- * can run the user's terminate function, which may call
- * pthread_exit() or be canceled.
- */
- try
- {
- status = sp->exitStatus = (*start) (arg);
- sp->state = PThreadStateExiting;
- }
- catch (ptw32_exception &)
- {
- /*
- * Pass these through to the outer block.
- */
- throw;
- }
- catch (...)
- {
- /*
- * We want to run the user's terminate function if supplied.
- * That function may call pthread_exit() or be canceled, which will
- * be handled by the outer try block.
- *
- * ptw32_terminate() will be called if there is no user
- * supplied function.
- */
- terminate_function
- term_func = set_terminate (0);
- set_terminate (term_func);
-
- if (term_func != 0)
- {
- term_func ();
- }
- throw;
- }
- }
- catch (ptw32_exception_cancel &)
- {
- /*
- * Thread was canceled.
- */
- status = sp->exitStatus = PTHREAD_CANCELED;
- }
- catch (ptw32_exception_exit &)
- {
- /*
- * Thread was exited via pthread_exit().
- */
- status = sp->exitStatus;
- }
- 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.
- */
- status = sp->exitStatus = PTHREAD_CANCELED;
- }
-
- (void) set_terminate (ptw32_oldTerminate);
-
-#else
-
-#error ERROR [__FILE__, line __LINE__]: Cleanup type undefined.
-
-#endif /* __CLEANUP_CXX */
-#endif /* __CLEANUP_C */
-#endif /* __CLEANUP_SEH */
-
-#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
- * only be partially cleaned up and must be fully cleaned
- * up by pthread_join() or pthread_detach().
- *
- * Note: if this library has been statically linked,
- * 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.
- */
- (void) pthread_win32_thread_detach_np ();
-#endif
-
-#if ! (defined(__MINGW64__) || defined(__MINGW32__)) || defined (__MSVCRT__) || defined (__DMC__)
- _endthreadex ((unsigned)(size_t) status);
-#else
- _endthread ();
-#endif
-
- /*
- * Never reached.
- */
-
-#if ! (defined(__MINGW64__) || defined(__MINGW32__)) || defined (__MSVCRT__) || defined (__DMC__)
- return (unsigned)(size_t) status;
-#endif
-
-} /* ptw32_threadStart */
+++ /dev/null
-/*
- * ptw32_throw.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"
-
-#if defined(__CLEANUP_C)
-# include <setjmp.h>
-#endif
-
-/*
- * ptw32_throw
- *
- * All canceled 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
-{
- /*
- * 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);
-
-#if defined(__CLEANUP_SEH)
- DWORD exceptionInformation[3];
-#endif
-
- sp->state = PThreadStateExiting;
-
- if (exception != PTW32_EPS_CANCEL && exception != PTW32_EPS_EXIT)
- {
- /* Should never enter here */
- exit (1);
- }
-
- if (NULL == sp || sp->implicit)
- {
- /*
- * We're inside a non-POSIX initialised Win32 thread
- * so there is no point to jump or throw back to. Just do an
- * 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__)
- 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;
- }
-#endif
-
-#if defined(PTW32_STATIC_LIB)
-
- pthread_win32_thread_detach_np ();
-
-#endif
-
-#if ! (defined(__MINGW64__) || defined(__MINGW32__)) || defined (__MSVCRT__) || defined (__DMC__)
- _endthreadex (exitCode);
-#else
- _endthread ();
-#endif
-
- }
-
-#if defined(__CLEANUP_SEH)
-
-
- exceptionInformation[0] = (DWORD) (exception);
- exceptionInformation[1] = (DWORD) (0);
- exceptionInformation[2] = (DWORD) (0);
-
- RaiseException (EXCEPTION_PTW32_SERVICES, 0, 3, exceptionInformation);
-
-#else /* __CLEANUP_SEH */
-
-#if defined(__CLEANUP_C)
-
- ptw32_pop_cleanup_all (1);
- longjmp (sp->start_mark, exception);
-
-#else /* __CLEANUP_C */
-
-#if defined(__CLEANUP_CXX)
-
- switch (exception)
- {
- case PTW32_EPS_CANCEL:
- throw ptw32_exception_cancel ();
- break;
- case PTW32_EPS_EXIT:
- throw ptw32_exception_exit ();
- break;
- }
-
-#else
-
-#error ERROR [__FILE__, line __LINE__]: Cleanup type undefined.
-
-#endif /* __CLEANUP_CXX */
-
-#endif /* __CLEANUP_C */
-
-#endif /* __CLEANUP_SEH */
-
- /* Never reached */
-}
-
-
-void
-ptw32_pop_cleanup_all (int execute)
-{
- while (NULL != ptw32_pop_cleanup (execute))
- {
- }
-}
-
-
-DWORD
-ptw32_get_exception_services_code (void)
-{
-#if defined(__CLEANUP_SEH)
-
- return EXCEPTION_PTW32_SERVICES;
-
-#else
-
- return (DWORD)0;
-
-#endif
-}
+++ /dev/null
-/*
- * ptw32_timespec.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"
-
-
-#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 )
-
-INLINE void
-ptw32_timespec_to_filetime (const struct timespec *ts, FILETIME * ft)
- /*
- * -------------------------------------------------------------------
- * converts struct timespec
- * where the time is expressed in seconds and nanoseconds from Jan 1, 1970.
- * into FILETIME (as set by GetSystemTimeAsFileTime), where the time is
- * expressed in 100 nanoseconds from Jan 1, 1601,
- * -------------------------------------------------------------------
- */
-{
- *(int64_t *) ft = ts->tv_sec * 10000000
- + (ts->tv_nsec + 50) / 100 + PTW32_TIMESPEC_TO_FILETIME_OFFSET;
-}
-
-INLINE void
-ptw32_filetime_to_timespec (const FILETIME * ft, struct timespec *ts)
- /*
- * -------------------------------------------------------------------
- * converts FILETIME (as set by GetSystemTimeAsFileTime), where the time is
- * expressed in 100 nanoseconds from Jan 1, 1601,
- * into struct timespec
- * where the time is expressed in seconds and nanoseconds from Jan 1, 1970.
- * -------------------------------------------------------------------
- */
-{
- ts->tv_sec =
- (int) ((*(int64_t *) ft - PTW32_TIMESPEC_TO_FILETIME_OFFSET) / 10000000);
- ts->tv_nsec =
- (int) ((*(int64_t *) ft - PTW32_TIMESPEC_TO_FILETIME_OFFSET -
- ((int64_t) ts->tv_sec * (int64_t) 10000000)) * 100);
-}
-
-#endif /* NEED_FTIME */
+++ /dev/null
-/*
- * ptw32_tkAssocCreate.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"
-
-
-int
-ptw32_tkAssocCreate (ptw32_thread_t * sp, pthread_key_t key)
- /*
- * -------------------------------------------------------------------
- * This routine creates an association that
- * is unique for the given (thread,key) combination.The association
- * is referenced by both the thread and the key.
- * This association allows us to determine what keys the
- * current thread references and what threads a given key
- * references.
- * See the detailed description
- * at the beginning of this file for further details.
- *
- * Notes:
- * 1) New associations are pushed to the beginning of the
- * chain so that the internal ptw32_selfThreadKey association
- * is always last, thus allowing selfThreadExit to
- * be implicitly called last by pthread_exit.
- * 2)
- *
- * Parameters:
- * thread
- * current running thread.
- * key
- * key on which to create an association.
- * Returns:
- * 0 - if successful,
- * ENOMEM - not enough memory to create assoc or other object
- * EINVAL - an internal error occurred
- * ENOSYS - an internal error occurred
- * -------------------------------------------------------------------
- */
-{
- ThreadKeyAssoc *assoc;
-
- /*
- * Have to create an association and add it
- * to both the key and the thread.
- *
- * Both key->keyLock and thread->threadLock are locked before
- * entry to this routine.
- */
- assoc = (ThreadKeyAssoc *) calloc (1, sizeof (*assoc));
-
- if (assoc == NULL)
- {
- return ENOMEM;
- }
-
- assoc->thread = sp;
- assoc->key = key;
-
- /*
- * Register assoc with key
- */
- assoc->prevThread = NULL;
- assoc->nextThread = (ThreadKeyAssoc *) key->threads;
- if (assoc->nextThread != NULL)
- {
- assoc->nextThread->prevThread = assoc;
- }
- key->threads = (void *) assoc;
-
- /*
- * Register assoc with thread
- */
- assoc->prevKey = NULL;
- assoc->nextKey = (ThreadKeyAssoc *) sp->keys;
- if (assoc->nextKey != NULL)
- {
- assoc->nextKey->prevKey = assoc;
- }
- sp->keys = (void *) assoc;
-
- return (0);
-
-} /* ptw32_tkAssocCreate */
+++ /dev/null
-/*
- * ptw32_tkAssocDestroy.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"
-
-
-void
-ptw32_tkAssocDestroy (ThreadKeyAssoc * assoc)
- /*
- * -------------------------------------------------------------------
- * This routine releases all resources for the given ThreadKeyAssoc
- * once it is no longer being referenced
- * ie) either the key or thread has stopped referencing it.
- *
- * Parameters:
- * assoc
- * an instance of ThreadKeyAssoc.
- * Returns:
- * N/A
- * -------------------------------------------------------------------
- */
-{
-
- /*
- * Both key->keyLock and thread->threadLock are locked before
- * entry to this routine.
- */
- if (assoc != NULL)
- {
- ThreadKeyAssoc * prev, * next;
-
- /* Remove assoc from thread's keys chain */
- prev = assoc->prevKey;
- next = assoc->nextKey;
- if (prev != NULL)
- {
- prev->nextKey = next;
- }
- if (next != NULL)
- {
- next->prevKey = prev;
- }
-
- if (assoc->thread->keys == assoc)
- {
- /* We're at the head of the thread's keys chain */
- assoc->thread->keys = next;
- }
- if (assoc->thread->nextAssoc == assoc)
- {
- /*
- * Thread is exiting and we're deleting the assoc to be processed next.
- * Hand thread the assoc after this one.
- */
- assoc->thread->nextAssoc = next;
- }
-
- /* Remove assoc from key's threads chain */
- prev = assoc->prevThread;
- next = assoc->nextThread;
- if (prev != NULL)
- {
- prev->nextThread = next;
- }
- if (next != NULL)
- {
- next->prevThread = prev;
- }
-
- if (assoc->key->threads == assoc)
- {
- /* We're at the head of the key's threads chain */
- assoc->key->threads = next;
- }
-
- free (assoc);
- }
-
-} /* ptw32_tkAssocDestroy */
+++ /dev/null
-/*
- * 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"
+++ /dev/null
-/*
- * 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"
+++ /dev/null
-/*
- * Module: sched.h
- *
- * Purpose:
- * Provides an implementation of POSIX realtime extensions
- * 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
- *
- * The 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(_SCHED_H)
-#define _SCHED_H
-
-#undef PTW32_SCHED_LEVEL
-
-#if defined(_POSIX_SOURCE)
-#define PTW32_SCHED_LEVEL 0
-/* Early POSIX */
-#endif
-
-#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309
-#undef PTW32_SCHED_LEVEL
-#define PTW32_SCHED_LEVEL 1
-/* Include 1b, 1c and 1d */
-#endif
-
-#if defined(INCLUDE_NP)
-#undef PTW32_SCHED_LEVEL
-#define PTW32_SCHED_LEVEL 2
-/* Include Non-Portable extensions */
-#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 */
-#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
-
-/*
- *
- */
-
-#if PTW32_SCHED_LEVEL >= PTW32_SCHED_LEVEL_MAX
-#if defined(NEED_ERRNO)
-#include "need_errno.h"
-#else
-#include <errno.h>
-#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 <sys/types.h>
-/* Required by Unix 98 */
-# include <time.h>
-# else
- typedef int pid_t;
-# endif
-#else
- typedef int pid_t;
-#endif
-
-/* Thread scheduling policies */
-
-enum {
- SCHED_OTHER = 0,
- SCHED_FIFO,
- SCHED_RR,
- SCHED_MIN = SCHED_OTHER,
- SCHED_MAX = SCHED_RR
-};
-
-struct sched_param {
- int sched_priority;
-};
-
-#if defined(__cplusplus)
-extern "C"
-{
-#endif /* __cplusplus */
-
-PTW32_DLLPORT int __cdecl sched_yield (void);
-
-PTW32_DLLPORT int __cdecl sched_get_priority_min (int policy);
-
-PTW32_DLLPORT int __cdecl sched_get_priority_max (int policy);
-
-PTW32_DLLPORT int __cdecl sched_setscheduler (pid_t pid, int policy);
-
-PTW32_DLLPORT int __cdecl sched_getscheduler (pid_t pid);
-
-/*
- * 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.
- */
-#define sched_rr_get_interval(_pid, _interval) \
- ( errno = ENOTSUP, (int) -1 )
-
-
-#if defined(__cplusplus)
-} /* End of extern "C" */
-#endif /* __cplusplus */
-
-#undef PTW32_SCHED_LEVEL
-#undef PTW32_SCHED_LEVEL_MAX
-
-#endif /* !_SCHED_H */
-
+++ /dev/null
-/*
- * sched_get_priority_max.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"
-
-/*
- * On Windows98, THREAD_PRIORITY_LOWEST is (-2) and
- * THREAD_PRIORITY_HIGHEST is 2, and everything works just fine.
- *
- * On WinCE 3.0, it so happen that THREAD_PRIORITY_LOWEST is 5
- * and THREAD_PRIORITY_HIGHEST is 1 (yes, I know, it is funny:
- * highest priority use smaller numbers) and the following happens:
- *
- * sched_get_priority_min() returns 5
- * sched_get_priority_max() returns 1
- *
- * 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.
- */
-
-
-int
-sched_get_priority_max (int policy)
-{
- if (policy < SCHED_MIN || policy > SCHED_MAX)
- {
- errno = EINVAL;
- return -1;
- }
-
-#if (THREAD_PRIORITY_LOWEST > THREAD_PRIORITY_NORMAL)
- /* WinCE? */
- 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);
-#endif
-}
+++ /dev/null
-/*
- * sched_get_priority_min.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"
-
-/*
- * On Windows98, THREAD_PRIORITY_LOWEST is (-2) and
- * THREAD_PRIORITY_HIGHEST is 2, and everything works just fine.
- *
- * On WinCE 3.0, it so happen that THREAD_PRIORITY_LOWEST is 5
- * and THREAD_PRIORITY_HIGHEST is 1 (yes, I know, it is funny:
- * highest priority use smaller numbers) and the following happens:
- *
- * sched_get_priority_min() returns 5
- * sched_get_priority_max() returns 1
- *
- * 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.
- *
- */
-
-
-int
-sched_get_priority_min (int policy)
-{
- if (policy < SCHED_MIN || policy > SCHED_MAX)
- {
- errno = EINVAL;
- return -1;
- }
-
-#if (THREAD_PRIORITY_LOWEST > THREAD_PRIORITY_NORMAL)
- /* WinCE? */
- 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);
-#endif
-}
+++ /dev/null
-/*
- * sched_getscheduler.c
- *
- * Description:
- * POSIX thread functions that deal with thread scheduling.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-#include "sched.h"
-
-int
-sched_getscheduler (pid_t pid)
-{
- /*
- * Win32 only has one policy which we call SCHED_OTHER.
- * However, we try to provide other valid side-effects
- * such as EPERM and ESRCH errors.
- */
- if (0 != pid)
- {
- int selfPid = (int) GetCurrentProcessId ();
-
- if (pid != selfPid)
- {
- HANDLE h =
- OpenProcess (PROCESS_QUERY_INFORMATION, PTW32_FALSE, (DWORD) pid);
-
- if (NULL == h)
- {
- errno =
- (GetLastError () ==
- (0xFF & ERROR_ACCESS_DENIED)) ? EPERM : ESRCH;
- return -1;
- }
- else
- CloseHandle(h);
- }
- }
-
- return SCHED_OTHER;
-}
+++ /dev/null
-/*
- * sched_setscheduler.c
- *
- * Description:
- * POSIX thread functions that deal with thread scheduling.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-#include "sched.h"
-
-int
-sched_setscheduler (pid_t pid, int policy)
-{
- /*
- * Win32 only has one policy which we call SCHED_OTHER.
- * However, we try to provide other valid side-effects
- * such as EPERM and ESRCH errors. Choosing to check
- * for a valid policy last allows us to get the most value out
- * of this function.
- */
- if (0 != pid)
- {
- int selfPid = (int) GetCurrentProcessId ();
-
- if (pid != selfPid)
- {
- HANDLE h =
- OpenProcess (PROCESS_SET_INFORMATION, PTW32_FALSE, (DWORD) pid);
-
- if (NULL == h)
- {
- errno =
- (GetLastError () ==
- (0xFF & ERROR_ACCESS_DENIED)) ? EPERM : ESRCH;
- return -1;
- }
- else
- CloseHandle(h);
- }
- }
-
- if (SCHED_OTHER != policy)
- {
- errno = ENOSYS;
- return -1;
- }
-
- /*
- * Don't set anything because there is nothing to set.
- * Just return the current (the only possible) value.
- */
- return SCHED_OTHER;
-}
+++ /dev/null
-/*
- * sched_yield.c
- *
- * Description:
- * POSIX thread functions that deal with thread scheduling.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-#include "sched.h"
-
-int
-sched_yield (void)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * This function indicates that the calling thread is
- * willing to give up some time slices to other threads.
- *
- * PARAMETERS
- * N/A
- *
- *
- * DESCRIPTION
- * This function indicates that the calling thread is
- * willing to give up some time slices to other threads.
- * NOTE: Since this is part of POSIX 1003.1b
- * (realtime extensions), it is defined as returning
- * -1 if an error occurs and sets errno to the actual
- * error.
- *
- * RESULTS
- * 0 successfully created semaphore,
- * ENOSYS sched_yield not supported,
- *
- * ------------------------------------------------------
- */
-{
- Sleep (0);
-
- return 0;
-}
+++ /dev/null
-/*
- * -------------------------------------------------------------
- *
- * Module: sem_close.c
- *
- * Purpose:
- * 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
- */
-
-#include "pthread.h"
-#include "semaphore.h"
-#include "implement.h"
-
-/* ignore warning "unreferenced formal parameter" */
-#if defined(_MSC_VER)
-#pragma warning( disable : 4100 )
-#endif
-
-int
-sem_close (sem_t * sem)
-{
- errno = ENOSYS;
- return -1;
-} /* sem_close */
+++ /dev/null
-/*
- * -------------------------------------------------------------
- *
- * Module: sem_destroy.c
- *
- * Purpose:
- * 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
- */
-
-#include "pthread.h"
-#include "semaphore.h"
-#include "implement.h"
-
-
-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'
- *
- * ------------------------------------------------------
- */
-{
- int result = 0;
- sem_t s = NULL;
-
- if (sem == NULL || *sem == NULL)
- {
- result = EINVAL;
- }
- else
- {
- s = *sem;
-
- if ((result = pthread_mutex_lock (&s->lock)) == 0)
- {
- if (s->value < 0)
- {
- (void) pthread_mutex_unlock (&s->lock);
- result = EBUSY;
- }
- else
- {
- /* There are no threads currently blocked on this semaphore. */
-
- 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);
- }
- }
- }
- }
-
- if (result != 0)
- {
- errno = result;
- return -1;
- }
-
- free (s);
-
- return 0;
-
-} /* sem_destroy */
+++ /dev/null
-/*
- * -------------------------------------------------------------
- *
- * Module: sem_getvalue.c
- *
- * Purpose:
- * Semaphores aren't actually part of PThreads.
- * They are defined by the POSIX Standard:
- *
- * 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 "pthread.h"
-#include "semaphore.h"
-#include "implement.h"
-
-
-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.
- */
-{
- if (sem == NULL || *sem == NULL || sval == NULL)
- {
- errno = EINVAL;
- return -1;
- }
- else
- {
- long value;
- register sem_t s = *sem;
- int result = 0;
-
- if ((result = pthread_mutex_lock(&s->lock)) == 0)
- {
- /* See sem_destroy.c
- */
- if (*sem == NULL)
- {
- (void) pthread_mutex_unlock (&s->lock);
- errno = EINVAL;
- return -1;
- }
-
- value = s->value;
- (void) pthread_mutex_unlock(&s->lock);
- *sval = value;
- }
-
- return result;
- }
-
-} /* sem_getvalue */
+++ /dev/null
-/*
- * -------------------------------------------------------------
- *
- * Module: sem_init.c
- *
- * Purpose:
- * Semaphores aren't actually part of PThreads.
- * They are defined by the POSIX Standard:
- *
- * 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 "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
- *
- * ------------------------------------------------------
- */
-{
- int result = 0;
- sem_t s = NULL;
-
- if (pshared != 0)
- {
- /*
- * Creating a semaphore that can be shared between
- * processes
- */
- result = EPERM;
- }
- else if (value > (unsigned int)SEM_VALUE_MAX)
- {
- result = EINVAL;
- }
- else
- {
- s = (sem_t) calloc (1, sizeof (*s));
-
- if (NULL == s)
- {
- result = ENOMEM;
- }
- else
- {
-
- s->value = value;
- if (pthread_mutex_init(&s->lock, NULL) == 0)
- {
-
-#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;
- }
-
-#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;
- }
-
-#endif /* NEED_SEM */
-
- }
- else
- {
- result = ENOSPC;
- }
-
- if (result != 0)
- {
- free(s);
- }
- }
- }
-
- if (result != 0)
- {
- errno = result;
- return -1;
- }
-
- *sem = s;
-
- return 0;
-
-} /* sem_init */
+++ /dev/null
-/*
- * -------------------------------------------------------------
- *
- * Module: sem_open.c
- *
- * Purpose:
- * 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
- */
-
-#include "pthread.h"
-#include "semaphore.h"
-#include "implement.h"
-
-/* ignore warning "unreferenced formal parameter" */
-#if defined(_MSC_VER)
-#pragma warning( disable : 4100 )
-#endif
-
-int
-sem_open (const char *name, int oflag, mode_t mode, unsigned int value)
-{
- errno = ENOSYS;
- return -1;
-} /* sem_open */
+++ /dev/null
-/*
- * -------------------------------------------------------------
- *
- * Module: sem_post.c
- *
- * Purpose:
- * 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
- */
-
-#include "pthread.h"
-#include "semaphore.h"
-#include "implement.h"
-
-
-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
- *
- * ------------------------------------------------------
- */
-{
- int result = 0;
- sem_t s = *sem;
-
- if (s == NULL)
- {
- result = EINVAL;
- }
- else if ((result = pthread_mutex_lock (&s->lock)) == 0)
- {
- /* See sem_destroy.c
- */
- if (*sem == NULL)
- {
- (void) pthread_mutex_unlock (&s->lock);
- result = EINVAL;
- return -1;
- }
-
- if (s->value < SEM_VALUE_MAX)
- {
-#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;
- }
-#endif /* NEED_SEM */
- }
- else
- {
- result = ERANGE;
- }
-
- (void) pthread_mutex_unlock (&s->lock);
- }
-
- if (result != 0)
- {
- errno = result;
- return -1;
- }
-
- return 0;
-
-} /* sem_post */
+++ /dev/null
-/*
- * -------------------------------------------------------------
- *
- * Module: sem_post_multiple.c
- *
- * Purpose:
- * 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
- */
-
-#include "pthread.h"
-#include "semaphore.h"
-#include "implement.h"
-
-
-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
- *
- * ------------------------------------------------------
- */
-{
- 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)
- {
- /* See sem_destroy.c
- */
- if (*sem == NULL)
- {
- (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;
- }
- }
-#else
- 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);
- }
-
- if (result != 0)
- {
- errno = result;
- return -1;
- }
-
- return 0;
-
-} /* sem_post_multiple */
+++ /dev/null
-/*
- * -------------------------------------------------------------
- *
- * Module: sem_timedwait.c
- *
- * Purpose:
- * 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
- */
-
-#include "pthread.h"
-#include "semaphore.h"
-#include "implement.h"
-
-
-typedef struct {
- sem_t sem;
- int * resultPtr;
-} sem_timedwait_cleanup_args_t;
-
-
-static void PTW32_CDECL
-ptw32_sem_timedwait_cleanup (void * args)
-{
- sem_timedwait_cleanup_args_t * a = (sem_timedwait_cleanup_args_t *)args;
- sem_t s = a->sem;
-
- if (pthread_mutex_lock (&s->lock) == 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++;
-#if defined(NEED_SEM)
- 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.
- */
-#endif
- }
- (void) pthread_mutex_unlock (&s->lock);
- }
-}
-
-
-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.
- *
- * ------------------------------------------------------
- */
-{
- int result = 0;
- sem_t s = *sem;
-
- pthread_testcancel();
-
- if (sem == NULL)
- {
- result = EINVAL;
- }
- 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)
- {
-#if defined(NEED_SEM)
- int timedout;
-#endif
- sem_timedwait_cleanup_args_t cleanup_args;
-
- cleanup_args.sem = s;
- cleanup_args.resultPtr = &result;
-
-#if defined(_MSC_VER) && _MSC_VER < 1400
-#pragma inline_depth(0)
-#endif
- /* Must wait */
- pthread_cleanup_push(ptw32_sem_timedwait_cleanup, (void *) &cleanup_args);
-#if defined(NEED_SEM)
- timedout =
-#endif
- result = pthreadCancelableTimedWait (s->sem, milliseconds);
- pthread_cleanup_pop(result);
-#if defined(_MSC_VER) && _MSC_VER < 1400
-#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);
- }
-
-#endif /* NEED_SEM */
-
- }
- }
-
- }
-
- if (result != 0)
- {
-
- errno = result;
- return -1;
-
- }
-
- return 0;
-
-} /* sem_timedwait */
+++ /dev/null
-/*
- * -------------------------------------------------------------
- *
- * Module: sem_trywait.c
- *
- * Purpose:
- * 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
- */
-
-#include "pthread.h"
-#include "semaphore.h"
-#include "implement.h"
-
-
-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.
- *
- * ------------------------------------------------------
- */
-{
- int result = 0;
- sem_t s = *sem;
-
- if (s == NULL)
- {
- result = EINVAL;
- }
- else 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;
- }
-
- if (s->value > 0)
- {
- s->value--;
- }
- else
- {
- result = EAGAIN;
- }
-
- (void) pthread_mutex_unlock (&s->lock);
- }
-
- if (result != 0)
- {
- errno = result;
- return -1;
- }
-
- return 0;
-
-} /* sem_trywait */
+++ /dev/null
-/*
- * -------------------------------------------------------------
- *
- * Module: sem_unlink.c
- *
- * Purpose:
- * 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
- */
-
-#include "pthread.h"
-#include "semaphore.h"
-#include "implement.h"
-
-/* ignore warning "unreferenced formal parameter" */
-#if defined(_MSC_VER)
-#pragma warning( disable : 4100 )
-#endif
-
-int
-sem_unlink (const char *name)
-{
- errno = ENOSYS;
- return -1;
-} /* sem_unlink */
+++ /dev/null
-/*
- * -------------------------------------------------------------
- *
- * Module: sem_wait.c
- *
- * Purpose:
- * 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
- */
-
-#include "pthread.h"
-#include "semaphore.h"
-#include "implement.h"
-
-
-static void PTW32_CDECL
-ptw32_sem_wait_cleanup(void * sem)
-{
- sem_t s = (sem_t) sem;
-
- if (pthread_mutex_lock (&s->lock) == 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;
-#if defined(NEED_SEM)
- 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.
- */
-#endif /* NEED_SEM */
- }
- (void) pthread_mutex_unlock (&s->lock);
- }
-}
-
-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.
- *
- * ------------------------------------------------------
- */
-{
- 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);
-
- if (v < 0)
- {
-#if defined(_MSC_VER) && _MSC_VER < 1400
-#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
-#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);
- }
-
-#endif /* NEED_SEM */
-
- }
-
- }
-
- if (result != 0)
- {
- errno = result;
- return -1;
- }
-
- return 0;
-
-} /* sem_wait */
+++ /dev/null
-/*
- * -------------------------------------------------------------
- *
- * 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 <sys/timeb.h>
-#endif
-
-#include <limits.h>
-
-#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"
+++ /dev/null
-/*
- * Module: semaphore.h
- *
- * Purpose:
- * 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( 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
-
-/*
- *
- */
-
-#if PTW32_SEMAPHORE_LEVEL >= PTW32_SEMAPHORE_LEVEL_MAX
-#if defined(NEED_ERRNO)
-#include "need_errno.h"
-#else
-#include <errno.h>
-#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
-
-
-typedef struct sem_t_ * sem_t;
-
-PTW32_DLLPORT int __cdecl sem_init (sem_t * sem,
- int pshared,
- unsigned int value);
-
-PTW32_DLLPORT int __cdecl sem_destroy (sem_t * sem);
-
-PTW32_DLLPORT int __cdecl sem_trywait (sem_t * sem);
-
-PTW32_DLLPORT int __cdecl sem_wait (sem_t * sem);
-
-PTW32_DLLPORT int __cdecl sem_timedwait (sem_t * sem,
- const struct timespec * abstime);
-
-PTW32_DLLPORT int __cdecl sem_post (sem_t * sem);
-
-PTW32_DLLPORT int __cdecl sem_post_multiple (sem_t * sem,
- int count);
-
-PTW32_DLLPORT int __cdecl sem_open (const char * name,
- int oflag,
- mode_t mode,
- unsigned int value);
-
-PTW32_DLLPORT int __cdecl sem_close (sem_t * sem);
-
-PTW32_DLLPORT int __cdecl sem_unlink (const char * name);
-
-PTW32_DLLPORT int __cdecl sem_getvalue (sem_t * sem,
- int * sval);
-
-#if defined(__cplusplus)
-} /* End of extern "C" */
-#endif /* __cplusplus */
-
-#undef PTW32_SEMAPHORE_LEVEL
-#undef PTW32_SEMAPHORE_LEVEL_MAX
-
-#endif /* !SEMAPHORE_H */
+++ /dev/null
-/*
- * signal.c
- *
- * Description:
- * Thread-aware signal 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
- */
-
-/*
- * Possible future strategy for implementing pthread_kill()
- * ========================================================
- *
- * Win32 does not implement signals.
- * Signals are simply software interrupts.
- * pthread_kill() asks the system to deliver a specified
- * signal (interrupt) to a specified thread in the same
- * process.
- * Signals are always asynchronous (no deferred signals).
- * Pthread-win32 has an async cancelation mechanism.
- * A similar system can be written to deliver signals
- * within the same process (on ix86 processors at least).
- *
- * Each thread maintains information about which
- * signals it will respond to. Handler routines
- * are set on a per-process basis - not per-thread.
- * When signalled, a thread will check it's sigmask
- * and, if the signal is not being ignored, call the
- * handler routine associated with the signal. The
- * thread must then (except for some signals) return to
- * the point where it was interrupted.
- *
- * Ideally the system itself would check the target thread's
- * mask before possibly needlessly bothering the thread
- * itself. This could be done by pthread_kill(), that is,
- * in the signaling thread since it has access to
- * all pthread_t structures. It could also retrieve
- * the handler routine address to minimise the target
- * threads response overhead. This may also simplify
- * serialisation of the access to the per-thread signal
- * structures.
- *
- * pthread_kill() eventually calls a routine similar to
- * 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
- * handler launcher routine can restore the context after
- * the signal handler has returned. Some handlers will not
- * return, eg. the default SIGKILL handler may simply
- * call pthread_exit().
- *
- * The current context is saved in the target threads
- * pthread_t structure.
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-#if defined(HAVE_SIGSET_T)
-
-static void
-ptw32_signal_thread ()
-{
-}
-
-static void
-ptw32_signal_callhandler ()
-{
-}
-
-int
-pthread_sigmask (int how, sigset_t const *set, sigset_t * oset)
-{
- pthread_t thread = pthread_self ();
-
- if (thread.p == NULL)
- {
- return ENOENT;
- }
-
- /* Validate the `how' argument. */
- if (set != NULL)
- {
- switch (how)
- {
- case SIG_BLOCK:
- break;
- case SIG_UNBLOCK:
- break;
- case SIG_SETMASK:
- break;
- default:
- /* Invalid `how' argument. */
- return EINVAL;
- }
- }
-
- /* Copy the old mask before modifying it. */
- if (oset != NULL)
- {
- memcpy (oset, &(thread.p->sigmask), sizeof (sigset_t));
- }
-
- if (set != NULL)
- {
- unsigned int i;
-
- /* FIXME: this code assumes that sigmask is an even multiple of
- the size of a long integer. */
-
- unsigned long *src = (unsigned long const *) set;
- unsigned long *dest = (unsigned long *) &(thread.p->sigmask);
-
- switch (how)
- {
- case SIG_BLOCK:
- for (i = 0; i < (sizeof (sigset_t) / sizeof (unsigned long)); i++)
- {
- /* OR the bit field longword-wise. */
- *dest++ |= *src++;
- }
- break;
- case SIG_UNBLOCK:
- for (i = 0; i < (sizeof (sigset_t) / sizeof (unsigned long)); i++)
- {
- /* XOR the bitfield longword-wise. */
- *dest++ ^= *src++;
- }
- case SIG_SETMASK:
- /* Replace the whole sigmask. */
- memcpy (&(thread.p->sigmask), set, sizeof (sigset_t));
- break;
- }
- }
-
- return 0;
-}
-
-int
-sigwait (const sigset_t * set, int *sig)
-{
- /* This routine is a cancellation point */
- pthread_test_cancel();
-}
-
-int
-sigaction (int signum, const struct sigaction *act, struct sigaction *oldact)
-{
-}
-
-#endif /* HAVE_SIGSET_T */
+++ /dev/null
-/*
- * 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"
+++ /dev/null
-/*
- * 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"
+++ /dev/null
-/*
- * 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"
+++ /dev/null
-/* This is an implementation of the threads API of POSIX 1003.1-2001.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include <winver.h>
-#include "pthread.h"
-
-/*
- * Note: the correct __CLEANUP_* macro must be defined corresponding to
- * the definition used for the object file builds. This is done in the
- * relevent makefiles for the command line builds, but users should ensure
- * that their resource compiler knows what it is too.
- * If using the default (no __CLEANUP_* defined), pthread.h will define it
- * as __CLEANUP_C.
- */
-#if defined(_WIN64)
-# define PTW32_ARCH "64 bit"
-#else
-# define PTW32_ARCH "32 bit"
-#endif
-
-#if defined(PTW32_RC_MSC)
-# if defined(__CLEANUP_C)
-# define PTW32_VERSIONINFO_NAME "pthreadVC\0"
-# define PTW32_VERSIONINFO_DESCRIPTION "MS C " PTW32_ARCH "\0"
-# elif defined(__CLEANUP_CXX)
-# define PTW32_VERSIONINFO_NAME "pthreadVCE\0"
-# define PTW32_VERSIONINFO_DESCRIPTION "MS C++ " PTW32_ARCH "\0"
-# elif defined(__CLEANUP_SEH)
-# define PTW32_VERSIONINFO_NAME "pthreadVSE\0"
-# define PTW32_VERSIONINFO_DESCRIPTION "MS C SEH " PTW32_ARCH "\0"
-# else
-# error Resource compiler doesn't know which cleanup style you're using - see version.rc
-# endif
-#elif defined(__GNUC__)
-# if defined(__CLEANUP_C)
-# define PTW32_VERSIONINFO_NAME "pthreadGC\0"
-# define PTW32_VERSIONINFO_DESCRIPTION "GNU C " PTW32_ARCH "\0"
-# elif defined(__CLEANUP_CXX)
-# define PTW32_VERSIONINFO_NAME "pthreadGCE\0"
-# define PTW32_VERSIONINFO_DESCRIPTION "GNU C++ " PTW32_ARCH "\0"
-# else
-# error Resource compiler doesn't know which cleanup style you're using - see version.rc
-# endif
-#elif defined(__BORLANDC__)
-# if defined(__CLEANUP_C)
-# define PTW32_VERSIONINFO_NAME "pthreadBC\0"
-# define PTW32_VERSIONINFO_DESCRIPTION "BORLAND C " PTW32_ARCH "\0"
-# elif defined(__CLEANUP_CXX)
-# define PTW32_VERSIONINFO_NAME "pthreadBCE\0"
-# define PTW32_VERSIONINFO_DESCRIPTION "BORLAND C++ " PTW32_ARCH "\0"
-# else
-# error Resource compiler doesn't know which cleanup style you're using - see version.rc
-# endif
-#elif defined(__WATCOMC__)
-# if defined(__CLEANUP_C)
-# define PTW32_VERSIONINFO_NAME "pthreadWC\0"
-# define PTW32_VERSIONINFO_DESCRIPTION "WATCOM C " PTW32_ARCH "\0"
-# elif defined(__CLEANUP_CXX)
-# define PTW32_VERSIONINFO_NAME "pthreadWCE\0"
-# define PTW32_VERSIONINFO_DESCRIPTION "WATCOM C++ " PTW32_ARCH "\0"
-# else
-# error Resource compiler doesn't know which cleanup style you're using - see version.rc
-# endif
-#else
-# error Resource compiler doesn't know which compiler you're using - see version.rc
-#endif
-
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION PTW32_VERSION
- PRODUCTVERSION PTW32_VERSION
- FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
- FILEFLAGS 0
- FILEOS VOS__WINDOWS32
- FILETYPE VFT_DLL
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "040904b0"
- BEGIN
- VALUE "ProductName", "POSIX Threads for Windows LPGL\0"
- VALUE "ProductVersion", PTW32_VERSION_STRING
- VALUE "FileVersion", PTW32_VERSION_STRING
- VALUE "FileDescription", PTW32_VERSIONINFO_DESCRIPTION
- VALUE "InternalName", PTW32_VERSIONINFO_NAME
- VALUE "OriginalFilename", PTW32_VERSIONINFO_NAME
- VALUE "CompanyName", "Open Source Software community LGPL\0"
- VALUE "LegalCopyright", "Copyright (C) Project contributors 2011\0"
- VALUE "Comments", "http://sourceware.org/pthreads-win32/\0"
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x409, 1200
- END
-END
-
-/*
-VERSIONINFO Resource
-
-The VERSIONINFO resource-definition statement creates a version-information
-resource. The resource contains such information about the file as its
-version number, its intended operating system, and its original filename.
-The resource is intended to be used with the Version Information functions.
-
-versionID VERSIONINFO fixed-info { block-statement...}
-
-versionID
- Version-information resource identifier. This value must be 1.
-
-fixed-info
- Version information, such as the file version and the intended operating
- system. This parameter consists of the following statements.
-
-
- Statement Description
- --------------------------------------------------------------------------
- FILEVERSION
- version Binary version number for the file. The version
- consists of two 32-bit integers, defined by four
- 16-bit integers. For example, "FILEVERSION 3,10,0,61"
- is translated into two doublewords: 0x0003000a and
- 0x0000003d, in that order. Therefore, if version is
- defined by the DWORD values dw1 and dw2, they need
- to appear in the FILEVERSION statement as follows:
- HIWORD(dw1), LOWORD(dw1), HIWORD(dw2), LOWORD(dw2).
- PRODUCTVERSION
- version Binary version number for the product with which the
- file is distributed. The version parameter is two
- 32-bit integers, defined by four 16-bit integers.
- For more information about version, see the
- FILEVERSION description.
- FILEFLAGSMASK
- fileflagsmask Bits in the FILEFLAGS statement are valid. If a bit
- is set, the corresponding bit in FILEFLAGS is valid.
- FILEFLAGSfileflags Attributes of the file. The fileflags parameter must
- be the combination of all the file flags that are
- valid at compile time. For 16-bit Windows, this
- value is 0x3f.
- FILEOSfileos Operating system for which this file was designed.
- The fileos parameter can be one of the operating
- system values given in the Remarks section.
- FILETYPEfiletype General type of file. The filetype parameter can be
- one of the file type values listed in the Remarks
- section.
- FILESUBTYPE
- subtype Function of the file. The subtype parameter is zero
- unless the type parameter in the FILETYPE statement
- is VFT_DRV, VFT_FONT, or VFT_VXD. For a list of file
- subtype values, see the Remarks section.
-
-block-statement
- Specifies one or more version-information blocks. A block can contain
- string information or variable information. For more information, see
- StringFileInfo Block or VarFileInfo Block.
-
-Remarks
-
-To use the constants specified with the VERSIONINFO statement, you must
-include the Winver.h or Windows.h header file in the resource-definition file.
-
-The following list describes the parameters used in the VERSIONINFO statement:
-
-fileflags
- A combination of the following values.
-
- Value Description
-
- VS_FF_DEBUG File contains debugging information or is compiled
- with debugging features enabled.
- VS_FF_PATCHED File has been modified and is not identical to the
- original shipping file of the same version number.
- VS_FF_PRERELEASE File is a development version, not a commercially
- released product.
- VS_FF_PRIVATEBUILD File was not built using standard release procedures.
- If this value is given, the StringFileInfo block must
- contain a PrivateBuild string.
- VS_FF_SPECIALBUILD File was built by the original company using standard
- release procedures but is a variation of the standard
- file of the same version number. If this value is
- given, the StringFileInfo block must contain a
- SpecialBuild string.
-
-fileos
- One of the following values.
-
- Value Description
-
- VOS_UNKNOWN The operating system for which the file was designed
- is unknown.
- VOS_DOS File was designed for MS-DOS.
- VOS_NT File was designed for Windows Server 2003 family,
- Windows XP, Windows 2000, or Windows NT.
- VOS__WINDOWS16 File was designed for 16-bit Windows.
- VOS__WINDOWS32 File was designed for 32-bit Windows.
- VOS_DOS_WINDOWS16 File was designed for 16-bit Windows running with
- MS-DOS.
- VOS_DOS_WINDOWS32 File was designed for 32-bit Windows running with
- MS-DOS.
- VOS_NT_WINDOWS32 File was designed for Windows Server 2003 family,
- Windows XP, Windows 2000, or Windows NT.
-
- The values 0x00002L, 0x00003L, 0x20000L and 0x30000L are reserved.
-
-filetype
- One of the following values.
-
- Value Description
-
- VFT_UNKNOWN File type is unknown.
- VFT_APP File contains an application.
- VFT_DLL File contains a dynamic-link library (DLL).
- VFT_DRV File contains a device driver. If filetype is
- VFT_DRV, subtype contains a more specific
- description of the driver.
- VFT_FONT File contains a font. If filetype is VFT_FONT,
- subtype contains a more specific description of the
- font.
- VFT_VXD File contains a virtual device.
- VFT_STATIC_LIB File contains a static-link library.
-
- All other values are reserved for use by Microsoft.
-
-subtype
- Additional information about the file type.
-
- If filetype specifies VFT_DRV, this parameter can be one of the
- following values.
-
- Value Description
-
- VFT2_UNKNOWN Driver type is unknown.
- VFT2_DRV_COMM File contains a communications driver.
- VFT2_DRV_PRINTER File contains a printer driver.
- VFT2_DRV_KEYBOARD File contains a keyboard driver.
- VFT2_DRV_LANGUAGE File contains a language driver.
- VFT2_DRV_DISPLAY File contains a display driver.
- VFT2_DRV_MOUSE File contains a mouse driver.
- VFT2_DRV_NETWORK File contains a network driver.
- VFT2_DRV_SYSTEM File contains a system driver.
- VFT2_DRV_INSTALLABLE File contains an installable driver.
- VFT2_DRV_SOUND File contains a sound driver.
- VFT2_DRV_VERSIONED_PRINTER File contains a versioned printer driver.
-
- If filetype specifies VFT_FONT, this parameter can be one of the
- following values.
-
- Value Description
-
- VFT2_UNKNOWN Font type is unknown.
- VFT2_FONT_RASTER File contains a raster font.
- VFT2_FONT_VECTOR File contains a vector font.
- VFT2_FONT_TRUETYPE File contains a TrueType font.
-
- If filetype specifies VFT_VXD, this parameter must be the virtual-device
- identifier included in the virtual-device control block.
-
- All subtype values not listed here are reserved for use by Microsoft.
-
-langID
- One of the following language codes.
-
- Code Language Code Language
-
- 0x0401 Arabic 0x0415 Polish
- 0x0402 Bulgarian 0x0416 Portuguese (Brazil)
- 0x0403 Catalan 0x0417 Rhaeto-Romanic
- 0x0404 Traditional Chinese 0x0418 Romanian
- 0x0405 Czech 0x0419 Russian
- 0x0406 Danish 0x041A Croato-Serbian (Latin)
- 0x0407 German 0x041B Slovak
- 0x0408 Greek 0x041C Albanian
- 0x0409 U.S. English 0x041D Swedish
- 0x040A Castilian Spanish 0x041E Thai
- 0x040B Finnish 0x041F Turkish
- 0x040C French 0x0420 Urdu
- 0x040D Hebrew 0x0421 Bahasa
- 0x040E Hungarian 0x0804 Simplified Chinese
- 0x040F Icelandic 0x0807 Swiss German
- 0x0410 Italian 0x0809 U.K. English
- 0x0411 Japanese 0x080A Mexican Spanish
- 0x0412 Korean 0x080C Belgian French
- 0x0413 Dutch 0x0C0C Canadian French
- 0x0414 Norwegian – Bokmal 0x100C Swiss French
- 0x0810 Swiss Italian 0x0816 Portuguese (Portugal)
- 0x0813 Belgian Dutch 0x081A Serbo-Croatian (Cyrillic)
- 0x0814 Norwegian – Nynorsk
-
-charsetID
- One of the following character-set identifiers.
-
- Identifier Character Set
-
- 0 7-bit ASCII
- 932 Japan (Shift \e%G–\e%@ JIS X-0208)
- 949 Korea (Shift \e%G–\e%@ 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\e%G—\e%@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\e%G—\e%@for example,
- "Keyboard Driver for AT-Style Keyboards". This
- string is required.
- FileVersion Version number of the file\e%G—\e%@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.
- */
+++ /dev/null
-/*
- * w32_CancelableWait.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"
-
-
-static INLINE int
-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
- * WaitForMultipleObjects on 'waitHandle' and a manually reset WIN32
- * event used to implement pthread_cancel.
- *
- * Given this hook it would be possible to implement more of the cancellation
- * points.
- * -------------------------------------------------------------------
- */
-{
- int result;
- pthread_t self;
- ptw32_thread_t * sp;
- HANDLE handles[2];
- DWORD nHandles = 1;
- DWORD status;
-
- handles[0] = waitHandle;
-
- self = pthread_self();
- sp = (ptw32_thread_t *) self.p;
-
- if (sp != NULL)
- {
- /*
- * Get cancelEvent handle
- */
- if (sp->cancelState == PTHREAD_CANCEL_ENABLE)
- {
-
- if ((handles[1] = sp->cancelEvent) != NULL)
- {
- nHandles++;
- }
- }
- }
- else
- {
- handles[1] = NULL;
- }
-
- status = WaitForMultipleObjects (nHandles, handles, PTW32_FALSE, timeout);
-
- switch (status - WAIT_OBJECT_0)
- {
- case 0:
- /*
- * Got the handle.
- * In the event that both handles are signalled, the smallest index
- * value (us) is returned. As it has been arranged, this ensures that
- * we don't drop a signal that we should act on (i.e. semaphore,
- * mutex, or condition variable etc).
- */
- result = 0;
- break;
-
- case 1:
- /*
- * Got cancel request.
- * In the event that both handles are signaled, the cancel will
- * be ignored (see case 0 comment).
- */
- ResetEvent (handles[1]);
-
- if (sp != NULL)
- {
- ptw32_mcs_local_node_t stateLock;
- /*
- * Should handle POSIX and implicit POSIX threads..
- * Make sure we haven't been async-canceled in the meantime.
- */
- 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);
-
- /* Never reached */
- }
- ptw32_mcs_lock_release (&stateLock);
- }
-
- /* Should never get to here. */
- result = EINVAL;
- break;
-
- default:
- if (status == WAIT_TIMEOUT)
- {
- result = ETIMEDOUT;
- }
- else
- {
- result = EINVAL;
- }
- break;
- }
-
- return (result);
-
-} /* CancelableWait */
-
-int
-pthreadCancelableWait (HANDLE waitHandle)
-{
- return (ptw32_cancelable_wait (waitHandle, INFINITE));
-}
-
-int
-pthreadCancelableTimedWait (HANDLE waitHandle, DWORD timeout)
-{
- return (ptw32_cancelable_wait (waitHandle, timeout));
-}
ev_child child_watcher;
#define UV_FS_PRIVATE_FIELDS \
+ struct stat statbuf; \
eio_req* eio;
-#define UV_WORK_PRIVATE_FIELDS
+#define UV_WORK_PRIVATE_FIELDS \
+ eio_req* eio;
#endif /* UV_UNIX_H */
};
/* Queues a work request to execute asynchronously on the thread pool. */
-int uv_queue_work(uv_work_t* req, uv_work_cb work_cb, uv_after_work_cb after_work_cb);
+int uv_queue_work(uv_work_t* req, uv_work_cb work_cb,
+ uv_after_work_cb after_work_cb);
typedef enum {
#include "internal.h"
#include "eio.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dirent.h>
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
static void uv_fs_req_init(uv_fs_t* req, uv_fs_type fs_type, uv_fs_cb cb) {
+ /* Make sure the thread pool is initialized. */
+ uv_eio_init();
+
uv__req_init((uv_req_t*) req);
req->type = UV_FS;
req->fs_type = fs_type;
void uv_fs_req_cleanup(uv_fs_t* req) {
- assert(0 && "implement me");
+ switch (req->fs_type) {
+ case UV_FS_READDIR:
+ assert(req->ptr);
+ free(req->ptr);
+ req->ptr = NULL;
+ break;
+
+ case UV_FS_STAT:
+ case UV_FS_LSTAT:
+ req->ptr = NULL;
+ break;
+
+ default:
+ break;
+ }
}
static int uv__fs_after(eio_req* eio) {
+ char* name;
+ int namelen;
+ int buflen = 0;
uv_fs_t* req = eio->data;
+ int i;
+
assert(req->cb);
req->result = req->eio->result;
+ req->errorno = req->eio->errorno;
+
+ if (req->fs_type == UV_FS_READDIR) {
+ /*
+ * XXX This is pretty bad.
+ * We alloc and copy the large null termiated string list from libeio.
+ * This is done because libeio is going to free eio->ptr2 after this
+ * callback. We must keep it until uv_fs_req_cleanup. If we get rid of
+ * libeio this can be avoided.
+ */
+ buflen = 0;
+ name = req->eio->ptr2;
+ for (i = 0; i < req->result; i++) {
+ namelen = strlen(name);
+ buflen += namelen + 1;
+ /* TODO check ENOMEM */
+ name += namelen;
+ assert(*name == '\0');
+ name++;
+ }
+ req->ptr = malloc(buflen);
+ memcpy(req->ptr, req->eio->ptr2, buflen);
+ } else if (req->fs_type == UV_FS_STAT || req->fs_type == UV_FS_LSTAT) {
+ req->ptr = req->eio->ptr2;
+ }
+
+ uv_unref();
req->eio = NULL; /* Freed by libeio */
req->cb(req);
uv_fs_req_init(req, UV_FS_CLOSE, cb);
if (cb) {
/* async */
+ uv_ref();
req->eio = eio_close(file, EIO_PRI_DEFAULT, uv__fs_after, req);
if (!req->eio) {
uv_err_new(NULL, ENOMEM);
if (cb) {
/* async */
+ uv_ref();
req->eio = eio_open(path, flags, mode, EIO_PRI_DEFAULT, uv__fs_after, req);
if (!req->eio) {
uv_err_new(NULL, ENOMEM);
if (cb) {
/* async */
+ uv_ref();
req->eio = eio_read(fd, buf, length, offset, EIO_PRI_DEFAULT,
uv__fs_after, req);
if (cb) {
/* async */
+ uv_ref();
req->eio = eio_unlink(path, EIO_PRI_DEFAULT, uv__fs_after, req);
if (!req->eio) {
uv_err_new(NULL, ENOMEM);
}
-int uv_fs_write(uv_fs_t* req, uv_file file, void* buf, size_t length, off_t offset, uv_fs_cb cb) {
- assert(0 && "implement me");
- return -1;
+int uv_fs_write(uv_fs_t* req, uv_file file, void* buf, size_t length,
+ off_t offset, uv_fs_cb cb) {
+ uv_fs_req_init(req, UV_FS_WRITE, cb);
+
+ if (cb) {
+ /* async */
+ uv_ref();
+ req->eio = eio_write(file, buf, length, offset, EIO_PRI_DEFAULT,
+ uv__fs_after, req);
+ if (!req->eio) {
+ uv_err_new(NULL, ENOMEM);
+ return -1;
+ }
+
+ } else {
+ /* sync */
+ req->result = offset < 0 ?
+ write(file, buf, length) :
+ pwrite(file, buf, length, offset);
+
+ if (req->result < 0) {
+ uv_err_new(NULL, errno);
+ return -1;
+ }
+ }
+
+ return 0;
}
int uv_fs_mkdir(uv_fs_t* req, const char* path, int mode, uv_fs_cb cb) {
- assert(0 && "implement me");
- return -1;
+ uv_fs_req_init(req, UV_FS_MKDIR, cb);
+
+ if (cb) {
+ /* async */
+ uv_ref();
+ req->eio = eio_mkdir(path, mode, EIO_PRI_DEFAULT, uv__fs_after, req);
+ if (!req->eio) {
+ uv_err_new(NULL, ENOMEM);
+ return -1;
+ }
+
+ } else {
+ /* sync */
+ req->result = mkdir(path, mode);
+
+ if (req->result < 0) {
+ uv_err_new(NULL, errno);
+ return -1;
+ }
+ }
+
+ return 0;
}
int uv_fs_rmdir(uv_fs_t* req, const char* path, uv_fs_cb cb) {
- assert(0 && "implement me");
- return -1;
+ uv_fs_req_init(req, UV_FS_RMDIR, cb);
+
+ if (cb) {
+ /* async */
+ uv_ref();
+ req->eio = eio_rmdir(path, EIO_PRI_DEFAULT, uv__fs_after, req);
+ if (!req->eio) {
+ uv_err_new(NULL, ENOMEM);
+ return -1;
+ }
+
+ } else {
+ /* sync */
+ req->result = rmdir(path);
+
+ if (req->result < 0) {
+ uv_err_new(NULL, errno);
+ return -1;
+ }
+ }
+
+ return 0;
}
int uv_fs_readdir(uv_fs_t* req, const char* path, int flags, uv_fs_cb cb) {
- assert(0 && "implement me");
- return -1;
+ int r;
+ struct dirent* entry;
+ size_t size = 0;
+
+ uv_fs_req_init(req, UV_FS_READDIR, cb);
+
+ if (cb) {
+ /* async */
+ uv_ref();
+ req->eio = eio_readdir(path, flags, EIO_PRI_DEFAULT, uv__fs_after, req);
+ if (!req->eio) {
+ uv_err_new(NULL, ENOMEM);
+ return -1;
+ }
+
+ } else {
+ /* sync */
+ DIR* dir = opendir(path);
+ if (!dir) {
+ uv_err_new(NULL, errno);
+ return -1;
+ }
+
+ while ((entry = readdir(dir))) {
+ req->ptr = realloc(req->ptr, size + entry->d_namlen + 1);
+ /* TODO check ENOMEM */
+ /* TODO skip . and .. */
+ memcpy((char*)req->ptr + size, entry->d_name, entry->d_namlen);
+ size += entry->d_namlen;
+ ((char*)req->ptr)[size] = '\0';
+ size++;
+ }
+
+ r = closedir(dir);
+ if (r) {
+ uv_err_new(NULL, errno);
+ return -1;
+ }
+ }
+
+ return 0;
}
int uv_fs_stat(uv_fs_t* req, const char* path, uv_fs_cb cb) {
- assert(0 && "implement me");
- return -1;
+ char* pathdup = path;
+ int pathlen;
+
+ uv_fs_req_init(req, UV_FS_STAT, cb);
+
+ /* TODO do this without duplicating the string. */
+ /* TODO security */
+ pathdup = strdup(path);
+ pathlen = strlen(path);
+
+ if (pathlen > 0 && path[pathlen - 1] == '\\') {
+ /* TODO do not modify input string */
+ pathdup[pathlen - 1] = '\0';
+ }
+
+ if (cb) {
+ /* async */
+ uv_ref();
+ req->eio = eio_stat(pathdup, EIO_PRI_DEFAULT, uv__fs_after, req);
+
+ free(pathdup);
+
+ if (!req->eio) {
+ uv_err_new(NULL, ENOMEM);
+ return -1;
+ }
+
+ } else {
+ /* sync */
+ req->result = stat(pathdup, &req->statbuf);
+
+ free(pathdup);
+
+ if (req->result < 0) {
+ uv_err_new(NULL, errno);
+ return -1;
+ }
+
+ req->ptr = &req->statbuf;
+ }
+
+ return 0;
}
}
-int uv_fs_rename(uv_fs_t* req, const char* path, const char* new_path, uv_fs_cb cb) {
- assert(0 && "implement me");
- return -1;
+int uv_fs_rename(uv_fs_t* req, const char* path, const char* new_path,
+ uv_fs_cb cb) {
+ uv_fs_req_init(req, UV_FS_RENAME, cb);
+
+ if (cb) {
+ /* async */
+ uv_ref();
+ req->eio = eio_rename(path, new_path, EIO_PRI_DEFAULT, uv__fs_after, req);
+ if (!req->eio) {
+ uv_err_new(NULL, ENOMEM);
+ return -1;
+ }
+
+ } else {
+ /* sync */
+ req->result = rename(path, new_path);
+
+ if (req->result) {
+ uv_err_new(NULL, errno);
+ return -1;
+ }
+ }
+
+ return 0;
}
int uv_fs_fsync(uv_fs_t* req, uv_file file, uv_fs_cb cb) {
- assert(0 && "implement me");
- return -1;
+ uv_fs_req_init(req, UV_FS_FSYNC, cb);
+
+ if (cb) {
+ /* async */
+ uv_ref();
+ req->eio = eio_fsync(file, EIO_PRI_DEFAULT, uv__fs_after, req);
+ if (!req->eio) {
+ uv_err_new(NULL, ENOMEM);
+ return -1;
+ }
+
+ } else {
+ /* sync */
+ req->result = fsync(file);
+
+ if (req->result) {
+ uv_err_new(NULL, errno);
+ return -1;
+ }
+ }
+
+ return 0;
}
int uv_fs_fdatasync(uv_fs_t* req, uv_file file, uv_fs_cb cb) {
- assert(0 && "implement me");
- return -1;
+ uv_fs_req_init(req, UV_FS_FDATASYNC, cb);
+
+ if (cb) {
+ /* async */
+ uv_ref();
+ req->eio = eio_fdatasync(file, EIO_PRI_DEFAULT, uv__fs_after, req);
+ if (!req->eio) {
+ uv_err_new(NULL, ENOMEM);
+ return -1;
+ }
+
+ } else {
+ /* sync */
+ req->result = fdatasync(file);
+
+ if (req->result) {
+ uv_err_new(NULL, errno);
+ return -1;
+ }
+ }
+
+ return 0;
}
int uv_fs_ftruncate(uv_fs_t* req, uv_file file, off_t offset, uv_fs_cb cb) {
- assert(0 && "implement me");
- return -1;
+ uv_fs_req_init(req, UV_FS_FTRUNCATE, cb);
+
+ if (cb) {
+ /* async */
+ uv_ref();
+ req->eio = eio_ftruncate(file, offset, EIO_PRI_DEFAULT, uv__fs_after, req);
+ if (!req->eio) {
+ uv_err_new(NULL, ENOMEM);
+ return -1;
+ }
+
+ } else {
+ /* sync */
+ req->result = ftruncate(file, offset);
+
+ if (req->result) {
+ uv_err_new(NULL, errno);
+ return -1;
+ }
+ }
+
+ return 0;
}
-int uv_fs_sendfile(uv_fs_t* req, uv_file out_fd, uv_file in_fd, off_t in_offset, size_t length, uv_fs_cb cb) {
- assert(0 && "implement me");
- return -1;
+int uv_fs_sendfile(uv_fs_t* req, uv_file out_fd, uv_file in_fd,
+ off_t in_offset, size_t length, uv_fs_cb cb) {
+ uv_fs_req_init(req, UV_FS_SENDFILE, cb);
+
+ if (cb) {
+ /* async */
+ uv_ref();
+ req->eio = eio_sendfile(out_fd, in_fd, in_offset, length, EIO_PRI_DEFAULT,
+ uv__fs_after, req);
+ if (!req->eio) {
+ uv_err_new(NULL, ENOMEM);
+ return -1;
+ }
+
+ } else {
+ /* sync */
+ req->result = eio_sendfile_sync(out_fd, in_fd, in_offset, length);
+
+ if (req->result) {
+ uv_err_new(NULL, errno);
+ return -1;
+ }
+ }
+
+ return 0;
}
int uv_fs_lstat(uv_fs_t* req, const char* path, uv_fs_cb cb) {
- assert(0 && "implement me");
- return -1;
+ char* pathdup = path;
+ int pathlen;
+
+ uv_fs_req_init(req, UV_FS_LSTAT, cb);
+
+ /* TODO do this without duplicating the string. */
+ /* TODO security */
+ pathdup = strdup(path);
+ pathlen = strlen(path);
+
+ if (pathlen > 0 && path[pathlen - 1] == '\\') {
+ /* TODO do not modify input string */
+ pathdup[pathlen - 1] = '\0';
+ }
+
+ if (cb) {
+ /* async */
+ uv_ref();
+ req->eio = eio_lstat(pathdup, EIO_PRI_DEFAULT, uv__fs_after, req);
+
+ free(pathdup);
+
+ if (!req->eio) {
+ uv_err_new(NULL, ENOMEM);
+ return -1;
+ }
+
+ } else {
+ /* sync */
+ req->result = lstat(pathdup, &req->statbuf);
+
+ free(pathdup);
+
+ if (req->result < 0) {
+ uv_err_new(NULL, errno);
+ return -1;
+ }
+
+ req->ptr = &req->statbuf;
+ }
+
+ return 0;
}
-int uv_fs_link(uv_fs_t* req, const char* path, const char* new_path, uv_fs_cb cb) {
+int uv_fs_link(uv_fs_t* req, const char* path, const char* new_path,
+ uv_fs_cb cb) {
assert(0 && "implement me");
return -1;
}
}
+static void uv__work(eio_req* eio) {
+ uv_work_t* req = eio->data;
+ if (req->work_cb) {
+ req->work_cb(req);
+ }
+}
+
+
+static int uv__after_work(eio_req *eio) {
+ uv_work_t* req = eio->data;
+ uv_unref();
+ if (req->after_work_cb) {
+ req->after_work_cb(req);
+ }
+ return 0;
+}
+
+
int uv_queue_work(uv_work_t* req, uv_work_cb work_cb,
uv_after_work_cb after_work_cb) {
- assert(0 && "implement me");
- return -1;
+ void* data = req->data;
+
+ uv_eio_init();
+
+ uv__req_init((uv_req_t*) req);
+ uv_ref();
+ req->data = data;
+ req->work_cb = work_cb;
+ req->after_work_cb = after_work_cb;
+
+ req->eio = eio_custom(uv__work, EIO_PRI_DEFAULT, uv__after_work, req);
+
+ if (!req->eio) {
+ uv_err_new(NULL, ENOMEM);
+ return -1;
+ }
+
+ return 0;
}
#include "uv.h"
#include "task.h"
+#include <string.h> /* memset */
+#include <fcntl.h>
+#include <sys/stat.h>
+
+
#if !UNIX
# include <direct.h>
# include <io.h>
+# define unlink _unlink
+# define rmdir _rmdir
+# define stat _stat
+# define open _open
+# define write _write
+# define lseek _lseek
+# define close _close
#endif
-#include <string.h> /* memset */
-#include <fcntl.h>
-#include <sys/stat.h>
-
static int close_cb_count;
static int create_cb_count;
static int open_cb_count;
int r;
ASSERT(req == &open_req1);
ASSERT(req->fs_type == UV_FS_OPEN);
- ASSERT(req->result != -1);
+ if (req->result < 0) {
+ /* TODO get error with uv_last_error() */
+ fprintf(stderr, "async open error: %d\n", req->errorno);
+ ASSERT(0);
+ }
open_cb_count++;
uv_fs_req_cleanup(req);
memset(buf, 0, sizeof(buf));
ASSERT(req->result != -1);
create_cb_count++;
uv_fs_req_cleanup(req);
- r = uv_fs_write(&write_req, req->result, test_buf, sizeof(test_buf), -1, write_cb);
+ r = uv_fs_write(&write_req, req->result, test_buf, sizeof(test_buf), -1,
+ write_cb);
}
static void stat_cb(uv_fs_t* req) {
ASSERT(req == &stat_req);
- ASSERT(req->fs_type == UV_FS_STAT);
+ ASSERT(req->fs_type == UV_FS_STAT || req->fs_type == UV_FS_LSTAT);
ASSERT(req->result != -1);
ASSERT(req->ptr);
stat_cb_count++;
static void sendfile_cb(uv_fs_t* req) {
ASSERT(req == &sendfile_req);
ASSERT(req->fs_type == UV_FS_SENDFILE);
- ASSERT(req->result == 65548);
+ ASSERT(req->result == 65546);
sendfile_cb_count++;
uv_fs_req_cleanup(req);
}
int r;
/* Setup. */
-#if UNIX
- ASSERT(0 && "implement me");
-#else
- _unlink("test_file");
- _unlink("test_file2");
-#endif
+ unlink("test_file");
+ unlink("test_file2");
uv_init();
- r = uv_fs_open(&open_req1, "test_file", O_WRONLY | O_CREAT, S_IWRITE, create_cb);
+ r = uv_fs_open(&open_req1, "test_file", O_WRONLY | O_CREAT,
+ S_IREAD | S_IWRITE, create_cb);
ASSERT(r == 0);
uv_run();
ASSERT(write_cb_count == 1);
ASSERT(ftruncate_cb_count == 1);
-#if UNIX
- ASSERT(0 && "implement me");
-#else
/* Cleanup. */
- _unlink("test_file");
- _unlink("test_file2");
-#endif
+ unlink("test_file");
+ unlink("test_file2");
return 0;
}
TEST_IMPL(fs_file_sync) {
int r;
-#if UNIX
- ASSERT(0 && "implement me");
-#else
/* Setup. */
- _unlink("test_file");
- _unlink("test_file2");
-#endif
+ unlink("test_file");
+ unlink("test_file2");
uv_init();
- r = uv_fs_open(&open_req1, "test_file", O_WRONLY | O_CREAT, S_IWRITE | S_IREAD, NULL);
+ r = uv_fs_open(&open_req1, "test_file", O_WRONLY | O_CREAT,
+ S_IWRITE | S_IREAD, NULL);
ASSERT(r == 0);
ASSERT(open_req1.result != -1);
uv_fs_req_cleanup(&open_req1);
- r = uv_fs_write(&write_req, open_req1.result, test_buf, sizeof(test_buf), -1, NULL);
+ r = uv_fs_write(&write_req, open_req1.result, test_buf, sizeof(test_buf), -1,
+ NULL);
ASSERT(r == 0);
ASSERT(write_req.result != -1);
uv_fs_req_cleanup(&write_req);
uv_fs_req_cleanup(&unlink_req);
/* Cleanup */
-#if UNIX
- ASSERT(0 && "implement me");
-#else
- _unlink("test_file");
- _unlink("test_file2");
-#endif
+ unlink("test_file");
+ unlink("test_file2");
return 0;
}
int r;
/* Setup */
-#if UNIX
- ASSERT(0 && "implement me");
-#else
- _unlink("test_dir/file1");
- _unlink("test_dir/file2");
- _rmdir("test_dir");
-#endif
+ unlink("test_dir/file1");
+ unlink("test_dir/file2");
+ rmdir("test_dir");
uv_init();
- r = uv_fs_mkdir(&mkdir_req, "test_dir", 0, mkdir_cb);
+ r = uv_fs_mkdir(&mkdir_req, "test_dir", 0755, mkdir_cb);
ASSERT(r == 0);
uv_run();
ASSERT(mkdir_cb_count == 1);
/* Create 2 files synchronously. */
- r = uv_fs_open(&open_req1, "test_dir/file1", O_WRONLY | O_CREAT, S_IWRITE | S_IREAD, NULL);
+ r = uv_fs_open(&open_req1, "test_dir/file1", O_WRONLY | O_CREAT,
+ S_IWRITE | S_IREAD, NULL);
ASSERT(r == 0);
uv_fs_req_cleanup(&open_req1);
r = uv_fs_close(&close_req, open_req1.result, NULL);
ASSERT(r == 0);
uv_fs_req_cleanup(&close_req);
- r = uv_fs_open(&open_req1, "test_dir/file2", O_WRONLY | O_CREAT, S_IWRITE | S_IREAD, NULL);
+ r = uv_fs_open(&open_req1, "test_dir/file2", O_WRONLY | O_CREAT,
+ S_IWRITE | S_IREAD, NULL);
ASSERT(r == 0);
uv_fs_req_cleanup(&open_req1);
r = uv_fs_close(&close_req, open_req1.result, NULL);
r = uv_fs_stat(&stat_req, "test_dir", stat_cb);
ASSERT(r == 0);
uv_run();
+
r = uv_fs_stat(&stat_req, "test_dir\\", stat_cb);
ASSERT(r == 0);
uv_run();
- ASSERT(stat_cb_count == 2);
+ r = uv_fs_lstat(&stat_req, "test_dir", stat_cb);
+ ASSERT(r == 0);
+ uv_run();
+
+ r = uv_fs_lstat(&stat_req, "test_dir\\", stat_cb);
+ ASSERT(r == 0);
+ uv_run();
+
+ ASSERT(stat_cb_count == 4);
r = uv_fs_unlink(&unlink_req, "test_dir/file1", unlink_cb);
ASSERT(r == 0);
ASSERT(rmdir_cb_count == 1);
/* Cleanup */
-#if UNIX
- ASSERT(0 && "implement me");
-#else
- _unlink("test_dir/file1");
- _unlink("test_dir/file2");
- _rmdir("test_dir");
-#endif
+ unlink("test_dir/file1");
+ unlink("test_dir/file2");
+ rmdir("test_dir");
return 0;
}
int f, r;
/* Setup. */
-#if UNIX
- ASSERT(0 && "implement me");
-#else
- struct _stat s1, s2;
+ struct stat s1, s2;
- _unlink("test_file");
- _unlink("test_file2");
+ unlink("test_file");
+ unlink("test_file2");
- f = _open("test_file", O_WRONLY | O_CREAT, S_IWRITE | S_IREAD);
+ f = open("test_file", O_WRONLY | O_CREAT, S_IWRITE | S_IREAD);
ASSERT(f != -1);
- r = _write(f, "begin\n", 6);
- ASSERT(r != -1);
+ r = write(f, "begin\n", 6);
+ ASSERT(r == 6);
- r = _lseek(f, 65536, SEEK_CUR);
- ASSERT(r == 65543);
+ r = lseek(f, 65536, SEEK_CUR);
+ ASSERT(r == 65542);
- r = _write(f, "end\n", 4);
+ r = write(f, "end\n", 4);
ASSERT(r != -1);
- r = _close(f);
+ r = close(f);
ASSERT(r == 0);
-#endif
/* Test starts here. */
uv_init();
ASSERT(open_req1.result != -1);
uv_fs_req_cleanup(&open_req1);
- r = uv_fs_open(&open_req2, "test_file2", O_WRONLY | O_CREAT, S_IWRITE | S_IREAD, NULL);
+ r = uv_fs_open(&open_req2, "test_file2", O_WRONLY | O_CREAT,
+ S_IWRITE | S_IREAD, NULL);
ASSERT(r == 0);
ASSERT(open_req2.result != -1);
uv_fs_req_cleanup(&open_req2);
- r = uv_fs_sendfile(&sendfile_req, open_req2.result, open_req1.result, 0, 131072, sendfile_cb);
+ r = uv_fs_sendfile(&sendfile_req, open_req2.result, open_req1.result, 0,
+ 131072, sendfile_cb);
ASSERT(r == 0);
uv_run();
ASSERT(r == 0);
uv_fs_req_cleanup(&close_req);
-#if UNIX
- ASSERT(0 && "implement me");
-#else
- _stat("test_file", &s1);
- _stat("test_file2", &s2);
- ASSERT(65548 == s2.st_size && s1.st_size == s2.st_size);
+ stat("test_file", &s1);
+ stat("test_file2", &s2);
+ ASSERT(65546 == s2.st_size && s1.st_size == s2.st_size);
/* Cleanup. */
- _unlink("test_file");
- _unlink("test_file2");
-#endif
+ unlink("test_file");
+ unlink("test_file2");
return 0;
}
for (int i = 0; i < nnames; i++) {
Local<String> name = String::New(namebuf);
names->Set(Integer::New(i), name);
-#ifndef NDEBUG
namebuf += strlen(namebuf);
assert(*namebuf == '\0');
namebuf += 1;
-#else
namebuf += strlen(namebuf) + 1;
-#endif
}
argv[1] = names;