--- lib/ioctl.c.old	2011-02-22 20:21:11.000000000 +0100
+++ lib/ioctl.c	2011-02-22 20:24:38.000000000 +0100
@@ -28,7 +28,11 @@
 /* Provide a wrapper with the POSIX prototype.  */
 # undef ioctl
 int
+#if __FreeBSD__ || __Darwin__
+rpl_ioctl (int fd, unsigned long request, ... /* {void *,char *} arg */)
+#else
 rpl_ioctl (int fd, int request, ... /* {void *,char *} arg */)
+#endif
 {
   void *buf;
   va_list args;
--- m4/ioctl.m4.old	2011-02-22 20:23:18.000000000 +0100
+++ m4/ioctl.m4	2011-02-22 20:26:10.000000000 +0100
@@ -24,7 +24,13 @@
       [AC_COMPILE_IFELSE(
          [AC_LANG_PROGRAM(
             [[#include <sys/ioctl.h>]],
-            [[extern int ioctl (int, int, ...);]])
+            [[
+		#if __FreeBSD__ || __Darwin__
+		extern int ioctl (int, unsigned long, ...);
+		#else
+		extern int ioctl (int, int, ...);
+		#endif
+	]])
          ],
          [gl_cv_func_ioctl_posix_signature=yes],
          [gl_cv_func_ioctl_posix_signature=no])
