summaryrefslogtreecommitdiffstats
path: root/osdep/timer.c
diff options
context:
space:
mode:
Diffstat (limited to 'osdep/timer.c')
-rw-r--r--osdep/timer.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/osdep/timer.c b/osdep/timer.c
index d8dd49b9f7..f2c64959ab 100644
--- a/osdep/timer.c
+++ b/osdep/timer.c
@@ -16,12 +16,14 @@
*/
#include <stdlib.h>
+#include <pthread.h>
#include "timer.h"
static uint64_t raw_time_offset;
+pthread_once_t timer_init_once = PTHREAD_ONCE_INIT;
-void mp_time_init(void)
+static void do_timer_init(void)
{
mp_raw_time_init();
srand(mp_raw_time_us());
@@ -32,6 +34,11 @@ void mp_time_init(void)
raw_time_offset -= 10000000;
}
+void mp_time_init(void)
+{
+ pthread_once(&timer_init_once, do_timer_init);
+}
+
int64_t mp_time_us(void)
{
return mp_raw_time_us() - raw_time_offset;