1
0
Fork 0

Olaf Flebbe: #332, Improve Nasal's "systime" method

Use gettimeofday for determine time, rather than time() and gettimeofday()
This commit is contained in:
ThorstenB 2011-06-02 23:53:42 +02:00
parent 5572c53a7e
commit 370645e593

View file

@ -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 // Converts from 100ns units in 1601 epoch to unix epoch in sec
return naNum((t * 1e-7) - 11644473600.0); return naNum((t * 1e-7) - 11644473600.0);
#else #else
time_t t;
struct timeval td; struct timeval td;
do { t = time(0); gettimeofday(&td, 0); } while(t != time(0)); gettimeofday(&td, 0);
return naNum(t + 1e-6 * td.tv_usec); return naNum(td.tv_sec + 1e-6 * td.tv_usec);
#endif #endif
} }