# HG changeset patch # User Paul Eggert # Date 1353479106 28800 # Node ID 1b3c19ad4b17782e3a7b290df211ec8754500c9d # Parent 7178d4d98ee532f5a35d5d264b2873564f633206 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. diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2012-11-29 Paul Eggert + 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): diff --git a/lib/math.c b/lib/math.c new file mode 100644 --- /dev/null +++ b/lib/math.c @@ -0,0 +1,3 @@ +#include +#define _GL_MATH_INLINE _GL_EXTERN_INLINE +#include "math.h" diff --git a/lib/math.in.h b/lib/math.in.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 */ diff --git a/m4/math_h.m4 b/m4/math_h.m4 --- 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 ]], diff --git a/modules/math b/modules/math --- 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 when the system # doesn't have one that works with the given compiler.