diff options
| author | Brent Cook <busterb@gmail.com> | 2019-01-06 13:20:29 -0600 |
|---|---|---|
| committer | Brent Cook <busterb@gmail.com> | 2019-01-06 15:47:55 -0600 |
| commit | 7af3ba340d608860d519210032d190c26c6f6eae (patch) | |
| tree | 60b1872ce6979728cccbb341afb0f4bc1cb8af24 | |
| parent | 779ec4dedcc62204a4d2acecb528a24931313a3d (diff) | |
| download | portable-7af3ba340d608860d519210032d190c26c6f6eae.tar.gz portable-7af3ba340d608860d519210032d190c26c6f6eae.tar.bz2 portable-7af3ba340d608860d519210032d190c26c6f6eae.zip | |
add configure-time check for timespecsub
| -rw-r--r-- | CMakeLists.txt | 5 | ||||
| -rw-r--r-- | include/compat/time.h | 7 | ||||
| -rw-r--r-- | m4/check-libc.m4 | 3 |
3 files changed, 13 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 1efe6bc..bcba254 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
| @@ -237,6 +237,11 @@ if(HAVE_GETPAGESIZE) | |||
| 237 | add_definitions(-DHAVE_GETPAGESIZE) | 237 | add_definitions(-DHAVE_GETPAGESIZE) |
| 238 | endif() | 238 | endif() |
| 239 | 239 | ||
| 240 | check_symbol_exists(timespecsub sys/time.h HAVE_TIMESPECSUB) | ||
| 241 | if(HAVE_TIMESPECSUB) | ||
| 242 | add_definitions(-DHAVE_TIMESPECSUB) | ||
| 243 | endif() | ||
| 244 | |||
| 240 | check_function_exists(timingsafe_bcmp HAVE_TIMINGSAFE_BCMP) | 245 | check_function_exists(timingsafe_bcmp HAVE_TIMINGSAFE_BCMP) |
| 241 | if(HAVE_TIMINGSAFE_BCMP) | 246 | if(HAVE_TIMINGSAFE_BCMP) |
| 242 | add_definitions(-DHAVE_TIMINGSAFE_BCMP) | 247 | add_definitions(-DHAVE_TIMINGSAFE_BCMP) |
diff --git a/include/compat/time.h b/include/compat/time.h index ccedba3..540807d 100644 --- a/include/compat/time.h +++ b/include/compat/time.h | |||
| @@ -39,7 +39,11 @@ typedef int clockid_t; | |||
| 39 | int clock_gettime(clockid_t clock_id, struct timespec *tp); | 39 | int clock_gettime(clockid_t clock_id, struct timespec *tp); |
| 40 | #endif | 40 | #endif |
| 41 | 41 | ||
| 42 | #ifndef timespecsub | 42 | #ifdef timespecsub |
| 43 | #define HAVE_TIMESPECSUB | ||
| 44 | #endif | ||
| 45 | |||
| 46 | #ifndef HAVE_TIMESPECSUB | ||
| 43 | #define timespecsub(tsp, usp, vsp) \ | 47 | #define timespecsub(tsp, usp, vsp) \ |
| 44 | do { \ | 48 | do { \ |
| 45 | (vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec; \ | 49 | (vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec; \ |
| @@ -50,6 +54,7 @@ int clock_gettime(clockid_t clock_id, struct timespec *tp); | |||
| 50 | } \ | 54 | } \ |
| 51 | } while (0) | 55 | } while (0) |
| 52 | #endif | 56 | #endif |
| 57 | |||
| 53 | #endif | 58 | #endif |
| 54 | 59 | ||
| 55 | #endif | 60 | #endif |
diff --git a/m4/check-libc.m4 b/m4/check-libc.m4 index 1fff77e..f726a43 100644 --- a/m4/check-libc.m4 +++ b/m4/check-libc.m4 | |||
| @@ -5,7 +5,7 @@ AC_CHECK_HEADERS([err.h readpassphrase.h]) | |||
| 5 | AC_CHECK_FUNCS([asprintf freezero memmem]) | 5 | AC_CHECK_FUNCS([asprintf freezero memmem]) |
| 6 | AC_CHECK_FUNCS([readpassphrase reallocarray recallocarray]) | 6 | AC_CHECK_FUNCS([readpassphrase reallocarray recallocarray]) |
| 7 | AC_CHECK_FUNCS([strlcat strlcpy strndup strnlen strsep strtonum]) | 7 | AC_CHECK_FUNCS([strlcat strlcpy strndup strnlen strsep strtonum]) |
| 8 | AC_CHECK_FUNCS([timegm _mkgmtime]) | 8 | AC_CHECK_FUNCS([timegm _mkgmtime timespecsub]) |
| 9 | AC_CACHE_CHECK([for getpagesize], ac_cv_func_getpagesize, [ | 9 | AC_CACHE_CHECK([for getpagesize], ac_cv_func_getpagesize, [ |
| 10 | AC_LINK_IFELSE([AC_LANG_PROGRAM([[ | 10 | AC_LINK_IFELSE([AC_LANG_PROGRAM([[ |
| 11 | // Since Android NDK v16 getpagesize is defined as inline inside unistd.h | 11 | // Since Android NDK v16 getpagesize is defined as inline inside unistd.h |
| @@ -22,6 +22,7 @@ AC_CACHE_CHECK([for getpagesize], ac_cv_func_getpagesize, [ | |||
| 22 | AM_CONDITIONAL([HAVE_ASPRINTF], [test "x$ac_cv_func_asprintf" = xyes]) | 22 | AM_CONDITIONAL([HAVE_ASPRINTF], [test "x$ac_cv_func_asprintf" = xyes]) |
| 23 | AM_CONDITIONAL([HAVE_FREEZERO], [test "x$ac_cv_func_freezero" = xyes]) | 23 | AM_CONDITIONAL([HAVE_FREEZERO], [test "x$ac_cv_func_freezero" = xyes]) |
| 24 | AM_CONDITIONAL([HAVE_GETPAGESIZE], [test "x$ac_cv_func_getpagesize" = xyes]) | 24 | AM_CONDITIONAL([HAVE_GETPAGESIZE], [test "x$ac_cv_func_getpagesize" = xyes]) |
| 25 | AM_CONDITIONAL([HAVE_TIMESPECSUB], [test "x$ac_cv_func_timespecsub" = xyes]) | ||
| 25 | AM_CONDITIONAL([HAVE_MEMMEM], [test "x$ac_cv_func_memmem" = xyes]) | 26 | AM_CONDITIONAL([HAVE_MEMMEM], [test "x$ac_cv_func_memmem" = xyes]) |
| 26 | AM_CONDITIONAL([HAVE_READPASSPHRASE], [test "x$ac_cv_func_readpassphrase" = xyes]) | 27 | AM_CONDITIONAL([HAVE_READPASSPHRASE], [test "x$ac_cv_func_readpassphrase" = xyes]) |
| 27 | AM_CONDITIONAL([HAVE_REALLOCARRAY], [test "x$ac_cv_func_reallocarray" = xyes]) | 28 | AM_CONDITIONAL([HAVE_REALLOCARRAY], [test "x$ac_cv_func_reallocarray" = xyes]) |
