aboutsummaryrefslogtreecommitdiff
path: root/m4/check-libc.m4
diff options
context:
space:
mode:
authorBrent Cook <busterb@gmail.com>2015-05-01 07:18:12 -0500
committerBrent Cook <busterb@gmail.com>2015-05-23 19:27:57 -0500
commitd3771a41cb106c945e0f538073d0a6e7b35d145b (patch)
tree0ec81fcb0eae37fc7f1f89e2a7d1de26e54d35d2 /m4/check-libc.m4
parent28353c1df15c3d0482a10ffe33fa34c053af2c2e (diff)
downloadportable-d3771a41cb106c945e0f538073d0a6e7b35d145b.tar.gz
portable-d3771a41cb106c945e0f538073d0a6e7b35d145b.tar.bz2
portable-d3771a41cb106c945e0f538073d0a6e7b35d145b.zip
refactor configure into separate m4 macros
this allows for some reusability with libtls
Diffstat (limited to 'm4/check-libc.m4')
-rw-r--r--m4/check-libc.m465
1 files changed, 65 insertions, 0 deletions
diff --git a/m4/check-libc.m4 b/m4/check-libc.m4
new file mode 100644
index 0000000..2bbfb81
--- /dev/null
+++ b/m4/check-libc.m4
@@ -0,0 +1,65 @@
1AC_DEFUN([CHECK_LIBC_COMPAT], [
2# Check for general libc functions
3AC_CHECK_FUNCS([asprintf memmem poll reallocarray])
4AC_CHECK_FUNCS([strlcat strlcpy strndup strnlen strsep strtonum])
5AM_CONDITIONAL([HAVE_ASPRINTF], [test "x$ac_cv_func_asprintf" = xyes])
6AM_CONDITIONAL([HAVE_MEMMEM], [test "x$ac_cv_func_memmem" = xyes])
7AM_CONDITIONAL([HAVE_POLL], [test "x$ac_cv_func_poll" = xyes])
8AM_CONDITIONAL([HAVE_REALLOCARRAY], [test "x$ac_cv_func_reallocarray" = xyes])
9AM_CONDITIONAL([HAVE_STRLCAT], [test "x$ac_cv_func_strlcat" = xyes])
10AM_CONDITIONAL([HAVE_STRLCPY], [test "x$ac_cv_func_strlcpy" = xyes])
11AM_CONDITIONAL([HAVE_STRNDUP], [test "x$ac_cv_func_strndup" = xyes])
12AM_CONDITIONAL([HAVE_STRNLEN], [test "x$ac_cv_func_strnlen" = xyes])
13AM_CONDITIONAL([HAVE_STRSEP], [test "x$ac_cv_func_strsep" = xyes])
14AM_CONDITIONAL([HAVE_STRTONUM], [test "x$ac_cv_func_strtonum" = xyes])
15])
16
17AC_DEFUN([CHECK_LIBC_CRYPTO_COMPAT], [
18# Check crypto-related libc functions
19AC_CHECK_FUNCS([arc4random_buf explicit_bzero getauxval getentropy])
20AC_CHECK_FUNCS([timingsafe_bcmp timingsafe_memcmp])
21AM_CONDITIONAL([HAVE_ARC4RANDOM_BUF], [test "x$ac_cv_func_arc4random_buf" = xyes])
22AM_CONDITIONAL([HAVE_EXPLICIT_BZERO], [test "x$ac_cv_func_explicit_bzero" = xyes])
23AM_CONDITIONAL([HAVE_GETENTROPY], [test "x$ac_cv_func_getentropy" = xyes])
24AM_CONDITIONAL([HAVE_TIMINGSAFE_BCMP], [test "x$ac_cv_func_timingsafe_bcmp" = xyes])
25AM_CONDITIONAL([HAVE_TIMINGSAFE_MEMCMP], [test "x$ac_cv_func_timingsafe_memcmp" = xyes])
26
27# Override arc4random_buf implementations with known issues
28AM_CONDITIONAL([HAVE_ARC4RANDOM_BUF],
29 [test "x$HOST_OS" != xdarwin \
30 -a "x$HOST_OS" != xfreebsd \
31 -a "x$HOST_OS" != xnetbsd \
32 -a "x$ac_cv_func_arc4random_buf" = xyes])
33
34# Check for getentropy fallback dependencies
35AC_CHECK_FUNC([getauxval])
36AC_CHECK_FUNC([clock_gettime],, [AC_SEARCH_LIBS([clock_gettime],[rt posix4])])
37AC_CHECK_FUNC([dl_iterate_phdr],, [AC_SEARCH_LIBS([dl_iterate_phdr],[dl])])
38])
39
40AC_DEFUN([CHECK_VA_COPY], [
41AC_CACHE_CHECK([whether va_copy exists], ac_cv_have_va_copy, [
42 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
43#include <stdarg.h>
44va_list x,y;
45 ]], [[ va_copy(x,y); ]])],
46 [ ac_cv_have_va_copy="yes" ],
47 [ ac_cv_have_va_copy="no"
48 ])
49])
50if test "x$ac_cv_have_va_copy" = "xyes" ; then
51 AC_DEFINE([HAVE_VA_COPY], [1], [Define if va_copy exists])
52fi
53
54AC_CACHE_CHECK([whether __va_copy exists], ac_cv_have___va_copy, [
55 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
56#include <stdarg.h>
57va_list x,y;
58 ]], [[ __va_copy(x,y); ]])],
59 [ ac_cv_have___va_copy="yes" ], [ ac_cv_have___va_copy="no"
60 ])
61])
62if test "x$ac_cv_have___va_copy" = "xyes" ; then
63 AC_DEFINE([HAVE___VA_COPY], [1], [Define if __va_copy exists])
64fi
65])