--- /dev/null
+diff --git a/noip.c b/noip.c
+index aca7b75..072d2fc 100644
+--- a/noip.c
++++ b/noip.c
+@@ -149,7 +152,7 @@ static impbind *impbinds, **impbind_tail = &impbinds;
+ struct sockaddr *from, socklen_t *fromlen)) \
+ _(sendmsg, ssize_t, (int, const struct msghdr *, int)) \
+ _(recvmsg, ssize_t, (int, struct msghdr *, int)) \
+- _(ioctl, int, (int, unsigned long, ...))
++ _(ioctl, int, (int, int, ...))
+
+ /* Function pointers to set up. */
+ #define DECL(imp, ret, args) static ret (*real_##imp) args;
+@@ -2000,7 +2003,7 @@ int setsockopt(int sk, int lev, int opt, const void *p, socklen_t len)
+ return (real_setsockopt(sk, lev, opt, p, len));
+ }
+
+-int ioctl(int fd, unsigned long op, ...)
++int ioctl(int fd, int op, ...)
+ {
+ va_list ap;
+ void *arg;
--- /dev/null
+diff --git a/noip.c b/noip.c
+index aca7b75..479bdf5 100644
+--- a/noip.c
++++ b/noip.c
+@@ -57,6 +57,11 @@
+ #include <ifaddrs.h>
+ #include <netdb.h>
+
++#ifndef SUN_LEN
++# define SUN_LEN(sun) \
++ (strlen((sun)->sun_path) + offsetof(struct sockaddr_un, sun_path))
++#endif
++
+ /*----- Data structures ---------------------------------------------------*/
+
+ /* Unix socket status values. */
+diff --git a/uopen.c b/uopen.c
+index 3c0d1d4..22b09db 100644
+--- a/uopen.c
++++ b/uopen.c
+@@ -42,6 +42,11 @@
+ #include <sys/stat.h>
+ #include <sys/un.h>
+
++#ifndef SUN_LEN
++# define SUN_LEN(sun) \
++ (strlen((sun)->sun_path) + offsetof(struct sockaddr_un, sun_path))
++#endif
++
+ /*----- Import the real versions of functions -----------------------------*/
+
+ /* The list of functions to immport. */