about summary refs log tree commit diff
path: root/sysdeps/unix/sysv/linux/adjtime.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2007-12-10 23:51:42 +0000
committerUlrich Drepper <drepper@redhat.com>2007-12-10 23:51:42 +0000
commitae18718f58a619abf463eca538c497972d24e173 (patch)
treef5846c2f572d694a81e6ec7d59b3c729550ef0c3 /sysdeps/unix/sysv/linux/adjtime.c
parentb4354cf42008f12cac246759b64db0439a82ce67 (diff)
downloadglibc-ae18718f58a619abf463eca538c497972d24e173.tar.gz
glibc-ae18718f58a619abf463eca538c497972d24e173.tar.xz
glibc-ae18718f58a619abf463eca538c497972d24e173.zip
* sysdeps/unix/sysv/linux/adjtime.c: Use ADJ_OFFSET_SS_READ if
	possible.
	* sysdeps/unix/sysv/linux/kernel-features.h
	(__ASSUME_ADJ_OFFSET_SS_READ): Define for 2.6.24.
	* sysdeps/unix/sysv/linux/sys/timex.h (ADJ_OFFSET_SS_READ): Define.
Diffstat (limited to 'sysdeps/unix/sysv/linux/adjtime.c')
-rw-r--r--sysdeps/unix/sysv/linux/adjtime.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/sysdeps/unix/sysv/linux/adjtime.c b/sysdeps/unix/sysv/linux/adjtime.c
index 38ef805cd5..202bb14485 100644
--- a/sysdeps/unix/sysv/linux/adjtime.c
+++ b/sysdeps/unix/sysv/linux/adjtime.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995, 1996, 1997, 1998, 2002, 2004
+/* Copyright (C) 1995, 1996, 1997, 1998, 2002, 2004, 2007
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -22,6 +22,8 @@
 #include <sys/time.h>
 #include <sys/timex.h>
 
+#include <kernel-features.h>
+
 #define MAX_SEC	(INT_MAX / 1000000L - 2)
 #define MIN_SEC	(INT_MIN / 1000000L + 2)
 
@@ -69,13 +71,29 @@ ADJTIME (const struct TIMEVAL *itv, struct TIMEVAL *otv)
 	  return -1;
 	}
       tntx.offset = tmp.tv_usec + tmp.tv_sec * 1000000L;
+#ifdef ADJ_OFFSET_SS_READ
+      tntx.modes = ADJ_OFFSET_SS_READ;
+#else
       tntx.modes = ADJ_OFFSET_SINGLESHOT;
+#endif
     }
   else
     tntx.modes = 0;
 
-  if (ADJTIMEX (&tntx) < 0)
-    return -1;
+#if defined ADJ_OFFSET_SS_READ && !defined __ASSUME_ADJ_OFFSET_SS_READ
+ again:
+#endif
+  if (__builtin_expect (ADJTIMEX (&tntx) < 0, 0))
+    {
+#if defined ADJ_OFFSET_SS_READ && !defined __ASSUME_ADJ_OFFSET_SS_READ
+      if (itv && errno == EINVAL && tntx.modes == ADJ_OFFSET_SS_READ)
+	{
+	  tntx.modes = ADJ_OFFSET_SINGLESHOT;
+	  goto again;
+	}
+#endif
+      return -1;
+    }
 
   if (otv)
     {