From 987aa6a084312be8501bdda42b0e5aab3b84d52a Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Thu, 22 Mar 2018 20:50:24 -0500 Subject: add clock_gettime for macos 10.11 and earlier --- include/compat/sys/time.h | 4 ---- include/compat/time.h | 13 +++++++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/compat/sys/time.h b/include/compat/sys/time.h index 3d31985..76428c1 100644 --- a/include/compat/sys/time.h +++ b/include/compat/sys/time.h @@ -13,10 +13,6 @@ int gettimeofday(struct timeval *tp, void *tzp); #include_next #endif -#ifndef CLOCK_MONOTONIC -#define CLOCK_MONOTONIC CLOCK_REALTIME -#endif - #ifndef timersub #define timersub(tvp, uvp, vvp) \ do { \ diff --git a/include/compat/time.h b/include/compat/time.h index df65530..d43dfcb 100644 --- a/include/compat/time.h +++ b/include/compat/time.h @@ -22,6 +22,19 @@ struct tm *__gmtime_r(const time_t * t, struct tm * tm); time_t timegm(struct tm *tm); #endif +#ifndef CLOCK_MONOTONIC +#define CLOCK_MONOTONIC CLOCK_REALTIME +#endif + +#ifndef CLOCK_REALTIME +#define CLOCK_REALTIME 0 +#endif + +#ifndef HAVE_CLOCK_GETTIME +int +clock_gettime(clockid_t clock_id, struct timespec *tp); +#endif + #ifndef timespecsub #define timespecsub(tsp, usp, vsp) \ do { \ -- cgit v1.2.3-55-g6feb From 7ffaf004153931ba77da7f6659feb1990f4ff760 Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Thu, 22 Mar 2018 21:11:46 -0500 Subject: hide clock_gettime on win32 --- include/compat/time.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/compat/time.h b/include/compat/time.h index d43dfcb..117a441 100644 --- a/include/compat/time.h +++ b/include/compat/time.h @@ -30,10 +30,12 @@ time_t timegm(struct tm *tm); #define CLOCK_REALTIME 0 #endif +#ifndef _WIN32 #ifndef HAVE_CLOCK_GETTIME int clock_gettime(clockid_t clock_id, struct timespec *tp); #endif +#endif #ifndef timespecsub #define timespecsub(tsp, usp, vsp) \ -- cgit v1.2.3-55-g6feb From 4b2a8cd1c16896ca5d4570656435aa1b69bcbd46 Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Fri, 23 Mar 2018 11:10:16 -0500 Subject: adjust definition of compat clock_gettime --- apps/openssl/compat/clock_gettime_osx.c | 2 +- include/compat/time.h | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/apps/openssl/compat/clock_gettime_osx.c b/apps/openssl/compat/clock_gettime_osx.c index e0a5f59..bb385e4 100644 --- a/apps/openssl/compat/clock_gettime_osx.c +++ b/apps/openssl/compat/clock_gettime_osx.c @@ -5,7 +5,7 @@ #define ORWL_GIGA UINT64_C(1000000000) int -clock_gettime(clock_id_t clock_id, struct timespec *tp) +clock_gettime(int clock_id, struct timespec *tp) { static double orwl_timebase = 0.0; static uint64_t orwl_timestart = 0; diff --git a/include/compat/time.h b/include/compat/time.h index 117a441..fb0ab29 100644 --- a/include/compat/time.h +++ b/include/compat/time.h @@ -30,11 +30,8 @@ time_t timegm(struct tm *tm); #define CLOCK_REALTIME 0 #endif -#ifndef _WIN32 #ifndef HAVE_CLOCK_GETTIME -int -clock_gettime(clockid_t clock_id, struct timespec *tp); -#endif +int clock_gettime(int clock_id, struct timespec *tp); #endif #ifndef timespecsub -- cgit v1.2.3-55-g6feb From 6b513a1c78b8a8c4c48b9ef476628728974f3171 Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Fri, 23 Mar 2018 13:45:05 -0500 Subject: add proper guard and typedef --- apps/openssl/compat/clock_gettime_osx.c | 2 +- include/compat/time.h | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/apps/openssl/compat/clock_gettime_osx.c b/apps/openssl/compat/clock_gettime_osx.c index bb385e4..5545187 100644 --- a/apps/openssl/compat/clock_gettime_osx.c +++ b/apps/openssl/compat/clock_gettime_osx.c @@ -5,7 +5,7 @@ #define ORWL_GIGA UINT64_C(1000000000) int -clock_gettime(int clock_id, struct timespec *tp) +clock_gettime(clockid_t clock_id, struct timespec *tp) { static double orwl_timebase = 0.0; static uint64_t orwl_timestart = 0; diff --git a/include/compat/time.h b/include/compat/time.h index fb0ab29..8f08c9a 100644 --- a/include/compat/time.h +++ b/include/compat/time.h @@ -3,6 +3,9 @@ * sys/time.h compatibility shim */ +#ifndef LIBCRYPTOCOMPAT_TIME_H +#define LIBCRYPTOCOMPAT_TIME_H + #ifdef _MSC_VER #if _MSC_VER >= 1900 #include <../ucrt/time.h> @@ -31,7 +34,8 @@ time_t timegm(struct tm *tm); #endif #ifndef HAVE_CLOCK_GETTIME -int clock_gettime(int clock_id, struct timespec *tp); +typedef int clockid_t; +int clock_gettime(clockid_t clock_id, struct timespec *tp); #endif #ifndef timespecsub @@ -45,3 +49,5 @@ int clock_gettime(int clock_id, struct timespec *tp); } \ } while (0) #endif + +#endif -- cgit v1.2.3-55-g6feb From 31c98c2969f70b2db3e866352ec027f7b965c406 Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Fri, 23 Mar 2018 15:35:58 -0500 Subject: always allow upstream time.h to be visible --- include/compat/time.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/compat/time.h b/include/compat/time.h index 8f08c9a..dc460ef 100644 --- a/include/compat/time.h +++ b/include/compat/time.h @@ -3,9 +3,6 @@ * sys/time.h compatibility shim */ -#ifndef LIBCRYPTOCOMPAT_TIME_H -#define LIBCRYPTOCOMPAT_TIME_H - #ifdef _MSC_VER #if _MSC_VER >= 1900 #include <../ucrt/time.h> @@ -16,6 +13,9 @@ #include_next #endif +#ifndef LIBCRYPTOCOMPAT_TIME_H +#define LIBCRYPTOCOMPAT_TIME_H + #ifdef _WIN32 struct tm *__gmtime_r(const time_t * t, struct tm * tm); #define gmtime_r(tp, tm) __gmtime_r(tp, tm) -- cgit v1.2.3-55-g6feb