]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
* init.c (__pthread_initialize_minimal_internal): Optimize test
authorUlrich Drepper <drepper@redhat.com>
Sun, 4 Jan 2009 18:10:04 +0000 (18:10 +0000)
committerUlrich Drepper <drepper@redhat.com>
Sun, 4 Jan 2009 18:10:04 +0000 (18:10 +0000)
FUTEX_CLOCK_REALTIME a bit.

nptl/ChangeLog
nptl/init.c

index a55ad52d80a1e95547f3a3d0780a9005ce27dd92..e25da8b6405bf262c22d485b613e51e015d890c4 100644 (file)
@@ -1,3 +1,8 @@
+2009-01-04  Ulrich Drepper  <drepper@redhat.com>
+
+       * init.c (__pthread_initialize_minimal_internal): Optimize test
+       FUTEX_CLOCK_REALTIME a bit.
+
 2009-01-03  Ulrich Drepper  <drepper@redhat.com>
 
        * init.c (__pthread_initialize_minimal_internal): Cheat a bit by
index 05883af1f4d3d484d6e5fdb1973fff796cf3a223..7a6dec593576b5c34b616bfeead13bc45fc22fc5 100644 (file)
@@ -300,24 +300,28 @@ __pthread_initialize_minimal_internal (void)
     if (!INTERNAL_SYSCALL_ERROR_P (word, err))
       THREAD_SETMEM (pd, header.private_futex, FUTEX_PRIVATE_FLAG);
   }
-#endif
 
+  /* Private futexes have been introduced earlier than the
+     FUTEX_CLOCK_REALTIME flag.  We don't have to run the test if we
+     know the former are not supported.  This also means we know the
+     kernel will return ENOSYS for unknown operations.  */
+  if (THREAD_GETMEM (pd, header.private_futex) != 0)
+#endif
 #ifndef __ASSUME_FUTEX_CLOCK_REALTIME
-  {
-    int word = 0;
-    /* NB: the syscall actually takes six parameters.  The last is the
-       bit mask.  But since we will not actually wait at all the value
-       is irrelevant.  Given that passing six parameters is difficult
-       on some architectures we just pass whatever random value the
-       calling convention calls for to the kernel.  It causes no harm.  */
-    word = INTERNAL_SYSCALL (futex, err, 5, &word,
-                            FUTEX_WAIT_BITSET | FUTEX_CLOCK_REALTIME
-                            | FUTEX_PRIVATE_FLAG, 1, NULL, 0);
-    if (!INTERNAL_SYSCALL_ERROR_P (word, err)
-       || (INTERNAL_SYSCALL_ERRNO (word, err) != ENOSYS
-           && INTERNAL_SYSCALL_ERRNO (word, err) != EINVAL))
-      __set_futex_clock_realtime ();
-  }
+    {
+      int word = 0;
+      /* NB: the syscall actually takes six parameters.  The last is the
+        bit mask.  But since we will not actually wait at all the value
+        is irrelevant.  Given that passing six parameters is difficult
+        on some architectures we just pass whatever random value the
+        calling convention calls for to the kernel.  It causes no harm.  */
+      word = INTERNAL_SYSCALL (futex, err, 5, &word,
+                              FUTEX_WAIT_BITSET | FUTEX_CLOCK_REALTIME
+                              | FUTEX_PRIVATE_FLAG, 1, NULL, 0);
+      assert (INTERNAL_SYSCALL_ERROR_P (word, err));
+      if (INTERNAL_SYSCALL_ERRNO (word, err) != ENOSYS)
+       __set_futex_clock_realtime ();
+    }
 #endif
 
   /* Set initial thread's stack block from 0 up to __libc_stack_end.