add clock_gettime for macos 10.11 and earlier
This commit is contained in:
parent
78600e9bec
commit
987aa6a084
@ -74,6 +74,12 @@ openssl_SOURCES += compat/poll_win.c
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if !HAVE_CLOCK_GETTIME
|
||||||
|
if HOST_DARWIN
|
||||||
|
openssl_SOURCES += compat/clock_gettime_osx.c
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
if !HAVE_STRTONUM
|
if !HAVE_STRTONUM
|
||||||
openssl_SOURCES += compat/strtonum.c
|
openssl_SOURCES += compat/strtonum.c
|
||||||
endif
|
endif
|
||||||
|
26
apps/openssl/compat/clock_gettime_osx.c
Normal file
26
apps/openssl/compat/clock_gettime_osx.c
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
#include <mach/mach_time.h>
|
||||||
|
#define ORWL_NANO (+1.0E-9)
|
||||||
|
#define ORWL_GIGA UINT64_C(1000000000)
|
||||||
|
|
||||||
|
int
|
||||||
|
clock_gettime(clock_id_t clock_id, struct timespec *tp)
|
||||||
|
{
|
||||||
|
static double orwl_timebase = 0.0;
|
||||||
|
static uint64_t orwl_timestart = 0;
|
||||||
|
|
||||||
|
if (!orwl_timestart) {
|
||||||
|
mach_timebase_info_data_t tb = { 0 };
|
||||||
|
mach_timebase_info(&tb);
|
||||||
|
orwl_timebase = tb.numer;
|
||||||
|
orwl_timebase /= tb.denom;
|
||||||
|
orwl_timestart = mach_absolute_time();
|
||||||
|
}
|
||||||
|
|
||||||
|
double diff = (mach_absolute_time() - orwl_timestart) * orwl_timebase;
|
||||||
|
tp->tv_sec = diff * ORWL_NANO;
|
||||||
|
tp->tv_nsec = diff - (tp->tv_sec * ORWL_GIGA);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
@ -13,10 +13,6 @@ int gettimeofday(struct timeval *tp, void *tzp);
|
|||||||
#include_next <sys/time.h>
|
#include_next <sys/time.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CLOCK_MONOTONIC
|
|
||||||
#define CLOCK_MONOTONIC CLOCK_REALTIME
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef timersub
|
#ifndef timersub
|
||||||
#define timersub(tvp, uvp, vvp) \
|
#define timersub(tvp, uvp, vvp) \
|
||||||
do { \
|
do { \
|
||||||
|
@ -22,6 +22,19 @@ struct tm *__gmtime_r(const time_t * t, struct tm * tm);
|
|||||||
time_t timegm(struct tm *tm);
|
time_t timegm(struct tm *tm);
|
||||||
#endif
|
#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
|
#ifndef timespecsub
|
||||||
#define timespecsub(tsp, usp, vsp) \
|
#define timespecsub(tsp, usp, vsp) \
|
||||||
do { \
|
do { \
|
||||||
|
@ -131,6 +131,8 @@ AC_SEARCH_LIBS([clock_gettime],[rt posix4])
|
|||||||
AC_CHECK_FUNC([clock_gettime])
|
AC_CHECK_FUNC([clock_gettime])
|
||||||
AC_SEARCH_LIBS([dl_iterate_phdr],[dl])
|
AC_SEARCH_LIBS([dl_iterate_phdr],[dl])
|
||||||
AC_CHECK_FUNC([dl_iterate_phdr])
|
AC_CHECK_FUNC([dl_iterate_phdr])
|
||||||
|
|
||||||
|
AM_CONDITIONAL([HAVE_CLOCK_GETTIME], [test "x$ac_cv_func_clock_gettime" = xyes])
|
||||||
])
|
])
|
||||||
|
|
||||||
AC_DEFUN([CHECK_VA_COPY], [
|
AC_DEFUN([CHECK_VA_COPY], [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user