New modules 'accept', 'bind', 'connect', 'getpeername', 'getsockname', 'getsockopt...
authorBruno Haible <bruno@clisp.org>
Mon, 6 Oct 2008 00:15:14 +0000 (02:15 +0200)
committerBruno Haible <bruno@clisp.org>
Mon, 6 Oct 2008 00:15:14 +0000 (02:15 +0200)
33 files changed:
ChangeLog
doc/posix-functions/accept.texi
doc/posix-functions/bind.texi
doc/posix-functions/connect.texi
doc/posix-functions/getpeername.texi
doc/posix-functions/getsockname.texi
doc/posix-functions/getsockopt.texi
doc/posix-functions/listen.texi
doc/posix-functions/recv.texi
doc/posix-functions/recvfrom.texi
doc/posix-functions/send.texi
doc/posix-functions/sendto.texi
doc/posix-functions/setsockopt.texi
doc/posix-functions/socket.texi
lib/sys_socket.in.h
lib/winsock.c
m4/sys_socket_h.m4
modules/accept [new file with mode: 0644]
modules/bind [new file with mode: 0644]
modules/connect [new file with mode: 0644]
modules/getpeername [new file with mode: 0644]
modules/getsockname [new file with mode: 0644]
modules/getsockopt [new file with mode: 0644]
modules/listen [new file with mode: 0644]
modules/poll-tests
modules/recv [new file with mode: 0644]
modules/recvfrom [new file with mode: 0644]
modules/select-tests
modules/send [new file with mode: 0644]
modules/sendto [new file with mode: 0644]
modules/setsockopt [new file with mode: 0644]
modules/socket [new file with mode: 0644]
modules/sys_socket

index 3c153a7..b5de6d8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,59 @@
 2008-10-05  Bruno Haible  <bruno@clisp.org>
 
+       * modules/accept: New file.
+       * modules/bind: New file.
+       * modules/connect: New file.
+       * modules/getpeername: New file.
+       * modules/getsockname: New file.
+       * modules/getsockopt: New file.
+       * modules/listen: New file.
+       * modules/recv: New file.
+       * modules/recvfrom: New file.
+       * modules/send: New file.
+       * modules/sendto: New file.
+       * modules/setsockopt: New file.
+       * modules/socket: New file.
+       * lib/sys_socket.in.h: Include the GL_LINK_WARNING definition.
+       (socket, connect, accept, bind, getpeername, getsockname, getsockopt,
+       listen, recv, send, recvfrom, sendto, setsockopt): Declare only when
+       the particular module is requested. Add a link warning when the
+       particular module is not requested.
+       * lib/winsock.c (rpl_socket, rpl_connect, rpl_accept, rpl_bind,
+       rpl_getpeername, rpl_getsockname, rpl_getsockopt, rpl_listen, rpl_recv,
+       rpl_send, rpl_recvfrom, rpl_sendto, rpl_setsockopt): Define only when
+       the particular module is requested.
+       * m4/sys_socket_h.m4 (gl_SYS_SOCKET_MODULE_INDICATOR,
+       gl_SYS_SOCKET_H_DEFAULTS): New macros.
+       (gl_HEADER_SYS_SOCKET): Require gl_SYS_SOCKET_H_DEFAULTS.
+       * modules/sys_socket (Depends-on): Add link-warning.
+       (Makeifle.am): Substitute GNULIB_SOCKET, GNULIB_CONNECT, GNULIB_ACCEPT,
+       GNULIB_BIND, GNULIB_GETPEERNAME, GNULIB_GETSOCKNAME, GNULIB_GETSOCKOPT,
+       GNULIB_LISTEN, GNULIB_RECV, GNULIB_SEND, GNULIB_RECVFROM,
+       GNULIB_SENDTO, GNULIB_SETSOCKOPT, and the definition of
+       GL_LINK_WARNING.
+       * doc/posix-functions/accept.texi: Mention the new module 'accept'.
+       * doc/posix-functions/bind.texi: Mention the new module 'bind'.
+       * doc/posix-functions/connect.texi: Mention the new module 'connect'.
+       * doc/posix-functions/getpeername.texi: Mention the new module
+       'getpeername'.
+       * doc/posix-functions/getsockname.texi: Mention the new module
+       'getsockname'.
+       * doc/posix-functions/getsockopt.texi: Mention the new module
+       'getsockopt'.
+       * doc/posix-functions/listen.texi: Mention the new module 'listen'.
+       * doc/posix-functions/recv.texi: Mention the new module 'recv'.
+       * doc/posix-functions/recvfrom.texi: Mention the new module 'recvfrom'.
+       * doc/posix-functions/send.texi: Mention the new module 'send'.
+       * doc/posix-functions/sendto.texi: Mention the new module 'sendto'.
+       * doc/posix-functions/setsockopt.texi: Mention the new module
+       'setsockopt'.
+       * doc/posix-functions/socket.texi: Mention the new module 'socket'.
+       * modules/poll-tests (Depends-on): Add socket, bind, getsockopt,
+       listen, connect, accept.
+       * modules/select-tests (Depends-on): Likewise.
+
+2008-10-05  Bruno Haible  <bruno@clisp.org>
+
        * lib/winsock.c (strerror): Remove unused #undef.
        (rpl_close): Remove unused local variable.
 
