On Haiku (a recent one), the gnulib module 'ioctl' produces a compilation error:
In file included from /boot/system/develop/headers/posix/sys/types.h:127:0, from ./sys/types.h:28, from ../../gllib/poll.c:29: ./sys/ioctl.h:484:1: error: conflicting types for 'ioctl' _GL_FUNCDECL_SYS (ioctl, int, ^ In file included from /boot/system/develop/headers/bsd/unistd.h:9:0, from ./unistd.h:40, from ../../gllib/poll.c:51: /boot/system/develop/headers/posix/unistd.h:182:13: note: previous declaration of 'ioctl' was here extern int ioctl(int fd, unsigned long op, ...); ^ The reason is that ioctl() is defined with a non-POSIX signature, and our m4/ioctl.m4 fails to detect it. This fixes it. 2017-10-28 Bruno Haible <br...@clisp.org> ioctl: Override non-POSIX declaration on Haiku. * m4/ioctl.m4 (gl_FUNC_IOCTL): Include also <unistd.h>. * lib/sys_ioctl.in.h: Add comment about Haiku. * doc/posix-functions/ioctl.texi: Mention Haiku problem. * doc/glibc-headers/sys_ioctl.texi: Likewise. diff --git a/m4/ioctl.m4 b/m4/ioctl.m4 index 30209dd..57ca2a3 100644 --- a/m4/ioctl.m4 +++ b/m4/ioctl.m4 @@ -1,4 +1,4 @@ -# ioctl.m4 serial 4 +# ioctl.m4 serial 5 dnl Copyright (C) 2008-2017 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -23,7 +23,10 @@ AC_DEFUN([gl_FUNC_IOCTL], [gl_cv_func_ioctl_posix_signature], [AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( - [[#include <sys/ioctl.h>]], + [[#include <sys/ioctl.h> + /* On some platforms, ioctl() is declared in <unistd.h>. */ + #include <unistd.h> + ]], [[extern #ifdef __cplusplus "C" diff --git a/doc/glibc-headers/sys_ioctl.texi b/doc/glibc-headers/sys_ioctl.texi index a4cb740..5685b89 100644 --- a/doc/glibc-headers/sys_ioctl.texi +++ b/doc/glibc-headers/sys_ioctl.texi @@ -25,7 +25,7 @@ This header file is missing on some platforms: mingw, MSVC 14. @item This header file does not declare the @code{ioctl} function on some platforms: -AIX 5.1, Solaris 11.3. +AIX 5.1, Solaris 11.3, Haiku 2017. @end itemize Portability problems not fixed by Gnulib: diff --git a/doc/posix-functions/ioctl.texi b/doc/posix-functions/ioctl.texi index e4a1dde..b146c0a 100644 --- a/doc/posix-functions/ioctl.texi +++ b/doc/posix-functions/ioctl.texi @@ -15,7 +15,7 @@ On Windows platforms (excluding Cygwin), @code{ioctl} is called @item The second parameter is of type @code{unsigned long} rather than @code{int} on some platforms: -glibc 2.26, Mac OS X 10.5, FreeBSD 11.0, NetBSD 7.0, OpenBSD 6.0, BeOS. +glibc 2.26, Mac OS X 10.5, FreeBSD 11.0, NetBSD 7.0, OpenBSD 6.0, BeOS, Haiku 2017. @end itemize Portability problems not fixed by Gnulib: diff --git a/lib/sys_ioctl.in.h b/lib/sys_ioctl.in.h index 9763a6c..b4f7e7d 100644 --- a/lib/sys_ioctl.in.h +++ b/lib/sys_ioctl.in.h @@ -31,6 +31,7 @@ /* AIX 5.1 and Solaris 10 declare ioctl() in <unistd.h> and in <stropts.h>, but not in <sys/ioctl.h>. + Haiku declares ioctl() in <unistd.h>, but not in <sys/ioctl.h>. But avoid namespace pollution on glibc systems. */ #ifndef __GLIBC__ # include <unistd.h>