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
commitfa070df4e9ac982c9097fdfdbfde16ed3bd693b4 (patch)
tree4c0f27df4110076994676980475f569ae6dc155d /configure
parent7c434303d65a005aca39c618e476d53039541d78 (diff)
downloaddhcpcd-fa070df4e9ac982c9097fdfdbfde16ed3bd693b4.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>