date: make %N work without -lrt on glibc
authorDenys Vlasenko <vda.linux@googlemail.com>
Fri, 18 Jun 2010 00:55:48 +0000 (02:55 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Fri, 18 Jun 2010 00:55:48 +0000 (02:55 +0200)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
coreutils/date.c

index 8f9aff8b0040f32c149ddedc767b4f69da92fc54..c737f09f3f71e1527b46c79e5133a44d20ad1544 100644 (file)
@@ -93,6 +93,9 @@
 //config:        MMDDhhmm[[YY]YY][.ss] format.
 
 #include "libbb.h"
+#if ENABLE_FEATURE_DATE_NANO
+# include <sys/syscall.h>
+#endif
 
 enum {
        OPT_RFC2822   = (1 << 0), /* R */
@@ -208,7 +211,9 @@ int date_main(int argc UNUSED_PARAM, char **argv)
 #endif
        } else {
 #if ENABLE_FEATURE_DATE_NANO
-               clock_gettime(CLOCK_REALTIME, &ts);
+               /* libc has incredibly messy way of doing this,
+                * typically requiring -lrt. We just skip all this mess */
+               syscall(__NR_clock_gettime, CLOCK_REALTIME, &ts);
 #else
                time(&ts.tv_sec);
 #endif