Kaydet (Commit) c85493b6 authored tarafından Arnaud Versini's avatar Arnaud Versini Kaydeden (comit) Norbert Thiebaud

Use clock_gettime instead of gettimeofday to have more precise time

Change-Id: I8e568368e7626789dee21d4823dbedec6257a231
Reviewed-on: https://gerrit.libreoffice.org/3841Reviewed-by: 's avatarNorbert Thiebaud <nthiebaud@gmail.com>
Tested-by: 's avatarNorbert Thiebaud <nthiebaud@gmail.com>
üst e84209af
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <osl/diagnose.h> #include <osl/diagnose.h>
#include <osl/time.h> #include <osl/time.h>
#include <time.h>
/* FIXME: detection should be done in configure script */ /* FIXME: detection should be done in configure script */
#if defined(MACOSX) || defined(FREEBSD) || defined(NETBSD) || \ #if defined(MACOSX) || defined(FREEBSD) || defined(NETBSD) || \
...@@ -38,15 +39,30 @@ ...@@ -38,15 +39,30 @@
sal_Bool SAL_CALL osl_getSystemTime(TimeValue* tv) sal_Bool SAL_CALL osl_getSystemTime(TimeValue* tv)
{ {
int res;
#if defined(LINUX)
struct timespec tp;
res = clock_gettime(CLOCK_REALTIME, &tp);
#else
struct timeval tp; struct timeval tp;
/* FIXME: use higher resolution */ res = gettimeofday(&tp, NULL);
gettimeofday(&tp, NULL); #endif
if (res != 0)
{
return sal_False;
}
tv->Seconds = tp.tv_sec; tv->Seconds = tp.tv_sec;
#if defined(LINUX)
tv->Nanosec = tp.tv_nsec;
#else
tv->Nanosec = tp.tv_usec * 1000; tv->Nanosec = tp.tv_usec * 1000;
#endif
return (sal_True); return sal_True;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment