From 95454b6b2dbb9f57bf5623a0fd8d40fb2433c4d7 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 13 Apr 2008 14:56:42 +0200 Subject: [PATCH] Override when it exists but is incomplete. --- ChangeLog | 9 +++++++++ doc/posix-headers/sys_socket.texi | 5 +++++ lib/sys_socket.in.h | 27 ++++++++++++++++++++++----- m4/sys_socket_h.m4 | 25 ++++++++++++++++++++++--- modules/sys_socket | 2 +- 5 files changed, 59 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 44deb66a8..c2117a8df 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2008-04-13 Bruno Haible + * doc/posix-headers/sys_socket.texi: Document the problem on EMX. + * lib/sys_socket.in.h (SHUT_RD, SHUT_WR, SHUT_RDWR): Define if missing. + * m4/sys_socket_h.m4 (gl_HEADER_SYS_SOCKET): Replace + also if it exists but lacks definitions of the SHUT_* macros. + * modules/sys_socket (Description): Update. + Reported by Elbert Pol . + +2008-04-13 Bruno Haible + * lib/localcharset.c (OS2): Don't redefine if already defined. Reported by Elbert Pol . diff --git a/doc/posix-headers/sys_socket.texi b/doc/posix-headers/sys_socket.texi index de71813f3..4680fa2f9 100644 --- a/doc/posix-headers/sys_socket.texi +++ b/doc/posix-headers/sys_socket.texi @@ -13,6 +13,11 @@ mingw. @item This header file is not self-contained on some platforms: it requires @code{} to be included first. +@item +This header file is lacking the @code{SHUT_RD}, @code{SHUT_WR}, +@code{SHUT_RDWR} macros on some platforms, despite having the @code{shutdown} +functions: +emx+gcc. @end itemize Portability problems not fixed by Gnulib: diff --git a/lib/sys_socket.in.h b/lib/sys_socket.in.h index c25b6ab84..d94f425fc 100644 --- a/lib/sys_socket.in.h +++ b/lib/sys_socket.in.h @@ -1,5 +1,6 @@ -/* Provide a sys/socket header file for systems lacking it (read: MinGW). - Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc. +/* Provide a sys/socket header file for systems lacking it (read: MinGW) + and for systems where it is incomplete. + Copyright (C) 2005-2008 Free Software Foundation, Inc. Written by Simon Josefsson. This program is free software; you can redistribute it and/or modify @@ -16,8 +17,9 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -/* This file is supposed to be used on platforms that lack - and on platforms where cannot be included standalone. +/* This file is supposed to be used on platforms that lack , + on platforms where cannot be included standalone, and on + platforms where does not provide all necessary definitions. It is intended to provide definitions and prototypes needed by an application. */ @@ -37,7 +39,22 @@ #ifndef _GL_SYS_SOCKET_H #define _GL_SYS_SOCKET_H -#if !@HAVE_SYS_SOCKET_H@ +#if @HAVE_SYS_SOCKET_H@ + +/* A platform that has . */ + +/* For shutdown(). */ +# if !defined SHUT_RD +# define SHUT_RD 0 +# endif +# if !defined SHUT_WR +# define SHUT_WR 1 +# endif +# if !defined SHUT_RDWR +# define SHUT_RDWR 2 +# endif + +#else /* A platform that lacks . diff --git a/m4/sys_socket_h.m4 b/m4/sys_socket_h.m4 index d9659c2d7..887cff80e 100644 --- a/m4/sys_socket_h.m4 +++ b/m4/sys_socket_h.m4 @@ -1,5 +1,5 @@ -# sys_socket_h.m4 serial 4 -dnl Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc. +# sys_socket_h.m4 serial 5 +dnl Copyright (C) 2005-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. @@ -17,9 +17,28 @@ AC_DEFUN([gl_HEADER_SYS_SOCKET], ]) if test $gl_cv_header_sys_socket_h_selfcontained = yes; then SYS_SOCKET_H='' + dnl If the shutdown function exists, should define + dnl SHUT_RD, SHUT_WR, SHUT_RDWR. + AC_CHECK_FUNCS([shutdown]) + if test $ac_cv_func_shutdown = yes; then + AC_CACHE_CHECK([whether defines the SHUT_* macros], + [gl_cv_header_sys_socket_h_shut], + [ + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#include ]], + [[int a[] = { SHUT_RD, SHUT_WR, SHUT_RDWR };]])], + [gl_cv_header_sys_socket_h_shut=yes], + [gl_cv_header_sys_socket_h_shut=no]) + ]) + if test $gl_cv_header_sys_socket_h_shut = no; then + SYS_SOCKET_H='sys/socket.h' + fi + fi else SYS_SOCKET_H='sys/socket.h' - + fi + if test -n "$SYS_SOCKET_H"; then + dnl Check prerequisites of the replacement. gl_CHECK_NEXT_HEADERS([sys/socket.h]) if test $ac_cv_header_sys_socket_h = yes; then HAVE_SYS_SOCKET_H=1 diff --git a/modules/sys_socket b/modules/sys_socket index 0c7b6dbb3..36af3cbca 100644 --- a/modules/sys_socket +++ b/modules/sys_socket @@ -1,5 +1,5 @@ Description: -A for systems lacking it. +A POSIX-like . Files: lib/sys_socket.in.h -- 2.11.0