forked from 0ad/0ad
janwas
c9f10be090
wtime: "implement" CLOCK_MONOTONIC (that's what the timer already did, anyhow) main: move early init to GameSetup!EarlyInit (fixes atlas problem with timer) This was SVN commit r5101.
73 lines
1.5 KiB
C
73 lines
1.5 KiB
C
/**
|
|
* =========================================================================
|
|
* File : wtime.h
|
|
* Project : 0 A.D.
|
|
* Description : emulate POSIX high resolution timer on Windows.
|
|
* =========================================================================
|
|
*/
|
|
|
|
// license: GPL; see lib/license.txt
|
|
|
|
#ifndef INCLUDED_WTIME
|
|
#define INCLUDED_WTIME
|
|
|
|
// advertise support for the timer routines we emulate; used by timer.cpp.
|
|
// #undef to avoid macro redefinition warning.
|
|
#undef HAVE_CLOCK_GETTIME
|
|
#define HAVE_CLOCK_GETTIME 1
|
|
#undef HAVE_GETTIMEOFDAY
|
|
#define HAVE_GETTIMEOFDAY 1
|
|
|
|
|
|
//
|
|
// <sys/types.h>
|
|
//
|
|
|
|
typedef unsigned long useconds_t;
|
|
typedef long suseconds_t;
|
|
|
|
|
|
//
|
|
// <unistd.h>
|
|
//
|
|
|
|
extern unsigned int sleep(unsigned int sec);
|
|
extern int usleep(useconds_t us);
|
|
|
|
|
|
//
|
|
// <time.h>
|
|
//
|
|
|
|
typedef enum
|
|
{
|
|
// in our implementation, these actually do the same thing
|
|
// (a timer that latches the system time at startup and uses the
|
|
// monotonic HRT to add elapsed time since then)
|
|
CLOCK_REALTIME,
|
|
CLOCK_MONOTONIC
|
|
}
|
|
clockid_t;
|
|
|
|
// BSD gettimeofday
|
|
struct timeval
|
|
{
|
|
time_t tv_sec;
|
|
suseconds_t tv_usec;
|
|
};
|
|
|
|
// POSIX realtime clock_*
|
|
struct timespec
|
|
{
|
|
time_t tv_sec;
|
|
long tv_nsec;
|
|
};
|
|
|
|
extern int gettimeofday(struct timeval* tv, void* tzp);
|
|
|
|
extern int nanosleep(const struct timespec* rqtp, struct timespec* rmtp);
|
|
extern int clock_gettime(clockid_t clock, struct timespec* ts);
|
|
extern int clock_getres(clockid_t clock, struct timespec* res);
|
|
|
|
#endif // #ifndef INCLUDED_WTIME
|