changeset 17102:9e72d3927af1

binary-io, eealloc, mbfile, mbiter, mbutil, xsize: better 'inline' * lib/binary-io.c, lib/eealloc.c, lib/mbfile.c, lib/mbiter.c: * lib/mbuiter.c, lib/xsize.c: New files. * lib/binary-io.h (BINARY_IO_INLINE): * lib/eealloc.h (EEALLOC_INLINE): * lib/mbfile.h (MBFILE_INLINE): * lib/mbiter.h (MBITER_INLINE): * lib/mbuiter.h (MBUITER_INLINE): * lib/xsize.h (XSIZE_INLINE): New macros. Replace all uses of 'static inline' with them. Use _GL_INLINE_HEADER_BEGIN, _GL_INLINE_HEADER_END. * m4/eealloc.m4 (gl_EEALLOC): * m4/mbfile.m4 (gl_MBFILE): * m4/mbiter.m4 (gl_MBITER): * m4/xsize.m4 (gl_XSIZE): Do not require AC_C_INLINE. * modules/binary-io (Files, lib_SOURCES): Add lib/binary-io.c * modules/eealloc (Files, lib_SOURCES): Add lib/eealloc.c. * modules/mbfile (Files, lib_SOURCES): Add lib/mbfile.c. * modules/mbiter (Files, lib_SOURCES): Add lib/mbiter.c. * modules/mbuiter (Files, lib_SOURCES): Add lib/mbuiter.c. * modules/xsize (Files, lib_SOURCES): Add lib/xsize.c. * modules/binary-io, modules/eealloc, modules/mbfile: * modules/mbiter, modules/mbuiter: (Depends-on): Add extern-inline.
author Paul Eggert <eggert@cs.ucla.edu>
date Wed, 29 Aug 2012 23:13:42 -0700
parents 99fa3b05f1c8
children 2e34750ea4c1
files ChangeLog lib/binary-io.c lib/binary-io.h lib/eealloc.c lib/eealloc.h lib/mbfile.c lib/mbfile.h lib/mbiter.c lib/mbiter.h lib/mbuiter.c lib/mbuiter.h lib/xsize.c lib/xsize.h m4/eealloc.m4 m4/mbfile.m4 m4/mbiter.m4 m4/xsize.m4 modules/binary-io modules/eealloc modules/mbfile modules/mbiter modules/mbuiter modules/xsize
diffstat 23 files changed, 126 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,32 @@
 2012-09-22  Paul Eggert  <eggert@cs.ucla.edu>
 
+	binary-io, eealloc, mbfile, mbiter, mbutil, xsize: better 'inline'
+	* lib/binary-io.c, lib/eealloc.c, lib/mbfile.c, lib/mbiter.c:
+	* lib/mbuiter.c, lib/xsize.c: New files.
+	* lib/binary-io.h (BINARY_IO_INLINE):
+	* lib/eealloc.h (EEALLOC_INLINE):
+	* lib/mbfile.h (MBFILE_INLINE):
+	* lib/mbiter.h (MBITER_INLINE):
+	* lib/mbuiter.h (MBUITER_INLINE):
+	* lib/xsize.h (XSIZE_INLINE):
+	New macros.
+	Replace all uses of 'static inline' with them.
+	Use _GL_INLINE_HEADER_BEGIN, _GL_INLINE_HEADER_END.
+	* m4/eealloc.m4 (gl_EEALLOC):
+	* m4/mbfile.m4 (gl_MBFILE):
+	* m4/mbiter.m4 (gl_MBITER):
+	* m4/xsize.m4 (gl_XSIZE):
+	Do not require AC_C_INLINE.
+	* modules/binary-io (Files, lib_SOURCES): Add lib/binary-io.c
+	* modules/eealloc (Files, lib_SOURCES): Add lib/eealloc.c.
+	* modules/mbfile (Files, lib_SOURCES): Add lib/mbfile.c.
+	* modules/mbiter (Files, lib_SOURCES): Add lib/mbiter.c.
+	* modules/mbuiter (Files, lib_SOURCES): Add lib/mbuiter.c.
+	* modules/xsize (Files, lib_SOURCES): Add lib/xsize.c.
+	* modules/binary-io, modules/eealloc, modules/mbfile:
+	* modules/mbiter, modules/mbuiter:
+	(Depends-on): Add extern-inline.
+
 	pipe-filter-gi, pipe-filter-ii: better use of 'inline'
 	* lib/pipe-filter-aux.c: New file.
 	* lib/pipe-filter-aux.h (PIPE_FILTER_AUX_INLINE): New macro.
