mirror of
https://github.com/wolfcw/libfaketime.git
synced 2026-05-17 08:36:28 +03:00
Started to integrate mpareja's CLOCK_BOOTTIME patch
This commit is contained in:
@@ -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 */
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user