index be125cf..18ddee7 100644 (file)
@@ -4,7 +4,7 @@
 
 POSIX specification: @url{http://www.opengroup.org/susv3xsh/accept.html}
 
-Gnulib module: sys_socket
+Gnulib module: accept
 
 Portability problems fixed by Gnulib:
 @itemize
index 5a2a8ff..0be1553 100644 (file)
@@ -4,7 +4,7 @@
 
 POSIX specification: @url{http://www.opengroup.org/susv3xsh/bind.html}
 
-Gnulib module: sys_socket
+Gnulib module: bind
 
 Portability problems fixed by Gnulib:
 @itemize
index 5a832c9..fe03a0b 100644 (file)
@@ -4,7 +4,7 @@
 
 POSIX specification: @url{http://www.opengroup.org/susv3xsh/connect.html}
 
-Gnulib module: sys_socket
+Gnulib module: connect
 
 Portability problems fixed by Gnulib:
 @itemize
index 0cd05a7..753533e 100644 (file)
@@ -4,7 +4,7 @@
 
 POSIX specification: @url{http://www.opengroup.org/susv3xsh/getpeername.html}
 
-Gnulib module: sys_socket
+Gnulib module: getpeername
 
 Portability problems fixed by Gnulib:
 @itemize
index d45469a..f8aadcb 100644 (file)
@@ -4,7 +4,7 @@
 
 POSIX specification: @url{http://www.opengroup.org/susv3xsh/getsockname.html}
 
-Gnulib module: sys_socket
+Gnulib module: getsockname
 
 Portability problems fixed by Gnulib:
 @itemize
index 34863f1..c77617c 100644 (file)
@@ -4,7 +4,7 @@
 
 POSIX specification: @url{http://www.opengroup.org/susv3xsh/getsockopt.html}
 
-Gnulib module: sys_socket
+Gnulib module: getsockopt
 
 Portability problems fixed by Gnulib:
 @itemize
index 02631fb..176c56d 100644 (file)
@@ -4,7 +4,7 @@
 
 POSIX specification: @url{http://www.opengroup.org/susv3xsh/listen.html}
 
-Gnulib module: sys_socket
+Gnulib module: listen
 
 Portability problems fixed by Gnulib:
 @itemize
index 6204b09..63c3e0d 100644 (file)
@@ -4,7 +4,7 @@
 
 POSIX specification: @url{http://www.opengroup.org/susv3xsh/recv.html}
 
-Gnulib module: sys_socket
+Gnulib module: recv
 
 Portability problems fixed by Gnulib:
 @itemize
index 9b15e13..78e4c57 100644 (file)
@@ -4,7 +4,7 @@
 
 POSIX specification: @url{http://www.opengroup.org/susv3xsh/recvfrom.html}
 
-Gnulib module: sys_socket
+Gnulib module: recvfrom
 
 Portability problems fixed by Gnulib:
 @itemize
index f7c9a4a..d9d8ded 100644 (file)
@@ -4,7 +4,7 @@
 
 POSIX specification: @url{http://www.opengroup.org/susv3xsh/send.html}
 
-Gnulib module: sys_socket
+Gnulib module: send
 
 Portability problems fixed by Gnulib:
 @itemize
index 47e38d2..e8b9083 100644 (file)
@@ -4,7 +4,7 @@
 
 POSIX specification: @url{http://www.opengroup.org/susv3xsh/sendto.html}
 
-Gnulib module: sys_socket
+Gnulib module: sendto
 
 Portability problems fixed by Gnulib:
 @itemize
index f439971..5d05f87 100644 (file)
@@ -4,7 +4,7 @@
 
 POSIX specification: @url{http://www.opengroup.org/susv3xsh/setsockopt.html}
 
-Gnulib module: sys_socket
+Gnulib module: setsockopt
 
 Portability problems fixed by Gnulib:
 @itemize
index 9675f32..8b2f0b4 100644 (file)
@@ -4,7 +4,7 @@
 
 POSIX specification: @url{http://www.opengroup.org/susv3xsh/socket.html}
 
-Gnulib module: sys_socket
+Gnulib module: socket
 
 Portability problems fixed by Gnulib:
 @itemize
index 6d7dc76..13729c6 100644 (file)
@@ -98,6 +98,8 @@
 #  define SHUT_RDWR SD_BOTH
 # endif
 
+/* The definition of GL_LINK_WARNING is copied here.  */
+
 # if @HAVE_WINSOCK2_H@
 /* Include headers needed by the emulation code.  */
 #  include <sys/types.h>
 
 typedef int socklen_t;
 
-#  ifdef __cplusplus
+# endif
+
+# ifdef __cplusplus
 extern "C" {
-#  endif
+# endif
+
+# if @HAVE_WINSOCK2_H@
 
 /* Re-define FD_ISSET to avoid a WSA call while we are not using
    network sockets.  */
@@ -128,62 +134,251 @@ rpl_fd_isset (int fd, fd_set * set)
 #  undef FD_ISSET
 #  define FD_ISSET(fd, set) rpl_fd_isset(fd, set)
 
+# endif
+
 /* Wrap everything else to use libc file descriptors for sockets.  */
 
+# if @HAVE_WINSOCK2_H@
 #  undef close
 #  define close                        rpl_close
+extern int rpl_close(int);
+# endif
+
+# if @GNULIB_SOCKET@
+#  if @HAVE_WINSOCK2_H@
+#   undef socket
+#   define socket              rpl_socket
+extern int rpl_socket (int, int, int protocol);
+#  endif
+# elif @HAVE_WINSOCK2_H@
 #  undef socket
-#  define socket               rpl_socket
+#  define socket socket_used_without_requesting_gnulib_module_socket
+# elif defined GNULIB_POSIXCHECK
+#  undef socket
+#  define socket(d,t,p) \
+     (GL_LINK_WARNING ("socket is not always POSIX compliant - " \
+                       "use gnulib module socket for portability"), \
+      socket (d, t, p))
+# endif
+
+# if @GNULIB_CONNECT@
+#  if @HAVE_WINSOCK2_H@
+#   undef connect
+#   define connect             rpl_connect
+extern int rpl_connect (int, struct sockaddr *, int);
+#  endif
+# elif @HAVE_WINSOCK2_H@
 #  undef connect
-#  define connect              rpl_connect
+#  define connect socket_used_without_requesting_gnulib_module_connect
+# elif defined GNULIB_POSIXCHECK
+#  undef connect
+#  define connect(s,a,l) \
+     (GL_LINK_WARNING ("connect is not always POSIX compliant - " \
+                       "use gnulib module connect for portability"), \
+      connect (s, a, l))
+# endif
+
+# if @GNULIB_ACCEPT@
+#  if @HAVE_WINSOCK2_H@
+#   undef accept
+#   define accept              rpl_accept
+extern int rpl_accept (int, struct sockaddr *, int *);
+#  endif
+# elif @HAVE_WINSOCK2_H@
+#  undef accept
+#  define accept accept_used_without_requesting_gnulib_module_accept
+# elif defined GNULIB_POSIXCHECK
 #  undef accept
-#  define accept               rpl_accept
+#  define accept(s,a,l) \
+     (GL_LINK_WARNING ("accept is not always POSIX compliant - " \
+                       "use gnulib module accept for portability"), \
+      accept (s, a, l))
+# endif
+
+# if @GNULIB_BIND@
+#  if @HAVE_WINSOCK2_H@
+#   undef bind
+#   define bind                        rpl_bind
+extern int rpl_bind (int, struct sockaddr *, int);
+#  endif
+# elif @HAVE_WINSOCK2_H@
 #  undef bind
-#  define bind                 rpl_bind
+#  define bind bind_used_without_requesting_gnulib_module_bind
+# elif defined GNULIB_POSIXCHECK
+#  undef bind
+#  define bind(s,a,l) \
+     (GL_LINK_WARNING ("bind is not always POSIX compliant - " \
+                       "use gnulib module bind for portability"), \
+      bind (s, a, l))
+# endif
+
+# if @GNULIB_GETPEERNAME@
+#  if @HAVE_WINSOCK2_H@
+#   undef getpeername
+#   define getpeername         rpl_getpeername
+extern int rpl_getpeername (int, struct sockaddr *, int *);
+#  endif
+# elif @HAVE_WINSOCK2_H@
+#  undef getpeername
+#  define getpeername getpeername_used_without_requesting_gnulib_module_getpeername
+# elif defined GNULIB_POSIXCHECK
 #  undef getpeername
-#  define getpeername          rpl_getpeername
+#  define getpeername(s,a,l) \
+     (GL_LINK_WARNING ("getpeername is not always POSIX compliant - " \
+                       "use gnulib module getpeername for portability"), \
+      getpeername (s, a, l))
+# endif
+
+# if @GNULIB_GETSOCKNAME@
+#  if @HAVE_WINSOCK2_H@
+#   undef getsockname
+#   define getsockname         rpl_getsockname
+extern int rpl_getsockname (int, struct sockaddr *, int *);
+#  endif
+# elif @HAVE_WINSOCK2_H@
+#  undef getsockname
+#  define getsockname getsockname_used_without_requesting_gnulib_module_getsockname
+# elif defined GNULIB_POSIXCHECK
 #  undef getsockname
-#  define getsockname          rpl_getsockname
+#  define getsockname(s,a,l) \
+     (GL_LINK_WARNING ("getsockname is not always POSIX compliant - " \
+                       "use gnulib module getsockname for portability"), \
+      getsockname (s, a, l))
+# endif
+
+# if @GNULIB_GETSOCKOPT@
+#  if @HAVE_WINSOCK2_H@
+#   undef getsockopt
+#   define getsockopt          rpl_getsockopt
+extern int rpl_getsockopt (int, int, int, void *, int *);
+#  endif
+# elif @HAVE_WINSOCK2_H@
+#  undef getsockopt
+#  define getsockopt getsockopt_used_without_requesting_gnulib_module_getsockopt
+# elif defined GNULIB_POSIXCHECK
 #  undef getsockopt
-#  define getsockopt           rpl_getsockopt
+#  define getsockopt(s,lvl,o,v,l) \
+     (GL_LINK_WARNING ("getsockopt is not always POSIX compliant - " \
+                       "use gnulib module getsockopt for portability"), \
+      getsockopt (s, lvl, o, v, l))
+# endif
+
+# if @GNULIB_LISTEN@
+#  if @HAVE_WINSOCK2_H@
+#   undef listen
+#   define listen              rpl_listen
+extern int rpl_listen (int, int);
+#  endif
+# elif @HAVE_WINSOCK2_H@
+#  undef listen
+#  define listen listen_used_without_requesting_gnulib_module_listen
+# elif defined GNULIB_POSIXCHECK
 #  undef listen
-#  define listen               rpl_listen
+#  define listen(s,b) \
+     (GL_LINK_WARNING ("listen is not always POSIX compliant - " \
+                       "use gnulib module listen for portability"), \
+      listen (s, b))
+# endif
+
+# if @HAVE_WINSOCK2_H@
 #  undef ioctl
 #  define ioctl                        rpl_ioctl
+extern int rpl_ioctl (int, unsigned long, char *);
+# endif
+
+# if @GNULIB_RECV@
+#  if @HAVE_WINSOCK2_H@
+#   undef recv
+#   define recv                        rpl_recv
+extern int rpl_recv (int, void *, int, int);
+#  endif
+# elif @HAVE_WINSOCK2_H@
 #  undef recv
-#  define recv                 rpl_recv
+#  define recv recv_used_without_requesting_gnulib_module_recv
+# elif defined GNULIB_POSIXCHECK
+#  undef recv
+#  define recv(s,b,n,f) \
+     (GL_LINK_WARNING ("recv is not always POSIX compliant - " \
+                       "use gnulib module recv for portability"), \
+      recv (s, b, n, f))
+# endif
+
+# if @GNULIB_SEND@
+#  if @HAVE_WINSOCK2_H@
+#   undef send
+#   define send                        rpl_send
+extern int rpl_send (int, const void *, int, int);
+#  endif
+# elif @HAVE_WINSOCK2_H@
+#  undef send
+#  define send send_used_without_requesting_gnulib_module_send
+# elif defined GNULIB_POSIXCHECK
 #  undef send
-#  define send                 rpl_send
+#  define send(s,b,n,f) \
+     (GL_LINK_WARNING ("send is not always POSIX compliant - " \
+                       "use gnulib module send for portability"), \
+      send (s, b, n, f))
+# endif
+
+# if @GNULIB_RECVFROM@
+#  if @HAVE_WINSOCK2_H@
+#   undef recvfrom
+#   define recvfrom            rpl_recvfrom
+extern int rpl_recvfrom (int, void *, int, int, struct sockaddr *, int *);
+#  endif
+# elif @HAVE_WINSOCK2_H@
 #  undef recvfrom
-#  define recvfrom             rpl_recvfrom
+#  define recvfrom recvfrom_used_without_requesting_gnulib_module_recvfrom
+# elif defined GNULIB_POSIXCHECK
+#  undef recvfrom
+#  define recvfrom(s,b,n,f,a,l) \
+     (GL_LINK_WARNING ("recvfrom is not always POSIX compliant - " \
+                       "use gnulib module recvfrom for portability"), \
+      recvfrom (s, b, n, f, a, l))
+# endif
+
+# if @GNULIB_SENDTO@
+#  if @HAVE_WINSOCK2_H@
+#   undef sendto
+#   define sendto              rpl_sendto
+extern int rpl_sendto (int, const void *, int, int, struct sockaddr *, int);
+#  endif
+# elif @HAVE_WINSOCK2_H@
+#  undef sendto
+#  define sendto sendto_used_without_requesting_gnulib_module_sendto
+# elif defined GNULIB_POSIXCHECK
 #  undef sendto
-#  define sendto               rpl_sendto
+#  define sendto(s,b,n,f,a,l) \
+     (GL_LINK_WARNING ("sendto is not always POSIX compliant - " \
+                       "use gnulib module sendto for portability"), \
+      sendto (s, b, n, f, a, l))
+# endif
+
+# if @GNULIB_SETSOCKOPT@
+#  if @HAVE_WINSOCK2_H@
+#   undef setsockopt
+#   define setsockopt          rpl_setsockopt
+extern int rpl_setsockopt (int, int, int, const void *, int);
+#  endif
+# elif @HAVE_WINSOCK2_H@
+#  undef setsockopt
+#  define setsockopt setsockopt_used_without_requesting_gnulib_module_setsockopt
+# elif defined GNULIB_POSIXCHECK
 #  undef setsockopt
-#  define setsockopt           rpl_setsockopt
+#  define setsockopt(s,lvl,o,v,l) \
+     (GL_LINK_WARNING ("setsockopt is not always POSIX compliant - " \
+                       "use gnulib module setsockopt for portability"), \
+      setsockopt (s, lvl, o, v, l))
+# endif
+
+# if @HAVE_WINSOCK2_H@
 #  undef select
 #  define select               select_used_without_including_sys_select_h
+# endif
 
-extern int rpl_close(int);
-extern int rpl_socket (int, int, int protocol);
-extern int rpl_connect (int, struct sockaddr *, int);
-extern int rpl_accept (int, struct sockaddr *, int *);
-extern int rpl_bind (int, struct sockaddr *, int);
-extern int rpl_getpeername (int, struct sockaddr *, int *);
-extern int rpl_getsockname (int, struct sockaddr *, int *);
-extern int rpl_getsockopt (int, int, int, void *, int *);
-extern int rpl_listen (int, int);
-extern int rpl_ioctl (int, unsigned long, char *);
-extern int rpl_recv (int, void *, int, int);
-extern int rpl_send (int, const void *, int, int);
-extern int rpl_recvfrom (int, void *, int, int, struct sockaddr *, int *);
-extern int rpl_sendto (int, const void *, int, int, struct sockaddr *, int);
-extern int rpl_setsockopt (int, int, int, const void *, int);
-
-#  ifdef __cplusplus
+# ifdef __cplusplus
 }
-#  endif
-
-# endif /* HAVE_WINSOCK2_H */
+# endif
 
 #endif /* HAVE_SYS_SOCKET_H */
 
index ba3e05f..00609cf 100644 (file)
@@ -104,6 +104,7 @@ set_winsock_errno (void)
     }
 }
 
+#if GNULIB_SOCKET
 int
 rpl_socket (int domain, int type, int protocol)
 {
@@ -119,8 +120,9 @@ rpl_socket (int domain, int type, int protocol)
   else
     return SOCKET_TO_FD (fh);
 }
+#endif
 
-
+#if GNULIB_CONNECT
 int
 rpl_connect (int fd, struct sockaddr *sockaddr, int len)
 {
@@ -138,7 +140,9 @@ rpl_connect (int fd, struct sockaddr *sockaddr, int len)
 
   return r;
 }
+#endif
 
+#if GNULIB_ACCEPT
 int
 rpl_accept (int fd, struct sockaddr *addr, int *addrlen)
 {
@@ -151,7 +155,9 @@ rpl_accept (int fd, struct sockaddr *addr, int *addrlen)
   else
     return SOCKET_TO_FD (fh);
 }
+#endif
 
+#if GNULIB_BIND
 int
 rpl_bind (int fd, struct sockaddr *sockaddr, int len)
 {
@@ -162,7 +168,9 @@ rpl_bind (int fd, struct sockaddr *sockaddr, int len)
 
   return r;
 }
+#endif
 
+#if GNULIB_GETPEERNAME
 int
 rpl_getpeername (int fd, struct sockaddr *addr, int *addrlen)
 {
@@ -173,7 +181,9 @@ rpl_getpeername (int fd, struct sockaddr *addr, int *addrlen)
 
   return r;
 }
+#endif
 
+#if GNULIB_GETSOCKNAME
 int
 rpl_getsockname (int fd, struct sockaddr *addr, int *addrlen)
 {
@@ -184,7 +194,9 @@ rpl_getsockname (int fd, struct sockaddr *addr, int *addrlen)
 
   return r;
 }
+#endif
 
+#if GNULIB_GETSOCKOPT
 int
 rpl_getsockopt (int fd, int level, int optname, void *optval, int *optlen)
 {
@@ -195,7 +207,9 @@ rpl_getsockopt (int fd, int level, int optname, void *optval, int *optlen)
 
   return r;
 }
+#endif
 
+#if GNULIB_LISTEN
 int
 rpl_listen (int fd, int backlog)
 {
@@ -206,6 +220,7 @@ rpl_listen (int fd, int backlog)
 
   return r;
 }
+#endif
 
 int
 rpl_ioctl (int fd, unsigned long req, char *buf)
@@ -218,6 +233,7 @@ rpl_ioctl (int fd, unsigned long req, char *buf)
   return r;
 }
 
+#if GNULIB_RECV
 int
 rpl_recv (int fd, void *buf, int len, int flags)
 {
@@ -228,7 +244,9 @@ rpl_recv (int fd, void *buf, int len, int flags)
 
   return r;
 }
+#endif
 
+#if GNULIB_SEND
 int
 rpl_send (int fd, const void *buf, int len, int flags)
 {
@@ -239,7 +257,9 @@ rpl_send (int fd, const void *buf, int len, int flags)
 
   return r;
 }
+#endif
 
+#if GNULIB_RECVFROM
 int
 rpl_recvfrom (int fd, void *buf, int len, int flags, struct sockaddr *from,
              int *fromlen)
@@ -258,7 +278,9 @@ rpl_recvfrom (int fd, void *buf, int len, int flags, struct sockaddr *from,
 
   return r;
 }
+#endif
 
+#if GNULIB_SENDTO
 int
 rpl_sendto (int fd, const void *buf, int len, int flags,
            struct sockaddr *to, int tolen)
@@ -270,7 +292,9 @@ rpl_sendto (int fd, const void *buf, int len, int flags,
 
   return r;
 }
+#endif
 
+#if GNULIB_SETSOCKOPT
 int
 rpl_setsockopt (int fd, int level, int optname, const void *optval, int optlen)
 {
@@ -281,3 +305,4 @@ rpl_setsockopt (int fd, int level, int optname, const void *optval, int optlen)
 
   return r;
 }
+#endif
index d901c3f..9981abc 100644 (file)
@@ -1,4 +1,4 @@
-# sys_socket_h.m4 serial 7
+# sys_socket_h.m4 serial 8
 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,
@@ -8,6 +8,7 @@ dnl From Simon Josefsson.
 
 AC_DEFUN([gl_HEADER_SYS_SOCKET],
 [
+  AC_REQUIRE([gl_SYS_SOCKET_H_DEFAULTS])
   AC_REQUIRE([AC_C_INLINE])
 
   AC_CACHE_CHECK([whether <sys/socket.h> is self-contained],
@@ -88,3 +89,28 @@ AC_DEFUN([gl_PREREQ_SYS_H_WINSOCK2],
   fi
   AC_SUBST([HAVE_WINSOCK2_H])
 ])
+
+AC_DEFUN([gl_SYS_SOCKET_MODULE_INDICATOR],
+[
+  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
+  AC_REQUIRE([gl_SYS_SOCKET_H_DEFAULTS])
+  GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
+  gl_MODULE_INDICATOR([$1])
+])
+
+AC_DEFUN([gl_SYS_SOCKET_H_DEFAULTS],
+[
+  GNULIB_SOCKET=0;      AC_SUBST([GNULIB_SOCKET])
+  GNULIB_CONNECT=0;     AC_SUBST([GNULIB_CONNECT])
+  GNULIB_ACCEPT=0;      AC_SUBST([GNULIB_ACCEPT])
+  GNULIB_BIND=0;        AC_SUBST([GNULIB_BIND])
+  GNULIB_GETPEERNAME=0; AC_SUBST([GNULIB_GETPEERNAME])
+  GNULIB_GETSOCKNAME=0; AC_SUBST([GNULIB_GETSOCKNAME])
+  GNULIB_GETSOCKOPT=0;  AC_SUBST([GNULIB_GETSOCKOPT])
+  GNULIB_LISTEN=0;      AC_SUBST([GNULIB_LISTEN])
+  GNULIB_RECV=0;        AC_SUBST([GNULIB_RECV])
+  GNULIB_SEND=0;        AC_SUBST([GNULIB_SEND])
+  GNULIB_RECVFROM=0;    AC_SUBST([GNULIB_RECVFROM])
+  GNULIB_SENDTO=0;      AC_SUBST([GNULIB_SENDTO])
+  GNULIB_SETSOCKOPT=0;  AC_SUBST([GNULIB_SETSOCKOPT])
+])
diff --git a/modules/accept b/modules/accept
new file mode 100644 (file)
index 0000000..f786882
--- /dev/null
@@ -0,0 +1,27 @@
+Description:
+accept() function: accept a connection to a server socket.
+
+Files:
+lib/winsock.c
+
+Depends-on:
+sys_socket
+errno
+
+configure.ac:
+AC_REQUIRE([gl_HEADER_SYS_SOCKET])
+if test "$ac_cv_header_winsock2_h" = yes; then
+  AC_LIBOBJ([winsock])
+fi
+gl_SYS_SOCKET_MODULE_INDICATOR([accept])
+
+Makefile.am:
+
+Include:
+<sys/socket.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+Paolo Bonzini, Simon Josefsson
diff --git a/modules/bind b/modules/bind
new file mode 100644 (file)
index 0000000..856148a
--- /dev/null
@@ -0,0 +1,27 @@
+Description:
+bind() function: bind a server socket to a port.
+
+Files:
+lib/winsock.c
+
+Depends-on:
+sys_socket
+errno
+
+configure.ac:
+AC_REQUIRE([gl_HEADER_SYS_SOCKET])
+if test "$ac_cv_header_winsock2_h" = yes; then
+  AC_LIBOBJ([winsock])
+fi
+gl_SYS_SOCKET_MODULE_INDICATOR([bind])
+
+Makefile.am:
+
+Include:
+<sys/socket.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+Paolo Bonzini, Simon Josefsson
diff --git a/modules/connect b/modules/connect
new file mode 100644 (file)
index 0000000..304e107
--- /dev/null
@@ -0,0 +1,27 @@
+Description:
+connect() function: connect a client socket.
+
+Files:
+lib/winsock.c
+
+Depends-on:
+sys_socket
+errno
+
+configure.ac:
+AC_REQUIRE([gl_HEADER_SYS_SOCKET])
+if test "$ac_cv_header_winsock2_h" = yes; then
+  AC_LIBOBJ([winsock])
+fi
+gl_SYS_SOCKET_MODULE_INDICATOR([connect])
+
+Makefile.am:
+
+Include:
+<sys/socket.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+Paolo Bonzini, Simon Josefsson
diff --git a/modules/getpeername b/modules/getpeername
new file mode 100644 (file)
index 0000000..f980bb8
--- /dev/null
@@ -0,0 +1,28 @@
+Description:
+getpeername() function: return information about the remote end of a connected
+socket.
+
+Files:
+lib/winsock.c
+
+Depends-on:
+sys_socket
+errno
+
+configure.ac:
+AC_REQUIRE([gl_HEADER_SYS_SOCKET])
+if test "$ac_cv_header_winsock2_h" = yes; then
+  AC_LIBOBJ([winsock])
+fi
+gl_SYS_SOCKET_MODULE_INDICATOR([getpeername])
+
+Makefile.am:
+
+Include:
+<sys/socket.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+Paolo Bonzini, Simon Josefsson
diff --git a/modules/getsockname b/modules/getsockname
new file mode 100644 (file)
index 0000000..2b4fd64
--- /dev/null
@@ -0,0 +1,28 @@
+Description:
+getsockname() function: return information about the local end of a connected
+socket.
+
+Files:
+lib/winsock.c
+
+Depends-on:
+sys_socket
+errno
+
+configure.ac:
+AC_REQUIRE([gl_HEADER_SYS_SOCKET])
+if test "$ac_cv_header_winsock2_h" = yes; then
+  AC_LIBOBJ([winsock])
+fi
+gl_SYS_SOCKET_MODULE_INDICATOR([getsockname])
+
+Makefile.am:
+
+Include:
+<sys/socket.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+Paolo Bonzini, Simon Josefsson
diff --git a/modules/getsockopt b/modules/getsockopt
new file mode 100644 (file)
index 0000000..a4e3131
--- /dev/null
@@ -0,0 +1,27 @@
+Description:
+getsockopt() function: retrieve optional settings on a socket.
+
+Files:
+lib/winsock.c
+
+Depends-on:
+sys_socket
+errno
+
+configure.ac:
+AC_REQUIRE([gl_HEADER_SYS_SOCKET])
+if test "$ac_cv_header_winsock2_h" = yes; then
+  AC_LIBOBJ([winsock])
+fi
+gl_SYS_SOCKET_MODULE_INDICATOR([getsockopt])
+
+Makefile.am:
+
+Include:
+<sys/socket.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+Paolo Bonzini, Simon Josefsson
diff --git a/modules/listen b/modules/listen
new file mode 100644 (file)
index 0000000..bbaa7a5
--- /dev/null
@@ -0,0 +1,27 @@
+Description:
+listen() function: make a server socket ready for accepting connections.
+
+Files:
+lib/winsock.c
+
+Depends-on:
+sys_socket
+errno
+
+configure.ac:
+AC_REQUIRE([gl_HEADER_SYS_SOCKET])
+if test "$ac_cv_header_winsock2_h" = yes; then
+  AC_LIBOBJ([winsock])
+fi
+gl_SYS_SOCKET_MODULE_INDICATOR([listen])
+
+Makefile.am:
+
+Include:
+<sys/socket.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+Paolo Bonzini, Simon Josefsson
index 94cca23..72241ae 100644 (file)
@@ -11,6 +11,12 @@ inet_pton
 errno
 perror
 sockets
+socket
+bind
+setsockopt
+listen
+connect
+accept
 
 configure.ac:
 AC_CHECK_HEADERS_ONCE([unistd.h sys/wait.h])
diff --git a/modules/recv b/modules/recv
new file mode 100644 (file)
index 0000000..a532240
--- /dev/null
@@ -0,0 +1,27 @@
+Description:
+recv() function: receive (read) data from a connected socket.
+
+Files:
+lib/winsock.c
+
+Depends-on:
+sys_socket
+errno
+
+configure.ac:
+AC_REQUIRE([gl_HEADER_SYS_SOCKET])
+if test "$ac_cv_header_winsock2_h" = yes; then
+  AC_LIBOBJ([winsock])
+fi
+gl_SYS_SOCKET_MODULE_INDICATOR([recv])
+
+Makefile.am:
+
+Include:
+<sys/socket.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+Paolo Bonzini, Simon Josefsson
diff --git a/modules/recvfrom b/modules/recvfrom
new file mode 100644 (file)
index 0000000..50e1339
--- /dev/null
@@ -0,0 +1,27 @@
+Description:
+recvfrom() function: receive (read) data from a potentially unconnected socket.
+
+Files:
+lib/winsock.c
+
+Depends-on:
+sys_socket
+errno
+
+configure.ac:
+AC_REQUIRE([gl_HEADER_SYS_SOCKET])
+if test "$ac_cv_header_winsock2_h" = yes; then
+  AC_LIBOBJ([winsock])
+fi
+gl_SYS_SOCKET_MODULE_INDICATOR([recvfrom])
+
+Makefile.am:
+
+Include:
+<sys/socket.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+Paolo Bonzini, Simon Josefsson
index 2285033..1788348 100644 (file)
@@ -10,6 +10,12 @@ inet_pton
 errno
 perror
 sockets
+socket
+bind
+setsockopt
+listen
+connect
+accept
 
 configure.ac:
 
diff --git a/modules/send b/modules/send
new file mode 100644 (file)
index 0000000..75309ce
--- /dev/null
@@ -0,0 +1,27 @@
+Description:
+send() function: send (write) data to a connected socket.
+
+Files:
+lib/winsock.c
+
+Depends-on:
+sys_socket
+errno
+
+configure.ac:
+AC_REQUIRE([gl_HEADER_SYS_SOCKET])
+if test "$ac_cv_header_winsock2_h" = yes; then
+  AC_LIBOBJ([winsock])
+fi
+gl_SYS_SOCKET_MODULE_INDICATOR([send])
+
+Makefile.am:
+
+Include:
+<sys/socket.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+Paolo Bonzini, Simon Josefsson
diff --git a/modules/sendto b/modules/sendto
new file mode 100644 (file)
index 0000000..888d0dc
--- /dev/null
@@ -0,0 +1,27 @@
+Description:
+sendto() function: send (write) data to a potentially unconnected socket.
+
+Files:
+lib/winsock.c
+
+Depends-on:
+sys_socket
+errno
+
+configure.ac:
+AC_REQUIRE([gl_HEADER_SYS_SOCKET])
+if test "$ac_cv_header_winsock2_h" = yes; then
+  AC_LIBOBJ([winsock])
+fi
+gl_SYS_SOCKET_MODULE_INDICATOR([sendto])
+
+Makefile.am:
+
+Include:
+<sys/socket.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+Paolo Bonzini, Simon Josefsson
diff --git a/modules/setsockopt b/modules/setsockopt
new file mode 100644 (file)
index 0000000..5cd3d1d
--- /dev/null
@@ -0,0 +1,27 @@
+Description:
+setsockopt() function: specify optional settings on a socket.
+
+Files:
+lib/winsock.c
+
+Depends-on:
+sys_socket
+errno
+
+configure.ac:
+AC_REQUIRE([gl_HEADER_SYS_SOCKET])
+if test "$ac_cv_header_winsock2_h" = yes; then
+  AC_LIBOBJ([winsock])
+fi
+gl_SYS_SOCKET_MODULE_INDICATOR([setsockopt])
+
+Makefile.am:
+
+Include:
+<sys/socket.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+Paolo Bonzini, Simon Josefsson
diff --git a/modules/socket b/modules/socket
new file mode 100644 (file)
index 0000000..900d9ec
--- /dev/null
@@ -0,0 +1,27 @@
+Description:
+socket() function: create a socket.
+
+Files:
+lib/winsock.c
+
+Depends-on:
+sys_socket
+errno
+
+configure.ac:
+AC_REQUIRE([gl_HEADER_SYS_SOCKET])
+if test "$ac_cv_header_winsock2_h" = yes; then
+  AC_LIBOBJ([winsock])
+fi
+gl_SYS_SOCKET_MODULE_INDICATOR([socket])
+
+Makefile.am:
+
+Include:
+<sys/socket.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+Paolo Bonzini, Simon Josefsson
index f5569c5..d2cf460 100644 (file)
@@ -9,6 +9,7 @@ m4/sockpfaf.m4
 
 Depends-on:
 include_next
+link-warning
 errno
 
 configure.ac:
@@ -27,8 +28,22 @@ sys/socket.h: sys_socket.in.h
              -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
              -e 's|@''NEXT_SYS_SOCKET_H''@|$(NEXT_SYS_SOCKET_H)|g' \
              -e 's|@''HAVE_SYS_SOCKET_H''@|$(HAVE_SYS_SOCKET_H)|g' \
+             -e 's|@''GNULIB_SOCKET''@|$(GNULIB_SOCKET)|g' \
+             -e 's|@''GNULIB_CONNECT''@|$(GNULIB_CONNECT)|g' \
+             -e 's|@''GNULIB_ACCEPT''@|$(GNULIB_ACCEPT)|g' \
+             -e 's|@''GNULIB_BIND''@|$(GNULIB_BIND)|g' \
+             -e 's|@''GNULIB_GETPEERNAME''@|$(GNULIB_GETPEERNAME)|g' \
+             -e 's|@''GNULIB_GETSOCKNAME''@|$(GNULIB_GETSOCKNAME)|g' \
+             -e 's|@''GNULIB_GETSOCKOPT''@|$(GNULIB_GETSOCKOPT)|g' \
+             -e 's|@''GNULIB_LISTEN''@|$(GNULIB_LISTEN)|g' \
+             -e 's|@''GNULIB_RECV''@|$(GNULIB_RECV)|g' \
+             -e 's|@''GNULIB_SEND''@|$()GNULIB_SEND|g' \
+             -e 's|@''GNULIB_RECVFROM''@|$(GNULIB_RECVFROM)|g' \
+             -e 's|@''GNULIB_SENDTO''@|$(GNULIB_SENDTO)|g' \
+             -e 's|@''GNULIB_SETSOCKOPT''@|$(GNULIB_SETSOCKOPT)|g' \
              -e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \
              -e 's|@''HAVE_WS2TCPIP_H''@|$(HAVE_WS2TCPIP_H)|g' \
+             -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
              < $(srcdir)/sys_socket.in.h; \
        } > $@-t
        mv -f $@-t $@