sal/osl/unx/time.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-)
New commits: commit c85493b6a8033f5bab937e970f824d3a4bcbc790 Author: Arnaud Versini <[email protected]> Date: Thu May 9 14:45:18 2013 +0200 Use clock_gettime instead of gettimeofday to have more precise time Change-Id: I8e568368e7626789dee21d4823dbedec6257a231 Reviewed-on: https://gerrit.libreoffice.org/3841 Reviewed-by: Norbert Thiebaud <[email protected]> Tested-by: Norbert Thiebaud <[email protected]> diff --git a/sal/osl/unx/time.c b/sal/osl/unx/time.c index e613248..c99036b 100644 --- a/sal/osl/unx/time.c +++ b/sal/osl/unx/time.c @@ -22,6 +22,7 @@ #include <osl/diagnose.h> #include <osl/time.h> +#include <time.h> /* FIXME: detection should be done in configure script */ #if defined(MACOSX) || defined(FREEBSD) || defined(NETBSD) || \ @@ -38,15 +39,30 @@ 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; - /* FIXME: use higher resolution */ - gettimeofday(&tp, NULL); + res = gettimeofday(&tp, NULL); +#endif + + if (res != 0) + { + return sal_False; + } tv->Seconds = tp.tv_sec; + #if defined(LINUX) + tv->Nanosec = tp.tv_nsec; + #else tv->Nanosec = tp.tv_usec * 1000; + #endif - return (sal_True); + return sal_True; } _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
