Commit Graph

15 Commits

Author SHA1 Message Date
Rich Felker d36751943a use c++-friendly initializers for pthread initializer definitions
these will also avoid obnoxious warnings with gcc -Wbraces.
2012-02-29 22:55:08 -05:00
Rich Felker afc35d5efd replace bad cancellation cleanup abi with a sane one
the old abi was intended to duplicate glibc's abi at the expense of
being ugly and slow, but it turns out glib was not even using that abi
except on non-gcc-compatible compilers (which it doesn't even support)
and was instead using an exceptions-in-c/unwind-based approach whose
abi we could not duplicate anyway without nasty dwarf2/unwind
integration.

the new abi is copied from a very old glibc abi, which seems to still
be supported/present in current glibc. it avoids all unwinding,
whether by sjlj or exceptions, and merely maintains a linked list of
cleanup functions to be called from the context of pthread_exit. i've
made some care to ensure that longjmp out of a cleanup function should
work, even though it is not required to.

this change breaks abi compatibility with programs which were using
pthread cancellation, which is unfortunate, but that's why i'm making
the change now rather than later. considering that most pthread
features have not been usable until recently anyway, i don't see it as
a major issue at this point.
2012-02-09 02:33:08 -05:00
Rich Felker 9205e48609 macro for pthread_equal
no sense bloating apps with a function call for an equality comparison...
2011-08-14 15:17:36 -04:00
Rich Felker cbf35978a9 use __attribute__((const)) for errno and pthread_self if __GNUC__ is defined
this is not too ugly and should result in significant code size and
performance improvements for many programs.
2011-06-06 20:12:42 -04:00
Rich Felker ddd87b2f10 implement pthread_[sg]etconcurrency.
there is a resource limit of 0 bits to store the concurrency level
requested. thus any positive level exceeds a resource limit, resulting
in EAGAIN. :-)
2011-05-30 11:31:07 -04:00
Rich Felker 3df3d4f512 fix misspelled PTHREAD_CANCELED constant 2011-04-01 20:48:02 -04:00
Rich Felker ea343364a7 match glibc/lsb cancellation abi on i386
glibc made the ridiculous choice to use pass-by-register calling
convention for these functions, which is impossible to duplicate
directly on non-gcc compilers. instead, we use ugly asm to wrap and
convert the calling convention. presumably this works with every
compiler anyone could potentially want to use.
2011-03-25 22:13:57 -04:00
Rich Felker 047e434ef5 implement robust mutexes
some of this code should be cleaned up, e.g. using macros for some of
the bit flags, masks, etc. nonetheless, the code is believed to be
working and correct at this point.
2011-03-17 20:41:37 -04:00
Rich Felker d8d19f4d46 pthread.h needs clockid_t
actually it gets this from time.h if _POSIX_C_SOURCE or any other
feature test macros are defined, but it breaks if they're not.
2011-03-12 21:54:19 -05:00
Rich Felker f1821fce81 missing const in some pthread_attr_* prototypes 2011-03-11 09:46:31 -05:00
Rich Felker 7d57e05fa8 add prototypes for pthread_condattr_* and pthread_rwlockattr_* 2011-03-07 16:45:48 -05:00
Rich Felker e9417fffb3 add pthread_atfork interface
note that this presently does not handle consistency of the libc's own
global state during forking. as per POSIX 2008, if the parent process
was threaded, the child process may only call async-signal-safe
functions until one of the exec-family functions is called, so the
current behavior is believed to be conformant even if non-ideal. it
may be improved at some later time.
2011-02-18 19:52:42 -05:00
Rich Felker e882756311 reorganize pthread data structures and move the definitions to alltypes.h
this allows sys/types.h to provide the pthread types, as required by
POSIX. this design also facilitates forcing ABI-compatible sizes in
the arch-specific alltypes.h, while eliminating the need for
developers changing the internals of the pthread types to poke around
with arch-specific headers they may not be able to test.
2011-02-17 17:16:20 -05:00
Rich Felker 56b784d603 add to pthread.h: pthread_mutex_timedlock and sched.h, time.h 2011-02-16 21:21:26 -05:00
Rich Felker 0b44a0315b initial check-in, version 0.5.0 2011-02-12 00:22:29 -05:00