mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
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>
This commit is contained in:
@ -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 */
|
||||
|
Reference in New Issue
Block a user