#include <sys/time.h>
+#include "timeutils.h"
+
extern int get_boot_time(struct timeval *boot_time);
-extern time_t get_suspended_time(void);
+extern usec_t get_suspended_time(void);
extern int gettime_monotonic(struct timeval *tv);
#endif
}
-time_t get_suspended_time(void)
+usec_t get_suspended_time(void)
{
#if defined(CLOCK_BOOTTIME) && defined(CLOCK_MONOTONIC)
struct timespec boot, mono;
if (clock_gettime(CLOCK_BOOTTIME, &boot) == 0 &&
clock_gettime(CLOCK_MONOTONIC, &mono) == 0)
- return boot.tv_sec - mono.tv_sec;
+ return timespec_to_usec(&boot) - timespec_to_usec(&mono);
#endif
return 0;
}
struct timeval lasttime; /* last printed timestamp */
struct tm lasttm; /* last localtime */
struct timeval boot_time; /* system boot time */
- time_t suspended_time; /* time spent in suspended state */
+ usec_t suspended_time; /* time spent in suspended state */
int action; /* SYSLOG_ACTION_* */
int method; /* DMESG_METHOD_* */
static time_t record_time(struct dmesg_control *ctl, struct dmesg_record *rec)
{
- return ctl->boot_time.tv_sec + ctl->suspended_time + rec->tv.tv_sec;
+ return ctl->boot_time.tv_sec + ctl->suspended_time / USEC_PER_SEC + rec->tv.tv_sec;
}
static int accept_record(struct dmesg_control *ctl, struct dmesg_record *rec)
char *buf, size_t bufsz)
{
struct timeval tv = {
- .tv_sec = ctl->boot_time.tv_sec + ctl->suspended_time + rec->tv.tv_sec,
+ .tv_sec = ctl->boot_time.tv_sec + ctl->suspended_time / USEC_PER_SEC + rec->tv.tv_sec,
.tv_usec = rec->tv.tv_usec
};
return get_boot_time(tv);
}
-static inline time_t dmesg_get_suspended_time(void)
+static inline usec_t dmesg_get_suspended_time(void)
{
if (getenv("DMESG_TEST_BOOTIME"))
return 0;