changeset 17172:1980691d8f7e

stdio: better 'inline' * lib/stdio.c: New file. * lib/stdio.in.h (_GL_STDIO_INLINE): New macro. Replace all uses of 'static inline' with it. Use _GL_INLINE_HEADER_BEGIN, _GL_INLINE_HEADER_END. * m4/stdio_h.m4 (gl_STDIO_H): Do not require AC_C_INLINE. * modules/stdio (Files, lib_SOURCES): Add lib/stdio.c. (Depends-on): Add extern-inline.
author Paul Eggert <eggert@cs.ucla.edu>
date Tue, 20 Nov 2012 22:25:06 -0800
parents 7531a1bd77d7
children 69d9b9c93232
files ChangeLog lib/stdio.c lib/stdio.in.h m4/stdio_h.m4 modules/stdio
diffstat 5 files changed, 23 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2012-11-29  Paul Eggert  <eggert@cs.ucla.edu>
 
+	stdio: better 'inline'
+	* lib/stdio.c: New file.
+	* lib/stdio.in.h (_GL_STDIO_INLINE):
+	New macro.  Replace all uses of 'static inline' with it.
+	Use _GL_INLINE_HEADER_BEGIN, _GL_INLINE_HEADER_END.
+	* m4/stdio_h.m4 (gl_STDIO_H): Do not require AC_C_INLINE.
+	* modules/stdio (Files, lib_SOURCES): Add lib/stdio.c.
+	(Depends-on): Add extern-inline.
+
 	sigaction: better 'inline'
 	* lib/sig-handler.c: New file.
 	* lib/sig-handler.h (SIG_HANDLER_INLINE):
new file mode 100644
--- /dev/null
+++ b/lib/stdio.c
@@ -0,0 +1,3 @@
+#include <config.h>
+#define _GL_STDIO_INLINE _GL_EXTERN_INLINE
+#include "stdio.h"
--- a/lib/stdio.in.h
+++ b/lib/stdio.in.h
@@ -46,6 +46,11 @@
 #ifndef _@GUARD_PREFIX@_STDIO_H
 #define _@GUARD_PREFIX@_STDIO_H
 
+_GL_INLINE_HEADER_BEGIN
+#ifndef _GL_STDIO_INLINE
+# define _GL_STDIO_INLINE _GL_INLINE
+#endif
+
 /* Get va_list.  Needed on many systems, including glibc 2.8.  */
 #include <stdarg.h>
 
@@ -581,7 +586,7 @@
    This affects only function declaration attributes, so it's not
    needed for C++.  */
 #  if !defined __cplusplus && 0 < __USE_FORTIFY_LEVEL
-static inline size_t _GL_ARG_NONNULL ((1, 4))
+_GL_STDIO_INLINE size_t _GL_ARG_NONNULL ((1, 4))
 rpl_fwrite (const void *ptr, size_t s, size_t n, FILE *stream)
 {
   size_t r = fwrite (ptr, s, n, stream);
@@ -1333,6 +1338,7 @@
                       "POSIX compliance");
 #endif
 
+_GL_INLINE_HEADER_END
 
 #endif /* _@GUARD_PREFIX@_STDIO_H */
 #endif /* _@GUARD_PREFIX@_STDIO_H */
--- a/m4/stdio_h.m4
+++ b/m4/stdio_h.m4
@@ -1,4 +1,4 @@
-# stdio_h.m4 serial 42
+# stdio_h.m4 serial 43
 dnl Copyright (C) 2007-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,
@@ -7,7 +7,6 @@
 AC_DEFUN([gl_STDIO_H],
 [
   AC_REQUIRE([gl_STDIO_H_DEFAULTS])
-  AC_REQUIRE([AC_C_INLINE])
   gl_NEXT_HEADERS([stdio.h])
 
   dnl No need to create extra modules for these functions. Everyone who uses
--- a/modules/stdio
+++ b/modules/stdio
@@ -2,10 +2,12 @@
 A GNU-like <stdio.h>.
 
 Files:
+lib/stdio.c
 lib/stdio.in.h
 m4/stdio_h.m4
 
 Depends-on:
+extern-inline
 include_next
 snippet/arg-nonnull
 snippet/c++defs
@@ -19,6 +21,7 @@
 
 Makefile.am:
 BUILT_SOURCES += stdio.h
+lib_SOURCES += stdio.c
 
 # We need the following in order to create <stdio.h> when the system
 # doesn't have one that works with the given compiler.