summaryrefslogtreecommitdiffstats
path: root/configure
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2015-01-31 01:02:07 +0000
committerRoy Marples <roy@marples.name>2015-01-31 01:02:07 +0000
commitf94b4eab068a6c0c1a9cdf61113e8a508632cc51 (patch)
treee15cab3e59f6314b0477c41febc1b658f876291f /configure
parent505d71953c5fb9a9d072f0338eb1c01a154b7cd8 (diff)
downloaddhcpcd-f94b4eab068a6c0c1a9cdf61113e8a508632cc51.tar.xz
Use strtoi(3) and strtou(3) from NetBSD-8 instead of the harder to use
strtol(3) calls. Add shims around strtoimax(3) and strtoumax(3) when these functions are not available.
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure24
1 files changed, 24 insertions, 0 deletions
diff --git a/configure b/configure
index bac56d7a..cf91a171 100755
--- a/configure
+++ b/configure
@@ -636,6 +636,30 @@ if [ "$STRLCPY" = no ]; then
echo "#include \"compat/strlcpy.h\"" >>$CONFIG_H
fi
+if [ -z "$STRTOI" ]; then
+ printf "Testing for strtoi ... "
+ cat <<EOF >_strtoi.c
+#include <stdlib.h>
+#include <limits.h>
+#include <inttypes.h>
+int main(void) {
+ int e;
+ return strtoi("1234", NULL, 0, 0, INT32_MAX, &e);
+}
+EOF
+ if $XCC _strtoi.c -o _strtoi 2>&3; then
+ STRTOI=yes
+ else
+ STRTOI=no
+ fi
+ echo "$STRTOI"
+ rm -f _strtoi.c _strtoi
+fi
+if [ "$STRTOI" = no ]; then
+ echo "COMPAT_SRCS+= compat/strtoi.c" >>$CONFIG_MK
+ echo "#include \"compat/strtoi.h\"" >>$CONFIG_H
+fi
+
if [ -z "$DPRINTF" ]; then
printf "Testing for dprintf ... "
cat <<EOF >_dprintf.c