Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/3841

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/41/3841/1

Use clock_gettime instead of gettimeofday to have more precise time

Change-Id: I8e568368e7626789dee21d4823dbedec6257a231
---
M sal/osl/unx/time.c
1 file changed, 11 insertions(+), 5 deletions(-)



diff --git a/sal/osl/unx/time.c b/sal/osl/unx/time.c
index e613248..e499d85 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,20 @@
 
 sal_Bool SAL_CALL osl_getSystemTime(TimeValue* tv)
 {
-    struct timeval tp;
+    struct timespec tp;
+    int res;
 
-    /* FIXME: use higher resolution */
-    gettimeofday(&tp, NULL);
+    res = clock_gettime(CLOCK_REALTIME, &tp);
+
+    if (res != 0)
+    {
+        return sal_False;
+    }
 
     tv->Seconds = tp.tv_sec;
-    tv->Nanosec = tp.tv_usec * 1000;
+    tv->Nanosec = tp.tv_nsec;
 
-    return (sal_True);
+    return sal_True;
 }
 
 

-- 
To view, visit https://gerrit.libreoffice.org/3841
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8e568368e7626789dee21d4823dbedec6257a231
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Arnaud Versini <arnaud.versini@gmail.com>


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.