Land #496, add configure-time check for timespecsub

This commit is contained in:
Brent Cook 2019-01-07 06:28:29 -06:00
commit 4eb8da3e07
3 changed files with 12 additions and 2 deletions

View File

@ -237,6 +237,11 @@ if(HAVE_GETPAGESIZE)
add_definitions(-DHAVE_GETPAGESIZE) add_definitions(-DHAVE_GETPAGESIZE)
endif() endif()
check_symbol_exists(timespecsub sys/time.h HAVE_TIMESPECSUB)
if(HAVE_TIMESPECSUB)
add_definitions(-DHAVE_TIMESPECSUB)
endif()
check_function_exists(timingsafe_bcmp HAVE_TIMINGSAFE_BCMP) check_function_exists(timingsafe_bcmp HAVE_TIMINGSAFE_BCMP)
if(HAVE_TIMINGSAFE_BCMP) if(HAVE_TIMINGSAFE_BCMP)
add_definitions(-DHAVE_TIMINGSAFE_BCMP) add_definitions(-DHAVE_TIMINGSAFE_BCMP)

View File

@ -39,7 +39,11 @@ typedef int clockid_t;
int clock_gettime(clockid_t clock_id, struct timespec *tp); int clock_gettime(clockid_t clock_id, struct timespec *tp);
#endif #endif
#ifndef timespecsub #ifdef timespecsub
#define HAVE_TIMESPECSUB
#endif
#ifndef HAVE_TIMESPECSUB
#define timespecsub(tsp, usp, vsp) \ #define timespecsub(tsp, usp, vsp) \
do { \ do { \
(vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec; \ (vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec; \
@ -50,6 +54,7 @@ int clock_gettime(clockid_t clock_id, struct timespec *tp);
} \ } \
} while (0) } while (0)
#endif #endif
#endif #endif
#endif #endif

View File

@ -5,7 +5,7 @@ AC_CHECK_HEADERS([err.h readpassphrase.h])
AC_CHECK_FUNCS([asprintf freezero memmem]) AC_CHECK_FUNCS([asprintf freezero memmem])
AC_CHECK_FUNCS([readpassphrase reallocarray recallocarray]) AC_CHECK_FUNCS([readpassphrase reallocarray recallocarray])
AC_CHECK_FUNCS([strlcat strlcpy strndup strnlen strsep strtonum]) AC_CHECK_FUNCS([strlcat strlcpy strndup strnlen strsep strtonum])
AC_CHECK_FUNCS([timegm _mkgmtime]) AC_CHECK_FUNCS([timegm _mkgmtime timespecsub])
AC_CACHE_CHECK([for getpagesize], ac_cv_func_getpagesize, [ AC_CACHE_CHECK([for getpagesize], ac_cv_func_getpagesize, [
AC_LINK_IFELSE([AC_LANG_PROGRAM([[ AC_LINK_IFELSE([AC_LANG_PROGRAM([[
// Since Android NDK v16 getpagesize is defined as inline inside unistd.h // Since Android NDK v16 getpagesize is defined as inline inside unistd.h