summaryrefslogtreecommitdiff
path: root/pthread.h
AgeCommit message (Collapse)Author
2002-01-312002-01-27 Ross Johnson <rpj@special.ise.canberra.edu.au>rpj
* mutex.c (pthread_mutex_timedlock): New function suggested by Alexander Terekhov. The logic required to implement this properly came from Alexander, with some collaboration with Thomas Pfaff. (pthread_mutex_unlock): Wrap the waiters check and sema post in a critical section to prevent a race with pthread_mutex_timedlock. (ptw32_timed_semwait): New function; returns a special result if the absolute timeout parameter represents a time already passed when called; used by pthread_mutex_timedwait(). Have deliberately not reused the name "ptw32_sem_timedwait" because they are not the same routine. * condvar.c (ptw32_cond_timedwait): Use the new sem_timedwait() instead of ptw32_sem_timedwait(), which now has a different function. See previous. * implement.h: Remove prototype for ptw32_sem_timedwait. See next. (pthread_mutex_t_): Add critical section element for access to lock_idx during mutex post-timeout processing. * semaphore.h (sem_timedwait): See next. * semaphore.c (sem_timedwait): See next. * private.c (ptw32_sem_timedwait): Move to semaphore.c and rename as sem_timedwait(). 2002-01-18 Ross Johnson <rpj@special.ise.canberra.edu.au> * sync.c (pthread_join): Was getting the exit code from the calling thread rather than the joined thread if defined(__MINGW32__) && !defined(__MSVCRT__). 2002-01-15 Ross Johnson <rpj@special.ise.canberra.edu.au> * pthread.h: Unless the build explicitly defines __CLEANUP_SEH, __CLEANUP_CXX, or __CLEANUP_C, then the build defaults to __CLEANUP_C style cleanup. This style uses setjmp/longjmp in the cancelation and thread exit implementations and therefore won't do stack unwinding if linked to applications that have it (e.g. C++ apps). This is currently consistent with most/all commercial Unix POSIX threads implementations. * spin.c (pthread_spin_init): Edit renamed function call. * nonportable.c (pthread_num_processors_np): New. (pthread_getprocessors_np): Renamed to ptw32_getprocessors and moved to private.c. * private.c (pthread_getprocessors): Moved here from nonportable.c. * pthread.def (pthread_getprocessors_np): Removed from export list. * rwlock.c (pthread_rwlockattr_init): New. (pthread_rwlockattr_destroy): New. (pthread_rwlockattr_getpshared): New. (pthread_rwlockattr_setpshared): New.
2001-12-18Include an interim complete Copyright notice in each source file;rpj
Remove unused autoconf files; Add the file COPYING, which describes the pthread-win32 license relative to the FSF LGPL.
2001-07-09 * barrier.c: Revamped to fix the race condition. Two alternatingrpj
semaphores are used instead of the PulseEvent. Also improved overall throughput by returning PTHREAD_BARRIER_SERIAL_THREAD to the first waking thread. * implement.h (pthread_barrier_t_): Revamped.
2001-07-06Spinlocks and barriers fixed and working. Beta level.rpj
* spin.c: Revamped and working; included static initialiser. * barrier.c: Likewise. * condvar.c: Macro constant change; inline auto init routine. * mutex.c: Likewise. * rwlock.c: Likewise. * private.c: Add support for spinlock initialiser. * global.c: Likewise. * implement.h: Likewise. * pthread.h (PTHREAD_SPINLOCK_INITIALIZER): Fix typo. tests/ChangeLog: * spin3.c: Changed test and fixed. * spin4.c: Fixed. * barrier3.c: Fixed. * barrier4.c: Fixed.
2001-07-05Fixups to last commit.rpj
2001-07-05 * barrier.c: Remove static initialisation - irreleventrpj
for this object. * pthread.h (PTHREAD_BARRIER_INITIALIZER): Removed. * rwlock.c (pthread_rwlock_wrlock): This routine is not a cancelation point - disable deferred cancelation around call to pthread_cond_wait(). tests/ChangeLog: * spin1.c: New; testing spinlocks. * spin2.c: New; testing spinlocks. * spin3.c: New; testing spinlocks. * spin4.c: New; testing spinlocks. * barrier1.c: New; testing barriers. * barrier2.c: New; testing barriers. * barrier3.c: New; testing barriers. * barrier4.c: New; testing barriers. * GNUmakefile: Add new tests. * Makefile: Add new tests.
2001-07-05Added new routines from POSIX 1003.1j. This is alpha level code.rpj
* spin.c: New module implementing spin locks. * barrier.c: New module implementing barriers. * pthread.h (_POSIX_SPIN_LOCKS): defined. (_POSIX_BARRIERS): Defined. (pthread_spin_*): Defined. (pthread_barrier*): Defined. (PTHREAD_BARRIER_SERIAL_THREAD): Defined. * implement.h (pthread_spinlock_t_): Defined. (pthread_barrier_t_): Defined. (pthread_barrierattr_t_): Defined. * mutex.c (pthread_mutex_lock): Return with the error if an auto-initialiser initialisation fails. * nonportable.c (pthread_getprocessors_np): New; gets the number of available processors for the current process.
2001-07-012001-07-01 Ross Johnson <rpj@setup1.ise.canberra.edu.au>rpj
Contributed by - Alexander Terekhov. * condvar.c: Fixed lost signal bug reported by Timur Aydin (taydin@snet.net). [RPJ (me) didn't translate the original algorithm correctly.] * semaphore.c: Added sem_post_multiple; this is a useful routine, but it doesn't appear to be standard. For now it's not an exported function.
2001-07-012001-06-25 Ross Johnson <rpj@setup1.ise.canberra.edu.au>rpj
* create.c (pthread_create): Add priority inheritance attributes. * mutex.c (pthread_mutex_lock): Remove some overhead for PTHREAD_MUTEX_NORMAL mutex types. Specifically, avoid calling pthread_self() and pthread_equal() to check/set the mutex owner. Introduce a new pseudo owner for this type. Test results suggest increases in speed of up to 90% for non-blocking locks. This is the default type of mutex used internally by other synchronising objects, ie. condition variables and read-write locks. The test rwlock7.c shows about a 30-35% speed increase over snapshot 2001-06-06. The price of this is that the application developer must ensure correct behaviour, or explicitly set the mutex to a safer type such as PTHREAD_MUTEX_ERRORCHECK. For example, PTHREAD_MUTEX_NORMAL (or PTHREAD_MUTEX_DEFAULT) type mutexes will not return an error if a thread which is not the owner calls pthread_mutex_unlock. The call will succeed in unlocking the mutex if it is currently locked, but a subsequent unlock by the true owner will then fail with EPERM. This is however consistent with some other implementations. (pthread_mutex_unlock): Likewise. (pthread_mutex_trylock): Likewise. (pthread_mutex_destroy): Likewise. * attr.c (pthread_attr_init): PTHREAD_EXPLICIT_SCHED is the default inheritance attribute; THREAD_PRIORITY_NORMAL is the default priority for new threads. * sched.c (pthread_attr_setschedpolicy): Added routine. (pthread_attr_getschedpolicy): Added routine. (pthread_attr_setinheritsched): Added routine. (pthread_attr_getinheritsched): Added routine. * pthread.h (sched_rr_set_interval): Added as a macro; returns -1 with errno set to ENOSYS. 2001-06-23 Ross Johnson <rpj@setup1.ise.canberra.edu.au> *sched.c (pthread_attr_setschedparam): Add priority range check. (sched_setscheduler): New function; checks for a valid pid and policy; checks for permission to set information in the target process; expects pid to be a Win32 process ID, not a process handle; the only scheduler policy allowed is SCHED_OTHER. (sched_getscheduler): Likewise, but checks for permission to query. * pthread.h (SCHED_*): Moved to sched.h as defined in the POSIX standard. * sched.h (SCHED_*): Moved from pthread.h. (pid_t): Defined if necessary. (sched_setscheduler): Defined. (sched_getscheduler): Defined. * pthread.def (sched_setscheduler): Exported. (sched_getscheduler): Likewise. 2001-06-23 Ross Johnson <rpj@setup1.ise.canberra.edu.au> Contributed by - Ralf Brese <Ralf.Brese@pdb4.siemens.de> * create.c (pthread_create): Set thread priority from thread attributes.
2001-06-19 * Made organisational-only changes to UWIN additions.rpj
* dll.c (dllMain): Moved UWIN process attach code to pthread_win32_process_attach_np(); moved instance of pthread_count to global.c. * global.c (pthread_count): Moved from dll.c. * nonportable.c (pthread_win32_process_attach_np): Moved _UWIN code to here from dll.c. * implement.h (pthread_count): Define extern int. * create.c (pthread_count): Remove extern int. * private.c (pthread_count): Likewise. * exit.c (pthread_count): Likewise. Contributed by - David Korn <dgk@research.att.com> * dll.c: Added changes necessary to work with UWIN. * create.c: Likewise. * pthread.h: Likewise. * misc.c: Likewise. * exit.c: Likewise. * private.c: Likewise. * implement.h: Likewise. There is some room at the start of struct pthread_t_ to implement the signal semantics in UWIN's posix.dll although this is not yet complete. * Nmakefile: Compatible with UWIN's Nmake utility. * Nmakefile.tests: Likewise - for running the tests.
2001-06-05 * nonportable.c (pthread_mutex_setdefaultkind_np):rpj
Remove - should not have been included in the first place. (pthread_mutex_getdefaultkind_np): Likewise. * global.c (ptw32_mutex_default_kind): Likewise. * mutex.c (pthread_mutex_init): Remove use of ptw32_mutex_default_kind. * pthread.h (pthread_mutex_setdefaultkind_np): Likewise. (pthread_mutex_getdefaultkind_np): Likewise. * pthread.def (pthread_mutexattr_setkind_np): Added. (pthread_mutexattr_getkind_np): Likewise. * README: Many changes that should have gone in before the last snapshot. * README.NONPORTABLE: New - referred to by ANNOUNCE but never created; documents the non-portable routines included in the library - moved from README with new routines added. * ANNOUNCE (pthread_mutexattr_setkind_np): Added to compliance list. (pthread_mutexattr_getkind_np): Likewise.
2001-05-312001-05-30 Ross Johnson <rpj@setup1.ise.canberra.edu.au>rpj
* pthread.h (rand_r): Fake using _seed argument to quell compiler warning (compiler should optimise this away later). * GNUmakefile (OPT): Leave symbolic information out of the library and increase optimisation level - for smaller faster prebuilt dlls. 2001-05-29 Ross Johnson <rpj@setup1.ise.canberra.edu.au> Contributed by - Milan Gardian <Milan.Gardian@LEIBINGER.com> * Makefile: fix typo. * pthreads.h: Fix problems with stdcall/cdecl conventions, in particular remove the need for PT_STDCALL everywhere; remove warning supression. * (errno): Fix the longstanding "inconsistent dll linkage" problem with errno; now also works with /MD debugging libs - warnings emerged when compiling pthreads library with /MD (or /MDd) compiler switch, instead of /MT (or /MTd) (i.e. when compiling pthreads using Multithreaded DLL CRT instead of Multithreaded statically linked CRT). * create.c (pthread_create): Likewise; fix typo. * private.c (ptw32_threadStart): Eliminate use of terminate() which doesn't throw exceptions. * Remove unnecessary #includes from a number of modules - [I had to #include malloc.h in implement.h for gcc - rpj]. 2001-05-29 Ross Johnson <rpj@setup1.ise.canberra.edu.au> Contributed by - Thomas Pfaff <tpfaff@gmx.net> * pthread.h (PTHREAD_MUTEX_DEFAULT): New; equivalent to PTHREAD_MUTEX_DEFAULT_NP. * (PTHREAD_MUTEX_NORMAL): Similarly. * (PTHREAD_MUTEX_ERRORCHECK): Similarly. * (PTHREAD_MUTEX_RECURSIVE): Similarly. * (pthread_mutex_setdefaultkind_np): New; Linux compatibility stub for pthread_mutexattr_settype. * (pthread_mutexattr_getkind_np): New; Linux compatibility stub for pthread_mutexattr_gettype. * mutex.c (pthread_mutexattr_settype): New; allow the following types of mutex: PTHREAD_MUTEX_DEFAULT_NP PTHREAD_MUTEX_NORMAL_NP PTHREAD_MUTEX_ERRORCHECK_NP PTHREAD_MUTEX_RECURSIVE_NP * Note that PTHREAD_MUTEX_DEFAULT is equivalent to PTHREAD_MUTEX_NORMAL - ie. mutexes should no longer be recursive by default, and a thread will deadlock if it tries to relock a mutex it already owns. This is inline with other pthreads implementations. * (pthread_mutex_lock): Process the lock request according to the mutex type. * (pthread_mutex_init): Eliminate use of Win32 mutexes as the basis of POSIX mutexes - instead, a combination of one critical section and one semaphore are used in conjunction with Win32 Interlocked* routines. * (pthread_mutex_destroy): Likewise. * (pthread_mutex_lock): Likewise. * (pthread_mutex_trylock): Likewise. * (pthread_mutex_unlock): Likewise. * Use longjmp/setjmp to implement cancelation when building the library using a C compiler which doesn't support exceptions, e.g. gcc -x c (note that gcc -x c++ uses exceptions). * Also fixed some of the same typos and eliminated PT_STDCALL as Milan Gardian's patches above. 2001-02-07 Ross Johnson <rpj@special.ise.canberra.edu.au> Contributed by - Alexander Terekhov <TEREKHOV@de.ibm.com> * rwlock.c: Revamped. * implement.h (pthread_rwlock_t_): Redefined. This implementation does not have reader/writer starvation problem. Rwlock attempts to behave more like a normal mutex with races and scheduling policy determining who is more important; It also supports recursive locking, has less synchronization overhead (no broadcasts at all, readers are not blocked on any condition variable) and seem to be faster than the current implementation [W98 appears to be approximately 15 percent faster at least - on top of speed increase from Thomas Pfaff's changes to mutex.c - rpj].
2000-12-29./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-12-28./ChangeLog:rpj
2000-12-28 Ross Johnson <rpj@special.ise.canberra.edu.au> * private.c (ptw32_threadStart): Unhandled exceptions are now passed through to the system to deal with. This is consistent with normal Windows behaviour. C++ applications may use set_terminate() to override the default behaviour which is to call ptw32_terminate(). Ptw32_terminate() cleans up some POSIX thread stuff before calling the system default function which calls abort(). The users termination function should conform to standard C++ semantics which is to not return. It should exit the thread (call pthread_exit()) or exit the application. * private.c (ptw32_terminate): Added as the default set_terminate() function. It calls the system default function after cleaning up some POSIX thread stuff. * implement.h (ptw32_try_enter_critical_section): Move declaration. * global.c (ptw32_try_enter_critical_section): Moved from dll.c. * dll.c: Move process and thread attach/detach code into functions in nonportable.c. * nonportable.c (pthread_win32_process_attach_np): Process attach code from dll.c is now available to static linked applications. * nonportable.c (pthread_win32_process_detach_np): Likewise. * nonportable.c (pthread_win32_thread_attach_np): Likewise. * nonportable.c (pthread_win32_thread_detach_np): Likewise. * pthread.h: Add new non-portable prototypes for static linked applications. * GNUmakefile (OPT): Increase optimisation flag and remove debug info flag. * pthread.def: Add new non-portable exports for static linked applications. 2000-12-11 Ross Johnson <rpj@special.ise.canberra.edu.au> * FAQ: Update Answer 6 re getting a fully working Mingw32 built library. 2000-09-09 Ross Johnson <rpj@special.ise.canberra.edu.au> * pthread.h (ctime_r): Fix arg. ./tests/ChangeLog: 2000-12-28 Ross Johnson <rpj@special.ise.canberra.edu.au> * eyal1.c: Increase thread work loads. * exception2.c: New test. * exception3.c: New test. * Makefile: Add new tests exception2.c and exception3.c. * GNUmakefile: Likewise. 2000-12-11 Ross Johnson <rpj@special.ise.canberra.edu.au> * cleanup3.c: Remove unused variable. * cleanup2.c: Likewise. * exception1.c: Throw an exception rather than use a deliberate zero divide so that catch(...) will handle it under Mingw32. Mingw32 now builds the library correctly to pass all tests - see Thomas Pfaff's detailed instructions re needed changes to Mingw32 in the Pthreads-Win32 FAQ.
2000-09-072000-09-08 Ross Johnson <rpj@special.ise.canberra.edu.au>rpj
* cancel.c (pthread_cancel): Must get "self" through calling pthread_self() which will ensure a POSIX thread struct is built for non-POSIX threads; return an error if this fails - Ollie Leahy <ollie@mpt.ie> (pthread_setcancelstate): Likewise. (pthread_setcanceltype): Likewise. * misc.c (ptw32_cancelable_wait): Likewise. * private.c (ptw32_tkAssocCreate): Remove unused #if 0 wrapped code. * pthread.h (ptw32_get_exception_services_code): Needed to be forward declared unconditionally. 2000-09-06 Ross Johnson <rpj@special.ise.canberra.edu.au> * cancel.c (pthread_cancel): If called from the main thread "self" would be NULL; get "self" via pthread_self() instead of directly from TLS so that an implicit pthread object is created. * misc.c (pthread_equal): Strengthen test for NULLs.
2000-09-022000-09-02 Ross Johnson <rpj@special.ise.canberra.edu.au>rpj
* condvar.c (ptw32_cond_wait_cleanup): Ensure that all waking threads check if they are the last, and notify the broadcaster if so - even if an error occurs in the waiter. * semaphore.c (_decrease_semaphore): Should be a call to ptw32_decrease_semaphore. (_increase_semaphore): Should be a call to ptw32_increase_semaphore. * misc.c (ptw32_cancelable_wait): Renamed from CancelableWait. (cond_wait_cleanup*): Rename to ptw32_cond_wait_cleanup*. (ptw32_cond_timedwait): Add comments.
2000-08-222000-08-22 Ross Johnson <rpj@setup1.ise.canberra.edu.au>rpj
* private.c (ptw32_throw): Fix exception test; move exceptionInformation declaration. * tsd.c (pthread_key_create): newkey wrongly declared. * pthread.h: Fix comment block.
2000-08-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-08-142000-08-13 Ross Johnson <rpj@special.ise.canberra.edu.au>rpj
* errno.c: Add _MD precompile condition; thus far had no effect when using /MD compile option but I thnk it should be there. * exit.c: Add __cplusplus to various #if lines; was compiling SEH code even when VC++ had C++ compile options. * private.c: ditto. * create.c (pthread_create): Add PT_STDCALL macro to function pointer arg in _beginthread(). * pthread.h: PT_STDCALL really does need to be defined in both this and impliment.h; don't set it to __cdecl - this macro is only used to extend function pointer casting for functions that will be passed as parameters. (~PThreadCleanup): add cast and group expression. (_errno): Add _MD compile conditional. (PtW32NoCatchWarn): Change pragma message. * implement.h: Move and change PT_STDCALL define. * need_errno.h: Add _MD to compilation conditional. * GNUmakefile: Substantial rewrite for new naming convention; set for nil optimisation (turn it up when we have a working library build; add target "fake.a" to build a libpthreadw32.a from the VC++ built DLL pthreadVCE.dll. * pthread.def (LIBRARY): Don't specify in the .def file - it is specified on the linker command line since we now use the same .def file for variously named .dlls. * Makefile: Substantial rewrite for new naming convention; default nmake target only issues a help message; run nmake with specific target corresponding to the EH scheme being used. * README: Update information; add naming convention explanation. * ANNOUNCE: Update information. 2000-08-12 Ross Johnson <rpj@special.ise.canberra.edu.au> * pthread.h: Add compile-time message when using MSC_VER compiler and C++ EH to warn application programmers to use PtW32Catch instead of catch(...) if they want cancelation and pthread_exit to work. * implement.h: Remove #include <semaphore.h>; we use our own local semaphore.h. tests/ChangeLog: 2000-08-13 Ross Johnson <rpj@special.ise.canberra.edu.au> * condvar3.c: Minor change to eliminate compiler warning. * condvar4.c: ditto. * condvar5.c: ditto. * condvar6.c: ditto. * condvar7.c: ditto. * condvar8.c: ditto. * condvar9.c: ditto. * exit1.c: Function needed return statement. * cleanup1.c: Remove unnecessary printf arg. * cleanup2.c: Fix cast. * rwlock6.c: Fix casts. * exception1.c (PtW32CatchAll): Had the wrong name; fix casts. * cancel3.c: Remove unused waitLock variable. * GNUmakefile: Change library/dll naming; add new tests; general minor changes. * Makefile: Change library/dll naming; add targets for testing each of the two VC++ EH scheme versions; default target now issues help message; compile warnings now interpreted as errors to stop the make; add new tests; restructure to remove prerequisites needed otherwise. * README: Updated.
2000-08-062000-08-06 Ross Johnson <rpj@special.ise.canberra.edu.au>rpj
* pthread.h: Remove #warning - VC++ doesn't accept it. 2000-08-05 Ross Johnson <rpj@special.ise.canberra.edu.au> * pthread.h (PtW32CatchAll): Add macro. When compiling applications using VC++ with C++ EH rather than SEH 'PtW32CatchAll' must be used in place of any 'catch( ... )' if the application wants pthread cancelation or pthread_exit() to work. 2000-08-03 Ross Johnson <rpj@special.ise.canberra.edu.au> * pthread.h: Add a base class Pthread_exception for library internal exceptions and change the "catch" re-define macro to use it. 2000-08-02 Ross Johnson <rpj@special.ise.canberra.edu.au> * GNUmakefile (CFLAGS): Add -mthreads. Add new targets to generate cpp and asm output. * sync.c (pthread_join): Remove dead code. tests: 2000-08-06 Ross Johnson <rpj@special.ise.canberra.edu.au> * ccl.bat: Add /nologo to remove extraneous output. * exception1.c (exceptionedThread): Init 'dummy'; put expression into if condition to prevent optimising away; remove unused variable. * cancel4.c (mythread): Cast return value to avoid warnings. * cancel2.c (mythread): Missing #endif. * condvar9.c (mythread): Cast return value to avoid warnings. * condvar8.c (mythread): Cast return value to avoid warnings. * condvar7.c (mythread): Cast return value to avoid warnings. * cleanup3.c (mythread): Cast return value to avoid warnings. * cleanup2.c (mythread): Cast return value to avoid warnings. * cleanup1.c (mythread): Cast return value to avoid warnings. * condvar5.c (mythread): Cast return value to avoid warnings. * condvar3.c (mythread): Cast return value to avoid warnings. * condvar6.c (mythread): Cast return value to avoid warnings. * condvar4.c (mythread): Cast return value to avoid warnings. 2000-08-05 Ross Johnson <rpj@special.ise.canberra.edu.au> * cancel2.c: Use PtW32CatchAll macro if defined. * exception1.c: Use PtW32CatchAll macro if defined. 2000-08-02 Ross Johnson <rpj@special.ise.canberra.edu.au> * tsd1.c: Fix typecasts of &result [g++ is now very fussy]. * test.h (assert): Return 0's explicitly to allay g++ errors. * join2.c: Add explicit typecasts. * join1.c: Add explicit typecasts. * join0.c: Add explicit typecasts. * eyal1.c: Add explicit typecasts. * count1.c (main): Add type cast to remove g++ parse warning [gcc-2.95.2 seems to have tightened up on this]. * Makefile (GLANG): Use c++ explicitly. Remove MSVC sections (was commented out). Add target to generate cpp output.
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.
2000-01-04Main changes (see ChangeLog diff for details and attributions):-rpj
- asynchronous cancellation added - attempt to hide internal exceptions from applications - kernel32 load/free problem fixed - new tests - changes only to comments in some tests
1999-11-05 * pthread.h (winsock.h): Include unconditionally.rpj
(ETIMEDOUT): Change fallback value to that defined by winsock.h.
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-10-211999-10-21 Ross Johnson <rpj@ixobrychus.canberra.edu.au>rpj
* pthread.h (_POSIX_THREADS): Only define it if it isn't already defined. Projects may need to define this on the CC command line under Win32 as it doesn't have unistd.h - Aurelio Medina <aureliom@crt.com>
1999-09-15Sat Sep 10 12:56:13 1999 Ross Johnson <rpj@swan.canberra.edu.au>rpj
The following code for POSIX read/write locks was contributed by Aurelio Medina. * implement.h (pthread_rwlock_t_): Add. * pthread.h (pthread_rwlock_t): Add. (PTHREAD_RWLOCK_INITIALIZER): Add. Add rwlock function prototypes. * rwlock.c: New module. * pthread.def: Add new rwlock functions. * private.c (_pthread_processInitialize): initialise _pthread_rwlock_test_init_lock critical section. * global.c (_pthread_rwlock_test_init_lock): Add. * mutex.c (pthread_mutex_destroy): Don't free mutex memory if mutex is PTHREAD_MUTEX_INITIALIZER and has not been initialised yet. tests/ChangeLog Sep 15 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au> * rwlock1.c: New test. * rwlock2.c: New test. * rwlock3.c: New test. * rwlock4.c: New test.
1999-08-191999-08-19 Ross Johnson <rpj@ixobrychus.canberra.edu.au>rpj
* private.c (_pthread_threadStart): Return exit status from the application thread startup routine. - Milan Gardian <mg@tatramed.sk> 1999-08-18 Ross Johnson <rpj@ixobrychus.canberra.edu.au> * exit.c (pthread_exit): Put status into pthread_t->exitStatus - John Bossom <john.Bossom@cognos.com> * private.c (_pthread_threadStart): Set pthread->exitStatus on exit of try{} block. - John Bossom <john.Bossom@cognos.com> * sync.c (pthread_join): use pthread_exitStatus value if the thread exit doesn't return a value (for Mingw32 CRTDLL which uses endthread instead of _endthreadex). - John Bossom <john.Bossom@cognos.com> Tue Aug 17 20:17:58 CDT 1999 Mumit Khan <khan@xraylith.wisc.edu> * create.c (pthread_create): Add CRTDLL suppport. * exit.c (pthread_exit): Likewise. * private.c (_pthread_threadStart): Likewise. (_pthread_threadDestroy): Likewise. * sync.c (pthread_join): Likewise. * tests/join1.c (main): Warn about partial support for CRTDLL. Tue Aug 17 20:00:08 1999 Mumit Khan <khan@xraylith.wisc.edu> * Makefile.in (LD): Delete entry point. * acconfig.h (STDCALL): Delete unused macro. * configure.in: Remove test for STDCALL. * config.h.in: Regenerate. * errno.c (_errno): Fix self type. * pthread.h (PT_STDCALL): Move from here to * implement.h (PT_STDCALL): here. (_pthread_threadStart): Fix prototype. * private.c (_pthread_threadStart): Likewise. 1999-08-14 Ross Johnson <rpj@ixobrychus.canberra.edu.au> * exit.c (pthread_exit): Don't call pthread_self() but get thread handle directly from TSD for efficiency.
1999-08-12Merged patches to main trunk.rpj
1999-04-06Wed Apr 7 14:09:52 1999 Ross Johnson <rpj@swan.canberra.edu.au>snap-1999-04-07rpj
* errno.c (_REENTRANT || _MT): Invert #if condition. * pthread.h (_errno): Conditionally include prototype.
1999-04-03./ChangeLogrpj
Sun Apr 4 11:05:57 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au> * sched.c (sched.h): Include. * sched.h: New file for POSIX 1b scheduling. * pthread.h: Move opaque structures to implement.h; move sched_* prototypes out and into sched.h. * implement.h: Add opaque structures from pthread.h. * sched.c (sched_yield): New function. * condvar.c (_pthread_sem_*): Rename to sem_*; except for _pthread_sem_timedwait which is an private function. Sat Apr 3 23:28:00 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au> * Makefile.in (OBJS): Add errno.o. Fri Apr 2 11:08:50 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au> * implement.h (_pthread_sem_*): Remove prototypes now defined in semaphore.h. * pthread.h (sempahore.h): Include. * semaphore.h: New file for POSIX 1b semaphores. * pthread.h (_pthread_sem_t): Change to sem_t. * semaphore.c (_pthread_sem_*): Change to sem_*; these functions will be exported from the library; set errno on error. - John Bossom <jebossom@cognos.com> (_pthread_sem_timedwait): Moved to private.c. * private.c (_pthread_sem_timedwait): Moved from semaphore.c; set errno on error. * errno.c (_errno): New file. New function. - John Bossom * pthread.h (pthread_t_): Add per-thread errno element. tests/ChangeLog Sun Apr 4 12:04:28 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au> * tsd1.c (mythread): Change Sleep(0) to sched_yield(). (sched.h): Include. * condvar3.c (mythread): Remove redundant Sleep(). * runtest.bat: Re-organised to make more informative.
1999-03-18==> ChangeLog <==rpj
Fri Mar 19 09:12:59 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au> * private.c (_pthread_threadStart): status returns PTHREAD_CANCELED. * pthread.h (PTHREAD_CANCELED): defined. ==> tests/ChangeLog <== Fri Mar 19 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au> * *.bat: redirect unwanted output to nul: * runall.bat: new. * cancel1.c: new. Not part of suite yet.
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-21Sun Feb 21 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au>rpj
* pthread.h (PTHREAD_MUTEX_INITIALIZER): missing braces around cs element initialiser. Bring some tests up-to-date.
1999-02-201999-02-21 Ben Elliston <bje@cygnus.com>bje
* pthread.h (pthread_exit): The return type of this function is void, not int. * exit.c (pthread_exit): Do not return 0.
1999-02-17Sat Feb 18 16:2s1703:30 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au>rpj
* pthread.h (struct pthread_once_t_): Remove redefinition.
1999-02-12Sat Feb 13 03:03:30 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au>rpj
* pthread.h (struct pthread_once_t_): Replaced. * misc.c (pthread_once): Replace with John Bossom's version; has lighter weight serialisation; fixes problem of not holding competing threads until after the init_routine completes.
1999-02-08Fri Feb 5 13:42:30 1999 Ross Johnson <rpj@swan.canberra.edu.au>rpj
* semaphore.c: Comment format changes. Wed Feb 3 13:04:44 1999 Ross Johnson <rpj@swan.canberra.edu.au> * cleanup.c: Rename _pthread_*_cleanup() to pthread_*_cleanup(). * pthread.def: Ditto. * pthread.h: Ditto. * pthread.def (pthread_cleanup_push): Remove from export list; the function is defined as a macro under all compilers. (pthread_cleanup_pop): Ditto. * pthread.h: Remove #if defined().
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-22Sat Jan 23 17:36:40 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au>snapshot-1999-01-23rpj
* pthread.h (PTHREAD_MUTEX_AUTO_CS_NP): New. (PTHREAD_MUTEX_FORCE_CS_NP): New.
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.
1999-01-18Tue Jan 19 18:27:42 1999 Ross Johnson <rpj@swan.canberra.edu.au>rpj
* 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>
1999-01-14Fri Jan 15 15:41:28 1999 Ross Johnson <rpj@swan.canberra.edu.au>rpj
* pthread.h: Add new 'abstime' arg to pthreadCancelableWait() prototype. * condvar.c (cond_timedwait): New generalised function called by both pthread_cond_wait() and pthread_cond_timedwait(). This is essentially pthread_cond_wait() renamed and modified to add the 'abstime' arg and call the new _pthread_sem_timedwait() instead of sem_wait(). (pthread_cond_wait): Now just calls the internal static function cond_timedwait() with an INFINITE wait. (pthread_cond_timedwait): Now implemented. Calls the internal static function cond_timedwait(). * implement.h (_pthread_sem_timedwait): New internal function prototype. * misc.c (pthreadCancelableWait): Added new 'abstime' argument to allow shorter than INFINITE wait. * semaphore.c (_pthread_sem_timedwait): New function for internal use. This is essentially sem_wait() modified to add the 'abstime' arg and call the modified (see above) pthreadCancelableWait().
1999-01-12Wed Jan 13 09:34:52 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au>rpj
* build.bat: Delete old binaries before compiling/linking. Tue Jan 12 09:58:38 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au> * dll.c: The Microsoft compiler pragmas probably are more appropriately protected by _MSC_VER than by _WIN32. - Tor Lillqvist <tml@iki.fi>. * condvar.c (pthread_cond_timedwait): Fix function description comments. * pthread.h: Define ETIMEDOUT. This should be returned by pthread_cond_timedwait which is not implemented yet as of snapshot-1999-01-04-1305. It was implemented in the older version. The Microsoft compiler pragmas probably are more appropriately protected by _MSC_VER than by _WIN32. - Tor Lillqvist <tml@iki.fi>. * pthread.def: pthread_mutex_destroy was missing from the def file - Tor Lillqvist <tml@iki.fi>. * condvar.c (pthread_cond_broadcast): Ensure we only wait on threads if there were any waiting on the condition. I think pthread_cond_broadcast should do the WaitForSingleObject only if cv->waiters > 0? Otherwise it seems to hang, at least in the testg thread program from glib. - Tor Lillqvist <tml@iki.fi>. * semaphore.c (sem_post): Correct typo in comment. Mon Jan 11 20:33:19 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au> * pthread.h: Re-arrange conditional compile of pthread_cleanup-* macros. * cleanup.c (_pthread_push_cleanup): Provide conditional compile of cleanup->prev.
1999-01-03Merge John Bossom's code into the main trunk. See ChangeLog for details.snapshot-1999-01-04-1305rpj
This will be tagged as snapshot-1999-01-04-1305
1998-10-14Thu Oct 15 11:53:21 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au>rpj
* global.c (_pthread_tsd_key_table): Fix declaration. * implement.h(_pthread_TSD_keys_TlsIndex): Add missing extern. (_pthread_tsd_mutex): Ditto. * create.c (_pthread_start_call): Fix "keys" array declaration. Add comment. * tsd.c (pthread_setspecific): Fix type declaration and cast. (pthread_getspecific): Ditto. * cleanup.c (_pthread_destructor_run_all): Declare missing loop counter.