diff options
| author | Brent Cook <busterb@gmail.com> | 2019-01-07 06:28:29 -0600 |
|---|---|---|
| committer | Brent Cook <busterb@gmail.com> | 2019-01-07 06:28:29 -0600 |
| commit | 4eb8da3e07717103fceadf7138a3f377ab1c5110 (patch) | |
| tree | d8dc02275cac927e77778fdf619ed94d4e5f7cf3 | |
| parent | 1e848d2e4eaa5664d99b0e59f124f1eabf039f05 (diff) | |
| parent | c1a44d2220db94fb3bb4d74e6ae4badbb2da6a62 (diff) | |
| download | portable-4eb8da3e07717103fceadf7138a3f377ab1c5110.tar.gz portable-4eb8da3e07717103fceadf7138a3f377ab1c5110.tar.bz2 portable-4eb8da3e07717103fceadf7138a3f377ab1c5110.zip | |
Land #496, 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 | 2 |
3 files changed, 12 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..a4df0b7 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 |
