build-sys: move all around clock_gettime() to monotonic.c

Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2014-11-19 11:54:47 +01:00
parent a4830f617e
commit cd2876d252
12 changed files with 39 additions and 36 deletions

View 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 \

View 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 */

View 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 */

View 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
}

View 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
}

View 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 \

View File

@ -25,7 +25,7 @@
#include "closestream.h"
#include "pathnames.h"
#include "mountP.h"
#include "timeutils.h"
#include "monotonic.h"
/*
* lock handler

View 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:

View 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

View 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

View 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"

View 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