Age | Commit message (Collapse) | Author |
|
|
|
* Versions (libc): Add __register_atfork with GLIBC_PRIVATE version.
* forward.c: Include <errno.h>
(atfork): New structure.
(atfork_lock): New mutex.
(fork_handlers, fork_last_handler): New variables.
(atfork_pthread_prepare, atfork_pthread_parent, atfork_pthread_child): New
atfork hooks
(__register_atfork): New function.
* sysdeps/generic/pt-atfork.c (pthread_atfork): Call __register_atfork.
|
|
* pthread/pt-create.c (__pthread_create_internal): Store pthread ID in
caller-provided memory before starting the new thread.
|
|
* pthread/pt-create.c (entry_point) [IS_IN_libpthread]: Call __ctype_init.
|
|
This new Hurd-specific function is meant to allow Hurd servers to wait
for events during a bounded period of time.
* Makefile (libpthread-routines): Add pt-hurd-cond-timedwait.
* Versions: Include pthread_hurd_cond_timedwait_np in version GLIBC_2.17
of libpthread.
* sysdeps/mach/hurd/bits/pthread-np.h (pthread_hurd_cond_timedwait_np): New
declaration.
* sysdeps/mach/hurd/pt-hurd-cond-timedwait.c: New file that provides
__pthread_hurd_cond_timedwait_internal and __pthread_hurd_cond_timedwait_np.
* sysdeps/mach/hurd/pt-hurd-cond-wait.c (__pthread_hurd_cond_wait_np):
Rewrite as a call to __pthread_hurd_cond_timedwait_internal with no timeout.
|
|
This patch solves two issues. The first one is cancellation handling
when a cancellation request is sent before reaching a cancellation
point (namely, pthread_cond_{timed,}wait). Cancellation is implemented
by pushing an appropriate cleanup handler and switching to
PTHREAD_CANCEL_ASYNCHRONOUS type. The main problem is that it doesn't
handle pending requests, only a cancellation that occurs while blocking.
Other problems occur when trying to correctly handle a timeout and a
cancellation request through the cleanup routine.
The other issue is correctly handling timeouts. This problem was already
well known, as explained by the following comment :
"FIXME: What do we do if we get a wakeup message before we disconnect
ourself? It may remain until the next time we block."
In addition, the prevp thread member is inconsistently used. It is
sometimes accessed while protected by the appropriate queue lock to
determine whether a thread is still queued, while at times, threads
are unqueued without holding a lock, as in pthread_cond_broadcast :
/* We can safely walk the list of waiting threads without holding
the lock since it is now decoupled from the condition. */
__pthread_dequeuing_iterate (wakeup, wakeup)
__pthread_wakeup (wakeup);
This is the root cause that triggers some assertion failures.
The solution brought by this patch is to consistently use the prevp link
to determine if both a thread has been unqueued and if a wakeup message
has been sent (both are needed to wake up a thread). A thread unblocked
because of a timeout can now accurately determine if it needs to drain
its message queue. A direct improvement is that the message queue size
can be limited to one message, and wakeups are guaranteed to be
non-blocking, which allows safely calling __pthread_wakeup from critical
sections.
As it now affects the cleanup cancellation routine of
__pthread_cond_timedwait_internal, cancellation is reworked as well.
Cancellation type is forced to PTHREAD_CANCEL_DEFERRED during the call,
and actually checked on both entry and return. A hook is set by the
blocking thread so that the waker doesn't need to know about the call
implementation. Cancellation members are now protected with a mutex for
truely safe access.
* pthread/pt-alloc.c (initialize_pthread): Initialize the new `cancel_lock',
`cancel_hook' and `cancel_hook_args' fields.
* pthread/pt-cancel.c (pthread_cancel): Rework cancellation handling.
* pthread/pt-internal.h (struct __pthread): Add `cancel_lock', `cancel_hook'
and `cancel_hook_args' fields.
(__pthread_dequeue): Assert thread->prevp isn't NULL.
* pthread/pt-join.c (pthread_join): Describe how the cancellation point is
implemented.
* pthread/pt-setcancelstate.c (__pthread_setcancelstate): Lock the given
thread cancellation lock when switching state.
* pthread/pt-setcanceltype.c (__pthread_setcanceltype): Likewise for
cancellation type.
* pthread/pt-testcancel.c (pthread_testcancel): Likewise for pending
cancellations.
* sysdeps/generic/pt-cond-brdcast.c (__pthread_cond_broadcast): Dequeue
and wake up threads with condition locked.
* sysdeps/generic/pt-cond-signal.c (cond_signal): Remove function, move
implementation to ...
(__pthread_cond_signal): ... this function. Remove unused `unblocked'
variable.
* sysdeps/generic/pt-cond-timedwait.c (struct cancel_ctx): New structure.
(cancel_hook): New static function.
(__pthread_cond_timedwait_internal): Fix cancellation and timeout handling.
* sysdeps/generic/pt-mutex-timedlock.c
(__pthread_mutex_timedlock_internal): Fix timeout handling.
* sysdeps/generic/pt-rwlock-timedrdlock.c
(__pthread_rwlock_timedrdlock_internal): Likewise.
* sysdeps/generic/pt-rwlock-timedwrlock.c
(__pthread_rwlock_timedwrlock_internal): Likewise.
* sysdeps/generic/pt-rwlock-unlock.c (pthread_rwlock_unlock): Dequeue and
wake up threads with rwlock internal lock held.
* sysdeps/generic/sem-timedwait.c (__sem_timedwait_internal): Fix timeout
handling.
* sysdeps/mach/hurd/pt-docancel.c (__pthread_do_cancel): Unlock the given
thread cancellation lock.
* sysdeps/mach/pt-thread-alloc.c (create_wakeupmsg): Limit the message
queue size of the wakeup port to 1.
* sysdeps/mach/pt-wakeup.c (__pthread_wakeup): Call __mach_msg in a
non-blocking way.
|
|
Hook the libpthread version when compiling glibc's confstr.c,
so that confstr can show it.
* sysdeps/pthread/Makefile: New file.
|
|
This allows the use of glibc sysdeps that use pthread-based
implementations.
* sysdeps/mach/hurd/Implies: Add pthread.
|
|
* Versions: Include _IO_flockfile, _IO_ftrylockfile and _IO_funlockfile
in version 2.2.6 of libpthread.
|
|
* Version: Do not include pthread_hurd_cond_wait_np in libc, as we don't
define a forward for it. Include pthread_hurd_cond_wait_np in version
GLIBC_2.17 of libpthread, as this is a new symbol.
|
|
This change is a temporary hack intended for the Hurd servers. Once Hurd
threadvars are replaced with TLS, this commit should be reverted.
* pthread/pt-internal.h (__pthread_default_attr): Remove const qualifier.
* sysdeps/generic/pt-attr.c (__pthread_default_attr): Likewise.
* sysdeps/mach/hurd/pt-sysdep.c (__pthread_stack_default_size): New variable.
(init_routine): Set __pthread_default_attr.stacksize if
__pthread_stack_default_size exists.
|
|
* Makefile (libpthread-routines): Add pt-hurd-cond-wait.
* Versions (libc): Add pthread_hurd_cond_wait_np.
(libpthread): Likewise.
* sysdeps/mach/hurd/bits/pthread-np.h: New file.
* sysdeps/mach/hurd/pt-hurd-cond-wait.c: Likewise.
|
|
|
|
glibc 2.16 dropped support for any binary format other than ELF, and the ELF variable has been removed too;
this causes a build failure when built as glibc addon with glibc >= 2.16, since it would not link to ld.so.
Defining ELF to 'yes' if not defined allows to retain compatibility with older glibc versions.
* Makefile [$(..) != ''] [$(elf) = ''] (elf): Define to 'yes'.
|
|
* .cvsignore: Remove file.
|
|
|
|
ENOMEM can be returned if some malloc fail, but it is not a valid POSIX error number for pthread_create;
thus turn it to EAGAIN.
* pthread/pt-create.c (pthread_create): Turn ENOMEM to EAGAIN.
|
|
* tests/Makefile [ifdef INSTALL_ROOT] (INSTALL_ROOT_CPPFLAGS)
(INSTALL_ROOT_LDFLAGS): New variables.
(%.o: %.c, %: %.o): New rules.
(%-static: %.o): Update rule.
* tests/README: Update.
|
|
* sysdeps/i386/Implies: Remove file.
* sysdeps/mach/hurd/i386/Implies: Likewise.
* sysdeps/ia32/bits/memory.h: Rename to sysdeps/i386/bits/memory.h.
* sysdeps/ia32/bits/pt-atomic.h: Rename to sysdeps/i386/bits/pt-atomic.h.
* sysdeps/ia32/bits/spin-lock-inline.h: Rename to
sysdeps/i386/bits/spin-lock-inline.h.
* sysdeps/ia32/bits/spin-lock.h: Rename to sysdeps/i386/bits/spin-lock.h.
* sysdeps/ia32/machine-sp.h: Rename to sysdeps/i386/machine-sp.h.
* sysdeps/ia32/pt-machdep.h: Rename to sysdeps/i386/pt-machdep.h.
* sysdeps/mach/hurd/ia32/pt-machdep.c: Rename to
sysdeps/mach/hurd/i386/pt-machdep.c.
* sysdeps/mach/hurd/ia32/pt-setup.c: Rename to
sysdeps/mach/hurd/i386/pt-setup.c.
* Makefile (SYSDEP_PATH): Adapt to that.
|
|
* sysdeps/powerpc/bits/machine-lock.h: Remove file.
* sysdeps/powerpc/bits/memory.h: Likewise.
* sysdeps/powerpc/bits/spin-lock.h: Likewise.
* sysdeps/powerpc/machine-sp.h: Likewise.
* sysdeps/powerpc/pt-machdep.h: Likewise.
* TODO: Update.
|
|
|
|
* Makefile.am: Remove file.
* headers.m4: Likewise.
* sysdeps/l4/bits/pthread-np.h: Likewise.
* sysdeps/l4/hurd/bits/pthread-np.h: Likewise.
* sysdeps/l4/hurd/ia32/pt-machdep.c: Likewise.
* sysdeps/l4/hurd/ia32/pt-setup.c: Likewise.
* sysdeps/l4/hurd/ia32/signal-dispatch-lowlevel.c: Likewise.
* sysdeps/l4/hurd/powerpc/pt-machdep.c: Likewise.
* sysdeps/l4/hurd/powerpc/pt-setup.c: Likewise.
* sysdeps/l4/hurd/pt-block.c: Likewise.
* sysdeps/l4/hurd/pt-kill.c: Likewise.
* sysdeps/l4/hurd/pt-setactivity-np.c: Likewise.
* sysdeps/l4/hurd/pt-sigstate-destroy.c: Likewise.
* sysdeps/l4/hurd/pt-sigstate-init.c: Likewise.
* sysdeps/l4/hurd/pt-sigstate.c: Likewise.
* sysdeps/l4/hurd/pt-startup.c: Likewise.
* sysdeps/l4/hurd/pt-sysdep.c: Likewise.
* sysdeps/l4/hurd/pt-sysdep.h: Likewise.
* sysdeps/l4/hurd/pt-thread-alloc.c: Likewise.
* sysdeps/l4/hurd/pt-thread-halt.c: Likewise.
* sysdeps/l4/hurd/pt-thread-start.c: Likewise.
* sysdeps/l4/hurd/pt-wakeup.c: Likewise.
* sysdeps/l4/hurd/sig-sysdep.h: Likewise.
* sysdeps/l4/hurd/sigprocmask.c: Likewise.
* sysdeps/l4/pt-block.c: Likewise.
* sysdeps/l4/pt-docancel.c: Likewise.
* sysdeps/l4/pt-pool-np.c: Likewise.
* sysdeps/l4/pt-spin.c: Likewise.
* sysdeps/l4/pt-stack-alloc.c: Likewise.
* sysdeps/l4/pt-thread-alloc.c: Likewise.
* sysdeps/l4/pt-thread-dealloc.c: Likewise.
* sysdeps/l4/pt-thread-halt.c: Likewise.
* sysdeps/l4/pt-thread-start.c: Likewise.
* sysdeps/l4/pt-timedblock.c: Likewise.
* sysdeps/l4/pt-wakeup.c: Likewise.
* TODO: Update.
* signal/README: Likewise.
|
|
* Makefile ($(inst_libdir)/libpthread.so): Symlink from absolute path
$(slibdir)/libpthread.so$(libpthread.so-version) instead of relative, as
both files may not be in the same directory (e.g. in Debian).
|
|
* Makefile (inst_libdir) [!IN_GLIBC]: Set variable to $(libdir) instead of
expanding it.
|
|
Later rounded up to a page.
* sysdeps/generic/pt-attr.c (__pthread_default_attr) [!PAGESIZE]: Set guardsize
field to 1.
|
|
* pthread/pt-internal.h (guardsize): Mention that we depart from the
standard which says guardsize is in addition to stacksize.
|
|
|
|
* libpthread.a (GROUP): Add -lrt.
|
|
* sysdeps/mach/hurd/pt-sysdep.h (_HURD_THREADVAR_THREAD): Remove macro.
(___pthread_self): Declare new __thread variable.
(_pthread_self): Take self pointer from ___pthread_self instead of
threadvar.
* sysdeps/mach/hurd/pt-sysdep.c (___pthread_self): Define new __thread
variable.
(init_routine): Set ___pthread_self to initial thread structure.
* pthread/pt-internal.h (__pthread_setup): Add `self' parameter to
`entry_point' parameter.
* pthread/pt-create.c (entry_point): Add `self' parameter. Store it in
___pthread_self.
* sysdeps/l4/hurd/ia32/pt-setup.c (stack_setup): Add `self parameter to
`entry_point' parameter. Pass it the `thread' parameter.
(__pthread_setup): Likewise.
* sysdeps/l4/hurd/powerpc/pt-setup.c (struct start_info): Add `self' field.
(first_entry_1): Pass `self' parameter.
(stack_setup): Add `self' parameter to `entry_point' parameter, pass it the
`thread' parameter.
(__pthread_setup): Likewise.
* sysdeps/mach/hurd/ia32/pt-setup.c (stack_setup): Pass `thread' parameter
to the start routine.
(stack_setup): Add `self' parameter to `entry_point' paramter.
|
|
* pthread/pt-initialize.c (pthread_functions): Always define.
(__pthread_init): Always pass address of pthread_functions.
|
|
The former conflicts with usage in glibc.
* pthread/pt-initialize.c (__pthread_initialize): Rename into
__pthread_init.
* pthread/pt-internal.h (__pthread_initialize): Likewise.
* sysdeps/l4/hurd/pt-sysdep.c (init_routine): Likewise.
* sysdeps/mach/hurd/pt-sysdep.c (init_routine): Likewise.
|
|
* Makeconfig (+includes): Add our include/ directory in the header include
path, for the rest of glibc.
|
|
|
|
* Makefile [IN_GLIBC=no] (inst_libdir): Define to $(libdir).
(install, .PHONY, libpthread2.a, libpthread2_pic.a): Use $(inst_libdir)
instead of $(libdir), enable in IN_GLIBC=yes too.
[IN_GLIBC=yes] ($(inst_libdir)/libpthread.so): Define to create symlink.
|
|
And make it expose only types, not the rest of the pthread API.
* Makefile (headers): Add bits/pthreadtypes.h.
* sysdeps/generic/bits/pthreadtypes.h: Include <pthread/pthreadtypes.h>
instead of <pthread.h>
|
|
* Makefile (extra-B-pthread.so): Define.
|
|
If CLOCK_MONOTONIC is requested, check (only once) for the
availability of a monotonic clock using `clock_getres'. If it is not,
reject CLOCK_MONOTONIC with EINVAL (as before).
* sysdeps/generic/pt-condattr-setclock.c (pthread_condattr_setclock):
Check for monotonic clock if requested.
|
|
Use `clock_gettime' with the provided clock instead of `gettimeofday',
linking to rt.
* sysdeps/mach/pt-timedblock.c (__pthread_timedblock): Switch to
`clock_gettime'.
* Makefile [!IN_GLIBC] (LDLIBS): Link to rt.
[IN_GLIBC] ($(objpfx)libpthread.so): Likewise.
* Makefile.am (libpthread_a_LDADD): Likewise.
|
|
To make `__pthread_timedblock' properly measure time using the right
clock, add a new argument representing the clock to use.
* pthread/pt-internal.h (__pthread_timedblock): New argument CLOCK_ID.
* sysdeps/l4/pt-timedblock.c (__pthread_timedblock): Likewise.
* sysdeps/mach/pt-timedblock.c (__pthread_timedblock): Likewise.
* sysdeps/generic/pt-cond-timedwait.c
(__pthread_cond_timedwait_internal): Pass the clock of the
`pthread_cond' to `__pthread_timedblock'.
* sysdeps/generic/pt-mutex-timedlock.c
(__pthread_mutex_timedlock_internal): Pass CLOCK_REALTIME to
`__pthread_timedblock'.
* sysdeps/generic/pt-rwlock-timedrdlock.c
(__pthread_rwlock_timedrdlock_internal): Likewise.
* sysdeps/generic/pt-rwlock-timedwrlock.c
(__pthread_rwlock_timedwrlock_internal): Likewise.
* sysdeps/generic/sem-timedwait.c (__sem_timedwait_internal):
Likewise.
|
|
* Makeconfig, Versions, configure.in, forward.c, libc_pthread_init.c,
pthread/pthread-functions.h, shlib-versions, sysdeps/i386/Implies,
sysdeps/mach/hurd/Implies, sysdeps/mach/hurd/i386/Implies: New files.
* Makefile: Add glibc rules, enabled when IN_GLIBC is defined to yes, when
$(..) is defined.
* pthread/pt-initialize.c [IS_IN_libpthread] (pthread_functions): New variable.
[IS_IN_libpthread] (__pthread_initialize): Call __libc_pthread_init.
|
|
* pthread/pt-internal.h (tcbhead_t): Define struct only if IS_IN_libpthread
is not defined.
|
|
This avoids a conflict with glibc-provided bits/atomic.h
* sysdeps/ia32/bits/atomic.h: Rename to...
* sysdeps/ia32/bits/pt-atomic.h: ... this.
* pthread/pt-create.c: Include <bits/pt-atomic.h> instead of <bits/atomic.h>
* pthread/pt-exit.c: Likewise.
* pthread/pt-internal.h: Likewise.
|
|
Libc will need to be able to call them, so they need to have a different
name.
* pthread/pt-exit.c (pthread_exit): Rename with __ prefix and add strong alias.
* pthread/pt-self.c (pthread_self): Likewise.
* pthread/pt-setcancelstate.c (pthread_setcancelstate): Likewise
* pthread/pt-setcanceltype.c (pthread_setcanceltype): Likewise
* sysdeps/generic/pt-attr-destroy.c (pthread_attr_destroy): Likewise
* sysdeps/generic/pt-attr-getdetachstate.c (pthread_attr_getdetachstate): Likewise
* sysdeps/generic/pt-attr-getinheritsched.c (pthread_attr_getinheritsched): Likewise
* sysdeps/generic/pt-attr-getschedparam.c (pthread_attr_getschedparam): Likewise
* sysdeps/generic/pt-attr-getschedpolicy.c (pthread_attr_getschedpolicy): Likewise
* sysdeps/generic/pt-attr-getscope.c (pthread_attr_getscope): Likewise
* sysdeps/generic/pt-attr-init.c (pthread_attr_init): Likewise
* sysdeps/generic/pt-attr-setdetachstate.c (pthread_attr_setdetachstate): Likewise
* sysdeps/generic/pt-attr-setinheritsched.c (pthread_attr_setinheritsched): Likewise
* sysdeps/generic/pt-attr-setschedparam.c (pthread_attr_setschedparam): Likewise
* sysdeps/generic/pt-attr-setschedpolicy.c (pthread_attr_setschedpolicy): Likewise
* sysdeps/generic/pt-attr-setscope.c (pthread_attr_setscope): Likewise
* sysdeps/generic/pt-cond-brdcast.c (pthread_cond_broadcast): Likewise
* sysdeps/generic/pt-cond-destroy.c (pthread_cond_destroy): Likewise
* sysdeps/generic/pt-cond-init.c (pthread_cond_init): Likewise
* sysdeps/generic/pt-cond-signal.c (pthread_cond_signal): Likewise
* sysdeps/generic/pt-cond-timedwait.c (pthread_cond_timedwait): Likewise
* sysdeps/generic/pt-cond-wait.c (pthread_cond_wait): Likewise
* sysdeps/generic/pt-condattr-destroy.c (pthread_condattr_destroy): Likewise
* sysdeps/generic/pt-condattr-init.c (pthread_condattr_init): Likewise
* sysdeps/generic/pt-equal.c (pthread_equal): Likewise
* sysdeps/generic/pt-getschedparam.c (pthread_getschedparam): Likewise
* sysdeps/generic/pt-setschedparam.c (pthread_setschedparam): Likewise
|
|
libc releases the spinlock before calling __mutex_unlock_solid, so we have to
try to reacquire it before possibly giving it to some blocked thread.
* pthread/cthreads-compat.c (__mutex_unlock_solid): Call
__pthread_spin_trylock before calling __pthread_mutex_unlock.
|
|
* include/pthread/pthread.h [__USE_XOPEN2K8] (PTHREAD_MUTEX_NORMAL,
PTHREAD_MUTEX_ERRORCHECK, PTHREAD_MUTEX_RECURSIVE, PTHREAD_MUTEX_DEFAULT,
pthread_mutexattr_gettype, pthread_mutexattr_settype): Expose.
|
|
|
|
When getting a TSD, handle gracefully the case of an invalid key.
When setting a TSD, check for the validity of the key as recommended
(although not required) by POSIX. This also avoids potentially
filling the `thread_specifics' hash of threads with TSD of invalid
keys.
Add two simple checks in test-7.c for the two situations above.
* sysdeps/hurd/pt-getspecific.c (pthread_getspecific): Check the
validity of the specified key.
* sysdeps/hurd/pt-setspecific.c (pthread_setspecific): Likewise.
* tests/test-7.c (main): Add two assertions.
|
|
Conflicts:
tests/Makefile
|
|
* sysdeps/hurd/pt-destroy-specific.c (__pthread_destroy_specific): Correct
logic for PTHREAD_KEY_INVALID slots.
* tests/test-__pthread_destroy_specific-skip.c: New file.
* tests/Makefile (CHECK_SRC): Add test-__pthread_destroy_specific-skip.c.
|
|
When deleting a key using `pthread_key_delete', delete all the values
associated to that key in all the threads available. Otherwise, the
key reuse in `pthread_key_create' can cause new keys to have thread
specific data of the previously used key with the same index.
Add a test for this case, which creates and deletes pairs of keys
checking that they have a NULL thread specific data after creation.
* sysdeps/hurd/pt-key-delete.c (pthread_key_delete): Remove all the
values of the key in all the threads.
* tests/Makefile (CHECK_SRC): Add test-17.c.
* tests/test-17.c: New file.
|