diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2018-01-27 20:21:28 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2018-01-27 20:21:28 +0100 |
commit | a7e90478b6bd2ca0a8df8db9a0ae6448f0b391af (patch) | |
tree | f48b86fc0df6e942158a5eb7f6f8f9b8562aca77 /sysdeps/pthread/libc-lockP.h | |
parent | ba1101b8755f1e843af4d9b160533f0b11e4b598 (diff) |
Use pthread_key for libc_key
* sysdeps/pthread/pthread-functions.h (struct pthread_functions): Rename
ptr_pthread_key_create, ptr_pthread_getspecific, ptr_pthread_setspecific
fields into ptr___pthread_key_create, ptr___pthread_getspecific,
ptr___pthread_setspecific
* pthread/pt-initialize.c (struct pthread_functions): Likewise.
* sysdeps/pthread/libc-lockP.h (__libc_key_t): Define type.
[IS_IN (libpthread)] (PTFAVAIL, __libc_ptf_call,
__libc_ptf_call_always): Directly call pthread functions.
(__libc_key_create): Define macro to calling __pthread_key_create.
(__libc_getspecific): Define macro to calling __pthread_getspecific.
(__libc_setspecific): Define macro to calling __pthread_setspecific.
Diffstat (limited to 'sysdeps/pthread/libc-lockP.h')
-rw-r--r-- | sysdeps/pthread/libc-lockP.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/sysdeps/pthread/libc-lockP.h b/sysdeps/pthread/libc-lockP.h index c04881d..9e034ad 100644 --- a/sysdeps/pthread/libc-lockP.h +++ b/sysdeps/pthread/libc-lockP.h @@ -22,6 +22,9 @@ #include <pthread.h> #include <pthread-functions.h> +/* Type for key to thread-specific data. */ +typedef pthread_key_t __libc_key_t; + /* If we check for a weakly referenced symbol and then perform a normal jump to it te code generated for some platforms in case of PIC is unnecessarily slow. What would happen is that the function @@ -43,6 +46,12 @@ (__libc_pthread_functions_init ? PTHFCT_CALL (ptr_##FUNC, ARGS) : ELSE) # define __libc_ptf_call_always(FUNC, ARGS) \ PTHFCT_CALL (ptr_##FUNC, ARGS) +#elif IS_IN (libpthread) +# define PTFAVAIL(NAME) 1 +# define __libc_ptf_call(FUNC, ARGS, ELSE) \ + FUNC ARGS +# define __libc_ptf_call_always(FUNC, ARGS) \ + FUNC ARGS #else # define PTFAVAIL(NAME) (NAME != NULL) # define __libc_ptf_call(FUNC, ARGS, ELSE) \ @@ -51,6 +60,19 @@ FUNC ARGS #endif +/* Create thread-specific key. */ +#define __libc_key_create(KEY, DESTRUCTOR) \ + __libc_ptf_call (__pthread_key_create, (KEY, DESTRUCTOR), 1) + +/* Get thread-specific data. */ +#define __libc_getspecific(KEY) \ + __libc_ptf_call (__pthread_getspecific, (KEY), NULL) + +/* Set thread-specific data. */ +#define __libc_setspecific(KEY, VALUE) \ + __libc_ptf_call (__pthread_setspecific, (KEY, VALUE), 0) + + /* Functions that are used by this file and are internal to the GNU C library. */ |