diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2016-09-21 00:05:53 +0200 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2016-09-21 00:05:53 +0200 |
commit | 1f32bdc2e2f54cf4279b720909ff9c2d64a1c406 (patch) | |
tree | 03761c564ebe347a2924667ac4b4d4fabbb58dfe | |
parent | a9d69ae8ab389dc9f47aef519dac4f422b4120ef (diff) | |
parent | 1d49ccdd73c182ad9f280d21d5a5e88bd59db871 (diff) |
Merge branch 'master' into master-glibc-2.23
-rw-r--r-- | Makefile | 6 | ||||
-rw-r--r-- | Versions | 6 | ||||
-rw-r--r-- | libc_pthread_init.c | 3 | ||||
-rw-r--r-- | pthread/pt-alloc.c | 14 | ||||
-rw-r--r-- | pthread/pt-create.c | 6 | ||||
-rw-r--r-- | pthread/pt-dealloc.c | 6 | ||||
-rw-r--r-- | pthread/pt-exit.c | 6 | ||||
-rw-r--r-- | pthread/pt-internal.h | 8 | ||||
-rw-r--r-- | pthread/pt-join.c | 2 | ||||
-rw-r--r-- | pthreadP.h | 26 | ||||
-rw-r--r-- | sysdeps/generic/pt-kill.c | 5 | ||||
-rw-r--r-- | sysdeps/generic/raise.c | 10 | ||||
-rw-r--r-- | sysdeps/hurd/pt-key-delete.c | 4 | ||||
-rw-r--r-- | sysdeps/hurd/pt-kill.c | 3 | ||||
-rw-r--r-- | sysdeps/mach/pt-thread-terminate.c | 2 | ||||
-rw-r--r-- | sysdeps/pthread/bits/once.h | 2 | ||||
-rw-r--r-- | sysdeps/pthread/flockfile.c | 3 | ||||
-rw-r--r-- | sysdeps/pthread/ftrylockfile.c | 3 | ||||
-rw-r--r-- | sysdeps/pthread/funlockfile.c | 3 |
19 files changed, 72 insertions, 46 deletions
@@ -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) @@ -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; } } @@ -93,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/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 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 d88afae..c9e0730 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) @@ -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/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 + <http://www.gnu.org/licenses/>. */ + +#ifndef _PTHREADP_H +#define _PTHREADP_H 1 + +#include <pthread.h> + +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 <http://www.gnu.org/licenses/>. */ +#include <pthreadP.h> #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 <http://www.gnu.org/licenses/>. */ -#include <pthread.h> +#include <pthreadP.h> #include <signal.h> #include <unistd.h> -#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-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); 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 <pt-internal.h> 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) 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. */ 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 */ diff --git a/sysdeps/pthread/flockfile.c b/sysdeps/pthread/flockfile.c index b552cd6..0153a2c 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 c33de88..48420de 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 05edc66..78fd211 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); |