+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.
@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:
-/* 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
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. */
#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>.
-# 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.
])
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
Description:
-A <sys/socket.h> for systems lacking it.
+A POSIX-like <sys/socket.h>.
Files:
lib/sys_socket.in.h