diff options
author | Florian Weimer <fweimer@redhat.com> | 2021-06-28 09:51:00 +0200 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2021-06-28 09:51:00 +0200 |
commit | 273a2a2ae8b097672cdc8e9888548b134955af42 (patch) | |
tree | a944110b3bfa9a0578aea7c5fc1994d801aee719 /sysdeps/unix/sysv/linux/timer_create.c | |
parent | d7d0efec47e76c022c3bcb30cdb4b0501d7a9b2a (diff) | |
download | glibc-273a2a2ae8b097672cdc8e9888548b134955af42.tar.gz |
Linux: Move timer_create, timer_delete from librt to libc
The symbols were moved using scripts/move-symbol-to-libc.py.
timer_create and timer_delete are tied together via the int/timer_t
compatibility code. The way the ABI intransition is implemented
is changed with this commit: the implementation is now consolidated
in one file with a TIMER_T_WAS_INT_COMPAT check.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Diffstat (limited to 'sysdeps/unix/sysv/linux/timer_create.c')
-rw-r--r-- | sysdeps/unix/sysv/linux/timer_create.c | 69 |
1 files changed, 56 insertions, 13 deletions
diff --git a/sysdeps/unix/sysv/linux/timer_create.c b/sysdeps/unix/sysv/linux/timer_create.c index b21b0ca949..58099e3204 100644 --- a/sysdeps/unix/sysv/linux/timer_create.c +++ b/sysdeps/unix/sysv/linux/timer_create.c @@ -27,17 +27,11 @@ #include <pthreadP.h> #include "kernel-posix-timers.h" #include "kernel-posix-cpu-timers.h" - - -#ifdef timer_create_alias -# define timer_create timer_create_alias -#endif - +#include <shlib-compat.h> int -timer_create (clockid_t clock_id, struct sigevent *evp, timer_t *timerid) +___timer_create (clockid_t clock_id, struct sigevent *evp, timer_t *timerid) { -#undef timer_create { clockid_t syscall_clockid = (clock_id == CLOCK_PROCESS_CPUTIME_ID ? MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED) @@ -74,7 +68,7 @@ timer_create (clockid_t clock_id, struct sigevent *evp, timer_t *timerid) else { /* Create the helper thread. */ - pthread_once (&__timer_helper_once, __timer_start_helper_thread); + __pthread_once (&__timer_helper_once, __timer_start_helper_thread); if (__timer_helper_tid == 0) { /* No resources to start the helper thread. */ @@ -93,7 +87,7 @@ timer_create (clockid_t clock_id, struct sigevent *evp, timer_t *timerid) /* We cannot simply copy the thread attributes since the implementation might keep internal information for each instance. */ - pthread_attr_init (&newp->attr); + __pthread_attr_init (&newp->attr); if (evp->sigev_notify_attributes != NULL) { struct pthread_attr *nattr; @@ -111,7 +105,7 @@ timer_create (clockid_t clock_id, struct sigevent *evp, timer_t *timerid) } /* In any case set the detach flag. */ - pthread_attr_setdetachstate (&newp->attr, PTHREAD_CREATE_DETACHED); + __pthread_attr_setdetachstate (&newp->attr, PTHREAD_CREATE_DETACHED); /* Create the event structure for the kernel timer. */ struct sigevent sev = @@ -132,10 +126,10 @@ timer_create (clockid_t clock_id, struct sigevent *evp, timer_t *timerid) } /* Add to the queue of active timers with thread delivery. */ - pthread_mutex_lock (&__timer_active_sigev_thread_lock); + __pthread_mutex_lock (&__timer_active_sigev_thread_lock); newp->next = __timer_active_sigev_thread; __timer_active_sigev_thread = newp; - pthread_mutex_unlock (&__timer_active_sigev_thread_lock); + __pthread_mutex_unlock (&__timer_active_sigev_thread_lock); *timerid = timer_to_timerid (newp); } @@ -143,3 +137,52 @@ timer_create (clockid_t clock_id, struct sigevent *evp, timer_t *timerid) return 0; } +versioned_symbol (libc, ___timer_create, timer_create, GLIBC_2_34); +libc_hidden_ver (___timer_create, __timer_create) + +#if TIMER_T_WAS_INT_COMPAT +# if OTHER_SHLIB_COMPAT (librt, GLIBC_2_3_3, GLIBC_2_34) +compat_symbol (librt, ___timer_create, timer_create, GLIBC_2_3_3); +# endif + +# if OTHER_SHLIB_COMPAT (librt, GLIBC_2_2, GLIBC_2_3_3) +timer_t __timer_compat_list[OLD_TIMER_MAX] __attribute__ ((nocommon)); +libc_hidden_data_def (__timer_compat_list) + +int +__timer_create_old (clockid_t clock_id, struct sigevent *evp, int *timerid) +{ + timer_t newp; + + int res = __timer_create (clock_id, evp, &newp); + if (res == 0) + { + int i; + for (i = 0; i < OLD_TIMER_MAX; ++i) + if (__timer_compat_list[i] == NULL + && ! atomic_compare_and_exchange_bool_acq (&__timer_compat_list[i], + newp, NULL)) + { + *timerid = i; + break; + } + + if (__glibc_unlikely (i == OLD_TIMER_MAX)) + { + /* No free slot. */ + __timer_delete (newp); + __set_errno (EINVAL); + res = -1; + } + } + + return res; +} +compat_symbol (librt, __timer_create_old, timer_create, GLIBC_2_2); +# endif /* OTHER_SHLIB_COMPAT */ + +#else /* !TIMER_T_WAS_INT_COMPAT */ +# if OTHER_SHLIB_COMPAT (librt, GLIBC_2_2, GLIBC_2_34) +compat_symbol (librt, ___timer_create, timer_create, GLIBC_2_2); +# endif +#endif /* !TIMER_T_WAS_INT_COMPAT */ |