From 23412596845e219b242a763f333fa60954cad84b Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 12 Sep 2016 00:08:58 +0200 Subject: Expose __register_atfork publicly Some applications make use of it, and get spurious strong dependencies when the symbol is versioned as private. * Version (__register_atfork): Move from GLIBC_PRIVATE to GLIBC_2.22. --- Versions | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Versions b/Versions index ec7477e..6a8e674 100644 --- a/Versions +++ b/Versions @@ -17,11 +17,12 @@ libc { pthread_self; pthread_setcancelstate; pthread_setcanceltype; __pthread_get_cleanup_stack; } + GLIBC_2.22 { + __register_atfork; + } GLIBC_PRIVATE { __libc_alloca_cutoff; __libc_pthread_init; - # TODO: expose this publicly - __register_atfork; } } -- cgit v1.2.3 From 8968cc85b696f305b8afe11c0a753ea1209f7abc Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 19 Sep 2016 00:16:48 +0200 Subject: Fix pthread_kill and pthread_self visibility from raise * pthreadP.h: New file. * sysdeps/generic/pt-kill.c (pthread_kill): Rename to __pthread_kill. pthread_kill: New strong alias. * sysdeps/hurd/pt-kill.c: Likewise. * sysdeps/generic/raise.c: Include instead of . Make __pthread_kill and __pthread_self weak. (raise): Use __pthread_kill and __pthread_self instead of pthread_kill and pthread_self. --- Versions | 1 + pthreadP.h | 26 ++++++++++++++++++++++++++ sysdeps/generic/pt-kill.c | 5 +++-- sysdeps/generic/raise.c | 10 +++++----- sysdeps/hurd/pt-kill.c | 3 ++- 5 files changed, 37 insertions(+), 8 deletions(-) create mode 100644 pthreadP.h diff --git a/Versions b/Versions index 6a8e674..089c6b5 100644 --- a/Versions +++ b/Versions @@ -94,6 +94,7 @@ libpthread { __pthread_key_create; pthread_kill; + __pthread_kill; pthread_mutex_destroy; pthread_mutex_getprioceiling; pthread_mutex_init; pthread_mutex_lock; pthread_mutex_setprioceiling; diff --git a/pthreadP.h b/pthreadP.h new file mode 100644 index 0000000..f1fd625 --- /dev/null +++ b/pthreadP.h @@ -0,0 +1,26 @@ +/* Copyright (C) 2016 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _PTHREADP_H +#define _PTHREADP_H 1 + +#include + +extern pthread_t __pthread_self (void); +extern int __pthread_kill (pthread_t threadid, int signo); + +#endif /* pthreadP.h */ diff --git a/sysdeps/generic/pt-kill.c b/sysdeps/generic/pt-kill.c index 0dfac34..fc83f93 100644 --- a/sysdeps/generic/pt-kill.c +++ b/sysdeps/generic/pt-kill.c @@ -18,10 +18,11 @@ License along with this program. If not, see . */ +#include #include "sig-internal.h" int -pthread_kill (pthread_t tid, int signo) +__pthread_kill (pthread_t tid, int signo) { siginfo_t si; memset (&si, 0, sizeof (si)); @@ -29,4 +30,4 @@ pthread_kill (pthread_t tid, int signo) return pthread_kill_siginfo_np (tid, si); } - +strong_alias (__pthread_kill, pthread_kill) diff --git a/sysdeps/generic/raise.c b/sysdeps/generic/raise.c index f086665..cc18b39 100644 --- a/sysdeps/generic/raise.c +++ b/sysdeps/generic/raise.c @@ -18,12 +18,12 @@ License along with this program. If not, see . */ -#include +#include #include #include -#pragma weak pthread_kill -#pragma weak pthread_self +#pragma weak __pthread_kill +#pragma weak __pthread_self int raise (int signo) { @@ -31,10 +31,10 @@ raise (int signo) "the effect of the raise() function shall be equivalent to calling: pthread_kill(pthread_self(), sig);" */ - if (pthread_kill) + if (__pthread_kill) { int err; - err = pthread_kill (pthread_self (), signo); + err = __pthread_kill (__pthread_self (), signo); if (err) { errno = err; diff --git a/sysdeps/hurd/pt-kill.c b/sysdeps/hurd/pt-kill.c index 49dfd7d..6aaf241 100644 --- a/sysdeps/hurd/pt-kill.c +++ b/sysdeps/hurd/pt-kill.c @@ -25,7 +25,7 @@ #include int -pthread_kill (pthread_t thread, int sig) +__pthread_kill (pthread_t thread, int sig) { struct __pthread *pthread; struct hurd_signal_detail detail; @@ -49,3 +49,4 @@ pthread_kill (pthread_t thread, int sig) __spin_lock (&ss->lock); return _hurd_raise_signal (ss, sig, &detail); } +strong_alias (__pthread_kill, pthread_kill) -- cgit v1.2.3 From 9ac3988fe16fc0aeb5ddefdf28d1104237ec91ab Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 19 Sep 2016 00:20:29 +0200 Subject: Fix getrlimit visibility * pthread/pt-create.c (__pthread_create_internal): Call __getrlimit instead of getrlimit. --- pthread/pt-create.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pthread/pt-create.c b/pthread/pt-create.c index d88afae..417605a 100644 --- a/pthread/pt-create.c +++ b/pthread/pt-create.c @@ -107,7 +107,7 @@ __pthread_create_internal (struct __pthread **thread, if (!stacksize) { struct rlimit rlim; - getrlimit(RLIMIT_STACK, &rlim); + __getrlimit(RLIMIT_STACK, &rlim); if (rlim.rlim_cur != RLIM_INFINITY) stacksize = rlim.rlim_cur; if (!stacksize) -- cgit v1.2.3 From 5f09d5e32706e1baf09bf27897c30e4bcfcb8fd6 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 19 Sep 2016 01:08:34 +0200 Subject: Fix hiding functions * Makefile (CPPFLAGS): Add -imacros $(srcdir)/not-in-libc.h only when IN_GLIBC is no. --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index d5f6d67..21c9b94 100644 --- a/Makefile +++ b/Makefile @@ -231,12 +231,12 @@ endif CPPFLAGS += \ -DENABLE_TLS \ - $(addprefix -I, $(SYSDEP_PATH)) \ - -imacros $(srcdir)/not-in-libc.h + $(addprefix -I, $(SYSDEP_PATH)) ifeq ($(IN_GLIBC),no) CPPFLAGS += \ - -imacros $(srcdir)/include/libc-symbols.h + -imacros $(srcdir)/include/libc-symbols.h \ + -imacros $(srcdir)/not-in-libc.h endif ifeq ($(IN_GLIBC),yes) -- cgit v1.2.3 From cea6489e43e9756f93f025291154a65fc35aa12c Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 19 Sep 2016 01:10:27 +0200 Subject: Make PTHREAD_ONCE_INIT a symbolic value as required by Posix * sysdeps/pthread/bits/once.h (__PTHREAD_ONCE_INIT): Cast initializer to (struct __pthread_once). --- sysdeps/pthread/bits/once.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysdeps/pthread/bits/once.h b/sysdeps/pthread/bits/once.h index 05895b9..53dbfd3 100644 --- a/sysdeps/pthread/bits/once.h +++ b/sysdeps/pthread/bits/once.h @@ -29,6 +29,6 @@ struct __pthread_once }; #define __PTHREAD_ONCE_INIT \ - { 0, __PTHREAD_SPIN_LOCK_INITIALIZER } + (struct __pthread_once) { 0, __PTHREAD_SPIN_LOCK_INITIALIZER } #endif /* bits/once.h */ -- cgit v1.2.3 From a87bf9a8eab3af79798131b60c1f7f92f995df8c Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 19 Sep 2016 01:44:07 +0200 Subject: Fix exposition of pthread functions * pthread/pt-alloc.c (__pthread_alloc): Use __pthread_rwlock_wrlock and __pthread_rwlock_unlock instead of pthread_rwlock_wrlock and pthread_rwlock_unlock. * pthread/pt-create.c (__pthread_create_internal): Use__pthread_rwlock_rdlock and __pthread_rwlock_unlock instead of pthread_rwlock_rdlock and pthread_rwlock_unlock. * pthread/pt-dealloc.c (__pthread_dealloc): Use __pthread_cond_broadcast, __pthread_mutex_lock, and __pthread_mutex_unlock instead of pthread_cond_broadcast, pthread_mutex_lock, and pthread_mutex_unlock * pthread/pt-exit.c (__pthread_exit): Use __pthread_setcancelstate and __pthread_cond_broadcast instead of pthread_setcancelstate and pthread_cond_broadcast. * pthread/pt-internal.h (__pthread_getid, __pthread_setid): Use __pthread_rwlock_rdlock, __pthread_rwlock_wrlock, and __pthread_rwlock_unlock instead of pthread_rwlock_rdlock, pthread_rwlock_wrlock, and pthread_rwlock_unlock * pthread/pt-join.c (pthread_join): Use __pthread_cond_wait instead of pthread_cond_wait. * sysdeps/hurd/pt-key-delete.c (pthread_key_delete): Use __pthread_rwlock_rdlock and __pthread_rwlock_unlock instead of pthread_rwlock_rdlock and pthread_rwlock_unlock. --- pthread/pt-alloc.c | 14 +++++++------- pthread/pt-create.c | 4 ++-- pthread/pt-dealloc.c | 6 +++--- pthread/pt-exit.c | 6 +++--- pthread/pt-internal.h | 8 ++++---- pthread/pt-join.c | 2 +- sysdeps/hurd/pt-key-delete.c | 4 ++-- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/pthread/pt-alloc.c b/pthread/pt-alloc.c index 4860f48..21063d5 100644 --- a/pthread/pt-alloc.c +++ b/pthread/pt-alloc.c @@ -139,7 +139,7 @@ __pthread_alloc (struct __pthread **pthread) } retry: - pthread_rwlock_wrlock (&__pthread_threads_lock); + __pthread_rwlock_wrlock (&__pthread_threads_lock); if (__pthread_num_threads < __pthread_max_threads) { @@ -148,7 +148,7 @@ __pthread_alloc (struct __pthread **pthread) new->thread = 1 + __pthread_num_threads++; __pthread_threads[new->thread - 1] = NULL; - pthread_rwlock_unlock (&__pthread_threads_lock); + __pthread_rwlock_unlock (&__pthread_threads_lock); *pthread = new; return 0; @@ -157,7 +157,7 @@ __pthread_alloc (struct __pthread **pthread) else if (__pthread_num_threads >= PTHREAD_THREADS_MAX) { /* We have reached the limit on the number of threads per process. */ - pthread_rwlock_unlock (&__pthread_threads_lock); + __pthread_rwlock_unlock (&__pthread_threads_lock); free (new); return EAGAIN; @@ -169,7 +169,7 @@ __pthread_alloc (struct __pthread **pthread) memory allocation, since that's a potentially blocking operation. */ max_threads = __pthread_max_threads; - pthread_rwlock_unlock (&__pthread_threads_lock); + __pthread_rwlock_unlock (&__pthread_threads_lock); /* Allocate a new lookup table that's twice as large. */ new_max_threads @@ -181,13 +181,13 @@ __pthread_alloc (struct __pthread **pthread) return ENOMEM; } - pthread_rwlock_wrlock (&__pthread_threads_lock); + __pthread_rwlock_wrlock (&__pthread_threads_lock); /* Check if nobody else has already enlarged the table. */ if (max_threads != __pthread_max_threads) { /* Yep, they did. */ - pthread_rwlock_unlock (&__pthread_threads_lock); + __pthread_rwlock_unlock (&__pthread_threads_lock); /* Free the newly allocated table and try again to allocate a slot. */ free (threads); @@ -210,7 +210,7 @@ __pthread_alloc (struct __pthread **pthread) new->thread = 1 + __pthread_num_threads++; __pthread_threads[new->thread - 1] = NULL; - pthread_rwlock_unlock (&__pthread_threads_lock); + __pthread_rwlock_unlock (&__pthread_threads_lock); free (old_threads); diff --git a/pthread/pt-create.c b/pthread/pt-create.c index 417605a..c9e0730 100644 --- a/pthread/pt-create.c +++ b/pthread/pt-create.c @@ -202,9 +202,9 @@ __pthread_create_internal (struct __pthread **thread, could use __thread_setid, however, we only lock for reading as no other thread should be using this entry (we also assume that the store is atomic). */ - pthread_rwlock_rdlock (&__pthread_threads_lock); + __pthread_rwlock_rdlock (&__pthread_threads_lock); __pthread_threads[pthread->thread - 1] = pthread; - pthread_rwlock_unlock (&__pthread_threads_lock); + __pthread_rwlock_unlock (&__pthread_threads_lock); /* At this point it is possible to guess our pthread ID. We have to make sure that all functions taking a pthread_t argument can diff --git a/pthread/pt-dealloc.c b/pthread/pt-dealloc.c index e324800..f44aefa 100644 --- a/pthread/pt-dealloc.c +++ b/pthread/pt-dealloc.c @@ -49,14 +49,14 @@ __pthread_dealloc (struct __pthread *pthread) by the standards. */ __pthread_mutex_lock (&pthread->state_lock); if (pthread->state != PTHREAD_EXITED) - pthread_cond_broadcast (&pthread->state_cond); + __pthread_cond_broadcast (&pthread->state_cond); __pthread_mutex_unlock (&pthread->state_lock); /* We do not actually deallocate the thread structure, but add it to a list of re-usable thread structures. */ - pthread_mutex_lock (&__pthread_free_threads_lock); + __pthread_mutex_lock (&__pthread_free_threads_lock); __pthread_enqueue (&__pthread_free_threads, pthread); - pthread_mutex_unlock (&__pthread_free_threads_lock); + __pthread_mutex_unlock (&__pthread_free_threads_lock); /* Setting PTHREAD->STATE to PTHREAD_TERMINATED makes this TCB available for reuse. After that point, we can no longer assume diff --git a/pthread/pt-exit.c b/pthread/pt-exit.c index 3427de5..b078db2 100644 --- a/pthread/pt-exit.c +++ b/pthread/pt-exit.c @@ -39,14 +39,14 @@ __pthread_exit (void *status) /* Run any cancelation handlers. According to POSIX, the cancellation cleanup handlers should be called with cancellation disabled. */ - pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &oldstate); + __pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &oldstate); for (handlers = __pthread_get_cleanup_stack (); *handlers; *handlers = (*handlers)->__next) (*handlers)->__handler ((*handlers)->__arg); - pthread_setcancelstate (oldstate, &oldstate); + __pthread_setcancelstate (oldstate, &oldstate); /* Decrease the number of threads. We use an atomic operation to make sure that only the last thread calls `exit'. */ @@ -86,7 +86,7 @@ __pthread_exit (void *status) /* Broadcast the condition. This will wake up threads that are waiting to join us. */ - pthread_cond_broadcast (&self->state_cond); + __pthread_cond_broadcast (&self->state_cond); __pthread_mutex_unlock (&self->state_lock); break; diff --git a/pthread/pt-internal.h b/pthread/pt-internal.h index 18b5b4c..c1b6c59 100644 --- a/pthread/pt-internal.h +++ b/pthread/pt-internal.h @@ -191,15 +191,15 @@ extern pthread_rwlock_t __pthread_threads_lock; #define __pthread_getid(thread) \ ({ struct __pthread *__t; \ - pthread_rwlock_rdlock (&__pthread_threads_lock); \ + __pthread_rwlock_rdlock (&__pthread_threads_lock); \ __t = __pthread_threads[thread - 1]; \ - pthread_rwlock_unlock (&__pthread_threads_lock); \ + __pthread_rwlock_unlock (&__pthread_threads_lock); \ __t; }) #define __pthread_setid(thread, pthread) \ - pthread_rwlock_wrlock (&__pthread_threads_lock); \ + __pthread_rwlock_wrlock (&__pthread_threads_lock); \ __pthread_threads[thread - 1] = pthread; \ - pthread_rwlock_unlock (&__pthread_threads_lock); + __pthread_rwlock_unlock (&__pthread_threads_lock); /* Similar to pthread_self, but returns the thread descriptor instead of the thread ID. */ diff --git a/pthread/pt-join.c b/pthread/pt-join.c index 122d130..9730afc 100644 --- a/pthread/pt-join.c +++ b/pthread/pt-join.c @@ -43,7 +43,7 @@ pthread_join (pthread_t thread, void **status) /* Rely on pthread_cond_wait being a cancellation point to make pthread_join one too. */ while (pthread->state == PTHREAD_JOINABLE) - pthread_cond_wait (&pthread->state_cond, &pthread->state_lock); + __pthread_cond_wait (&pthread->state_cond, &pthread->state_lock); pthread_cleanup_pop (0); diff --git a/sysdeps/hurd/pt-key-delete.c b/sysdeps/hurd/pt-key-delete.c index 9d88647..8b2c8bb 100644 --- a/sysdeps/hurd/pt-key-delete.c +++ b/sysdeps/hurd/pt-key-delete.c @@ -40,7 +40,7 @@ pthread_key_delete (pthread_key_t key) __pthread_key_destructors[key] = PTHREAD_KEY_INVALID; __pthread_key_invalid_count ++; - pthread_rwlock_rdlock (&__pthread_threads_lock); + __pthread_rwlock_rdlock (&__pthread_threads_lock); for (i = 0; i < __pthread_num_threads; ++i) { struct __pthread *t; @@ -55,7 +55,7 @@ pthread_key_delete (pthread_key_t key) if (t->thread_specifics) hurd_ihash_remove (t->thread_specifics, key); } - pthread_rwlock_unlock (&__pthread_threads_lock); + __pthread_rwlock_unlock (&__pthread_threads_lock); } __pthread_mutex_unlock (&__pthread_key_lock); -- cgit v1.2.3 From 73a04c4916f11e1f30aaca770ec1a2dbb78f7686 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Tue, 20 Sep 2016 22:48:54 +0200 Subject: Fix old-style function definitions * sysdeps/pthread/flockfile.c (__flockfile): Fix old-style function definition. * sysdeps/pthread/ftrylockfile.c (__ftrylockfile): Likewise. * sysdeps/pthread/funlockfile.c (__funlockfile): Likewise. --- sysdeps/pthread/flockfile.c | 3 +-- sysdeps/pthread/ftrylockfile.c | 3 +-- sysdeps/pthread/funlockfile.c | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/sysdeps/pthread/flockfile.c b/sysdeps/pthread/flockfile.c index 89e690d..749a11c 100644 --- a/sysdeps/pthread/flockfile.c +++ b/sysdeps/pthread/flockfile.c @@ -22,8 +22,7 @@ void -__flockfile (stream) - FILE *stream; +__flockfile (FILE *stream) { #ifdef SHARED __libc_ptf_call (_IO_flockfile, (stream), 0); diff --git a/sysdeps/pthread/ftrylockfile.c b/sysdeps/pthread/ftrylockfile.c index e8f8060..1ae6abc 100644 --- a/sysdeps/pthread/ftrylockfile.c +++ b/sysdeps/pthread/ftrylockfile.c @@ -23,8 +23,7 @@ int -__ftrylockfile (stream) - FILE *stream; +__ftrylockfile (FILE *stream) { #ifdef SHARED return __libc_ptf_call (_IO_ftrylockfile, (stream), 0); diff --git a/sysdeps/pthread/funlockfile.c b/sysdeps/pthread/funlockfile.c index 65201ed..8dda960 100644 --- a/sysdeps/pthread/funlockfile.c +++ b/sysdeps/pthread/funlockfile.c @@ -23,8 +23,7 @@ void -__funlockfile (stream) - FILE *stream; +__funlockfile (FILE *stream) { #ifdef SHARED __libc_ptf_call (_IO_funlockfile, (stream), 0); -- cgit v1.2.3 From d10c3db401fb427e796fb51ac20bff438388d1b3 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Tue, 20 Sep 2016 23:01:43 +0200 Subject: Fix old-style function definition * libc_pthread_init.c (__libc_pthread_init): Fix old-style function definition. --- libc_pthread_init.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libc_pthread_init.c b/libc_pthread_init.c index f7997da..afce1f7 100644 --- a/libc_pthread_init.c +++ b/libc_pthread_init.c @@ -22,8 +22,7 @@ void internal_function -__libc_pthread_init (functions) - const struct pthread_functions *functions; +__libc_pthread_init (const struct pthread_functions *functions) { #ifdef SHARED /* We copy the content of the variable pointed to by the FUNCTIONS -- cgit v1.2.3 From 1d49ccdd73c182ad9f280d21d5a5e88bd59db871 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Tue, 20 Sep 2016 23:04:20 +0200 Subject: Fix warning * sysdeps/mach/pt-thread-terminate.c (__pthread_thread_terminate): Cast stack address to vm_address_t before calling __thread_terminate_release. --- sysdeps/mach/pt-thread-terminate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysdeps/mach/pt-thread-terminate.c b/sysdeps/mach/pt-thread-terminate.c index cb9e26a..5d9da26 100644 --- a/sysdeps/mach/pt-thread-terminate.c +++ b/sysdeps/mach/pt-thread-terminate.c @@ -74,7 +74,7 @@ __pthread_thread_terminate (struct __pthread *thread) /* Terminate and release all that's left. */ err = __thread_terminate_release (kernel_thread, mach_task_self (), kernel_thread, reply_port, - stackaddr, stacksize); + (vm_address_t) stackaddr, stacksize); /* The kernel does not support it yet. Leak but at least terminate correctly. */ -- cgit v1.2.3