Mercurial > hg > octave-lyh > gnulib-hg
changeset 16618:ca62953d33cd
New module 'exp2f'.
* lib/math.in.h (exp2f): New declaration.
* lib/exp2f.c: New file.
* m4/exp2f.m4: New file.
* m4/math_h.m4 (gl_MATH_H): Test whether exp2f is declared.
(gl_MATH_H_DEFAULTS): Initialize GNULIB_EXP2F, HAVE_DECL_EXP2F.
* modules/math (Makefile.am): Substitute GNULIB_EXP2F, HAVE_DECL_EXP2F.
* modules/exp2f: New file.
* tests/test-math-c++.cc: Check the declaration of exp2f.
* doc/posix-functions/exp2f.texi: Mention the new module and the
IRIX problem.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Thu, 08 Mar 2012 20:24:53 +0100 |
parents | 927dd3ecbb9e |
children | a249e5e18fa4 |
files | ChangeLog doc/posix-functions/exp2f.texi lib/exp2f.c lib/math.in.h m4/exp2f.m4 m4/math_h.m4 modules/exp2f modules/math tests/test-math-c++.cc |
diffstat | 9 files changed, 137 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2012-03-08 Bruno Haible <bruno@clisp.org> + + New module 'exp2f'. + * lib/math.in.h (exp2f): New declaration. + * lib/exp2f.c: New file. + * m4/exp2f.m4: New file. + * m4/math_h.m4 (gl_MATH_H): Test whether exp2f is declared. + (gl_MATH_H_DEFAULTS): Initialize GNULIB_EXP2F, HAVE_DECL_EXP2F. + * modules/math (Makefile.am): Substitute GNULIB_EXP2F, HAVE_DECL_EXP2F. + * modules/exp2f: New file. + * tests/test-math-c++.cc: Check the declaration of exp2f. + * doc/posix-functions/exp2f.texi: Mention the new module and the + IRIX problem. + 2012-03-08 Bruno Haible <bruno@clisp.org> Tests for module 'exp2'.
--- a/doc/posix-functions/exp2f.texi +++ b/doc/posix-functions/exp2f.texi @@ -4,15 +4,18 @@ POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/exp2f.html} -Gnulib module: --- +Gnulib module: exp2f Portability problems fixed by Gnulib: @itemize +@item +This function is missing on some platforms: +FreeBSD 5.2.1, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 5.1, HP-UX 11, older IRIX 6.5, OSF/1 4.0, Solaris 9, MSVC 9, Interix 3.5. +@item +This function is not declared on some platforms: +IRIX 6.5. @end itemize Portability problems not fixed by Gnulib: @itemize -@item -This function is missing on some platforms: -FreeBSD 5.2.1, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 5.1, HP-UX 11, IRIX 6.5, OSF/1 4.0, Solaris 9, MSVC 9, Interix 3.5. @end itemize
new file mode 100644 --- /dev/null +++ b/lib/exp2f.c @@ -0,0 +1,26 @@ +/* Exponential base 2 function. + Copyright (C) 2011-2012 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +#include <config.h> + +/* Specification. */ +#include <math.h> + +float +exp2f (float x) +{ + return (float) exp2 ((double) x); +}
--- a/lib/math.in.h +++ b/lib/math.in.h @@ -532,6 +532,20 @@ #endif +#if @GNULIB_EXP2F@ +# if !@HAVE_DECL_EXP2F@ +_GL_FUNCDECL_SYS (exp2f, float, (float x)); +# endif +_GL_CXXALIAS_SYS (exp2f, float, (float x)); +_GL_CXXALIASWARN (exp2f); +#elif defined GNULIB_POSIXCHECK +# undef exp2f +# if HAVE_RAW_DECL_EXP2F +_GL_WARN_ON_USE (exp2f, "exp2f is unportable - " + "use gnulib module exp2f for portability"); +# endif +#endif + #if @GNULIB_EXP2@ # if @REPLACE_EXP2@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
new file mode 100644 --- /dev/null +++ b/m4/exp2f.m4 @@ -0,0 +1,34 @@ +# exp2f.m4 serial 1 +dnl Copyright (C) 2011-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, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_EXP2F], +[ + AC_REQUIRE([gl_MATH_H_DEFAULTS]) + AC_REQUIRE([gl_FUNC_EXP2]) + + dnl Persuade glibc <math.h> to declare exp2f(). + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + + dnl Test whether exp2f() exists. Assume that exp2f(), if it exists, is + dnl defined in the same library as exp2(). + save_LIBS="$LIBS" + LIBS="$LIBS $EXP2_LIBM" + AC_CHECK_FUNCS([exp2f]) + LIBS="$save_LIBS" + if test $ac_cv_func_exp2f = yes; then + HAVE_EXP2F=1 + EXP2F_LIBM="$EXP2_LIBM" + dnl Also check whether it's declared. + dnl IRIX 6.5 has exp2f() in libm but doesn't declare it in <math.h>. + AC_CHECK_DECL([exp2f], , [HAVE_DECL_EXP2F=0], [[#include <math.h>]]) + else + HAVE_EXP2F=0 + HAVE_DECL_EXP2F=0 + dnl Find libraries needed to link lib/exp2f.c. + EXP2F_LIBM="$EXP2_LIBM" + fi + AC_SUBST([EXP2F_LIBM]) +])
--- a/m4/math_h.m4 +++ b/m4/math_h.m4 @@ -1,4 +1,4 @@ -# math_h.m4 serial 89 +# math_h.m4 serial 90 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, @@ -41,7 +41,8 @@ gl_WARN_ON_USE_PREPARE([[#include <math.h>]], [acosf acosl asinf asinl atanf atanl cbrt cbrtf cbrtl ceilf ceill copysign copysignf copysignl cosf cosl coshf - expf expl exp2 expm1 expm1f expm1l fabsf fabsl floorf floorl fma fmaf fmal + expf expl exp2 exp2f expm1 expm1f expm1l + fabsf fabsl floorf floorl fma fmaf fmal fmod fmodf fmodl frexpf frexpl hypotf hypotl ldexpf ldexpl logb logf logl log10f log10l modf modff modfl powf remainder remainderf remainderl @@ -82,6 +83,7 @@ GNULIB_EXPF=0; AC_SUBST([GNULIB_EXPF]) GNULIB_EXPL=0; AC_SUBST([GNULIB_EXPL]) GNULIB_EXP2=0; AC_SUBST([GNULIB_EXP2]) + GNULIB_EXP2F=0; AC_SUBST([GNULIB_EXP2F]) GNULIB_EXPM1=0; AC_SUBST([GNULIB_EXPM1]) GNULIB_EXPM1F=0; AC_SUBST([GNULIB_EXPM1F]) GNULIB_EXPM1L=0; AC_SUBST([GNULIB_EXPM1L]) @@ -204,6 +206,7 @@ HAVE_DECL_COSL=1; AC_SUBST([HAVE_DECL_COSL]) HAVE_DECL_EXPL=1; AC_SUBST([HAVE_DECL_EXPL]) HAVE_DECL_EXP2=1; AC_SUBST([HAVE_DECL_EXP2]) + HAVE_DECL_EXP2F=1; AC_SUBST([HAVE_DECL_EXP2F]) HAVE_DECL_EXPM1L=1; AC_SUBST([HAVE_DECL_EXPM1L]) HAVE_DECL_FLOORF=1; AC_SUBST([HAVE_DECL_FLOORF]) HAVE_DECL_FLOORL=1; AC_SUBST([HAVE_DECL_FLOORL])
new file mode 100644 --- /dev/null +++ b/modules/exp2f @@ -0,0 +1,32 @@ +Description: +exp2f() function: exponential base 2 function. + +Files: +lib/exp2f.c +m4/exp2f.m4 + +Depends-on: +math +extensions +exp2 [test $HAVE_EXP2F = 0] + +configure.ac: +gl_FUNC_EXP2F +if test $HAVE_EXP2F = 0; then + AC_LIBOBJ([exp2f]) +fi +gl_MATH_MODULE_INDICATOR([exp2f]) + +Makefile.am: + +Include: +<math.h> + +Link: +$(EXP2F_LIBM) + +License: +LGPL + +Maintainer: +Bruno Haible
--- a/modules/math +++ b/modules/math @@ -50,6 +50,7 @@ -e 's/@''GNULIB_EXPF''@/$(GNULIB_EXPF)/g' \ -e 's/@''GNULIB_EXPL''@/$(GNULIB_EXPL)/g' \ -e 's/@''GNULIB_EXP2''@/$(GNULIB_EXP2)/g' \ + -e 's/@''GNULIB_EXP2F''@/$(GNULIB_EXP2F)/g' \ -e 's/@''GNULIB_EXPM1''@/$(GNULIB_EXPM1)/g' \ -e 's/@''GNULIB_EXPM1F''@/$(GNULIB_EXPM1F)/g' \ -e 's/@''GNULIB_EXPM1L''@/$(GNULIB_EXPM1L)/g' \ @@ -172,6 +173,7 @@ -e 's|@''HAVE_DECL_COSL''@|$(HAVE_DECL_COSL)|g' \ -e 's|@''HAVE_DECL_EXPL''@|$(HAVE_DECL_EXPL)|g' \ -e 's|@''HAVE_DECL_EXP2''@|$(HAVE_DECL_EXP2)|g' \ + -e 's|@''HAVE_DECL_EXP2F''@|$(HAVE_DECL_EXP2F)|g' \ -e 's|@''HAVE_DECL_EXPM1L''@|$(HAVE_DECL_EXPM1L)|g' \ -e 's|@''HAVE_DECL_FLOORF''@|$(HAVE_DECL_FLOORF)|g' \ -e 's|@''HAVE_DECL_FLOORL''@|$(HAVE_DECL_FLOORL)|g' \
--- a/tests/test-math-c++.cc +++ b/tests/test-math-c++.cc @@ -124,6 +124,9 @@ SIGNATURE_CHECK (GNULIB_NAMESPACE::expl, long double, (long double)); #endif +#if GNULIB_TEST_EXP2F +SIGNATURE_CHECK (GNULIB_NAMESPACE::exp2f, float, (float)); +#endif #if GNULIB_TEST_EXP2 SIGNATURE_CHECK (GNULIB_NAMESPACE::exp2, double, (double)); #endif