bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sys/socket.h on mingw32 vs socklen (resend)


From: Simon Josefsson
Subject: Re: sys/socket.h on mingw32 vs socklen (resend)
Date: Tue, 10 Jan 2006 15:27:39 +0100
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux)

Bruno Haible <address@hidden> writes:

> Simon Josefsson wrote:
>> >> + rmdir sys
>> >
>> > Remove the directory only when it exists and is empty. (Some systems
>> > create files in your directories without being asked for, e.g. .DS_Store
>> > on MacOS X.)
>>
>> How do I test for that in a portable way?
>
> Let rmdir do the test, and ignore a possible error:
>
>       -rmdir sys 2>/dev/null

Of course.  Added.

>> Applications that need socklen_t should probably depend on
>> the sys/socket.h module.  Perhaps the socklen_t module should depend
>> on the sys_socket module?
>
> I don't think so: Applications that use <netdb.h> but not <sys/socket.h>
> are also supposed to be able to use socklen_t. See
> http://www.opengroup.org/onlinepubs/009695399/basedefs/netdb.h.html

Right.

>> +AC_DEFUN([gl_HEADER_SYS_SOCKET],
>> +[
>> +  AC_CHECK_HEADERS_ONCE([sys/socket.h])
>> +  if test $ac_cv_header_sys_socket_h = yes; then
>> +    SYS_SOCKET_H=''
>> +  else
>> +    AC_CHECK_HEADERS_ONCE([winsock2.h])
>
> Here a test for ws2tcpip.h is missing.

Added.

>> --- /dev/null        1 Jan 1970 00:00:00 -0000
>> +++ modules/sys_socket       9 Jan 2006 16:24:40 -0000
>> @@ -0,0 +1,36 @@
>> +Description:
>> +A <sys/socket.h> for systems lacking it.
>> +(Currently only useful for mingw32, it will simply include winsock2.h.)
>
> The second line doesn't belong here, IMO, since it describes the
> implementation of the module, which can change over time if we encounter
> more bad systems.

Removed.

> Otherwise it looks fine, please commit!

I installed the patch below.

Thanks!

Index: lib/socket_.h
===================================================================
RCS file: lib/socket_.h
diff -N lib/socket_.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ lib/socket_.h       10 Jan 2006 14:28:10 -0000
@@ -0,0 +1,37 @@
+/* Provide a sys/socket header file for systems lacking it (read: mingw32).
+   Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+   Written by Simon Josefsson.
+
+   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 _SYS_SOCKET_H
+#define _SYS_SOCKET_H
+
+/* This file is supposed to be used on platforms that lack
+   sys/socket.h.  It is intended to provide definitions and prototypes
+   needed by an application.
+
+   Currently only mingw32 is supported, which has the header files
+   winsock2.h and ws2tcpip.h that declare the sys/socket.h definitions
+   we need. */
+
+#if HAVE_WINSOCK2_H
+# include <winsock2.h>
+#endif
+#if HAVE_WS2TCPIP_H
+# include <ws2tcpip.h>
+#endif
+
+#endif /* _SYS_SOCKET_H */
Index: lib/ChangeLog
===================================================================
RCS file: /sources/gnulib/gnulib/lib/ChangeLog,v
retrieving revision 1.1069
diff -u -p -r1.1069 ChangeLog
--- lib/ChangeLog       10 Jan 2006 13:52:11 -0000      1.1069
+++ lib/ChangeLog       10 Jan 2006 14:28:12 -0000
@@ -1,3 +1,7 @@
+2006-01-10  Simon Josefsson  <address@hidden>
+
+       * socket_.h: New file.
+
 2006-01-10  Bruno Haible  <address@hidden>
 
        * localcharset.c: Update from GNU gettext.
Index: m4/sys_socket_h.m4
===================================================================
RCS file: m4/sys_socket_h.m4
diff -N m4/sys_socket_h.m4
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ m4/sys_socket_h.m4  10 Jan 2006 14:28:12 -0000
@@ -0,0 +1,19 @@
+# sys_socket_h.m4 serial 1
+dnl Copyright (C) 2005, 2006 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 From Simon Josefsson.
+
+AC_DEFUN([gl_HEADER_SYS_SOCKET],
+[
+  AC_CHECK_HEADERS_ONCE([sys/socket.h])
+  if test $ac_cv_header_sys_socket_h = yes; then
+    SYS_SOCKET_H=''
+  else
+    AC_CHECK_HEADERS_ONCE([winsock2.h ws2tcpip.h])
+    SYS_SOCKET_H='sys/socket.h'
+  fi
+  AC_SUBST(SYS_SOCKET_H)
+])
Index: m4/ChangeLog
===================================================================
RCS file: /sources/gnulib/gnulib/m4/ChangeLog,v
retrieving revision 1.767
diff -u -p -r1.767 ChangeLog
--- m4/ChangeLog        10 Jan 2006 13:57:21 -0000      1.767
+++ m4/ChangeLog        10 Jan 2006 14:28:13 -0000
@@ -1,3 +1,7 @@
+2006-01-10  Simon Josefsson  <address@hidden>
+
+       * sys_socket_h.m4: New file.
+
 2006-01-10  Bruno Haible  <address@hidden>
 
        * localcharset.m4 (gl_LOCALCHARSET): Also test for getc_unlocked.
Index: ChangeLog
===================================================================
RCS file: /sources/gnulib/gnulib/ChangeLog,v
retrieving revision 1.462
diff -u -p -r1.462 ChangeLog
--- ChangeLog   10 Jan 2006 13:37:12 -0000      1.462
+++ ChangeLog   10 Jan 2006 14:28:13 -0000
@@ -1,3 +1,7 @@
+2006-01-10  Simon Josefsson  <address@hidden>
+
+       * modules/sys_socket: New file.
+
 2006-01-07  Bruno Haible  <address@hidden>
 
        * gnulib-tool (func_emit_tests_Makefile_am): Emit an empty SUBDIR
Index: modules/sys_socket
===================================================================
RCS file: modules/sys_socket
diff -N modules/sys_socket
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ modules/sys_socket  10 Jan 2006 14:28:13 -0000
@@ -0,0 +1,35 @@
+Description:
+A <sys/socket.h> for systems lacking it.
+
+Files:
+lib/socket_.h
+m4/sys_socket_h.m4
+
+Depends-on:
+
+configure.ac:
+gl_HEADER_SYS_SOCKET
+
+Makefile.am:
+BUILT_SOURCES += $(SYS_SOCKET_H)
+EXTRA_DIST += socket_.h
+
+# We need the following in order to create <sys/socket.h> when the system
+# doesn't have one that works with the given compiler.
+sys/socket.h: socket_.h
+       test -d sys || mkdir sys
+       cp $(srcdir)/socket_.h address@hidden
+       mv address@hidden $@
+MOSTLYCLEANFILES += sys/socket.h sys/socket.h-t
+
+mostlyclean-local:
+       -rmdir sys 2>/dev/null
+
+Include:
+#include <sys/socket.h>
+
+License:
+LGPL
+
+Maintainer:
+Simon Josefsson




reply via email to

[Prev in Thread] Current Thread [Next in Thread]