about summary refs log tree commit diff
path: root/nptl/init.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2009-01-03 05:06:46 +0000
committerUlrich Drepper <drepper@redhat.com>2009-01-03 05:06:46 +0000
commitcbd8aeb836c8061c23a5e00419e0fb25a34abee7 (patch)
tree3f205876a4edffbc06a9474542dfe2a8cdcb27a4 /nptl/init.c
parent7dd650d7fc8191aa99c14602b9a44bccb276d4f8 (diff)
downloadglibc-cbd8aeb836c8061c23a5e00419e0fb25a34abee7.tar.gz
glibc-cbd8aeb836c8061c23a5e00419e0fb25a34abee7.tar.xz
glibc-cbd8aeb836c8061c23a5e00419e0fb25a34abee7.zip
* init.c (__pthread_initialize_minimal_internal): Check for
	FUTEX_CLOCK_REALTIME flag.
	* sysdeps/unix/sysv/linux/x86_64/lowlevellock.S (__lll_timedlock_wait):
	Use FUTEX_WAIT_BITSET|FUTEX_CLOCK_READTIME instead of computing
	relative timeout.
Diffstat (limited to 'nptl/init.c')
-rw-r--r--nptl/init.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/nptl/init.c b/nptl/init.c
index d445de0795..af5bb24b59 100644
--- a/nptl/init.c
+++ b/nptl/init.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002,2003,2004,2005,2006,2007 Free Software Foundation, Inc.
+/* Copyright (C) 2002-2007, 2008, 2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
 
@@ -18,6 +18,7 @@
    02111-1307 USA.  */
 
 #include <assert.h>
+#include <errno.h>
 #include <limits.h>
 #include <signal.h>
 #include <stdlib.h>
@@ -49,6 +50,15 @@ int __set_robust_list_avail;
 # define set_robust_list_not_avail() do { } while (0)
 #endif
 
+#ifndef __ASSUME_FUTEX_CLOCK_REALTIME
+/* Nonzero if we do not have FUTEX_CLOCK_REALTIME.  */
+int __have_futex_clock_realtime;
+# define __set_futex_clock_realtime() \
+  __have_futex_clock_realtime = 1
+#else
+#define __set_futex_clock_realtime() do { } while (0)
+#endif
+
 /* Version of the library, used in libthread_db to detect mismatches.  */
 static const char nptl_version[] __attribute_used__ = VERSION;
 
@@ -292,6 +302,20 @@ __pthread_initialize_minimal_internal (void)
   }
 #endif
 
+#ifndef __ASSUME_FUTEX_CLOCK_REALTIME
+  {
+    int word = 0;
+    word = INTERNAL_SYSCALL (futex, err, 6, &word,
+			     FUTEX_WAIT_BITSET | FUTEX_CLOCK_REALTIME
+			     | FUTEX_PRIVATE_FLAG, 1, NULL, 0,
+			     FUTEX_BITSET_MATCH_ANY);
+    if (!INTERNAL_SYSCALL_ERROR_P (word, err)
+	|| (INTERNAL_SYSCALL_ERRNO (word, err) != ENOSYS
+	    && INTERNAL_SYSCALL_ERRNO (word, err) != EINVAL))
+      __set_futex_clock_realtime ();
+  }
+#endif
+
   /* Set initial thread's stack block from 0 up to __libc_stack_end.
      It will be bigger than it actually is, but for unwind.c/pt-longjmp.c
      purposes this is good enough.  */