diff options
| author | Roy Marples <roy@marples.name> | 2020-01-08 20:13:20 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2020-01-08 20:13:20 +0000 |
| commit | fa070df4e9ac982c9097fdfdbfde16ed3bd693b4 (patch) | |
| tree | 4c0f27df4110076994676980475f569ae6dc155d /src/if.h | |
| parent | 7c434303d65a005aca39c618e476d53039541d78 (diff) | |
| download | dhcpcd-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 'src/if.h')
| -rw-r--r-- | src/if.h | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -62,6 +62,16 @@ #endif #include "config.h" + +/* POSIX defines ioctl request as an int, which Solaris and musl use. + * Everyone else use an unsigned long, which happens to be the bigger one + * so we use that in our on wire API. */ +#ifdef IOCTL_REQUEST_TYPE +typedef IOCTL_REQUEST_TYPE ioctl_request_t; +#else +typedef unsigned long ioctl_request_t; +#endif + #include "dhcpcd.h" #include "ipv4.h" #include "ipv6.h" @@ -110,7 +120,7 @@ int if_getifaddrs(struct ifaddrs **); int if_getsubnet(struct dhcpcd_ctx *, const char *, int, void *, size_t); #endif -int if_ioctl(struct dhcpcd_ctx *, unsigned long, void *, size_t); +int if_ioctl(struct dhcpcd_ctx *, ioctl_request_t, void *, size_t); int if_getflags(struct interface *ifp); int if_setflag(struct interface *ifp, short flag); #define if_up(ifp) if_setflag((ifp), (IFF_UP | IFF_RUNNING)) |
