summaryrefslogtreecommitdiff
path: root/private.c
AgeCommit message (Collapse)Author
1999-01-03Mon Jan 4 11:23:40 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au>bossom-merge-99-01-04bossom-merge-98-12-08rpj
* all: No code changes, just cleanup. - remove #if 0 /* Pre Bossom */ enclosed code. - Remove some redundant #includes. * pthread.h: Update implemented/unimplemented routines list. * Tag the bossom merge branch getting ready to merge back to main trunk.
1998-12-28With this update I'm able to build the library and build and run therpj
tsd1.c test successfully using buildlib.bat and build.bat scripts. I not convinced that I understand the relationships between "__cplusplus" and "_WIN32" and the MS compiler, particularly in pthread.h where pthread_cleanup_push etc is defined. In particular, I have assumed that the __try/__finally blocks are only available if _WIN32 and __cplusplus are defined. I suspect this is wrong. Tue Dec 29 13:11:16 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au> * implement.h: Move the following struct definitions to pthread.h: pthread_t_, pthread_attr_t_, pthread_mutex_t_, pthread_mutex_t_, pthread_mutexattr_t_, pthread_key_t_, pthread_cond_t_, pthread_condattr_t_, pthread_once_t_. * pthread.h: Add "_" prefix to pthread_push_cleanup and pthread_pop_cleanup internal routines, and associated struct and typedefs. * buildlib.bat: Add compile command for semaphore.c * pthread.def: Comment out pthread_atfork routine name. Now unimplemented. * tsd.c (pthread_setspecific): Rename tkAssocCreate to _pthread_tkAssocCreate. (pthread_key_delete): Rename tkAssocDestroy to _pthread_tkAssocDestroy. * sync.c (pthread_join): Rename threadDestroy to _pthread_threadDestroy * sched.c (is_attr): attr is now **attr (was *attr), so add extra NULL pointer test. (pthread_attr_setschedparam): Increase redirection for attr which is now a **. (pthread_attr_getschedparam): Ditto. (pthread_setschedparam): Change thread validation and rename "thread" Win32 thread Handle element name to match John Bossom's version. (pthread_getschedparam): Ditto. * private.c (_pthread_threadDestroy): Rename call to callUserDestroyRoutines() as _pthread_callUserDestroyRoutines() * misc.c: Add #include "implement.h". * dll.c: Remove defined(KLUDGE) wrapped code. * fork.c: Remove redefinition of ENOMEM. Remove pthread_atfork() and fork() with #if 0/#endif. * create.c (pthread_create): Rename threadStart and threadDestroy calls to _pthread_threadStart and _pthread_threadDestroy. * implement.h: Rename "detachedstate" to "detachstate". * attr.c: Rename "detachedstate" to "detachstate". Mon Dec 28 09:54:39 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au> * pthread.h (pthread_attr_t_): Change to *pthread_attr_t. * attr.c (pthread_attr_setstacksize): Merge with John Bossom's version. (pthread_attr_getstacksize): Merge with John Bossom's version. (pthread_attr_setstackaddr): Merge with John Bossom's version. (pthread_attr_getstackaddr): Merge with John Bossom's version. (pthread_attr_init): Merge with John Bossom's version. (pthread_attr_destroy): Merge with John Bossom's version. (pthread_attr_getdetachstate): Merge with John Bossom's version. (pthread_attr_setdetachstate): Merge with John Bossom's version. (is_attr): attr is now **attr (was *attr), so add extra NULL pointer test. * implement.h (pthread_attr_t_): Add and rename elements in JEB's version to correspond to original, so that it can be used with original attr routines. * pthread.h: Add #endif at end which was truncated in merging.
1998-12-22Sun Dec 20 14:51:58 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au>rpj
* misc.c (pthreadCancelableWait): New function by John Bossom. Non-stand ard but provides a hook that can be used to implement cancellation points in applications that use this library. * pthread.h (pthread_cleanup_pop): C++ (non-WIN32) version uses try/catch to emulate John Bossom's WIN32 __try/__finally behaviour. In the WIN32 version __finally block, add a test for AbnormalTermination otherwise cleanup is only run if the cleanup_pop execute arg is non-zero. Cancella tion should cause the cleanup to run irrespective of the execute arg. * condvar.c (pthread_condattr_init): Replaced by John Bossom's version. (pthread_condattr_destroy): Replaced by John Bossom's version. (pthread_condattr_getpshared): Replaced by John Bossom's version. (pthread_condattr_setpshared): Replaced by John Bossom's version. (pthread_cond_init): Replaced by John Bossom's version. Fix comment (refered to mutex rather than condition variable). (pthread_cond_destroy): Replaced by John Bossom's version. (pthread_cond_wait): Replaced by John Bossom's version. (pthread_cond_timedwait): Replaced by John Bossom's version. (pthread_cond_signal): Replaced by John Bossom's version. (pthread_cond_broadcast): Replaced by John Bossom's version. Thu Dec 17 19:10:46 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au> * tsd.c (pthread_key_create): Replaced by John Bossom's version. (pthread_key_delete): Replaced by John Bossom's version. (pthread_setspecific): Replaced by John Bossom's version. (pthread_getspecific): Replaced by John Bossom's version. Mon Dec 7 09:44:40 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au> * cancel.c (pthread_setcancelstate): Replaced by John Bossom's version. (pthread_setcanceltype): Replaced by John Bossom's version. (pthread_testcancel): Replaced by John Bossom's version. (pthread_cancel): Replaced by John Bossom's version. * exit.c (pthread_exit): Replaced by John Bossom's version. * misc.c (pthread_self): Replaced by John Bossom's version. (pthread_equal): Replaced by John Bossom's version. * sync.c (pthread_detach): Replaced by John Bossom's version. (pthread_join): Replaced by John Bossom's version. * create.c (pthread_create): Replaced by John Bossom's version. * private.c (_pthread_processInitialize): New by John Bossom. (_pthread_processTerminate): Non-public function by John Bossom. (_pthread_threadStart): Non-public function by John Bossom. (_pthread_threadDestroy): Non-public function by John Bossom. (_pthread_cleanupStack): Non-public function by John Bossom. (_pthread_tkAssocCreate): Non-public function by John Bossom. (_pthread_tkAssocDestroy): Non-public function by John Bossom. (_pthread_callUserDestroyRoutines): Non-public function by John Bossom. * implement.h: Added John Bossom's non-API structures and declarations. * dll.c (PthreadsEntryPoint): Cast return value of GetProcAddress to resolve compile warning from MSVC. * dll.c (DLLmain): Replaced by John Bossom's version. * dll.c (PthreadsEntryPoint): Re-applied Anders Norlander's patch:- Initialize _pthread_try_enter_critical_section at startup and release kernel32 handle when DLL is being unloaded.
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-14Thu Oct 15 14:05:01 1998 Ross Johnson <rpj@swan.canberra.edu.au>rpj
* private.c (_pthread_new_thread): Remove init of destructorstack. No longer an element of pthread_t.
1998-10-14Wed Oct 14 21:09:24 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au>rpj
* private.c (_pthread_new_thread): Increment _pthread_threads_count. (_pthread_delete_thread): Decrement _pthread_threads_count. Remove some comments. * exit.c (_pthread_exit): : Fix two pthread_mutex_lock() calls that should have been pthread_mutex_unlock() calls. (_pthread_vacuum): Remove call to _pthread_destructor_pop_all(). * create.c (pthread_create): Fix two pthread_mutex_lock() calls that should have been pthread_mutex_unlock() calls. * global.c (_pthread_tsd_mutex): Add mutex for TSD operations. * tsd.c (pthread_key_create): Add critical section. (pthread_setspecific): Ditto. (pthread_getspecific): Ditto. (pthread_key_delete): Ditto. * sync.c (pthread_join): Fix two pthread_mutex_lock() calls that should have been pthread_mutex_unlock() calls.
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-06*** empty log message ***rpj
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-30Thu Jul 30 23:12:45 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au>rpj
* implement.h: Remove _pthread_find_entry() prototype. * private.c: Extend comments. Remove _pthread_find_entry() - no longer needed. * create.c (_pthread_start_call): Add call to TlsSetValue() to store the thread ID. * dll.c (PthreadsEntryPoint): Implement. This is called whenever a process loads the DLL. Used to initialise thread local storage. * implement.h: Add _pthread_threadID_TlsIndex. Add ()s around _PTHREAD_VALID expression. * misc.c (pthread_self): Re-implement using Win32 TLS to store the threads own ID.
1998-07-29Wed Jul 29 11:39:03 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au>rpj
* private.c: Corrections in comments. (_pthread_new_thread): Alter "if" flow to be more natural.
1998-07-29Wed Jul 29 11:39:03 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au>rpj
* cleanup.c (_pthread_handler_push): Same as below. * create.c (pthread_create): Same as below. * private.c (_pthread_new_thread): Rename "new" to "new_thread". Since when has a C programmer been required to know C++?
1998-07-28Tue Jul 28 14:04:29 1998 Ross Johnson <rpj@swan.canberra.edu.au>rpj
* implement.h: Add _PTHREAD_VALID macro. * sync.c (pthread_join): Modify to use the new thread type and _pthread_delete_thread(). Rename "target" to "thread". Remove extra local variable "target". (pthread_detach): Ditto. * signal.c (pthread_sigmask): Move init of "us" out of inner block. Fix instance of "this" should have been "us". Rename "us" to "thread". * sched.c (pthread_setschedparam): Modify to use the new thread type. (pthread_getschedparam): Ditto. * private.c (_pthread_find_thread): Fix return type and arg. * implement.h: Remove _PTHREAD_YES and _PTHREAD_NO. (_pthread_new_thread): Add prototype. (_pthread_find_thread): Ditto. (_pthread_delete_thread): Ditto. (_pthread_new_thread_entry): Remove prototype. (_pthread_find_thread_entry): Ditto. (_pthread_delete_thread_entry): Ditto. ( _PTHREAD_NEW, _PTHREAD_INUSE, _PTHREAD_EXITED, _PTHREAD_REUSE): Add. * create.c (pthread_create): Minor rename "us" to "new" (I need these cues but it doesn't stop me coming out with some major bugs at times). Load start_routine and arg into the thread so the wrapper can call it. * exit.c (pthread_exit): Fix pthread_this should be pthread_self. * cancel.c (pthread_setcancelstate): Change _pthread_threads_thread_t * to pthread_t and init with pthread_this(). (pthread_setcanceltype): Ditto.
1998-07-28Tue Jul 28 14:04:29 1998 Ross Johnson <rpj@swan.canberra.edu.au>rpj
* private.c: Added detailed explanation of the new thread allocation scheme. (_pthread_new_thread): Totally rewritten to use new thread allocation scheme. (_pthread_delete_thread): Ditto. (_pthread_find_thread): Obsolete.
1998-07-27Mon Jul 27 17:46:37 1998 Ross Johnson <rpj@swan.canberra.edu.au>rpj
* create.c (pthread_create): Start of rewrite. Not completed yet. * private.c (_pthread_new_thread_entry): Start of rewrite. Not complete. * implement.h (_pthread_threads_thread): Rename, remove thread member, add win32handle and ptstatus members. (_pthread_t): Add. * pthread.h: pthread_t is no longer mapped directly to a Win32 HANDLE type. This is so we can let the Win32 thread terminate and reuse the HANDLE while pthreads holds it's own thread ID until the last waiting join exits.
1998-07-26Mon Jul 27 00:20:37 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au>rpj
* private.c (_pthread_delete_thread_entry): Destroy the thread entry attribute object before deleting the thread entry itself. * attr.c (pthread_attr_init): Initialise cancel_pending = FALSE. (pthread_attr_setdetachstate): Rename "detached" to "detachedstate". (pthread_attr_getdetachstate): Ditto. * exit.c (_pthread_exit): Fix incorrect check for detachedstate. * implement.h (_pthread_call_t): Remove env member.
1998-07-25Sun Jul 26 00:09:59 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au>rpj
* private.c (_pthread_delete_thread_entry): Mutex locks removed. Mutexes must be applied at the caller level. (_pthread_new_thread_entry): Ditto. (_pthread_new_thread_entry): Init cancelstate, canceltype, and cancel_pending to default values. (_pthread_new_thread_entry): Rename "this" to "new". (_pthread_find_thread_entry): Rename "this" to "entry". (_pthread_delete_thread_entry): Rename "thread_entry" to "entry". * create.c (_pthread_start_call): Mutexes changed to _pthread_count_mutex. All access to the threads table entries is under the one mutex. Otherwise chaos reigns. Sat Jul 25 23:16:51 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au> * implement.h (_pthread_threads_thread): Move cancelstate and canceltype members out of pthread_attr_t into here.
1998-07-25Sat Jul 25 00:00:13 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au>rpj
* create.c (_pthread_start_call): Set thread priority. Ensure our thread entry is removed from the thread table but only if pthread_detach() was called and there are no waiting joins. (pthread_create): Set detach flag in thread entry if the thread is created PTHREAD_CREATE_DETACHED. * pthread.h (pthread_attr_t): Rename member "detachedstate". * attr.c (pthread_attr_init): Rename attr members. * exit.c (pthread_exit): Fix indirection mistake. * implement.h (_PTHREAD_THREADS_TABLE_INDEX): Add. * exit.c (_pthread_vacuum): Fix incorrect args to _pthread_handler_pop_all() calls. Make thread entry removal conditional. * sync.c (pthread_join): Add multiple join and async detach handling. * implement.h (_PTHREAD_THREADS_TABLE_INDEX): Add. * global.c (_pthread_threads_mutex_table): Add. * implement.h (_pthread_once_flag): Remove. (_pthread_once_lock): Ditto. (_pthread_threads_mutex_table): Add. * global.c (_pthread_once_flag): Remove. (_pthread_once_lock): Ditto. * sync.c (pthread_join): Fix tests involving new return value from _pthread_find_thread_entry(). (pthread_detach): Ditto. * private.c (_pthread_find_thread_entry): Failure return code changed from -1 to NULL.
1998-07-24 * sync.c (pthread_join): Save valueptr arg in joinvalueptr forrpj
pthread_exit() to use. * private.c (_pthread_new_thread_entry): Initialise joinvalueptr to NULL. * create.c (_pthread_start_call): Rewrite to facilitate joins. pthread_exit() will do a longjmp() back to here. Does appropriate cleanup and exit/return from the thread. (pthread_create): _beginthreadex() now passes a pointer to our thread table entry instead of just the call member of that entry. * implement.h (_pthread_threads_thread): New member void ** joinvalueptr. (_pthread_call_t): New member jmpbuf env. * exit.c (pthread_exit): Major rewrite to handle joins and handing value pointer to joining thread. Uses longjmp() back to _pthread_start_call().
1998-07-23Fri Jul 24 03:00:25 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au>rpj
* attr.c (pthread_attr_destroy): Fix merge conflicts. (pthread_attr_getdetachstate): Fix merge conflicts. (pthread_attr_setdetachstate): Fix merge conflicts. * pthread.h: Fix merge conflicts. * sync.c (pthread_join): Fix merge conflicts.
1998-07-23Fri Jul 24 00:21:21 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au>rpj
* create.c (pthread_create): Arg to _pthread_new_thread_entry() changed. See next entry. Move mutex locks out. Changes made yesterday and today allow us to start the new thread running rather than temporarily suspended. * private.c (_pthread_new_thread_entry): _pthread_thread_table was changed back to a table of thread structures rather than pointers. As such we're trading storage for increaded speed. This routine was modified to work with the new table. Mutex lock put in around global data accesses. (_pthread_find_thread_entry): Ditto (_pthread_delete_thread_entry): Ditto
1998-07-22Wed Jul 22 00:16:22 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au>rpj
* attr.c, implement.h, pthread.h, ChangeLog: Resolve CVS merge conflicts. * private.c (_pthread_find_thread_entry): Changes to return type to support leaner _pthread_threads_table[] which now only stores _pthread_thread_thread_t *. (_pthread_new_thread_entry): Internal changes. (_pthread_delete_thread_entry): Internal changes to avoid contention. Calling routines changed accordingly. * pthread.h: Modified cleanup macros to use new generic push and pop. Added destructor and atfork stacks to _pthread_threads_thread_t. * cleanup.c (_pthread_handler_push, _pthread_handler_pop, _pthread_handler_pop_all): Renamed cleanup push and pop routines and made generic to handle destructors and atfork handlers as well. * create.c (_pthread_start_call): New function is a wrapper for all new threads. It allows us to do some cleanup when the thread returns, ie. that is otherwise only done if the thread is cancelled. * exit.c (_pthread_vacuum): New function contains code from pthread_exit() that we need in the new _pthread_start_call() as well. * implement.h: Various additions and minor changes. * pthread.h: Various additions and minor changes. Change cleanup handler macros to use generic handler push and pop functions. * attr.c: Minor mods to all functions. (is_attr): Implemented missing function. * create.c (pthread_create): More clean up. * private.c (_pthread_find_thread_entry): Implement. (_pthread_delete_thread_entry): Implement. (_pthread_new_thread_entry): Implement. These functions manipulate the implementations internal thread table and are part of general code cleanup and modularisation. They replace _pthread_getthreadindex() which was removed. * exit.c (pthread_exit): Changed to use the new code above. * pthread.h: Add cancelability constants. Update comments.
1998-07-21Wed Jul 22 00:16:22 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au>rpj
* cleanup.c (_pthread_cleanup_push): Implement. (_pthread_cleanup_pop): Implement. (_pthread_do_cancellation): Implement. These are private to the implementation. The real cleanup functions are macros. See below. * pthread.h (pthread_cleanup_push): Implement as a macro. (pthread_cleanup_pop): Implement as a macro. Because these are macros which start and end a block, the POSIX scoping requirement is observed. See the comment in the file. * exit.c (pthread_exit): Refine the code. * create.c (pthread_create): Code cleanup. * implement.h (RND_SIZEOF): Add RND_SIZEOF(T) to round sizeof(T) up to multiple of DWORD. Add function prototypes. * private.c (_pthread_getthreadindex): "*thread" should have been "thread". Detect empty slot fail condition.
1998-07-19Mon Jul 20 02:31:05 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au>rpj
* private.c (_pthread_getthreadindex): Implement.