[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnurl] 32/116: timeval: use mach time on MacOS
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnurl] 32/116: timeval: use mach time on MacOS |
Date: |
Tue, 05 Dec 2017 14:51:02 +0100 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to branch master
in repository gnurl.
commit d531f33ba2210ef11d0849bc73654e03affd0cfa
Author: Dmitri Tikhonov <address@hidden>
AuthorDate: Mon Oct 30 08:12:41 2017 -0400
timeval: use mach time on MacOS
If clock_gettime() is not supported, use mach_absolute_time() on MacOS.
closes #2033
---
CMakeLists.txt | 1 +
configure.ac | 1 +
lib/curl_config.h.cmake | 3 +++
lib/timeval.c | 31 +++++++++++++++++++++++++++++++
4 files changed, 36 insertions(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c41759aa1..3aaeb346e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -878,6 +878,7 @@ check_symbol_exists(setrlimit "${CURL_INCLUDES}"
HAVE_SETRLIMIT)
check_symbol_exists(fcntl "${CURL_INCLUDES}" HAVE_FCNTL)
check_symbol_exists(ioctl "${CURL_INCLUDES}" HAVE_IOCTL)
check_symbol_exists(setsockopt "${CURL_INCLUDES}" HAVE_SETSOCKOPT)
+check_function_exists(mach_absolute_time HAVE_MACH_ABSOLUTE_TIME)
# symbol exists in win32, but function does not.
if(WIN32)
diff --git a/configure.ac b/configure.ac
index 68b3a071a..5272feaa0 100755
--- a/configure.ac
+++ b/configure.ac
@@ -3385,6 +3385,7 @@ AC_CHECK_FUNCS([geteuid \
getrlimit \
gettimeofday \
if_nametoindex \
+ mach_absolute_time \
pipe \
setlocale \
setmode \
diff --git a/lib/curl_config.h.cmake b/lib/curl_config.h.cmake
index c80484f65..e4d14c784 100644
--- a/lib/curl_config.h.cmake
+++ b/lib/curl_config.h.cmake
@@ -1000,3 +1000,6 @@
/* the signed version of size_t */
#cmakedefine ssize_t ${ssize_t}
+
+/* Define to 1 if you have the mach_absolute_time function. */
+#cmakedefine HAVE_MACH_ABSOLUTE_TIME 1
diff --git a/lib/timeval.c b/lib/timeval.c
index 4f630bafc..66f923a8e 100644
--- a/lib/timeval.c
+++ b/lib/timeval.c
@@ -84,6 +84,37 @@ struct curltime Curl_now(void)
return cnow;
}
+#elif defined(HAVE_MACH_ABSOLUTE_TIME)
+
+#include <stdint.h>
+#include <mach/mach_time.h>
+
+struct curltime Curl_now(void)
+{
+ /*
+ ** Monotonic timer on Mac OS is provided by mach_absolute_time(), which
+ ** returns time in Mach "absolute time units," which are platform-dependent.
+ ** To convert to nanoseconds, one must use conversion factors specified by
+ ** mach_timebase_info().
+ */
+ static mach_timebase_info_data_t timebase;
+ struct curltime cnow;
+ uint64_t usecs;
+
+ if(0 == timebase.denom)
+ (void) mach_timebase_info(&timebase);
+
+ usecs = mach_absolute_time();
+ usecs *= timebase.numer;
+ usecs /= timebase.denom;
+ usecs /= 1000;
+
+ cnow.tv_sec = usecs / 1000000;
+ cnow.tv_usec = usecs % 1000000;
+
+ return cnow;
+}
+
#elif defined(HAVE_GETTIMEOFDAY)
struct curltime Curl_now(void)
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [gnurl] 41/116: include: remove conncache.h inclusion from where its not needed, (continued)
- [GNUnet-SVN] [gnurl] 41/116: include: remove conncache.h inclusion from where its not needed, gnunet, 2017/12/05
- [GNUnet-SVN] [gnurl] 56/116: Makefile.m32: allow to customize brotli libs, gnunet, 2017/12/05
- [GNUnet-SVN] [gnurl] 64/116: imap: deal with commands case insensitively, gnunet, 2017/12/05
- [GNUnet-SVN] [gnurl] 34/116: select: update comments, gnunet, 2017/12/05
- [GNUnet-SVN] [gnurl] 31/116: cli tool: improve "; type=" handling in -F option arguments, gnunet, 2017/12/05
- [GNUnet-SVN] [gnurl] 53/116: HTTP: implement Brotli content encoding, gnunet, 2017/12/05
- [GNUnet-SVN] [gnurl] 36/116: runtests.pl: Fixed typo in message, gnunet, 2017/12/05
- [GNUnet-SVN] [gnurl] 37/116: mkhelp.pl: support reproducible build, gnunet, 2017/12/05
- [GNUnet-SVN] [gnurl] 55/116: travis: add a job with brotli enabled, gnunet, 2017/12/05
- [GNUnet-SVN] [gnurl] 63/116: connect: store IPv6 connection status after valid connection, gnunet, 2017/12/05
- [GNUnet-SVN] [gnurl] 32/116: timeval: use mach time on MacOS,
gnunet <=
- [GNUnet-SVN] [gnurl] 47/116: curl: pass through [] in URLs instead of calling globbing error, gnunet, 2017/12/05
- [GNUnet-SVN] [gnurl] 72/116: curl_share_setopt: va_end was not called if conncache errors, gnunet, 2017/12/05
- [GNUnet-SVN] [gnurl] 14/116: transfer: Fix chunked-encoding upload bug, gnunet, 2017/12/05
- [GNUnet-SVN] [gnurl] 49/116: RELEASE-NOTES: synced with ee8016b3d, gnunet, 2017/12/05
- [GNUnet-SVN] [gnurl] 48/116: curl: speed up handling of many URLs, gnunet, 2017/12/05
- [GNUnet-SVN] [gnurl] 43/116: tests: Fixed torture tests on tests 556 and 650, gnunet, 2017/12/05
- [GNUnet-SVN] [gnurl] 75/116: README.md: fixed layout, gnunet, 2017/12/05
- [GNUnet-SVN] [gnurl] 77/116: SMB: fix uninitialized local variable, gnunet, 2017/12/05
- [GNUnet-SVN] [gnurl] 27/116: RELEASE-NOTES: synced with f20cbac97, gnunet, 2017/12/05
- [GNUnet-SVN] [gnurl] 68/116: curl_share_setopt.3: document CURL_LOCK_DATA_CONNECT, gnunet, 2017/12/05