Use a realtime clock for measuring time
This commit is contained in:
parent
fb258a7416
commit
dcd6a55529
@ -234,6 +234,11 @@ IF(NOT HAVE_WINDOWS_H)
|
||||
IF(HAVE_LIBPTHREAD)
|
||||
SET(EXTRA_LIBS pthread ${EXTRA_LIBS})
|
||||
ENDIF()
|
||||
|
||||
CHECK_LIBRARY_EXISTS(rt clock_gettime "" HAVE_LIBRT)
|
||||
IF(HAVE_LIBRT)
|
||||
SET(EXTRA_LIBS rt ${EXTRA_LIBS})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
# Check for a 64-bit type
|
||||
|
@ -28,6 +28,7 @@ typedef DWORD tls_type;
|
||||
|
||||
#else
|
||||
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
#include <pthread.h>
|
||||
#ifdef HAVE_PTHREAD_NP_H
|
||||
@ -91,13 +92,22 @@ static inline void DeleteCriticalSection(CRITICAL_SECTION *cs)
|
||||
* as opposed to the actual time. */
|
||||
static inline ALuint timeGetTime(void)
|
||||
{
|
||||
struct timeval tv;
|
||||
int ret;
|
||||
#ifdef _POSIX_TIMERS
|
||||
struct timespec ts;
|
||||
|
||||
ret = clock_gettime(CLOCK_REALTIME, &ts);
|
||||
assert(ret == 0);
|
||||
|
||||
return ts.tv_nsec/1000000 + ts.tv_sec*1000;
|
||||
#else
|
||||
struct timeval tv;
|
||||
|
||||
ret = gettimeofday(&tv, NULL);
|
||||
assert(ret == 0);
|
||||
|
||||
return tv.tv_usec/1000 + tv.tv_sec*1000;
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void Sleep(ALuint t)
|
||||
|
Loading…
x
Reference in New Issue
Block a user