Add a timing wrapper, using gettimeofday
This commit is contained in:
parent
bc56c00a9a
commit
a97ecb8690
@ -132,6 +132,11 @@ ENDIF()
|
|||||||
# Check if we have Windows headers
|
# Check if we have Windows headers
|
||||||
CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H)
|
CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H)
|
||||||
IF(NOT "${HAVE_WINDOWS_H}")
|
IF(NOT "${HAVE_WINDOWS_H}")
|
||||||
|
CHECK_FUNCTION_EXISTS(gettimeofday HAVE_GETTIMEOFDAY)
|
||||||
|
IF(NOT "${HAVE_GETTIMEOFDAY}")
|
||||||
|
MESSAGE(FATAL_ERROR "No timing function found!")
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
# We need pthreads outside of Windows
|
# We need pthreads outside of Windows
|
||||||
CHECK_INCLUDE_FILE(pthread.h HAVE_PTHREAD_H)
|
CHECK_INCLUDE_FILE(pthread.h HAVE_PTHREAD_H)
|
||||||
IF(NOT "${HAVE_PTHREAD_H}")
|
IF(NOT "${HAVE_PTHREAD_H}")
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
#define IsBadWritePtr(a,b) (0)
|
#define IsBadWritePtr(a,b) (0)
|
||||||
|
|
||||||
@ -52,6 +53,21 @@ static inline void DeleteCriticalSection(CRITICAL_SECTION *cs)
|
|||||||
assert(ret == 0);
|
assert(ret == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* NOTE: This wrapper isn't quite accurate as it returns an ALuint, as opposed
|
||||||
|
* to the expected DWORD. Both are defined as unsigned 32-bit types, however.
|
||||||
|
* Additionally, Win32 is supposed to measure the time since Windows started,
|
||||||
|
* as opposed to the actual time. */
|
||||||
|
static inline ALuint timeGetTime(void)
|
||||||
|
{
|
||||||
|
struct timeval tv;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = gettimeofday(&tv, NULL);
|
||||||
|
assert(ret == 0);
|
||||||
|
|
||||||
|
return tv.tv_usec/1000 + tv.tv_sec*1000;
|
||||||
|
}
|
||||||
|
|
||||||
#define min(x,y) (((x)<(y))?(x):(y))
|
#define min(x,y) (((x)<(y))?(x):(y))
|
||||||
#define max(x,y) (((x)>(y))?(x):(y))
|
#define max(x,y) (((x)>(y))?(x):(y))
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user