Skip to content

Commit

Permalink
Merge pull request wolfcw#84 from vavrusa/master
Browse files Browse the repository at this point in the history
Fixed coarse clock on platforms that don't support them
  • Loading branch information
wolfcw committed Jan 29, 2016
2 parents 74425d7 + 811b791 commit 904cc50
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/libfaketime.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,6 @@ typedef int clockid_t;
#endif
#endif

#ifndef CLOCK_REALTIME_COARSE
#define CLOCK_REALTIME_COARSE CLOCK_REALTIME
#endif
#ifndef CLOCK_MONOTONIC_COARSE
#define CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC
#endif

/* some systems lack raw clock */
#ifndef CLOCK_MONOTONIC_RAW
#define CLOCK_MONOTONIC_RAW (CLOCK_MONOTONIC + 1)
Expand Down Expand Up @@ -1920,11 +1913,15 @@ int fake_clock_gettime(clockid_t clk_id, struct timespec *tp)
switch (clk_id)
{
case CLOCK_REALTIME:
#ifdef CLOCK_REALTIME_COARSE
case CLOCK_REALTIME_COARSE:
#endif
timespecsub(tp, &ftpl_starttime.real, &tmp_ts);
break;
case CLOCK_MONOTONIC:
#ifdef CLOCK_MONOTONIC_COARSE
case CLOCK_MONOTONIC_COARSE:
#endif
timespecsub(tp, &ftpl_starttime.mon, &tmp_ts);
break;
case CLOCK_MONOTONIC_RAW:
Expand Down Expand Up @@ -2062,11 +2059,15 @@ int fake_clock_gettime(clockid_t clk_id, struct timespec *tp)
switch (clk_id)
{
case CLOCK_REALTIME:
#ifdef CLOCK_REALTIME_COARSE
case CLOCK_REALTIME_COARSE:
#endif
timespecsub(tp, &ftpl_starttime.real, &tdiff);
break;
case CLOCK_MONOTONIC:
#ifdef CLOCK_MONOTONIC_COARSE
case CLOCK_MONOTONIC_COARSE:
#endif
timespecsub(tp, &ftpl_starttime.mon, &tdiff);
break;
case CLOCK_MONOTONIC_RAW:
Expand Down

0 comments on commit 904cc50

Please sign in to comment.