aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/sys
diff options
context:
space:
mode:
authorPatrik Nyblom <[email protected]>2013-03-05 11:48:47 +0100
committerPatrik Nyblom <[email protected]>2013-03-05 11:48:47 +0100
commit03d418dcd339c8878186fcc8e165b62289d3d17c (patch)
treebc0c351cf357ab42dc3a74ada93e5d15e2774ed8 /erts/emulator/sys
parent05f11890bdfec4bfc3a78e191a87e70a937ffc54 (diff)
downloadotp-03d418dcd339c8878186fcc8e165b62289d3d17c.tar.gz
otp-03d418dcd339c8878186fcc8e165b62289d3d17c.tar.bz2
otp-03d418dcd339c8878186fcc8e165b62289d3d17c.zip
Tmp
Diffstat (limited to 'erts/emulator/sys')
-rw-r--r--erts/emulator/sys/win32/sys_time.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/erts/emulator/sys/win32/sys_time.c b/erts/emulator/sys/win32/sys_time.c
index 2f2dfc8197..8775b6a24d 100644
--- a/erts/emulator/sys/win32/sys_time.c
+++ b/erts/emulator/sys/win32/sys_time.c
@@ -63,6 +63,7 @@
static SysHrTime wrap = 0;
static DWORD last_tick_count = 0;
+static erts_smp_spinlock_t wrap_lock;
/* Getting timezone information is a heavy operation, so we want to do this
only once */
@@ -82,6 +83,7 @@ sys_init_time(void)
static_tzi.DaylightDate.wMonth != 0) {
have_static_tzi = 1;
}
+ erts_smp_spinlock_init(&wrap_lock, "sys_gethrtime");
return 1;
}
@@ -367,11 +369,15 @@ SysHrTime
sys_gethrtime(void)
{
DWORD ticks = (SysHrTime) (GetTickCount() & 0x7FFFFFFF);
+ SysHrTime res;
+ erts_smp_spin_lock(&wrap_lock);
if (ticks < (SysHrTime) last_tick_count) {
wrap += LL_LITERAL(1) << 31;
}
last_tick_count = ticks;
- return ((((LONGLONG) ticks) + wrap) * LL_LITERAL(1000000));
+ res = ((((LONGLONG) ticks) + wrap) * LL_LITERAL(1000000));
+ erts_smp_spin_unlock(&wrap_lock);
+ return res
}
clock_t