Land #412, fix builds for macos 10.11

This commit is contained in:
Brent Cook 2018-03-23 18:15:50 -05:00
commit 31a66e1c5b
6 changed files with 62 additions and 8 deletions

View File

@ -283,6 +283,12 @@ endif()
if(WIN32)
set(OPENSSL_LIBS ${OPENSSL_LIBS} ws2_32)
endif()
check_function_exists(clock_gettime HAVE_CLOCK_GETTIME)
if(HAVE_CLOCK_GETTIME)
add_definitions(-DHAVE_CLOCK_GETTIME)
endif()
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
check_library_exists(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME)
if (HAVE_CLOCK_GETTIME)

View File

@ -74,6 +74,12 @@ openssl_SOURCES += compat/poll_win.c
endif
endif
if !HAVE_CLOCK_GETTIME
if HOST_DARWIN
openssl_SOURCES += compat/clock_gettime_osx.c
endif
endif
if !HAVE_STRTONUM
openssl_SOURCES += compat/strtonum.c
endif

View 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(clockid_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;
}

View File

@ -13,10 +13,6 @@ int gettimeofday(struct timeval *tp, void *tzp);
#include_next <sys/time.h>
#endif
#ifndef CLOCK_MONOTONIC
#define CLOCK_MONOTONIC CLOCK_REALTIME
#endif
#ifndef timersub
#define timersub(tvp, uvp, vvp) \
do { \

View File

@ -13,6 +13,9 @@
#include_next <time.h>
#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)
@ -22,6 +25,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
typedef int clockid_t;
int clock_gettime(clockid_t clock_id, struct timespec *tp);
#endif
#ifndef timespecsub
#define timespecsub(tsp, usp, vsp) \
do { \
@ -33,3 +49,5 @@ time_t timegm(struct tm *tm);
} \
} while (0)
#endif
#endif

View File

@ -126,11 +126,13 @@ AM_CONDITIONAL([HAVE_ARC4RANDOM_BUF],
-a "x$ac_cv_func_arc4random_buf" = xyes])
# Check for getentropy fallback dependencies
AC_CHECK_FUNC([getauxval])
AC_SEARCH_LIBS([clock_gettime],[rt posix4])
AC_CHECK_FUNC([clock_gettime])
AC_CHECK_FUNCS([getauxval])
AC_SEARCH_LIBS([dl_iterate_phdr],[dl])
AC_CHECK_FUNC([dl_iterate_phdr])
AC_CHECK_FUNCS([dl_iterate_phdr])
AC_SEARCH_LIBS([clock_gettime],[rt posix4])
AC_CHECK_FUNCS([clock_gettime])
AM_CONDITIONAL([HAVE_CLOCK_GETTIME], [test "x$ac_cv_func_clock_gettime" = xyes])
])
AC_DEFUN([CHECK_VA_COPY], [