]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
build-sys: move all around clock_gettime() to monotonic.c
authorKarel Zak <kzak@redhat.com>
Wed, 19 Nov 2014 10:54:47 +0000 (11:54 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 19 Nov 2014 10:54:47 +0000 (11:54 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
12 files changed:
include/Makemodule.am
include/monotonic.h [moved from include/boottime.h with 80% similarity]
include/timeutils.h
lib/monotonic.c [moved from lib/boottime.c with 57% similarity]
lib/timeutils.c
libmount/src/Makemodule.am
libmount/src/lock.c
login-utils/Makemodule.am
login-utils/last.c
sys-utils/Makemodule.am
sys-utils/dmesg.c
sys-utils/eject.c

index d162d24b4ef65a65749affe1ef5ae56b17c5e355..c4a52e4cf33988420f62a2e6cc5155b00cba1f8d 100644 (file)
@@ -4,7 +4,7 @@ dist_noinst_HEADERS += \
        include/at.h \
        include/bitops.h \
        include/blkdev.h \
-       include/boottime.h \
+       include/monotonic.h \
        include/c.h \
        include/canonicalize.h \
        include/carefulputc.h \
similarity index 80%
rename from include/boottime.h
rename to include/monotonic.h
index f1d0d0b277731dedd52e21f3840c1ec11fe4c51d..f3b03d3d00401f744014d60dcbc6da9e50a5ef99 100644 (file)
@@ -6,4 +6,6 @@
  */
 extern int get_boot_time(struct timeval *boot_time);
 
+extern int gettime_monotonic(struct timeval *tv);
+
 #endif /* UTIL_LINUX_BOOTTIME_H */
index 97f054489efb3cea2dafc1b6c7110aad0d694e27..8ed501b9dbb07eef236abde38f757a947c426cff 100644 (file)
@@ -53,6 +53,4 @@ typedef uint64_t nsec_t;
 
 int parse_timestamp(const char *t, usec_t *usec);
 
-int gettime_monotonic(struct timeval *tv);
-
 #endif /* UTIL_LINUX_TIME_UTIL_H */
similarity index 57%
rename from lib/boottime.c
rename to lib/monotonic.c
index f9366bd33cf13a293467aa6f9e9117a476584736..3d4a4438e0637641fcb3364dc858b625bae27a59 100644 (file)
@@ -1,11 +1,14 @@
-
+/*
+ * Please, don't add this file to libcommon because clock_gettime() requires
+ * -lrt on systems with old libc.
+ */
 #include <time.h>
 #include <sys/sysinfo.h>
 #include <sys/time.h>
 
 #include "c.h"
 #include "nls.h"
-#include "boottime.h"
+#include "monotonic.h"
 
 int get_boot_time(struct timeval *boot_time)
 {
@@ -41,3 +44,25 @@ int get_boot_time(struct timeval *boot_time)
        return -ENOSYS;
 #endif
 }
+
+int gettime_monotonic(struct timeval *tv)
+{
+#ifdef CLOCK_MONOTONIC
+       /* Can slew only by ntp and adjtime */
+       int ret;
+       struct timespec ts;
+
+# ifdef CLOCK_MONOTONIC_RAW
+       /* Linux specific, cant slew */
+       if (!(ret = clock_gettime(CLOCK_MONOTONIC_RAW, &ts))) {
+# else
+       if (!(ret = clock_gettime(CLOCK_MONOTONIC, &ts))) {
+# endif
+               tv->tv_sec = ts.tv_sec;
+               tv->tv_usec = ts.tv_nsec / 1000;
+       }
+       return ret;
+#else
+       return gettimeofday(tv, NULL);
+#endif
+}
index bd3d402488e1dde15a7221f8e1aae9e3567cfb57..b811041e453b6feff4a480553b5bdce2ef1b2f88 100644 (file)
@@ -340,26 +340,3 @@ int parse_timestamp(const char *t, usec_t *usec)
 
        return 0;
 }
-
-
-int gettime_monotonic(struct timeval *tv)
-{
-#ifdef CLOCK_MONOTONIC
-       /* Can slew only by ntp and adjtime */
-       int ret;
-       struct timespec ts;
-
-# ifdef CLOCK_MONOTONIC_RAW
-       /* Linux specific, cant slew */
-       if (!(ret = clock_gettime(CLOCK_MONOTONIC_RAW, &ts))) {
-# else
-       if (!(ret = clock_gettime(CLOCK_MONOTONIC, &ts))) {
-# endif
-               tv->tv_sec = ts.tv_sec;
-               tv->tv_usec = ts.tv_nsec / 1000;
-       }
-       return ret;
-#else
-       return gettimeofday(tv, NULL);
-#endif
-}
index 9b0eadefbb195848bf5886c253750e79deb25588..cc4ab22f4a0a245365bba6dc6d71cee593efe38a 100644 (file)
@@ -6,6 +6,7 @@ nodist_mountinc_HEADERS = $(top_builddir)/libmount/src/libmount.h
 usrlib_exec_LTLIBRARIES += libmount.la
 libmount_la_SOURCES = \
        include/list.h \
+       lib/monotonic.c \
        \
        libmount/src/cache.c \
        libmount/src/fs.c \
index 0a07e9b0322840ab59614b3e34b5492738060bc6..a940a0e690edb665195602c8c49840db5129d3d4 100644 (file)
@@ -25,7 +25,7 @@
 #include "closestream.h"
 #include "pathnames.h"
 #include "mountP.h"
-#include "timeutils.h"
+#include "monotonic.h"
 
 /*
  * lock handler
index 73fc761d551a11aed24c3fe66960154905637989..34c5fb424728fd53a5ad8ccac1e592ea1e065331 100644 (file)
@@ -4,7 +4,7 @@ usrbin_exec_PROGRAMS += last
 dist_man_MANS += \
        login-utils/last.1 \
        login-utils/lastb.1
-last_SOURCES = login-utils/last.c lib/boottime.c
+last_SOURCES = login-utils/last.c lib/monotonic.c
 last_LDADD = $(LDADD) libcommon.la $(CLOCKGETTIME_LIBS)
 
 install-exec-hook-last:
index 54d9e1f8e32e677121a43643b29c85ee0709fed5..bf2c2da3297d3e5e5adf3e8792b524167bdde13b 100644 (file)
@@ -50,7 +50,7 @@
 #include "carefulputc.h"
 #include "strutils.h"
 #include "timeutils.h"
-#include "boottime.h"
+#include "monotonic.h"
 
 #if defined(_HAVE_UT_TV)
 # define UL_UT_TIME ut_tv.tv_sec
index 50d3eb3a4142758b5d6fb642ce1ca48f6cb26701..25e1ad7bfdca5539c5ed990515c78151805ad66f 100644 (file)
@@ -71,7 +71,7 @@ EXTRA_DIST += sys-utils/fstrim.timer
 if BUILD_DMESG
 bin_PROGRAMS += dmesg
 dist_man_MANS += sys-utils/dmesg.1
-dmesg_SOURCES = sys-utils/dmesg.c lib/boottime.c
+dmesg_SOURCES = sys-utils/dmesg.c lib/monotonic.c
 dmesg_LDADD = $(LDADD) libcommon.la $(CLOCKGETTIME_LIBS)
 endif
 
@@ -90,7 +90,7 @@ endif
 if BUILD_BLKDISCARD
 sbin_PROGRAMS += blkdiscard
 dist_man_MANS += sys-utils/blkdiscard.8
-blkdiscard_SOURCES = sys-utils/blkdiscard.c
+blkdiscard_SOURCES = sys-utils/blkdiscard.c lib/monotonic.c
 blkdiscard_LDADD = $(LDADD) libcommon.la $(CLOCKGETTIME_LIBS)
 endif
 
@@ -166,7 +166,7 @@ endif # BUILD_SETARCH
 
 if BUILD_EJECT
 usrbin_exec_PROGRAMS += eject
-eject_SOURCES =  sys-utils/eject.c
+eject_SOURCES =  sys-utils/eject.c lib/monotonic.c
 eject_LDADD = $(LDADD) libmount.la libcommon.la $(CLOCKGETTIME_LIBS)
 eject_CFLAGS = $(AM_CFLAGS) -I$(ul_libmount_incdir)
 dist_man_MANS += sys-utils/eject.1
index 1a1ace4ab40b17e4f3cb723e77a278cef6c52f83..c6152d49ad90127e1ab2963497c666dd80ead1e1 100644 (file)
@@ -33,7 +33,7 @@
 #include "closestream.h"
 #include "optutils.h"
 #include "timeutils.h"
-#include "boottime.h"
+#include "monotonic.h"
 #include "mangle.h"
 #include "pager.h"
 
index 5a181644d2cefee12234baf8dee77d48cb5d37ec..0dfd30166673de1b7dead58e03e9dfb263dfda42 100644 (file)
@@ -52,7 +52,7 @@
 #include "xalloc.h"
 #include "pathnames.h"
 #include "sysfs.h"
-#include "timeutils.h"
+#include "monotonic.h"
 
 /*
  * sg_io_hdr_t driver_status -- see kernel include/scsi/scsi.h