summaryrefslogtreecommitdiffstats
path: root/OpenAL32/Include/alMain.h
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2008-01-11 06:01:51 -0800
committerChris Robinson <[email protected]>2008-01-11 06:01:51 -0800
commita97ecb8690c64a6007ad3f0e983cb8ef67b47795 (patch)
treedfc3b7c59098ac593c782b7ebe5a01610c43be8c /OpenAL32/Include/alMain.h
parentbc56c00a9a99ccbf2523ecb5f25a0e14922aed56 (diff)
Add a timing wrapper, using gettimeofday
Diffstat (limited to 'OpenAL32/Include/alMain.h')
-rw-r--r--OpenAL32/Include/alMain.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index d8611a71..adf3f2c3 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -13,6 +13,7 @@
#include <assert.h>
#include <pthread.h>
+#include <sys/time.h>
#define IsBadWritePtr(a,b) (0)
@@ -52,6 +53,21 @@ static inline void DeleteCriticalSection(CRITICAL_SECTION *cs)
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 max(x,y) (((x)>(y))?(x):(y))
#endif