#ifndef _GL_SYS_SOCKET_H
#define _GL_SYS_SOCKET_H
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
+#if !@HAVE_SA_FAMILY_T@
+typedef unsigned short sa_family_t;
+#endif
+
#if !@HAVE_STRUCT_SOCKADDR_STORAGE@
# include <alignof.h>
/* Code taken from glibc sysdeps/unix/sysv/linux/bits/socket.h on
# define __ss_aligntype unsigned long int
# define _SS_SIZE 256
# define _SS_PADSIZE \
- (_SS_SIZE - ((sizeof (sa_family_t) >= alignof (__ss_aligntype) \
- ? sizeof (sa_family_t) \
- : alignof (__ss_aligntype)) \
- + sizeof (__ss_aligntype)))
+ (_SS_SIZE - ((sizeof (sa_family_t) >= alignof (__ss_aligntype) \
+ ? sizeof (sa_family_t) \
+ : alignof (__ss_aligntype)) \
+ + sizeof (__ss_aligntype)))
struct sockaddr_storage
{
# if @GNULIB_SOCKET@
# if @HAVE_WINSOCK2_H@
# undef socket
-# define socket rpl_socket
+# define socket rpl_socket
extern int rpl_socket (int, int, int protocol);
# endif
# elif @HAVE_WINSOCK2_H@
# if @GNULIB_CONNECT@
# if @HAVE_WINSOCK2_H@
# undef connect
-# define connect rpl_connect
-extern int rpl_connect (int, struct sockaddr *, int);
+# define connect rpl_connect
+extern int rpl_connect (int, struct sockaddr *, int) _GL_ARG_NONNULL ((2));
# endif
# elif @HAVE_WINSOCK2_H@
# undef connect
# if @GNULIB_ACCEPT@
# if @HAVE_WINSOCK2_H@
# undef accept
-# define accept rpl_accept
+# define accept rpl_accept
extern int rpl_accept (int, struct sockaddr *, int *);
# endif
# elif @HAVE_WINSOCK2_H@
# if @GNULIB_BIND@
# if @HAVE_WINSOCK2_H@
# undef bind
-# define bind rpl_bind
-extern int rpl_bind (int, struct sockaddr *, int);
+# define bind rpl_bind
+extern int rpl_bind (int, struct sockaddr *, int) _GL_ARG_NONNULL ((2));
# endif
# elif @HAVE_WINSOCK2_H@
# undef bind
# if @GNULIB_GETPEERNAME@
# if @HAVE_WINSOCK2_H@
# undef getpeername
-# define getpeername rpl_getpeername
-extern int rpl_getpeername (int, struct sockaddr *, int *);
+# define getpeername rpl_getpeername
+extern int rpl_getpeername (int, struct sockaddr *, int *)
+ _GL_ARG_NONNULL ((2, 3));
# endif
# elif @HAVE_WINSOCK2_H@
# undef getpeername
# if @GNULIB_GETSOCKNAME@
# if @HAVE_WINSOCK2_H@
# undef getsockname
-# define getsockname rpl_getsockname
-extern int rpl_getsockname (int, struct sockaddr *, int *);
+# define getsockname rpl_getsockname
+extern int rpl_getsockname (int, struct sockaddr *, int *)
+ _GL_ARG_NONNULL ((2, 3));
# endif
# elif @HAVE_WINSOCK2_H@
# undef getsockname
# if @GNULIB_GETSOCKOPT@
# if @HAVE_WINSOCK2_H@
# undef getsockopt
-# define getsockopt rpl_getsockopt
-extern int rpl_getsockopt (int, int, int, void *, socklen_t *);
+# define getsockopt rpl_getsockopt
+extern int rpl_getsockopt (int, int, int, void *, socklen_t *)
+ _GL_ARG_NONNULL ((4, 5));
# endif
# elif @HAVE_WINSOCK2_H@
# undef getsockopt
# if @GNULIB_LISTEN@
# if @HAVE_WINSOCK2_H@
# undef listen
-# define listen rpl_listen
+# define listen rpl_listen
extern int rpl_listen (int, int);
# endif
# elif @HAVE_WINSOCK2_H@
# if @GNULIB_RECV@
# if @HAVE_WINSOCK2_H@
# undef recv
-# define recv rpl_recv
-extern int rpl_recv (int, void *, int, int);
+# define recv rpl_recv
+extern int rpl_recv (int, void *, int, int) _GL_ARG_NONNULL ((2));
# endif
# elif @HAVE_WINSOCK2_H@
# undef recv
# if @GNULIB_SEND@
# if @HAVE_WINSOCK2_H@
# undef send
-# define send rpl_send
-extern int rpl_send (int, const void *, int, int);
+# define send rpl_send
+extern int rpl_send (int, const void *, int, int) _GL_ARG_NONNULL ((2));
# endif
# elif @HAVE_WINSOCK2_H@
# undef send
# if @GNULIB_RECVFROM@
# if @HAVE_WINSOCK2_H@
# undef recvfrom
-# define recvfrom rpl_recvfrom
-extern int rpl_recvfrom (int, void *, int, int, struct sockaddr *, int *);
+# define recvfrom rpl_recvfrom
+extern int rpl_recvfrom (int, void *, int, int, struct sockaddr *, int *)
+ _GL_ARG_NONNULL ((2));
# endif
# elif @HAVE_WINSOCK2_H@
# undef recvfrom
# 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);
+# define sendto rpl_sendto
+extern int rpl_sendto (int, const void *, int, int, struct sockaddr *, int)
+ _GL_ARG_NONNULL ((2));
# endif
# elif @HAVE_WINSOCK2_H@
# undef sendto
# if @GNULIB_SETSOCKOPT@
# if @HAVE_WINSOCK2_H@
# undef setsockopt
-# define setsockopt rpl_setsockopt
-extern int rpl_setsockopt (int, int, int, const void *, socklen_t);
+# define setsockopt rpl_setsockopt
+extern int rpl_setsockopt (int, int, int, const void *, socklen_t)
+ _GL_ARG_NONNULL ((4));
# endif
# elif @HAVE_WINSOCK2_H@
# undef setsockopt
# if @GNULIB_SHUTDOWN@
# if @HAVE_WINSOCK2_H@
# undef shutdown
-# define shutdown rpl_shutdown
+# define shutdown rpl_shutdown
extern int rpl_shutdown (int, int);
# endif
# elif @HAVE_WINSOCK2_H@
# if @HAVE_WINSOCK2_H@
# undef select
-# define select select_used_without_including_sys_select_h
+# define select select_used_without_including_sys_select_h
# endif
# ifdef __cplusplus
#endif /* HAVE_SYS_SOCKET_H */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if @GNULIB_ACCEPT4@
+/* Accept a connection on a socket, with specific opening flags.
+ The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
+ and O_TEXT, O_BINARY (defined in "binary-io.h").
+ See also the Linux man page at
+ <http://www.kernel.org/doc/man-pages/online/pages/man2/accept4.2.html>. */
+# if @HAVE_ACCEPT4@
+# define accept4 rpl_accept4
+# endif
+extern int accept4 (int sockfd, struct sockaddr *addr, socklen_t *addrlen,
+ int flags);
+#elif defined GNULIB_POSIXCHECK
+# undef accept4
+# define accept4(s,a,l,f) \
+ (GL_LINK_WARNING ("accept4 is unportable - " \
+ "use gnulib module accept4 for portability"), \
+ accept4 (s, a, l, f))
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _GL_SYS_SOCKET_H */
#endif /* _GL_SYS_SOCKET_H */