From 0806b2e000515c8c9f32c5276df88936d3f890cb Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Fri, 10 Oct 2008 04:25:28 +0200 Subject: [PATCH] New module 'sys_ioctl'. --- ChangeLog | 8 +++++ doc/glibc-headers/sys_ioctl.texi | 10 +++--- lib/sys_ioctl.in.h | 68 ++++++++++++++++++++++++++++++++++++++++ m4/sys_ioctl_h.m4 | 60 +++++++++++++++++++++++++++++++++++ modules/sys_ioctl | 46 +++++++++++++++++++++++++++ 5 files changed, 187 insertions(+), 5 deletions(-) create mode 100644 lib/sys_ioctl.in.h create mode 100644 m4/sys_ioctl_h.m4 create mode 100644 modules/sys_ioctl diff --git a/ChangeLog b/ChangeLog index 1a778b0eb..09a89678e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2008-10-09 Bruno Haible + New module 'sys_ioctl'. + * lib/sys_ioctl.in.h: New file. + * m4/sys_ioctl_h.m4: New file. + * modules/sys_ioctl: New file. + * doc/glibc-headers/sys_ioctl.texi: Mention the new module. + +2008-10-09 Bruno Haible + * lib/sys_socket.in.h (ioctl): Make signature POSIX compliant. * lib/winsock.c: Include . (rpl_ioctl): Change to second argument 'int' and then varargs. diff --git a/doc/glibc-headers/sys_ioctl.texi b/doc/glibc-headers/sys_ioctl.texi index 16908bd18..4d615dc6d 100644 --- a/doc/glibc-headers/sys_ioctl.texi +++ b/doc/glibc-headers/sys_ioctl.texi @@ -16,14 +16,10 @@ Documentation: @uref{http://www.kernel.org/doc/man-pages/online/pages/man2/ioctl.2.html,,man ioctl}. @end itemize -Gnulib module: --- +Gnulib module: sys_ioctl Portability problems fixed by Gnulib: @itemize -@end itemize - -Portability problems not fixed by Gnulib: -@itemize @item This header file is missing on some platforms: mingw. @@ -31,3 +27,7 @@ mingw. This header file does not declare the @code{ioctl} function on some platforms: AIX 5.1, Solaris 10. @end itemize + +Portability problems not fixed by Gnulib: +@itemize +@end itemize diff --git a/lib/sys_ioctl.in.h b/lib/sys_ioctl.in.h new file mode 100644 index 000000000..221177a3c --- /dev/null +++ b/lib/sys_ioctl.in.h @@ -0,0 +1,68 @@ +/* Substitute for and wrapper around . + Copyright (C) 2008 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +#ifndef _GL_SYS_IOCTL_H + +@PRAGMA_SYSTEM_HEADER@ + +/* The include_next requires a split double-inclusion guard. */ +#if @HAVE_SYS_IOCTL_H@ +# @INCLUDE_NEXT@ @NEXT_SYS_IOCTL_H@ +#endif + +#ifndef _GL_SYS_IOCTL_H +#define _GL_SYS_IOCTL_H + +/* AIX 5.1 and Solaris 10 declare ioctl() in and in , + but not in . */ +#include + +/* The definition of GL_LINK_WARNING is copied here. */ + + +/* Declare overridden functions. */ + +#ifdef __cplusplus +extern "C" { +#endif + + +#if @GNULIB_IOCTL@ +# if @SYS_IOCTL_H_HAVE_WINSOCK2_H@ +# undef ioctl +# define ioctl rpl_ioctl +extern int ioctl (int fd, int request, ... /* {void *,char *} arg */); +# endif +#elif @SYS_IOCTL_H_HAVE_WINSOCK2_H@ +# undef ioctl +# define ioctl ioctl_used_without_requesting_gnulib_module_ioctl +#elif defined GNULIB_POSIXCHECK +# undef ioctl +# define ioctl(f,c,a) \ + (GL_LINK_WARNING ("ioctl does not portably work on sockets - " \ + "use gnulib module ioctl for portability"), \ + ioctl (f, c, a)) +#endif + + +#ifdef __cplusplus +} +#endif + + +#endif /* _GL_SYS_IOCTL_H */ +#endif /* _GL_SYS_IOCTL_H */ diff --git a/m4/sys_ioctl_h.m4 b/m4/sys_ioctl_h.m4 new file mode 100644 index 000000000..5488039b6 --- /dev/null +++ b/m4/sys_ioctl_h.m4 @@ -0,0 +1,60 @@ +# sys_ioctl_h.m4 serial 1 +dnl Copyright (C) 2008 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Written by Bruno Haible. + +AC_DEFUN([gl_SYS_IOCTL_H], +[ + dnl Use AC_REQUIRE here, so that the default behavior below is expanded + dnl once only, before all statements that occur in other macros. + AC_REQUIRE([gl_SYS_IOCTL_H_DEFAULTS]) + + AC_CHECK_HEADERS_ONCE([sys/ioctl.h]) + if test $ac_cv_header_sys_ioctl_h = yes; then + HAVE_SYS_IOCTL_H=1 + dnl Test whether declares ioctl(), or whether some other + dnl header file, such as or , is needed for that. + AC_CACHE_CHECK([whether declares ioctl], + [gl_cv_decl_ioctl_in_sys_ioctl_h], + [AC_CHECK_DECL([ioctl], + [gl_cv_decl_ioctl_in_sys_ioctl_h=yes], + [gl_cv_decl_ioctl_in_sys_ioctl_h=no], + [#include ]) + ]) + if test $gl_cv_decl_ioctl_in_sys_ioctl_h != yes; then + SYS_IOCTL_H='sys/ioctl.h' + fi + else + HAVE_SYS_IOCTL_H=0 + SYS_IOCTL_H='sys/ioctl.h' + fi + AC_SUBST([HAVE_SYS_IOCTL_H]) + dnl Execute this unconditionally, because SYS_IOCTL_H may be set by other + dnl modules, after this code is executed. + gl_CHECK_NEXT_HEADERS([sys/ioctl.h]) +]) + +dnl Unconditionally enables the replacement of . +AC_DEFUN([gl_REPLACE_SYS_IOCTL_H], +[ + AC_REQUIRE([gl_SYS_IOCTL_H_DEFAULTS]) + SYS_IOCTL_H='sys/ioctl.h' +]) + +AC_DEFUN([gl_SYS_IOCTL_MODULE_INDICATOR], +[ + dnl Use AC_REQUIRE here, so that the default settings are expanded once only. + AC_REQUIRE([gl_SYS_IOCTL_H_DEFAULTS]) + GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1 +]) + +AC_DEFUN([gl_SYS_IOCTL_H_DEFAULTS], +[ + GNULIB_IOCTL=0; AC_SUBST([GNULIB_IOCTL]) + dnl Assume proper GNU behavior unless another module says otherwise. + SYS_IOCTL_H_HAVE_WINSOCK2_H=0; AC_SUBST([SYS_IOCTL_H_HAVE_WINSOCK2_H]) + SYS_IOCTL_H=''; AC_SUBST([SYS_IOCTL_H]) +]) diff --git a/modules/sys_ioctl b/modules/sys_ioctl new file mode 100644 index 000000000..a00893c96 --- /dev/null +++ b/modules/sys_ioctl @@ -0,0 +1,46 @@ +Description: +A for systems with missing declarations. + +Files: +lib/sys_ioctl.in.h +m4/sys_ioctl_h.m4 + +Depends-on: +include_next +link-warning +unistd + +configure.ac: +gl_SYS_IOCTL_H +AC_PROG_MKDIR_P + +Makefile.am: +BUILT_SOURCES += $(SYS_IOCTL_H) + +# We need the following in order to create when the system +# does not have a complete one. +sys/ioctl.h: sys_ioctl.in.h + @MKDIR_P@ sys + rm -f $@-t $@ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ + sed -e 's|@''HAVE_SYS_IOCTL_H''@|$(HAVE_SYS_IOCTL_H)|g' \ + -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ + -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''NEXT_SYS_IOCTL_H''@|$(NEXT_SYS_IOCTL_H)|g' \ + -e 's|@''GNULIB_IOCTL''@|$(GNULIB_IOCTL)|g' \ + -e 's|@''SYS_IOCTL_H_HAVE_WINSOCK2_H''@|$(SYS_IOCTL_H_HAVE_WINSOCK2_H)|g' \ + -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ + < $(srcdir)/sys_ioctl.in.h; \ + } > $@-t + mv $@-t $@ +MOSTLYCLEANFILES += sys/ioctl.h sys/ioctl.h-t +MOSTLYCLEANDIRS += sys + +Include: +#include + +License: +LGPLv2+ + +Maintainer: +all -- 2.11.0