Mercurial > hg > octave-lyh > gnulib-hg
changeset 9907:be905220886f
Override <sys/socket.h> when it exists but is incomplete.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 13 Apr 2008 14:56:42 +0200 |
parents | 09359378ead6 |
children | a69cc9d85bcc |
files | ChangeLog doc/posix-headers/sys_socket.texi lib/sys_socket.in.h m4/sys_socket_h.m4 modules/sys_socket |
diffstat | 5 files changed, 59 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2008-04-13 Bruno Haible <bruno@clisp.org> + + * 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 <sys/socket.h> + also if it exists but lacks definitions of the SHUT_* macros. + * modules/sys_socket (Description): Update. + Reported by Elbert Pol <e.pol@chello.nl>. + 2008-04-13 Bruno Haible <bruno@clisp.org> * lib/localcharset.c (OS2): Don't redefine if already defined.
--- a/doc/posix-headers/sys_socket.texi +++ b/doc/posix-headers/sys_socket.texi @@ -13,6 +13,11 @@ @item This header file is not self-contained on some platforms: it requires @code{<sys/types.h>} 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:
--- 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 <sys/socket.h> - and on platforms where <sys/socket.h> cannot be included standalone. +/* This file is supposed to be used on platforms that lack <sys/socket.h>, + on platforms where <sys/socket.h> cannot be included standalone, and on + platforms where <sys/socket.h> 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 <sys/socket.h>. */ + +/* 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 <sys/socket.h>.
--- 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 @@ ]) if test $gl_cv_header_sys_socket_h_selfcontained = yes; then SYS_SOCKET_H='' + dnl If the shutdown function exists, <sys/socket.h> 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 <sys/socket.h> defines the SHUT_* macros], + [gl_cv_header_sys_socket_h_shut], + [ + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#include <sys/socket.h>]], + [[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 <sys/socket.h> replacement. gl_CHECK_NEXT_HEADERS([sys/socket.h]) if test $ac_cv_header_sys_socket_h = yes; then HAVE_SYS_SOCKET_H=1