summaryrefslogtreecommitdiff
path: root/mutex.c
AgeCommit message (Collapse)Author
2000-12-29./ChangeLog:rpj
2000-12-29 Ross Johnson <rpj@special.ise.canberra.edu.au> * Makefile: Back-out "for" loops which don't work. * GNUmakefile: Remove the fake.a target; add the "realclean" target; don't remove built libs under the "clean" target. * config.h: Add a guard against multiple inclusion. * semaphore.h: Add some defines from config.h to make semaphore.h independent of config.h when building apps. * pthread.h (_errno): Back-out previous fix until we know how to fix it properly. * implement.h (lockCount): Add missing element to pthread_mutex_t_. * sync.c (pthread_join): Spelling fix in comment. * private.c (ptw32_threadStart): Reset original termination function (C++). (ptw32_threadStart): Cleanup detached threads early in case the library is statically linked. (ptw32_callUserDestroyRoutines): Remove [SEH] __try block from destructor call so that unhandled exceptions will be passed through to the system; call terminate() from [C++] try block for the same reason. * tsd.c (pthread_getspecific): Add comment. * mutex.c (pthread_mutex_init): Initialise new elements in pthread_mutex_t. (pthread_mutex_unlock): Invert "pthread_equal()" test. 2000-12-28 Ross Johnson <rpj@special.ise.canberra.edu.au> * semaphore.c (mode_t): Use ifndef HAVE_MODE_T to include definition. * config.h.in (HAVE_MODE_T): Added. (_UWIN): Start adding defines for the UWIN package. ./tests/ChangeLog: 2000-12-29 Ross Johnson <rpj@special.ise.canberra.edu.au> * GNUmakefile: Add mutex4 test; ensure libpthreadw32.a is removed for "clean" target. * Makefile: Add mutex4 test. * exception3.c: Remove SEH code; automatically pass the test under SEH (which is an N/A environment). * mutex4.c: New test. * eyal1.c (do_work_unit): Add a dummy "if" to force the optimiser to retain code; reduce thread work loads. * condvar8.c (main): Add an additional "assert" for debugging; increase pthread_cond_signal timeout.
2000-12-282000-10-10 Ross Johnson <rpj@setup1.ise.canberra.edu.au>rpj
* misc.c (pthread_self): Restore Win32 "last error" cleared by TlsGetValue() call in pthread_getspecific() - "Steven Reddie" <smr@essemer.com.au> 2000-09-20 Ross Johnson <rpj@setup1.ise.canberra.edu.au> * mutex.c (pthread_mutex_lock): Record the owner of the mutex. This requires also keeping count of recursive locks ourselves rather than leaving it to Win32 since we need to know when to NULL the thread owner when the mutex is unlocked. (pthread_mutex_trylock): Likewise. (pthread_mutex_unlock): Check that the calling thread owns the mutex, decrement the recursive lock count, and NULL the owner if zero. Return EPERM if the mutex is owned by another thread. * implement.h (pthread_mutex_t_): Add ownerThread and lockCount members. - reported by Arthur Kantor <akantor@bexusa.com>
2000-09-132000-09-13 Ross Johnson <rpj@setup1.ise.canberra.edu.au>rpj
* mutex.c (pthread_mutex_init): Call TryEnterCriticalSection through the pointer rather than directly so that the dll can load on Windows versions that can't resolve the function, eg. Windows 95 - "Jef Gearhart" <jgearhart@tpssys.com>
2000-09-022000-09-02 Ross Johnson <rpj@special.ise.canberra.edu.au>rpj
* rwlock.c (_rwlock_check*): Renamed to ptw32_rwlock_check*. * mutex.c (_mutex_check*): Renamed to ptw32_mutex_check*. * condvar.c (cond_timed*): Renamed to ptw32_cond_timed*. (_cond_check*): Renamed to ptw32_cond_check*.
2000-08-182000-08-18 Ross Johnson <rpj@special.ise.canberra.edu.au>rpj
* mutex.c (pthread_mutex_destroy): Check that the mutex isn't held; invalidate the mutex as early as possible to avoid contention; not perfect - FIXME! * rwlock.c (pthread_rwlock_init): Remove redundant assignment to "rw". (pthread_rwlock_destroy): Invalidate the rwlock before freeing up any of it's resources - to avoid contention. * private.c (ptw32_tkAssocCreate): Change assoc->lock to use a dynamically initialised mutex - only consumes a W32 mutex or critical section when first used, not before. * mutex.c (pthread_mutex_init): Remove redundant assignment to "mx". (pthread_mutexattr_destroy): Set attribute to NULL before freeing it's memory - to avoid contention.
2000-08-182000-08-18 Ross Johnson <rpj@setup1.ise.canberra.edu.au>rpj
* Several: Fix typos from scripted edit session yesterday. * nonportable.c (pthread_mutexattr_setforcecs_np): Moved this function from mutex.c. (pthread_getw32threadhandle_np): New function to return the win32 thread handle that the POSIX thread is using. * mutex.c (pthread_mutexattr_setforcecs_np): Moved to new file "nonportable.c". * pthread.h (PTW32_BUILD): Only redefine __except and catch compiler keywords if we aren't building the library (ie. PTW32_BUILD is not defined) - this is safer than defining and then undefining if not building the library. * implement.h: Remove __except and catch undefines. * Makefile (CFLAGS): Define PTW32_BUILD. * GNUmakefile (CFLAGS): Define PTW32_BUILD. * All appropriate: Change Pthread_exception* to ptw32_exception* to be consistent with internal identifier naming. * private.c (ptw32_throw): New function to provide a generic exception throw for all internal exceptions and EH schemes. (ptw32_threadStart): pthread_exit() value is now returned via the thread structure exitStatus element. * exit.c (pthread_exit): pthread_exit() value is now returned via the thread structure exitStatus element. * cancel.c (ptw32_cancel_self): Now uses ptw32_throw. (pthread_setcancelstate): Ditto. (pthread_setcanceltype): Ditto. (pthread_testcancel): Ditto. (pthread_cancel): Ditto. * misc.c (CancelableWait): Ditto. * exit.c (pthread_exit): Ditto. * All applicable: Change PTW32_ prefix to PTW32_ prefix to remove leading underscores from private library identifiers.
2000-08-172000-08-17 Ross Johnson <rpj@special.ise.canberra.edu.au>rpj
* All applicable: Change _pthread_ prefix to ptw32_ prefix to remove leading underscores from private library identifiers (single and double leading underscores are reserved in the ANSI C standard for compiler implementations).
2000-07-252000-07-25 Ross Johnson <rpj@special.ise.canberra.edu.au>rpj
* sched.c (sched_get_priority_max): Handle different WinCE and Win32 priority values together. (sched_get_priority_min): Ditto. - Tristan Savatier <tristan@mpegtv.com> * create.c (pthread_create): Force new threads to wait until pthread_create has the new thread's handle; we also retain a local copy of the handle for internal use until pthread_create returns. * private.c (_pthread_threadStart): Initialise ei[]. (_pthread_threadStart): When beginthread is used to start the thread, force waiting until the creator thread had the thread handle. * cancel.c (_pthread_cancel_thread): Include context switch code for defined(_X86_) environments in addition to _M_IX86. * rwlock.c (pthread_rwlock_destroy): Assignment changed to avoid compiler warning. * private.c (_pthread_get_exception_services_code): Cast NULL return value to avoid compiler warning. * cleanup.c (pthread_pop_cleanup): Initialise "cleanup" variable to avoid compiler warnings. * misc.c (_pthread_new): Change "new" variable to "t" to avoid confusion with the C++ keyword of the same name. * condvar.c (cond_wait_cleanup): Initialise lastWaiter variable. (cond_timedwait): Remove unused local variables. to avoid compiler warnings. * dll.c (dllMain): Remove 2000-07-21 change - problem appears to be in pthread_create(). 2000-07-22 Ross Johnson <rpj@special.ise.canberra.edu.au> * tsd.c (pthread_key_create): If a destructor was given and the pthread_mutex_init failed, then would try to reference a NULL pointer (*key); eliminate this section of code by using a dynamically initialised mutex (PTHREAD_MUTEX_INITIALIZER). * tsd.c (pthread_setspecific): Return an error if unable to set the value; simplify cryptic conditional. * tsd.c (pthread_key_delete): Locking threadsLock relied on mutex_lock returning an error if the key has no destructor. ThreadsLock is only initialised if the key has a destructor. Making this mutex a static could reduce the number of mutexes used by an application since it is actually created only at first use and it's often destroyed soon after. 2000-07-22 Ross Johnson <rpj@special.ise.canberra.edu.au> * FAQ: Added Q5 and Q6. tests/ChangeLog: 2000-07-25 Ross Johnson <rpj@special.ise.canberra.edu.au> * runtest.bat: modified to work under W98. * runall.bat: Add new tests; modified to work under W98. It was ok under NT. * Makefile: Add new tests. * exception1.c: New; Test passing exceptions back to the application and retaining library internal exceptions. * join0.c: New; Test a single join.
1999-11-041999-11-05 Ross Johnson <rpj@ixobrychus.canberra.edu.au>rpj
* general: Patched for portability to WinCE. The details are described in the file WinCE-PORT. Follow the instructions in README.WinCE to make the appropriate changes in config.h. - Tristan Savatier <tristan@mpegtv.com>
1999-09-16Thu Sep 16 1999 Ross Johnson <rpj@swan.canberra.edu.au>rpj
* rwlock.c (pthread_rwlock_destroy): Add serialisation. (_rwlock_check_need_init): Check for detroyed rwlock. * rwlock.c: Check return codes from _rwlock_check_need_init(); modify comments; serialise access to rwlock objects during operations; rename rw_mutex to rw_lock. * implement.h: Rename rw_mutex to rw_lock. * mutex.c (pthread_mutex_destroy): Add serialisation. (_mutex_check_need_init): Check for detroyed mutex. * condvar.c (pthread_cond_destroy): Add serialisation. (_cond_check_need_init): Check for detroyed condvar. * mutex.c: Modify comments. * condvar.c: Modify comments.
1999-09-11Sat Sep 10 12:56:13 1999 Ross Johnson <rpj@swan.canberra.edu.au>rpj
* mutex.c (pthread_mutex_destroy): Don't free mutex memory if mutex is PTHREAD_MUTEX_INITIALIZER and has not been initialised yet.
1999-09-10Wed Sep 8 12:56:13 1999 Ross Johnson <rpj@swan.canberra.edu.au>rpj
* mutex.c (pthread_mutex_destroy): Free mutex memory. - Milan Gardian <mg@tatramed.sk>
1999-03-16Tue Mar 16 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au>rpj
* all: Add GNU LGPL and Copyright and Warranty.
1999-03-11Thu Mar 11 09:01:48 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au>rpj
* pthread.h (pthread_mutex_t): revert to (pthread_mutex_t *); define a value to serve as PTHREAD_MUTEX_INITIALIZER. (pthread_mutex_t_): remove staticinit and valid elements. (pthread_cond_t): revert to (pthread_cond_t_ *); define a value to serve as PTHREAD_COND_INITIALIZER. (pthread_cond_t_): remove staticinit and valid elements. * mutex.c (pthread_mutex_t args): adjust indirection of references. (all functions): check for PTHREAD_MUTEX_INITIALIZER value; check for NULL (invalid). * condvar.c (pthread_cond_t args): adjust indirection of references. (all functions): check for PTHREAD_COND_INITIALIZER value; check for NULL (invalid). Wed Mar 10 17:18:12 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au> * misc.c (CancelableWait): Undo changes from Mar 8 and 7. tests/ChangeLog Fri Mar 12 08:34:15 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au> * eyal1.c (main): Fix trylock loop; was not waiting for thread to lock the "started" mutex.
1999-03-07Mon Mar 8 11:18:59 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au>rpj
* misc.c (CancelableWait): Ensure cancelEvent handle is the lowest indexed element in the handles array. Enhance test for abandoned objects. * pthread.h (PTHREAD_MUTEX_INITIALIZER): Trailing elements not initialised are set to zero by the compiler. This avoids the problem of initialising the opaque critical section element in it. (PTHREAD_COND_INITIALIZER): Ditto. * semaphore.c (_pthread_sem_timedwait): Check sem == NULL earlier. Sun Mar 7 12:31:14 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au> * condvar.c (pthread_cond_init): set semaphore initial value to 0, not 1. cond_timedwait was returning signaled immediately. * misc.c (CancelableWait): Place the cancel event handle first in the handle table for WaitForMultipleObjects. This ensures that the cancel event is recognised and acted apon if both objects happen to be signaled together. * private.c (_pthread_cond_test_init_lock): Initialise and destroy. * implement.h (_pthread_cond_test_init_lock): Add extern. * global.c (_pthread_cond_test_init_lock): Add declaration. * condvar.c (pthread_cond_destroy): check for valid initialised CV; flag destroyed CVs as invalid. (pthread_cond_init): pthread_cond_t is no longer just a pointer. This is because PTHREAD_COND_INITIALIZER needs state info to reside in pthread_cond_t so that it can initialise on first use. Will work on making pthread_cond_t (and other objects like it) opaque again, if possible, later. (cond_timedwait): add check for statically initialisation of CV; initialise on first use. (pthread_cond_signal): check for valid CV. (pthread_cond_broadcast): check for valid CV. (_cond_check_need_init): Add. * pthread.h (PTHREAD_COND_INITIALIZER): Fix. (pthread_cond_t): no longer a pointer to pthread_cond_t_. (pthread_cond_t_): add 'staticinit' and 'valid' elements. tests/ChangeLog Sun Mar 7 10:41:52 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au> * Makefile (condvar3, condvar4): Add tests. * condvar4.c (General): Reduce to simple test case; prerequisite is condvar3.c; add description. * condvar3.c (General): Reduce to simple test case; prerequisite is condvar2.c; add description. * condvar2.c (General): Reduce to simple test case; prerequisite is condvar1.c; add description. * condvar1.c (General): Reduce to simple test case; add description. * Template.c (Comments): Add generic test detail.
1999-02-20Sat Feb 20 16:03:30 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au>rpj
* dll.c (DLLMain): Expand TryEnterCriticalSection support test. * mutex.c (pthread_mutex_trylock): The check for _pthread_try_enter_critical_section == NULL should have been removed long ago.
1999-02-19Fri Feb 19 16:2s1703:30 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au>rpj
* sync.c (pthread_join): Fix pthread_equal() test. * mutex.c (pthread_mutex_trylock): Check mutex != NULL before using it.
1999-02-02Mods to compile under Mingw32 egcs.rpj
Tue Feb 2 18:07:43 1999 Ross Johnson <rpj@swan.canberra.edu.au> * implement.h: Add #include <pthread.h>. Change sem_t to _pthread_sem_t. Various patches by Kevin Ruland <Kevin.Ruland@anheuser-busch.com> * signal.c (pthread_sigmask): Add and modify casts. Reverse LHS/RHS bitwise assignments. * pthread.h: Remove #include <semaphore.h>. (_PTHREAD_ATTR_VALID): Add cast. (struct pthread_t_): Add sigmask element. * dll.c: Add "extern C" for DLLMain. (DllMain): Add cast. * create.c (pthread_create): Set sigmask in thread. * condvar.c: Remove #include. Change sem_* to _pthread_sem_*. * attr.c: Changed #include. * Makefile.in: Additional targets and changes to build the library as a DLL. Fri Jan 29 11:56:28 1999 Ross Johnson <rpj@swan.canberra.edu.au> * Makefile.in (OBJS): Add semaphore.o to list. * semaphore.c (_pthread_sem_timedwait): Move from private.c. Rename sem_* to _pthread_sem_*. * pthread.h (pthread_cond_t): Change type of sem_t. _POSIX_SEMAPHORES no longer defined. * semaphore.h: Contents moved to implement.h. Removed from source tree. * implement.h: Add semaphore function prototypes and ename all functions to prepend '_pthread_'. They are now private to the pthreads-win32 implementation. * private.c: Change #warning. Move _pthread_sem_timedwait() to semaphore.c. * cleanup.c: Change #warning. * misc.c: Remove #include <errno.h> * pthread.def: Cleanup CVS merge conflicts. * global.c: Ditto. * ChangeLog: Ditto. * cleanup.c: Ditto.
1999-01-23Fixing problems building with GNU compilers:rpj
Sun Jan 24 01:34:52 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au> * semaphore.c (sem_wait): Remove second arg to pthreadCancelableWait() call. Fri Jan 22 14:31:59 1999 Ross Johnson <rpj@swan.canberra.edu.au> * Makefile.in (CFLAGS): Remove -fhandle-exceptions. Not needed with egcs. Add -g for debugging. * create.c (pthread_create): Replace __stdcall with PT_STDCALL macro. This is a hack and must be fixed. * misc.c (CancelableWait): Remove redundant statement. * mutex.c (pthread_mutexattr_init): Cast calloc return value. * misc.c (CancelableWait): Add cast. (pthread_self): Add cast. * exit.c (pthread_exit): Add cast. * condvar.c (pthread_condattr_init): Cast calloc return value. * cleanup.c: Reorganise conditional compilation. * attr.c (pthread_attr_init): Remove unused 'result'. Cast malloc return value. * private.c (_pthread_callUserDestroyRoutines): Redo conditional compilation. * misc.c (CancelableWait): C++ version uses 'throw'. * cancel.c (pthread_testcancel): Ditto. * implement.h (class pthread_exception): Define for C++. * pthread.h: Fix C, C++, and Win32 SEH condition compilation mayhem around pthread_cleanup_* defines. C++ version now uses John Bossom's cleanup handlers. (pthread_attr_t): Make 'valid' unsigned. Define '_timeb' as 'timeb' for Ming32. Define PT_STDCALL as nothing for Mingw32. May be temporary. * cancel.c (pthread_testcancel): Cast return value.
1999-01-20Wed Jan 20 09:31:28 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au>rpj
* pthread.h (pthread_mutexattr_t): Changed to a pointer. * mutex.c (pthread_mutex_init): Conditionally create Win32 mutex - from John Bossom's implementation. (pthread_mutex_destroy): Conditionally close Win32 mutex - from John Bossom's implementation. (pthread_mutexattr_init): Replaced by John Bossom's version. (pthread_mutexattr_destroy): Ditto. (pthread_mutexattr_getpshared): New function from John Bossom's implementation. (pthread_mutexattr_setpshared): New function from John Bossom's implementation. Tue Jan 19 18:27:42 1999 Ross Johnson <rpj@swan.canberra.edu.au> * pthread.h (pthreadCancelableTimedWait): New prototype. (pthreadCancelableWait): Remove second argument. * misc.c (CancelableWait): New static function is pthreadCancelableWait() renamed. (pthreadCancelableWait): Now just calls CancelableWait() with INFINITE timeout. (pthreadCancelableTimedWait): Just calls CancelableWait() with passed in timeout. * private.c (_pthread_sem_timedwait): 'abstime' arg really is absolute time. Calculate relative time to wait from current time before passing timeout to new routine pthreadCancelableTimedWait(). - Scott Lightner <scott@curriculum.com> Tue Jan 19 10:27:39 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au> * pthread.h (pthread_mutexattr_setforcecs_np): New prototype. * mutex.c (pthread_mutexattr_init): Init 'pshared' and 'forcecs' attributes to 0. (pthread_mutexattr_setforcecs_np): New function (not portable). * pthread.h (pthread_mutex_t): Add 'mutex' element. Set to NULL in PTHREAD_MUTEX_INITIALIZER. The pthread_mutex_*() routines will try to optimise performance by choosing either mutexes or critical sections as the basis for pthread mutexes for each indevidual mutex. (pthread_mutexattr_t_): Add 'forcecs' element. Some applications may choose to force use of critical sections if they know that:- the mutex is PROCESS_PRIVATE and, either the OS supports TryEnterCriticalSection() or pthread_mutex_trylock() will never be called on the mutex. This attribute will be setable via a non-portable routine. Note: We don't yet support PROCESS_SHARED mutexes, so the implementation as it stands will default to Win32 mutexes only if the OS doesn't support TryEnterCriticalSection. On Win9x, and early versions of NT 'forcecs' will need to be set in order to get critical section based mutexes. Sun Jan 17 12:01:26 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au> * pthread.h (PTHREAD_MUTEX_INITIALIZER): Init new 'staticinit' value to '1' and existing 'valid' value to '1'. * global.c (_pthread_mutex_test_init_lock): Add. * implement.h (_pthread_mutex_test_init_lock.): Add extern. * private.c (_pthread_processInitialize): Init critical section for global lock used by _mutex_check_need_init(). (_pthread_processTerminate): Ditto (:s/Init/Destroy/). * dll.c (dllMain): Move call to FreeLibrary() so that it is only called once when the process detaches. * mutex.c (_mutex_check_need_init): New static function to test and init PTHREAD_MUTEX_INITIALIZER mutexes. Provides serialised access to the internal state of the uninitialised static mutex. Called from pthread_mutex_trylock() and pthread_mutex_lock() which do a quick unguarded test to check if _mutex_check_need_init() needs to be called. This is safe as the test is conservative and is repeated inside the guarded section of _mutex_check_need_init(). Thus in all calls except the first calls to lock static mutexes, the additional overhead to lock any mutex is a single memory fetch and test for zero. * pthread.h (pthread_mutex_t_): Add 'staticinit' member. Mutexes initialised by PTHREAD_MUTEX_INITIALIZER aren't really initialised until the first attempt to lock it. Using the 'valid' flag (which flags the mutex as destroyed or not) to record this information would be messy. It is possible for a statically initialised mutex such as this to be destroyed before ever being used. * mutex.c (pthread_mutex_trylock): Call _mutex_check_need_init() to test/init PTHREAD_MUTEX_INITIALIZER mutexes. (pthread_mutex_lock): Ditto. (pthread_mutex_unlock): Add check to ensure we don't try to unlock an unitialised static mutex. (pthread_mutex_destroy): Add check to ensure we don't try to delete a critical section that we never created. Allows us to destroy a static mutex that has never been locked (and hence initialised). (pthread_mutex_init): Set 'staticinit' flag to 0 for the new mutex.
1998-12-06As well as patches from Anders, this commit includes some older changesrpj
that hadn't been checked in. Those are to finish off the original TSD management scheme which will now start to be replaced by John Bossom's implementation. Anders' description of his changes:- Fixes the problem with `TryEnterCriticalSection' on w95 systems. Instead of directly calling `TryEnterCriticalSection' it tries to get a pointer at DLL startup and only calls the function if it exists. See ChangeLog for things changed. 1998-12-05 Anders Norlander <anorland@hem2.passagen.se> * implement.h (_pthread_try_enter_critical_section): New extern * dll.c (_pthread_try_enter_critical_section): New pointer to TryEnterCriticalSection if it exists; otherwise NULL. * dll.c (PthreadsEntryPoint): Initialize _pthread_try_enter_critical_section at startup and release kernel32 handle when DLL is being unloaded. * mutex.c (pthread_mutex_trylock): Replaced check for NT with a check if _pthread_try_enter_critical_section is valid pointer to a function. Call _pthread_try_enter_critical_section instead of TryEnterCriticalSection to avoid errors on Win95. Sun Nov 15 21:24:06 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au> * cleanup.c (_pthread_destructor_run_all): Declare missing void * arg. Fixup CVS merge conflicts. Fri Oct 30 15:15:50 1998 Ross Johnson <rpj@swan.canberra.edu.au> * cleanup.c (_pthread_handler_push): Fixed bug appending new handler to list reported by Peter Slacik <Peter.Slacik@leibinger.freinet.de>. (new_thread): Rename poorly named local variable to "new_handler". Sat Oct 24 18:34:59 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au> * global.c: Add TSD key management array and index declarations. * implement.h: Ditto for externs. Fri Oct 23 00:08:09 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au> * implement.h (_PTHREAD_TSD_KEY_REUSE): Add enum. * private.c (_pthread_delete_thread): Add call to _pthread_destructor_run_all() to clean up the threads keys. * cleanup.c (_pthread_destructor_run_all): Check for no more dirty keys to run destructors on. Assume that the destructor call always succeeds and set the key value to NULL.
1998-10-041998-10-05 Ben Elliston <bje@cygnus.com>bje
* global.c (PTHREAD_MUTEX_INITIALIZER): Move to pthread.h. * pthread.h (PTHREAD_MUTEX_INITIALIZER): Define. (pthread_mutex_t): Reimplement as a struct containing a valid flag. If the flag is ever down upon entry to a mutex operation, we call pthread_mutex_create() to initialise the object. This fixes the problem of how to handle statically initialised objects that can't call InitializeCriticalSection() due to their context. * mutex.c (pthread_mutex_init): Set valid flag. (pthread_mutex_destroy): Clear valid flag. (pthread_mutex_lock): Check and handle the valid flag. (pthread_mutex_unlock): Likewise. (pthread_mutex_trylock): Likewise. * tests/mutex3.c: New file; test for the static initialisation macro. Passes.
1998-10-031998-10-03 Ben Elliston <bje@cygnus.com>bje
* mutex.c (pthread_mutex_init): Correct function signature.
1998-09-121998-09-12 Ben Elliston <bje@cygnus.com>bje
* {most}.c: Include <errno.h> to get POSIX error values. * signal.c (pthread_sigmask): Only provide if HAVE_SIGSET_T is defined. * config.h: #undef features, don't #define them. This will be generated by autoconf very soon.
1998-08-04Tue Aug 4 16:57:58 1998 Ross Johnson <rpj@swan.canberra.edu.au>rpj
* private.c (_pthread_delete_thread): Fix typo. Add missing ';'. * global.c (_pthread_virgins): Change types from pointer to array pointer. (_pthread_reuse): Ditto. (_pthread_win32handle_map): Ditto. (_pthread_threads_mutex_table): Ditto. * implement.h(_pthread_virgins): Change types from pointer to array pointer. (_pthread_reuse): Ditto. (_pthread_win32handle_map): Ditto. (_pthread_threads_mutex_table): Ditto. * private.c (_pthread_delete_thread): Fix "entry" should be "thread". * misc.c (pthread_self): Add extern for _pthread_threadID_TlsIndex. * global.c: Add comment. * misc.c (pthread_once): Fix member -> dereferences. Change _pthread_once_flag to once_control->flag in "if" test.
1998-07-251998-07-26 Ben Elliston <bje@cygnus.com>bje
* mutex.c (pthread_mutexattr_setpshared): Not supported; remove. (pthread_mutexattr_getpshared): Likewise. * pthread.h (pthread_mutexattr_setpshared): Remove prototype. (pthread_mutexattr_getpshared): Likewise.
1998-07-231998-07-24 Ben Elliston <bje@cygnus.com>bje
* mutex.c (pthread_mutexattr_setprotocol): Remove; not supported. (pthread_mutexattr_getprotocol): Likewise. (pthread_mutexattr_setprioceiling): Likewise. (pthread_mutexattr_getprioceiling): Likewise.
1998-07-22i1998-07-22 Ben Elliston <bje@cygnus.com>bje
* attr.c (pthread_setstacksize): Update test of attr argument. (pthread_getstacksize): Likewise. (pthread_setstackaddr): Likewise. (pthread_getstackaddr): Likewise. (pthread_attr_init): No need to allocate any storage. (pthread_attr_destroy): No need to free any storage. * mutex.c (is_attr): Not likely to be needed; remove. (remove_attr): Likewise. (insert_attr): Likewise. * pthread.h (pthread_attr_t): Moved here from implement.h. * implement.h (_pthread_mutexattr_t): Moved to a public definition in pthread.h. There was little gain in hiding these details. (_pthread_condattr_t): Likewise.
1998-07-191998-07-19 Ben Elliston <bje@cygnus.com>bje
* mutex.c (pthread_mutex_trylock): Return ENOSYS if this function is called on a Win32 platform which is not Windows NT.
1998-07-171998-07-17 Ben Elliston <bje@cygnus.com>bje
* mutex.c (pthread_mutex_init): Use InitializeCritcalSection(). (pthread_mutex_destroy): Use DeleteCriticalSection(). (pthread_mutex_lock): Use EnterCriticalSection(). (pthread_mutex_trylock): Use TryEnterCriticalSection(). This is not supported by Windows 9x, but trylock is a hack anyway, IMHO. (pthread_mutex_unlock): Use LeaveCriticalSection().
1998-07-171998-07-17 Ben Elliston <bje@cygnus.com>bje
* mutex.c (pthread_mutexattr_init): No need to malloc any storage; the attributes structure is now empty. (pthread_mutexattr_destroy): This is now a nop.
1998-07-171998-07-17 Ben Elliston <bje@cygnus.com>bje
* mutex.c (pthread_mutexattr_setpshared): This optional function is no longer supported, since we want to implement POSIX mutex variables using the much more efficient Win32 critical section primitives. Critical section objects in Win32 cannot be shared between processes. (pthread_mutexattr_getpshared): Likewise.
1998-07-131998-07-14 Ben Elliston <bje@cygnus.com>bje
* mutex.c (pthread_mutex_lock): Add `_mutex' to function name. (pthread_mutex_trylock): Likewise. (pthread_mutex_unlock): Likewise.
1998-07-12See the ChangeLog.rpj
1998-07-12 * mutex.c (pthread_mutexattr_destory): Simplify flow of control.bje
1998-07-121998-07-13 Ben Elliston <bje@cygnus.com>bje
* mutex.c (pthread_mutex_init): Implement. (pthread_mutex_destroy): Likewise. (pthread_lock): Likewise. (pthread_trylock): Likewise. (pthread_unlock): Likewise.
1998-07-12 * mutex.c (pthread_mutexattr_init): Implement.bje
(pthread_mutexattr_destroy): Implement. (pthread_mutexattr_setpshared): Likewise. (pthread_mutexattr_getpshared): Likewise. (insert_attr): New function; very preliminary implementation! (is_attr): Likewise. (remove_attr): Likewise.
1998-07-121998-07-12 Ben Elliston <bje@cygnus.com>bje
* mutex.c (pthread_mutexattr_setprotocol): Implement. (pthread_mutexattr_getprotocol): Likewise. (pthread_mutexattr_setprioceiling): Likewise. (pthread_mutexattr_getprioceiling): Likewise.