summaryrefslogtreecommitdiffstats
path: root/configure
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2020-01-08 20:13:20 +0000
committerRoy Marples <roy@marples.name>2020-01-08 20:13:20 +0000
commit84bb0708e0d5996f010b733fdb68d17bf441e255 (patch)
tree4c0f27df4110076994676980475f569ae6dc155d /configure
parentc55279517dc3df6743100c5e525d464010f563c6 (diff)
downloaddhcpcd-84bb0708e0d5996f010b733fdb68d17bf441e255.tar.xz
ioctl: The POSIX signature differs from BSD and glibc
BSD and glibc have the signature for request as unsigned long. musl and Solaris have a signed int. As such, we need to detect this at compile time and adjust the signature of our internal ioctl functions to match. To keep the onwire format the same, memcpy the request to the unsigned long request and back again, thus preserving the signedness.
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure23
1 files changed, 22 insertions, 1 deletions
diff --git a/configure b/configure
index 0cb27ce1..263afbf7 100755
--- a/configure
+++ b/configure
@@ -549,7 +549,7 @@ if [ "$PRIVSEP" = yes ]; then
fi
done
fi
- : ${PRIVSEP_USER:= _dhcpcd}
+ : ${PRIVSEP_USER:=_dhcpcd}
echo "CPPFLAGS+= -DPRIVSEP" >>$CONFIG_MK
echo "#ifndef PRIVSEP_USER" >>$CONFIG_H
@@ -737,6 +737,27 @@ fi
rm -f _clock_gettime.c _clock_gettime
$abort && exit 1
+printf "Testing ioctl request type ... "
+cat <<EOF >_ioctl.c
+#include <sys/ioctl.h>
+int main(void) {
+ unsigned long req = 0;
+ return ioctl(3, req, &req);
+}
+EOF
+if $XCC _ioctl.c -o _ioctl 2>&3; then
+ IOCTL_REQ="unsigned long"
+else
+ IOCTL_REQ="int"
+fi
+echo "$IOCTL_REQ"
+# Our default is unsigned long
+# We can still define it, but it makes the code path slightly bigger
+if [ "$IOCTL_REQ" != "unsigned long" ]; then
+ echo "#define IOCTL_REQUEST_TYPE $IOCTL_REQ" >>$CONFIG_H
+fi
+rm -f _ioctl.c _ioctl
+
printf "Testing for inet_ntoa ... "
cat <<EOF >_inet_ntoa.c
#include <netinet/in.h>