diff --git a/sim_timer.c b/sim_timer.c index 5b05d00e..2a364cdf 100644 --- a/sim_timer.c +++ b/sim_timer.c @@ -175,7 +175,7 @@ return sim_os_msec () - stime; } #if defined(SIM_ASYNCH_IO) -#ifdef NEED_CLOCK_REALTIME +#ifdef NEED_CLOCK_GETTIME int clock_gettime(int clk_id, struct timespec *tp) { uint32 secs, ns, tod[2], unixbase[2] = {0xd53e8000, 0x019db1de}; @@ -247,7 +247,7 @@ Sleep (msec); return sim_os_msec () - stime; } -#if defined(NEED_CLOCK_REALTIME) +#if defined(NEED_CLOCK_GETTIME) int clock_gettime(int clk_id, struct timespec *tp) { t_uint64 now, unixbase; @@ -338,7 +338,7 @@ treq.tv_nsec = (milliseconds % MILLIS_PER_SEC) * NANOS_PER_MILLI; return sim_os_msec () - stime; } -#if defined(NEED_CLOCK_REALTIME) +#if defined(NEED_CLOCK_GETTIME) int clock_gettime(int clk_id, struct timespec *tp) { struct timeval cur; @@ -399,7 +399,7 @@ if (tim > SIM_IDLE_MAX) return tim; } #if !defined(_POSIX_SOURCE) && defined(SIM_ASYNCH_IO) -#ifdef NEED_CLOCK_REALTIME +#ifdef NEED_CLOCK_GETTIME typedef int clockid_t; int clock_gettime(clockid_t clk_id, struct timespec *tp) { diff --git a/sim_timer.h b/sim_timer.h index 1bf8aa42..ace58461 100644 --- a/sim_timer.h +++ b/sim_timer.h @@ -35,7 +35,14 @@ #ifndef CLOCK_REALTIME #define CLOCK_REALTIME 1 -#define NEED_CLOCK_REALTIME 1 +#define NEED_CLOCK_GETTIME 1 +#ifndef HAVE_STRUCT_TIMESPEC +#define HAVE_STRUCT_TIMESPEC 1 +struct timespec { + long tv_sec; + long tv_nsec; +}; +#endif /* HAVE_STRUCT_TIMESPEC */ int clock_gettime(int clock_id, struct timespec *tp); #endif