Started to integrate mpareja's CLOCK_BOOTTIME patch

This commit is contained in:
Wolfgang Hommel
2017-05-19 19:14:58 +02:00
parent 725c80673c
commit fa91edb0a3
2 changed files with 24 additions and 1 deletions

View File

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

View File

@@ -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);