[Glibc-bsd-commits] r4641 - trunk/glibc-ports/kfreebsd/fbtl

Petr Salinger ps-guest at alioth.debian.org
Mon Jul 8 12:48:08 UTC 2013


Author: ps-guest
Date: 2013-06-28 15:11:58 +0000 (Fri, 28 Jun 2013)
New Revision: 4641

Modified:
   trunk/glibc-ports/kfreebsd/fbtl/Makefile
   trunk/glibc-ports/kfreebsd/fbtl/Versions
   trunk/glibc-ports/kfreebsd/fbtl/kernel-posix-timers.h
   trunk/glibc-ports/kfreebsd/fbtl/timer_create.c
   trunk/glibc-ports/kfreebsd/fbtl/timer_routines.c
Log:
migrate timers from linuxthreads to fbtl


Modified: trunk/glibc-ports/kfreebsd/fbtl/Makefile
===================================================================
--- trunk/glibc-ports/kfreebsd/fbtl/Makefile	2013-06-28 15:09:36 UTC (rev 4640)
+++ trunk/glibc-ports/kfreebsd/fbtl/Makefile	2013-06-28 15:11:58 UTC (rev 4641)
@@ -41,6 +41,8 @@
 libpthread-routines += ptw-sys_thr_self
 libpthread-routines += ptw-sys_thr_set_name
 libpthread-routines += ptw-sys_thr_exit
+librt-routines += sys_sigwaitinfo
+routines += sys_sigwaitinfo
 endif
 
 ifeq ($(subdir),posix)

Modified: trunk/glibc-ports/kfreebsd/fbtl/Versions
===================================================================
--- trunk/glibc-ports/kfreebsd/fbtl/Versions	2013-06-28 15:09:36 UTC (rev 4640)
+++ trunk/glibc-ports/kfreebsd/fbtl/Versions	2013-06-28 15:11:58 UTC (rev 4641)
@@ -9,6 +9,7 @@
 # needed by pthread library
     __exit_thread;
     __syscall_sigprocmask;
+    __syscall_sigwaitinfo;
     __sigprocmask;
     __syscall_sigsuspend;
     __ioctl;

Modified: trunk/glibc-ports/kfreebsd/fbtl/kernel-posix-timers.h
===================================================================
--- trunk/glibc-ports/kfreebsd/fbtl/kernel-posix-timers.h	2013-06-28 15:09:36 UTC (rev 4640)
+++ trunk/glibc-ports/kfreebsd/fbtl/kernel-posix-timers.h	2013-06-28 15:11:58 UTC (rev 4641)
@@ -21,16 +21,8 @@
 #include <setjmp.h>
 #include <signal.h>
 #include <sys/types.h>
-#include <sys/_types.h>
 
-/* The signal used for asynchronous cancelation.  */
-#define SIGCANCEL	(PTHREAD_SIGBASE + 1)
 
-/* Signal needed for the kernel-supported POSIX timer implementation.
-   We can reuse the cancellation signal since we can distinguish
-   cancellation from timer expirations.  */
-#define SIGTIMER	SIGCANCEL
-
 /* Nonzero if the system calls are not available.  */
 extern int __no_posix_timers attribute_hidden;
 
@@ -41,7 +33,7 @@
 extern pthread_once_t __helper_once attribute_hidden;
 
 /* TID of the helper thread.  */
-extern __lwpid_t __helper_tid attribute_hidden;
+extern pid_t __helper_tid attribute_hidden;
 
 /* List of active SIGEV_THREAD timers.  */
 extern struct timer *__active_timer_sigev_thread attribute_hidden;
@@ -82,13 +74,19 @@
 {
   unsigned int i;
   struct timer *timer = malloc (sizeof (struct timer));
+  
+  if (timer == NULL)
+      goto fail;
 
   /* Find a free slot (and reserve it atomically).  */
   for (i = 0; i < TIMER_MAX; i++)
     if (atomic_compare_and_exchange_val_acq (&__all_timers[i],
 					     timer, NULL) == NULL)
       return timer;
+      
+  free (timer);    
 
+fail:
   errno = EAGAIN;
   return NULL;
 }

Modified: trunk/glibc-ports/kfreebsd/fbtl/timer_create.c
===================================================================
--- trunk/glibc-ports/kfreebsd/fbtl/timer_create.c	2013-06-28 15:09:36 UTC (rev 4640)
+++ trunk/glibc-ports/kfreebsd/fbtl/timer_create.c	2013-06-28 15:11:58 UTC (rev 4641)
@@ -25,6 +25,8 @@
 #include <time.h>
 #include <sysdep.h>
 #include <kernel-features.h>
+#include <internaltypes.h>
+#include <nptl/pthreadP.h>
 #include "kernel-posix-timers.h"
 #include "kernel-posix-cpu-timers.h"
 
