From c75f87d6e47194491fbd3f5db974cf94a5c61f20 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 20 Nov 2012 22:25:06 -0800 Subject: [PATCH] sys_socket: better 'inline' * lib/sys_socket.c: New file. * lib/sys_socket.in.h (_GL_SYS_SOCKET_INLINE): New macro. Replace all uses of 'static inline' with it. Use _GL_INLINE_HEADER_BEGIN, _GL_INLINE_HEADER_END. * m4/sys_socket_h.m4 (gl_HEADER_SYS_SOCKET): Do not require AC_C_INLINE. * modules/sys_socket (Files, lib_SOURCES): Add lib/sys_socket.c. (Depends-on): Add extern-inline. --- ChangeLog | 9 +++++++++ lib/sys_socket.c | 3 +++ lib/sys_socket.in.h | 9 ++++++++- m4/sys_socket_h.m4 | 3 +-- modules/sys_socket | 3 +++ 5 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 lib/sys_socket.c diff --git a/ChangeLog b/ChangeLog index 5692442a7..1869b71a7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2012-11-29 Paul Eggert + sys_socket: better 'inline' + * lib/sys_socket.c: New file. + * lib/sys_socket.in.h (_GL_SYS_SOCKET_INLINE): + New macro. Replace all uses of 'static inline' with it. + Use _GL_INLINE_HEADER_BEGIN, _GL_INLINE_HEADER_END. + * m4/sys_socket_h.m4 (gl_HEADER_SYS_SOCKET): Do not require AC_C_INLINE. + * modules/sys_socket (Files, lib_SOURCES): Add lib/sys_socket.c. + (Depends-on): Add extern-inline. + stdio: better 'inline' * lib/stdio.c: New file. * lib/stdio.in.h (_GL_STDIO_INLINE): diff --git a/lib/sys_socket.c b/lib/sys_socket.c new file mode 100644 index 000000000..3f017f8fc --- /dev/null +++ b/lib/sys_socket.c @@ -0,0 +1,3 @@ +#include +#define _GL_SYS_SOCKET_INLINE _GL_EXTERN_INLINE +#include "sys/socket.h" diff --git a/lib/sys_socket.in.h b/lib/sys_socket.in.h index c9157d3d9..2b4c93fab 100644 --- a/lib/sys_socket.in.h +++ b/lib/sys_socket.in.h @@ -63,6 +63,11 @@ #ifndef _@GUARD_PREFIX@_SYS_SOCKET_H #define _@GUARD_PREFIX@_SYS_SOCKET_H +_GL_INLINE_HEADER_BEGIN +#ifndef _GL_SYS_SOCKET_INLINE +# define _GL_SYS_SOCKET_INLINE _GL_INLINE +#endif + /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ /* The definition of _GL_ARG_NONNULL is copied here. */ @@ -201,7 +206,7 @@ struct msghdr { /* Re-define FD_ISSET to avoid a WSA call while we are not using network sockets. */ -static inline int +_GL_SYS_SOCKET_INLINE int rpl_fd_isset (SOCKET fd, fd_set * set) { u_int i; @@ -677,6 +682,8 @@ _GL_WARN_ON_USE (accept4, "accept4 is unportable - " # endif #endif +_GL_INLINE_HEADER_END + #endif /* _@GUARD_PREFIX@_SYS_SOCKET_H */ #endif /* _@GUARD_PREFIX@_SYS_SOCKET_H */ #endif diff --git a/m4/sys_socket_h.m4 b/m4/sys_socket_h.m4 index 8d4e7e1eb..acfae4132 100644 --- a/m4/sys_socket_h.m4 +++ b/m4/sys_socket_h.m4 @@ -1,4 +1,4 @@ -# sys_socket_h.m4 serial 22 +# sys_socket_h.m4 serial 23 dnl Copyright (C) 2005-2012 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -10,7 +10,6 @@ AC_DEFUN([gl_HEADER_SYS_SOCKET], [ AC_REQUIRE([gl_SYS_SOCKET_H_DEFAULTS]) AC_REQUIRE([AC_CANONICAL_HOST]) - AC_REQUIRE([AC_C_INLINE]) dnl On OSF/1, the functions recv(), send(), recvfrom(), sendto() have dnl old-style declarations (with return type 'int' instead of 'ssize_t') diff --git a/modules/sys_socket b/modules/sys_socket index 704f2a511..df78751fd 100644 --- a/modules/sys_socket +++ b/modules/sys_socket @@ -2,12 +2,14 @@ Description: A POSIX-like . Files: +lib/sys_socket.c lib/sys_socket.in.h m4/sys_socket_h.m4 m4/sockpfaf.m4 Depends-on: errno +extern-inline include_next snippet/arg-nonnull snippet/c++defs @@ -23,6 +25,7 @@ AC_PROG_MKDIR_P Makefile.am: BUILT_SOURCES += sys/socket.h +lib_SOURCES += sys_socket.c # We need the following in order to create when the system # doesn't have one that works with the given compiler. -- 2.11.0