aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrent Cook <busterb@gmail.com>2019-01-06 13:20:29 -0600
committerBrent Cook <busterb@gmail.com>2019-01-06 15:47:55 -0600
commit7af3ba340d608860d519210032d190c26c6f6eae (patch)
tree60b1872ce6979728cccbb341afb0f4bc1cb8af24
parent779ec4dedcc62204a4d2acecb528a24931313a3d (diff)
downloadportable-7af3ba340d608860d519210032d190c26c6f6eae.tar.gz
portable-7af3ba340d608860d519210032d190c26c6f6eae.tar.bz2
portable-7af3ba340d608860d519210032d190c26c6f6eae.zip
add configure-time check for timespecsub
-rw-r--r--CMakeLists.txt5
-rw-r--r--include/compat/time.h7
-rw-r--r--m4/check-libc.m43
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)
238endif() 238endif()
239 239
240check_symbol_exists(timespecsub sys/time.h HAVE_TIMESPECSUB)
241if(HAVE_TIMESPECSUB)
242 add_definitions(-DHAVE_TIMESPECSUB)
243endif()
244
240check_function_exists(timingsafe_bcmp HAVE_TIMINGSAFE_BCMP) 245check_function_exists(timingsafe_bcmp HAVE_TIMINGSAFE_BCMP)
241if(HAVE_TIMINGSAFE_BCMP) 246if(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;
39int clock_gettime(clockid_t clock_id, struct timespec *tp); 39int 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])
5AC_CHECK_FUNCS([asprintf freezero memmem]) 5AC_CHECK_FUNCS([asprintf freezero memmem])
6AC_CHECK_FUNCS([readpassphrase reallocarray recallocarray]) 6AC_CHECK_FUNCS([readpassphrase reallocarray recallocarray])
7AC_CHECK_FUNCS([strlcat strlcpy strndup strnlen strsep strtonum]) 7AC_CHECK_FUNCS([strlcat strlcpy strndup strnlen strsep strtonum])
8AC_CHECK_FUNCS([timegm _mkgmtime]) 8AC_CHECK_FUNCS([timegm _mkgmtime timespecsub])
9AC_CACHE_CHECK([for getpagesize], ac_cv_func_getpagesize, [ 9AC_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, [
22AM_CONDITIONAL([HAVE_ASPRINTF], [test "x$ac_cv_func_asprintf" = xyes]) 22AM_CONDITIONAL([HAVE_ASPRINTF], [test "x$ac_cv_func_asprintf" = xyes])
23AM_CONDITIONAL([HAVE_FREEZERO], [test "x$ac_cv_func_freezero" = xyes]) 23AM_CONDITIONAL([HAVE_FREEZERO], [test "x$ac_cv_func_freezero" = xyes])
24AM_CONDITIONAL([HAVE_GETPAGESIZE], [test "x$ac_cv_func_getpagesize" = xyes]) 24AM_CONDITIONAL([HAVE_GETPAGESIZE], [test "x$ac_cv_func_getpagesize" = xyes])
25AM_CONDITIONAL([HAVE_TIMESPECSUB], [test "x$ac_cv_func_timespecsub" = xyes])
25AM_CONDITIONAL([HAVE_MEMMEM], [test "x$ac_cv_func_memmem" = xyes]) 26AM_CONDITIONAL([HAVE_MEMMEM], [test "x$ac_cv_func_memmem" = xyes])
26AM_CONDITIONAL([HAVE_READPASSPHRASE], [test "x$ac_cv_func_readpassphrase" = xyes]) 27AM_CONDITIONAL([HAVE_READPASSPHRASE], [test "x$ac_cv_func_readpassphrase" = xyes])
27AM_CONDITIONAL([HAVE_REALLOCARRAY], [test "x$ac_cv_func_reallocarray" = xyes]) 28AM_CONDITIONAL([HAVE_REALLOCARRAY], [test "x$ac_cv_func_reallocarray" = xyes])