From 370645e5937d2cf7a51d9a56dc7dfb110b385f24 Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Thu, 2 Jun 2011 23:53:42 +0200 Subject: [PATCH] Olaf Flebbe: #332, Improve Nasal's "systime" method Use gettimeofday for determine time, rather than time() and gettimeofday() --- src/Scripting/NasalSys.cxx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Scripting/NasalSys.cxx b/src/Scripting/NasalSys.cxx index 2690bda6d..af67ae368 100644 --- a/src/Scripting/NasalSys.cxx +++ b/src/Scripting/NasalSys.cxx @@ -476,10 +476,9 @@ static naRef f_systime(naContext c, naRef me, int argc, naRef* args) // Converts from 100ns units in 1601 epoch to unix epoch in sec return naNum((t * 1e-7) - 11644473600.0); #else - time_t t; struct timeval td; - do { t = time(0); gettimeofday(&td, 0); } while(t != time(0)); - return naNum(t + 1e-6 * td.tv_usec); + gettimeofday(&td, 0); + return naNum(td.tv_sec + 1e-6 * td.tv_usec); #endif }