changeset 17168:1b3c19ad4b17

math: better 'inline' * lib/math.c: New file. * lib/math.in.h (_GL_MATH_INLINE): New macro. Replace all uses of 'static inline' with it. Use _GL_INLINE_HEADER_BEGIN, _GL_INLINE_HEADER_END. * m4/math_h.m4 (gl_MATH_H): Do not require AC_C_INLINE. * modules/math (Files, lib_SOURCES): Add lib/math.c. (Depends-on): Add extern-inline.
author Paul Eggert <eggert@cs.ucla.edu>
date Tue, 20 Nov 2012 22:25:06 -0800
parents 7178d4d98ee5
children 8b10fbdb551e
files ChangeLog lib/math.c lib/math.in.h m4/math_h.m4 modules/math
diffstat 5 files changed, 27 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2012-11-29  Paul Eggert  <eggert@cs.ucla.edu>
 
+	math: better 'inline'
+	* lib/math.c: New file.
+	* lib/math.in.h (_GL_MATH_INLINE):
+	New macro.  Replace all uses of 'static inline' with it.
+	Use _GL_INLINE_HEADER_BEGIN, _GL_INLINE_HEADER_END.
+	* m4/math_h.m4 (gl_MATH_H):
+	Do not require AC_C_INLINE.
+	* modules/math (Files, lib_SOURCES):
+	Add lib/math.c.
+	(Depends-on): Add extern-inline.
+
 	count-one-bits: better 'inline'
 	* lib/count-one-bits.c: New file.
 	* lib/count-one-bits.h (COUNT_ONE_BITS_INLINE):
new file mode 100644
--- /dev/null
+++ b/lib/math.c
@@ -0,0 +1,3 @@
+#include <config.h>
+#define _GL_MATH_INLINE _GL_EXTERN_INLINE
+#include "math.h"
--- a/lib/math.in.h
+++ b/lib/math.in.h
@@ -28,6 +28,10 @@
 #ifndef _@GUARD_PREFIX@_MATH_H
 #define _@GUARD_PREFIX@_MATH_H
 
+_GL_INLINE_HEADER_BEGIN
+#ifndef _GL_MATH_INLINE
+# define _GL_MATH_INLINE _GL_INLINE
+#endif
 
 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
 
@@ -78,17 +82,17 @@
    classification macros with an argument of real-floating (that is,
    one of float, double, or long double).  */
 #define _GL_WARN_REAL_FLOATING_DECL(func) \
-static inline int                                                   \
+_GL_MATH_INLINE int                                                 \
 rpl_ ## func ## f (float f)                                         \
 {                                                                   \
   return func (f);                                                  \
 }                                                                   \
-static inline int                                                   \
+_GL_MATH_INLINE int                                                 \
 rpl_ ## func ## d (double d)                                        \
 {                                                                   \
   return func (d);                                                  \
 }                                                                   \
-static inline int                                                   \
+_GL_MATH_INLINE int                                                 \
 rpl_ ## func ## l (long double l)                                   \
 {                                                                   \
   return func (l);                                                  \
@@ -124,7 +128,7 @@
   /* The Compaq (ex-DEC) C 6.4 compiler and the Microsoft MSVC 9 compiler
      choke on the expression 0.0 / 0.0.  */
 #  if defined __DECC || defined _MSC_VER
-static float
+_GL_MATH_INLINE float
 _NaN ()
 {
   static float zero = 0.0f;
@@ -2265,6 +2269,7 @@
 # endif
 #endif
 
+_GL_INLINE_HEADER_END
 
 #endif /* _@GUARD_PREFIX@_MATH_H */
 #endif /* _@GUARD_PREFIX@_MATH_H */
--- a/m4/math_h.m4
+++ b/m4/math_h.m4
@@ -1,4 +1,4 @@
-# math_h.m4 serial 113
+# math_h.m4 serial 114
 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,
@@ -8,7 +8,6 @@
 [
   AC_REQUIRE([gl_MATH_H_DEFAULTS])
   gl_CHECK_NEXT_HEADERS([math.h])
-  AC_REQUIRE([AC_C_INLINE])
 
   AC_CACHE_CHECK([whether NAN macro works], [gl_cv_header_math_nan_works],
     [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <math.h>]],
--- a/modules/math
+++ b/modules/math
@@ -3,9 +3,11 @@
 
 Files:
 lib/math.in.h
+lib/math.c
 m4/math_h.m4
 
 Depends-on:
+extern-inline
 include_next
 snippet/arg-nonnull
 snippet/c++defs
@@ -17,6 +19,7 @@
 
 Makefile.am:
 BUILT_SOURCES += math.h
+lib_SOURCES += math.c
 
 # We need the following in order to create <math.h> when the system
 # doesn't have one that works with the given compiler.