Hi,
I have submitted a patch for review:
https://gerrit.libreoffice.org/3964
To pull it, you can do:
git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/64/3964/1
Use clock_gettime when available on *nix
Change-Id: I65df2b119dbda274749ab2b4d0825fbdf44eb4e8
---
M sal/osl/unx/time.c
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/sal/osl/unx/time.c b/sal/osl/unx/time.c
index 4294cd2..796e882 100644
--- a/sal/osl/unx/time.c
+++ b/sal/osl/unx/time.c
@@ -24,6 +24,7 @@
#include <osl/time.h>
#include <time.h>
#include <assert.h>
+#include <unistd>
/* FIXME: detection should be done in configure script */
#if defined(MACOSX) || defined(FREEBSD) || defined(NETBSD) || \
@@ -34,7 +35,11 @@
#define HAS_ALTZONE 1
#endif
-#if defined(LINUX)
+#if defined(_POSIX_TIMERS) && (_POSIX_TIMERS > 0)
+#define USE_CLOCK_GETTIME 1
+#endif
+
+#if USE_CLOCK_GETTIME
typedef struct timespec osl_time_t;
#else
typedef struct timeval osl_time_t;
@@ -48,7 +53,7 @@
{
int res;
osl_time_t tp;
-#if defined(LINUX)
+#if defined(USE_CLOCK_GETTIME)
res = clock_gettime(CLOCK_REALTIME, &tp);
#else
res = gettimeofday(&tp, NULL);
@@ -60,7 +65,7 @@
}
tv->Seconds = tp.tv_sec;
- #if defined(LINUX)
+ #if defined(USE_CLOCK_GETTIME)
tv->Nanosec = tp.tv_nsec;
#else
tv->Nanosec = tp.tv_usec * 1000;
@@ -262,7 +267,7 @@
void sal_initGlobalTimer()
{
int res;
- #if defined(LINUX)
+ #if defined(USE_CLOCK_GETTIME)
res = clock_gettime(CLOCK_REALTIME, &startTime);
#else
res = gettimeofday( &startTime, NULL );
@@ -277,7 +282,7 @@
int res;
sal_uInt32 nSeconds;
- #if defined(LINUX)
+ #if defined(USE_CLOCK_GETTIME)
res = clock_gettime(CLOCK_REALTIME, &startTime);
#else
res = gettimeofday( &startTime, NULL );
@@ -289,7 +294,7 @@
return 0;
nSeconds = (sal_uInt32)( currentTime.tv_sec - startTime.tv_sec );
- #if defined(LINUX)
+ #if defined(USE_CLOCK_GETTIME)
nSeconds = ( nSeconds * 1000 ) + (long) (( currentTime.tv_nsec - startTime.tv_nsec) / 1000000 );
#else
nSeconds = ( nSeconds * 1000 ) + (long) (( currentTime.tv_usec - startTime.tv_usec) / 1000 );
--
To view, visit https://gerrit.libreoffice.org/3964
To unsubscribe, visit https://gerrit.libreoffice.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I65df2b119dbda274749ab2b4d0825fbdf44eb4e8
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Arnaud Versini <arnaud.versini@gmail.com>
Context
- [PATCH] Use clock_gettime when available on *nix · Arnaud Versini (via Code Review)
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.