@@ -113,17 +115,18 @@
 	      (void) pthread_attr_init (&newp->attr);
 	      if (evp->sigev_notify_attributes != NULL)
 		{
-		  pthread_attr_t *nattr;
-		  pthread_attr_t *oattr;
+		  struct pthread_attr *nattr;
+		  struct pthread_attr *oattr;
 
-		  nattr = (pthread_attr_t *) &newp->attr;
-		  oattr = (pthread_attr_t *) evp->sigev_notify_attributes;
+		  nattr = (struct pthread_attr *) &newp->attr;
+		  oattr = (struct pthread_attr *) evp->sigev_notify_attributes;
 
-		  nattr->__schedparam = oattr->__schedparam;
-		  nattr->__schedpolicy = oattr->__schedpolicy;
-		  nattr->__guardsize = oattr->__guardsize;
-		  nattr->__stackaddr = oattr->__stackaddr;
-		  nattr->__stacksize = oattr->__stacksize;
+		  nattr->schedparam = oattr->schedparam;
+		  nattr->schedpolicy = oattr->schedpolicy;
+		  nattr->flags = oattr->flags;
+		  nattr->guardsize = oattr->guardsize;
+		  nattr->stackaddr = oattr->stackaddr;
+		  nattr->stacksize = oattr->stacksize;
 		}
 
 	      /* In any case set the detach flag.  */

Modified: trunk/glibc-ports/kfreebsd/fbtl/timer_routines.c
===================================================================
--- trunk/glibc-ports/kfreebsd/fbtl/timer_routines.c	2013-06-28 15:09:36 UTC (rev 4640)
+++ trunk/glibc-ports/kfreebsd/fbtl/timer_routines.c	2013-06-28 15:11:58 UTC (rev 4641)
@@ -22,11 +22,8 @@
 #include <signal.h>
 #include <stdbool.h>
 #include <sysdep.h>
-#include <sys/_types.h> /* __lwpid_t */
-#include <atomic.h>
 #include <kernel-features.h>
-#include <linuxthreads/internals.h>	/* LIBC_CANCEL_ASYNC */
-#include <semaphore.h>
+#include <nptl/pthreadP.h>
 #include "kernel-posix-timers.h"
 
 /* NPTL/Linux simply casts "timer_t" to "struct timer *", but on
@@ -46,9 +43,6 @@
   sigval_t sival;
 };
 
-/* TID of the helper thread.  */
-__lwpid_t __helper_tid attribute_hidden;
-sem_t __helper_tid_semaphore attribute_hidden;
 
 /* Helper thread to call the user-provided function.  */
 static void *
@@ -59,8 +53,9 @@
      signals.  */
   sigset_t ss;
   sigemptyset (&ss);
-  sigprocmask (SIG_SETMASK, &ss, NULL);
 
+  INLINE_SYSCALL (sigprocmask, 3, SIG_SETMASK, &ss, NULL);
+
   struct thread_start_data *td = (struct thread_start_data *) arg;
 
   void (*thrfunc) (sigval_t) = td->thrfunc;
@@ -86,9 +81,6 @@
   sigemptyset (&ss);
   __sigaddset (&ss, SIGTIMER);
 
-  syscall (SYS_thr_self, &__helper_tid);
-  sem_post (&__helper_tid_semaphore);
-
   /* Endless loop of waiting for signals.  The loop is only ended when
      the thread is canceled.  */
   while (1)
@@ -97,12 +89,11 @@
 
       /* sigwaitinfo cannot be used here, since it deletes
 	 SIGCANCEL == SIGTIMER from the set.  */
+      /* but direct interface to kernel does not do such things */
 
       int oldtype = LIBC_CANCEL_ASYNC ();
 
-      /* XXX The size argument hopefully will have to be changed to the
-	 real size of the user-level sigset_t.  */
-      int result = sigtimedwait (&ss, &si, NULL);
+      int result = INLINE_SYSCALL (sigwaitinfo, 2, &ss, &si);
 
       LIBC_CANCEL_RESET (oldtype);
 
@@ -156,13 +147,16 @@
 pthread_once_t __helper_once attribute_hidden;
 
 
+/* TID of the helper thread.  */
+pid_t __helper_tid attribute_hidden;
+
+
 /* Reset variables so that after a fork a new helper thread gets started.  */
 static void
 reset_helper_control (void)
 {
   __helper_once = PTHREAD_ONCE_INIT;
   __helper_tid = 0;
-  sem_destroy (&__helper_tid_semaphore);
 }
 
 
@@ -185,19 +179,18 @@
   sigset_t oss;
   sigfillset (&ss);
   __sigaddset (&ss, SIGCANCEL);
-  sigprocmask (SIG_SETMASK, &ss, &oss);
+  INLINE_SYSCALL (sigprocmask, 3, SIG_SETMASK, &ss, &oss);
 
-  sem_init (&__helper_tid_semaphore, 0, 0);
 
   /* Create the helper thread for this timer.  */
   pthread_t th;
   int res = pthread_create (&th, &attr, timer_helper_thread, NULL);
   if (res == 0)
     /* We managed to start the helper thread.  */
-    sem_wait (&__helper_tid_semaphore);
+    __helper_tid = ((struct pthread *) th)->tid;
 
   /* Restore the signal mask.  */
-  sigprocmask (SIG_SETMASK, &oss, NULL);
+  INLINE_SYSCALL (sigprocmask, 3, SIG_SETMASK, &oss, NULL);
 
   /* No need for the attribute anymore.  */
   (void) pthread_attr_destroy (&attr);




More information about the Glibc-bsd-commits mailing list