summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWolfgang Hommel <wolfgang.hommel@unibw.de>2017-05-19 19:14:58 +0200
committerWolfgang Hommel <wolfgang.hommel@unibw.de>2017-05-19 19:14:58 +0200
commitfa91edb0a322c65f985eebe515ec4a7f3f08b5cb (patch)
treef053aa54e658e6267a769fcd331807ef04efed87
parent725c80673c4cceb082c01d8c3a05812d6f4fb951 (diff)
downloadlibfaketime-fa91edb0a322c65f985eebe515ec4a7f3f08b5cb.tar.gz
Started to integrate mpareja's CLOCK_BOOTTIME patch
-rw-r--r--src/faketime_common.h4
-rw-r--r--src/libfaketime.c21
2 files changed, 24 insertions, 1 deletions
diff --git a/src/faketime_common.h b/src/faketime_common.h
index 411ac99..9fda6a7 100644
--- a/src/faketime_common.h
+++ b/src/faketime_common.h
@@ -32,6 +32,10 @@ struct system_time_s
struct timespec mon;
/* System time according to CLOCK_MONOTONIC_RAW */
struct timespec mon_raw;
+#ifdef CLOCK_BOOTTIME
+ /* System time according to CLOCK_BOOTTIME */
+ struct timespec boot;
+#endif
};
/* Data shared among faketime-spawned processes */
diff --git a/src/libfaketime.c b/src/libfaketime.c
index 89a7de1..c586da1 100644
--- a/src/libfaketime.c
+++ b/src/libfaketime.c
@@ -228,7 +228,11 @@ static int cache_duration = 10; /* cache fake time input for 10 seconds */
* Static timespec to store our startup time, followed by a load-time library
* initialization declaration.
*/
+#ifndef CLOCK_BOOTTIME
static struct system_time_s ftpl_starttime = {{0, -1}, {0, -1}, {0, -1}};
+#else
+static struct system_time_s ftpl_starttime = {{0, -1}, {0, -1}, {0, -1}, {0, -1}};
+#endif
static char user_faked_time_fmt[BUFSIZ] = {0};
@@ -342,7 +346,12 @@ static void system_time_from_system (struct system_time_s * systime)
;
DONT_FAKE_TIME((*real_clock_gettime)(CLOCK_MONOTONIC, &systime->mon))
;
- DONT_FAKE_TIME((*real_clock_gettime)(CLOCK_MONOTONIC_RAW, &systime->mon_raw));
+ DONT_FAKE_TIME((*real_clock_gettime)(CLOCK_MONOTONIC_RAW, &systime->mon_raw))
+ ;
+#ifdef CLOCK_BOOTTIME
+ DONT_FAKE_TIME((*real_clock_gettime)(CLOCK_BOOTTIME, &systime->boot))
+ ;
+#endif
#endif
}
@@ -2001,6 +2010,11 @@ int fake_clock_gettime(clockid_t clk_id, struct timespec *tp)
case CLOCK_MONOTONIC_RAW:
timespecsub(tp, &ftpl_starttime.mon_raw, &tmp_ts);
break;
+#ifdef CLOCK_BOOTTIME
+ case CLOCK_BOOTTIME:
+ timespecsub(tp, &ftpl_starttime.boot, &tmp_ts);
+ break;
+#endif
default:
printf("Invalid clock_id for clock_gettime: %d", clk_id);
exit(EXIT_FAILURE);
@@ -2147,6 +2161,11 @@ int fake_clock_gettime(clockid_t clk_id, struct timespec *tp)
case CLOCK_MONOTONIC_RAW:
timespecsub(tp, &ftpl_starttime.mon_raw, &tdiff);
break;
+#ifdef CLOCK_BOOTTIME
+ case CLOCK_BOOTTIME:
+ timespecsub(tp, &ftpl_starttime.boot, &tdiff);
+ break;
+#endif
default:
printf("Invalid clock_id for clock_gettime: %d", clk_id);
exit(EXIT_FAILURE);