summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/Makemodule.am2
-rw-r--r--include/monotonic.h (renamed from include/boottime.h)2
-rw-r--r--include/timeutils.h2
-rw-r--r--lib/monotonic.c (renamed from lib/boottime.c)29
-rw-r--r--lib/timeutils.c23
-rw-r--r--libmount/src/Makemodule.am1
-rw-r--r--libmount/src/lock.c2
-rw-r--r--login-utils/Makemodule.am2
-rw-r--r--login-utils/last.c2
-rw-r--r--sys-utils/Makemodule.am6
-rw-r--r--sys-utils/dmesg.c2
-rw-r--r--sys-utils/eject.c2
12 files changed, 39 insertions, 36 deletions
diff --git a/include/Makemodule.am b/include/Makemodule.am
index d162d24b4..c4a52e4cf 100644
--- a/include/Makemodule.am
+++ b/include/Makemodule.am
@@ -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 \
diff --git a/include/boottime.h b/include/monotonic.h
index f1d0d0b27..f3b03d3d0 100644
--- a/include/boottime.h
+++ b/include/monotonic.h
@@ -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 */
diff --git a/include/timeutils.h b/include/timeutils.h
index 97f054489..8ed501b9d 100644
--- a/include/timeutils.h
+++ b/include/timeutils.h
@@ -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 */
diff --git a/lib/boottime.c b/lib/monotonic.c
index f9366bd33..3d4a4438e 100644
--- a/lib/boottime.c
+++ b/lib/monotonic.c
@@ -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
+}
diff --git a/lib/timeutils.c b/lib/timeutils.c
index bd3d40248..b811041e4 100644
--- a/lib/timeutils.c
+++ b/lib/timeutils.c
@@ -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
-}
diff --git a/libmount/src/Makemodule.am b/libmount/src/Makemodule.am
index 9b0eadefb..cc4ab22f4 100644
--- a/libmount/src/Makemodule.am
+++ b/libmount/src/Makemodule.am
@@ -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 \
diff --git a/libmount/src/lock.c b/libmount/src/lock.c
index 0a07e9b03..a940a0e69 100644
--- a/libmount/src/lock.c
+++ b/libmount/src/lock.c
@@ -25,7 +25,7 @@
#include "closestream.h"
#include "pathnames.h"
#include "mountP.h"
-#include "timeutils.h"
+#include "monotonic.h"
/*
* lock handler
diff --git a/login-utils/Makemodule.am b/login-utils/Makemodule.am
index 73fc761d5..34c5fb424 100644
--- a/login-utils/Makemodule.am
+++ b/login-utils/Makemodule.am
@@ -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:
diff --git a/login-utils/last.c b/login-utils/last.c
index 54d9e1f8e..bf2c2da32 100644
--- a/login-utils/last.c
+++ b/login-utils/last.c
@@ -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
diff --git a/sys-utils/Makemodule.am b/sys-utils/Makemodule.am
index 50d3eb3a4..25e1ad7bf 100644
--- a/sys-utils/Makemodule.am
+++ b/sys-utils/Makemodule.am
@@ -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
diff --git a/sys-utils/dmesg.c b/sys-utils/dmesg.c
index 1a1ace4ab..c6152d49a 100644
--- a/sys-utils/dmesg.c
+++ b/sys-utils/dmesg.c
@@ -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"
diff --git a/sys-utils/eject.c b/sys-utils/eject.c
index 5a181644d..0dfd30166 100644
--- a/sys-utils/eject.c
+++ b/sys-utils/eject.c
@@ -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