about summary refs log tree commit diff
path: root/sysdeps/unix/sysv/linux/timer_create.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/unix/sysv/linux/timer_create.c')
-rw-r--r--sysdeps/unix/sysv/linux/timer_create.c69
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 */