New module 'exp2f'.
authorBruno Haible <bruno@clisp.org>
Thu, 8 Mar 2012 19:24:53 +0000 (20:24 +0100)
committerBruno Haible <bruno@clisp.org>
Fri, 9 Mar 2012 01:15:35 +0000 (02:15 +0100)
* 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.

ChangeLog
doc/posix-functions/exp2f.texi
lib/exp2f.c [new file with mode: 0644]
lib/math.in.h
m4/exp2f.m4 [new file with mode: 0644]
m4/math_h.m4
modules/exp2f [new file with mode: 0644]
modules/math
tests/test-math-c++.cc

index af5fd9f..ebd2796 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
 2012-03-08  Bruno Haible  <bruno@clisp.org>
 
 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'.
        * modules/exp2-tests: New file.
        * tests/test-exp2.c: New file.
        Tests for module 'exp2'.
        * modules/exp2-tests: New file.
        * tests/test-exp2.c: New file.
index acf65f4..3a9a4e8 100644 (file)
@@ -4,15 +4,18 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/exp2f.html}
 
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/exp2f.html}
 
-Gnulib module: ---
+Gnulib module: exp2f
 
 Portability problems fixed by Gnulib:
 @itemize
 
 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
 @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
 @end itemize
diff --git a/lib/exp2f.c b/lib/exp2f.c
new file mode 100644 (file)
index 0000000..a3a3cdd
--- /dev/null
@@ -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);
+}
index d0df55b..642d8b3 100644 (file)
@@ -532,6 +532,20 @@ _GL_WARN_ON_USE (expl, "expl is unportable - "
 #endif
 
 
 #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)
 #if @GNULIB_EXP2@
 # if @REPLACE_EXP2@
 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
diff --git a/m4/exp2f.m4 b/m4/exp2f.m4
new file mode 100644 (file)
index 0000000..3be34e4
--- /dev/null
@@ -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])
+])
index 938dcf1..772b998 100644 (file)
@@ -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,
 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 @@ AC_DEFUN([gl_MATH_H],
   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
   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
      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 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
   GNULIB_EXPF=0;       AC_SUBST([GNULIB_EXPF])
   GNULIB_EXPL=0;       AC_SUBST([GNULIB_EXPL])
   GNULIB_EXP2=0;       AC_SUBST([GNULIB_EXP2])
   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])
   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 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
   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_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])
   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])
diff --git a/modules/exp2f b/modules/exp2f
new file mode 100644 (file)
index 0000000..cb98872
--- /dev/null
@@ -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
index bb03a84..3116618 100644 (file)
@@ -50,6 +50,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
              -e 's/@''GNULIB_EXPF''@/$(GNULIB_EXPF)/g' \
              -e 's/@''GNULIB_EXPL''@/$(GNULIB_EXPL)/g' \
              -e 's/@''GNULIB_EXP2''@/$(GNULIB_EXP2)/g' \
              -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' \
              -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 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
              -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_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' \
              -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' \
index 18ec07a..904e927 100644 (file)
@@ -124,6 +124,9 @@ SIGNATURE_CHECK (GNULIB_NAMESPACE::expf, float, (float));
 SIGNATURE_CHECK (GNULIB_NAMESPACE::expl, long double, (long double));
 #endif
 
 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
 #if GNULIB_TEST_EXP2
 SIGNATURE_CHECK (GNULIB_NAMESPACE::exp2, double, (double));
 #endif