new file mode 100644
--- /dev/null
+++ b/lib/binary-io.c
@@ -0,0 +1,3 @@
+#include <config.h>
+#define BINARY_IO_INLINE _GL_EXTERN_INLINE
+#include "binary-io.h"
--- a/lib/binary-io.h
+++ b/lib/binary-io.h
@@ -25,6 +25,11 @@
    so we include it here first.  */
 #include <stdio.h>
 
+_GL_INLINE_HEADER_BEGIN
+#ifndef BINARY_IO_INLINE
+# define BINARY_IO_INLINE _GL_INLINE
+#endif
+
 /* set_binary_mode (fd, mode)
    sets the binary/text I/O mode of file descriptor fd to the given mode
    (must be O_BINARY or O_TEXT) and returns the previous mode.  */
@@ -41,7 +46,7 @@
   /* On reasonable systems, binary I/O is the only choice.  */
   /* Use a function rather than a macro, to avoid gcc warnings
      "warning: statement with no effect".  */
-static inline int
+BINARY_IO_INLINE int
 set_binary_mode (int fd, int mode)
 {
   (void) fd;
@@ -62,4 +67,6 @@
 # define SET_BINARY(fd) ((void) set_binary_mode (fd, O_BINARY))
 #endif
 
+_GL_INLINE_HEADER_END
+
 #endif /* _BINARY_H */
new file mode 100644
--- /dev/null
+++ b/lib/eealloc.c
@@ -0,0 +1,3 @@
+#include <config.h>
+#define EEALLOC_INLINE _GL_EXTERN_INLINE
+#include "eealloc.h"
--- a/lib/eealloc.h
+++ b/lib/eealloc.h
@@ -31,18 +31,23 @@
 
 #include <stdlib.h>
 
+_GL_INLINE_HEADER_BEGIN
+#ifndef EEALLOC_INLINE
+# define EEALLOC_INLINE _GL_INLINE
+#endif
+
 #if MALLOC_0_IS_NONNULL
 # define eemalloc malloc
 #else
 # if __GNUC__ >= 3
-static inline void *eemalloc (size_t n)
+EEALLOC_INLINE void *eemalloc (size_t n)
      __attribute__ ((__malloc__))
 #  if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
      __attribute__ ((__alloc_size__ (1)))
 #  endif
   ;
 # endif
-static inline void *
+EEALLOC_INLINE void *
 eemalloc (size_t n)
 {
   /* If n is zero, allocate a 1-byte block.  */
@@ -56,10 +61,10 @@
 # define eerealloc realloc
 #else
 # if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
-static inline void *eerealloc (void *p, size_t n)
+EEALLOC_INLINE void *eerealloc (void *p, size_t n)
      __attribute__ ((__alloc_size__ (2)));
 # endif
-static inline void *
+EEALLOC_INLINE void *
 eerealloc (void *p, size_t n)
 {
   /* If n is zero, allocate or keep a 1-byte block.  */
@@ -76,4 +81,6 @@
     eenrealloc (void *p, size_t n, size_t s) - like eerealloc (p, n * s)
    If this would be useful in your application. please speak up.  */
 
+_GL_INLINE_HEADER_END
+
 #endif /* _EEALLOC_H */
new file mode 100644
--- /dev/null
+++ b/lib/mbfile.c
@@ -0,0 +1,3 @@
+#include <config.h>
+#define MBFILE_INLINE _GL_EXTERN_INLINE
+#include "mbfile.h"
--- a/lib/mbfile.h
+++ b/lib/mbfile.h
@@ -62,6 +62,11 @@
 
 #include "mbchar.h"
 
+_GL_INLINE_HEADER_BEGIN
+#ifndef MBFILE_INLINE
+# define MBFILE_INLINE _GL_INLINE
+#endif
+
 struct mbfile_multi {
   FILE *fp;
   bool eof_seen;
@@ -72,7 +77,7 @@
   struct mbchar pushback;
 };
 
-static inline void
+MBFILE_INLINE void
 mbfile_multi_getc (struct mbchar *mbc, struct mbfile_multi *mbf)
 {
   size_t bytes;
@@ -215,7 +220,7 @@
   return;
 }
 
-static inline void
+MBFILE_INLINE void
 mbfile_multi_ungetc (const struct mbchar *mbc, struct mbfile_multi *mbf)
 {
   mb_copy (&mbf->pushback, mbc);
@@ -239,4 +244,6 @@
 
 #define mb_iseof(mbc) ((mbc).bytes == 0)
 
+_GL_INLINE_HEADER_BEGIN
+
 #endif /* _MBFILE_H */
new file mode 100644
--- /dev/null
+++ b/lib/mbiter.c
@@ -0,0 +1,3 @@
+#include <config.h>
+#define MBITER_INLINE _GL_EXTERN_INLINE
+#include "mbiter.h"
--- a/lib/mbiter.h
+++ b/lib/mbiter.h
@@ -97,6 +97,11 @@
 
 #include "mbchar.h"
 
+_GL_INLINE_HEADER_BEGIN
+#ifndef MBITER_INLINE
+# define MBITER_INLINE _GL_INLINE
+#endif
+
 struct mbiter_multi
 {
   const char *limit;    /* pointer to end of string */
@@ -112,7 +117,7 @@
         */
 };
 
-static inline void
+MBITER_INLINE void
 mbiter_multi_next (struct mbiter_multi *iter)
 {
   if (iter->next_done)
@@ -172,14 +177,14 @@
   iter->next_done = true;
 }
 
-static inline void
+MBITER_INLINE void
 mbiter_multi_reloc (struct mbiter_multi *iter, ptrdiff_t ptrdiff)
 {
   iter->cur.ptr += ptrdiff;
   iter->limit += ptrdiff;
 }
 
-static inline void
+MBITER_INLINE void
 mbiter_multi_copy (struct mbiter_multi *new_iter, const struct mbiter_multi *old_iter)
 {
   new_iter->limit = old_iter->limit;
@@ -212,4 +217,6 @@
 /* Copying an iterator.  */
 #define mbi_copy mbiter_multi_copy
 
+_GL_INLINE_HEADER_END
+
 #endif /* _MBITER_H */
new file mode 100644
--- /dev/null
+++ b/lib/mbuiter.c
@@ -0,0 +1,3 @@
+#include <config.h>
+#define MBUITER_INLINE _GL_EXTERN_INLINE
+#include "mbuiter.h"
--- a/lib/mbuiter.h
+++ b/lib/mbuiter.h
@@ -106,6 +106,11 @@
 #include "mbchar.h"
 #include "strnlen1.h"
 
+_GL_INLINE_HEADER_BEGIN
+#ifndef MBUITER_INLINE
+# define MBUITER_INLINE _GL_INLINE
+#endif
+
 struct mbuiter_multi
 {
   bool in_shift;        /* true if next byte may not be interpreted as ASCII */
@@ -120,7 +125,7 @@
         */
 };
 
-static inline void
+MBUITER_INLINE void
 mbuiter_multi_next (struct mbuiter_multi *iter)
 {
   if (iter->next_done)
@@ -181,13 +186,13 @@
   iter->next_done = true;
 }
 
-static inline void
+MBUITER_INLINE void
 mbuiter_multi_reloc (struct mbuiter_multi *iter, ptrdiff_t ptrdiff)
 {
   iter->cur.ptr += ptrdiff;
 }
 
-static inline void
+MBUITER_INLINE void
 mbuiter_multi_copy (struct mbuiter_multi *new_iter, const struct mbuiter_multi *old_iter)
 {
   if ((new_iter->in_shift = old_iter->in_shift))
@@ -219,4 +224,6 @@
 /* Copying an iterator.  */
 #define mbui_copy mbuiter_multi_copy
 
+_GL_INLINE_HEADER_END
+
 #endif /* _MBUITER_H */
new file mode 100644
--- /dev/null
+++ b/lib/xsize.c
@@ -0,0 +1,3 @@
+#include <config.h>
+#define XSIZE_INLINE _GL_EXTERN_INLINE
+#include "xsize.h"
--- a/lib/xsize.h
+++ b/lib/xsize.h
@@ -27,6 +27,11 @@
 # include <stdint.h>
 #endif
 
+_GL_INLINE_HEADER_BEGIN
+#ifndef XSIZE_INLINE
+# define XSIZE_INLINE _GL_INLINE
+#endif
+
 /* The size of memory objects is often computed through expressions of
    type size_t. Example:
       void* p = malloc (header_size + n * element_size).
@@ -48,7 +53,7 @@
   ((N) <= SIZE_MAX ? (size_t) (N) : SIZE_MAX)
 
 /* Sum of two sizes, with overflow check.  */
-static inline size_t
+XSIZE_INLINE size_t
 #if __GNUC__ >= 3
 __attribute__ ((__pure__))
 #endif
@@ -59,7 +64,7 @@
 }
 
 /* Sum of three sizes, with overflow check.  */
-static inline size_t
+XSIZE_INLINE size_t
 #if __GNUC__ >= 3
 __attribute__ ((__pure__))
 #endif
@@ -69,7 +74,7 @@
 }
 
 /* Sum of four sizes, with overflow check.  */
-static inline size_t
+XSIZE_INLINE size_t
 #if __GNUC__ >= 3
 __attribute__ ((__pure__))
 #endif
@@ -79,7 +84,7 @@
 }
 
 /* Maximum of two sizes, with overflow check.  */
-static inline size_t
+XSIZE_INLINE size_t
 #if __GNUC__ >= 3
 __attribute__ ((__pure__))
 #endif
@@ -104,4 +109,6 @@
 #define size_in_bounds_p(SIZE) \
   ((SIZE) != SIZE_MAX)
 
+_GL_INLINE_HEADER_END
+
 #endif /* _XSIZE_H */
--- a/m4/eealloc.m4
+++ b/m4/eealloc.m4
@@ -1,4 +1,4 @@
-# eealloc.m4 serial 2
+# eealloc.m4 serial 3
 dnl Copyright (C) 2003, 2009-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,
@@ -8,7 +8,6 @@
 [
   AC_REQUIRE([gl_EEMALLOC])
   AC_REQUIRE([gl_EEREALLOC])
-  AC_REQUIRE([AC_C_INLINE])
 ])
 
 AC_DEFUN([gl_EEMALLOC],
--- a/m4/mbfile.m4
+++ b/m4/mbfile.m4
@@ -1,4 +1,4 @@
-# mbfile.m4 serial 6
+# mbfile.m4 serial 7
 dnl Copyright (C) 2005, 2008-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,
@@ -9,7 +9,6 @@
 
 AC_DEFUN([gl_MBFILE],
 [
-  AC_REQUIRE([AC_C_INLINE])
   AC_REQUIRE([AC_TYPE_MBSTATE_T])
   :
 ])
--- a/m4/mbiter.m4
+++ b/m4/mbiter.m4
@@ -1,4 +1,4 @@
-# mbiter.m4 serial 6
+# mbiter.m4 serial 7
 dnl Copyright (C) 2005, 2008-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,
@@ -9,7 +9,6 @@
 
 AC_DEFUN([gl_MBITER],
 [
-  AC_REQUIRE([AC_C_INLINE])
   AC_REQUIRE([AC_TYPE_MBSTATE_T])
   :
 ])
--- a/m4/xsize.m4
+++ b/m4/xsize.m4
@@ -1,4 +1,4 @@
-# xsize.m4 serial 4
+# xsize.m4 serial 5
 dnl Copyright (C) 2003-2004, 2008-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,
@@ -8,6 +8,5 @@
 [
   dnl Prerequisites of lib/xsize.h.
   AC_REQUIRE([gl_SIZE_MAX])
-  AC_REQUIRE([AC_C_INLINE])
   AC_CHECK_HEADERS([stdint.h])
 ])
--- a/modules/binary-io
+++ b/modules/binary-io
@@ -3,15 +3,16 @@
 
 Files:
 lib/binary-io.h
+lib/binary-io.c
 
 Depends-on:
+extern-inline
 fcntl-h
 
 configure.ac:
-AC_REQUIRE([AC_C_INLINE])
 
 Makefile.am:
-lib_SOURCES += binary-io.h
+lib_SOURCES += binary-io.h binary-io.c
 
 Include:
 "binary-io.h"
@@ -21,4 +22,3 @@
 
 Maintainer:
 Bruno Haible
-
--- a/modules/eealloc
+++ b/modules/eealloc
@@ -3,16 +3,19 @@
 
 Files:
 lib/eealloc.h
+lib/eealloc.c
 m4/eealloc.m4
 m4/malloc.m4
 m4/realloc.m4
 
 Depends-on:
+extern-inline
 
 configure.ac:
 gl_EEALLOC
 
 Makefile.am:
+lib_SOURCES += eealloc.c
 
 Include:
 <eealloc.h>
--- a/modules/mbfile
+++ b/modules/mbfile
@@ -3,10 +3,12 @@
 
 Files:
 lib/mbfile.h
+lib/mbfile.c
 m4/mbfile.m4
 m4/mbrtowc.m4
 
 Depends-on:
+extern-inline
 mbchar
 mbrtowc
 mbsinit
@@ -17,7 +19,7 @@
 gl_MBFILE
 
 Makefile.am:
-lib_SOURCES += mbfile.h
+lib_SOURCES += mbfile.h mbfile.c
 
 Include:
 "mbfile.h"
@@ -27,4 +29,3 @@
 
 Maintainer:
 Bruno Haible
-
--- a/modules/mbiter
+++ b/modules/mbiter
@@ -3,10 +3,12 @@
 
 Files:
 lib/mbiter.h
+lib/mbiter.c
 m4/mbiter.m4
 m4/mbrtowc.m4
 
 Depends-on:
+extern-inline
 mbchar
 mbrtowc
 mbsinit
@@ -17,7 +19,7 @@
 gl_MBITER
 
 Makefile.am:
-lib_SOURCES += mbiter.h
+lib_SOURCES += mbiter.h mbiter.c
 
 Include:
 "mbiter.h"
@@ -27,4 +29,3 @@
 
 Maintainer:
 Bruno Haible
-
--- a/modules/mbuiter
+++ b/modules/mbuiter
@@ -3,10 +3,12 @@
 
 Files:
 lib/mbuiter.h
+lib/mbuiter.c
 m4/mbiter.m4
 m4/mbrtowc.m4
 
 Depends-on:
+extern-inline
 mbchar
 mbrtowc
 mbsinit
@@ -18,7 +20,7 @@
 gl_MBITER
 
 Makefile.am:
-lib_SOURCES += mbuiter.h
+lib_SOURCES += mbuiter.h mbuiter.c
 
 Include:
 "mbuiter.h"
@@ -28,4 +30,3 @@
 
 Maintainer:
 Bruno Haible
-
--- a/modules/xsize
+++ b/modules/xsize
@@ -3,16 +3,18 @@
 
 Files:
 lib/xsize.h
+lib/xsize.c
 m4/xsize.m4
 
 Depends-on:
+extern-inline
 size_max
 
 configure.ac:
 gl_XSIZE
 
 Makefile.am:
-lib_SOURCES += xsize.h
+lib_SOURCES += xsize.h xsize.c
 
 Include:
 "xsize.h"
@@ -22,4 +24,3 @@
 
 Maintainer:
 Bruno Haible
-