mirror of
https://git.savannah.gnu.org/git/gnulib.git
synced 2025-09-02 15:41:25 +03:00
New module 'hypotf'.
* lib/math.in.h (hypotf): New declaration. * lib/hypotf.c: New file. * m4/hypotf.m4: New file. * m4/math_h.m4 (gl_MATH_H): Test whether hypotf is declared. (gl_MATH_H_DEFAULTS): Initialize GNULIB_HYPOTF, HAVE_HYPOTF, REPLACE_HYPOTF. * modules/math (Makefile.am): Substitute GNULIB_HYPOTF, HAVE_HYPOTF, REPLACE_HYPOTF. * modules/hypotf: New file. * tests/test-math-c++.cc: Check the hypotf declaration. * doc/posix-functions/hypotf.texi: Mention the new module.
This commit is contained in:
13
ChangeLog
13
ChangeLog
@@ -1,5 +1,18 @@
|
|||||||
2012-02-29 Bruno Haible <bruno@clisp.org>
|
2012-02-29 Bruno Haible <bruno@clisp.org>
|
||||||
|
|
||||||
|
New module 'hypotf'.
|
||||||
|
* lib/math.in.h (hypotf): New declaration.
|
||||||
|
* lib/hypotf.c: New file.
|
||||||
|
* m4/hypotf.m4: New file.
|
||||||
|
* m4/math_h.m4 (gl_MATH_H): Test whether hypotf is declared.
|
||||||
|
(gl_MATH_H_DEFAULTS): Initialize GNULIB_HYPOTF, HAVE_HYPOTF,
|
||||||
|
REPLACE_HYPOTF.
|
||||||
|
* modules/math (Makefile.am): Substitute GNULIB_HYPOTF, HAVE_HYPOTF,
|
||||||
|
REPLACE_HYPOTF.
|
||||||
|
* modules/hypotf: New file.
|
||||||
|
* tests/test-math-c++.cc: Check the hypotf declaration.
|
||||||
|
* doc/posix-functions/hypotf.texi: Mention the new module.
|
||||||
|
|
||||||
hypot: Prepare for hypotf module.
|
hypot: Prepare for hypotf module.
|
||||||
* m4/hypot.m4: New file.
|
* m4/hypot.m4: New file.
|
||||||
* modules/hypot (Files): Add m4/hypot.m4.
|
* modules/hypot (Files): Add m4/hypot.m4.
|
||||||
|
@@ -4,15 +4,18 @@
|
|||||||
|
|
||||||
POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/hypotf.html}
|
POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/hypotf.html}
|
||||||
|
|
||||||
Gnulib module: ---
|
Gnulib module: hypotf
|
||||||
|
|
||||||
Portability problems fixed by Gnulib:
|
Portability problems fixed by Gnulib:
|
||||||
@itemize
|
@itemize
|
||||||
@end itemize
|
|
||||||
|
|
||||||
Portability problems not fixed by Gnulib:
|
|
||||||
@itemize
|
|
||||||
@item
|
@item
|
||||||
This function is missing on some platforms:
|
This function is missing on some platforms:
|
||||||
Minix 3.1.8, AIX 5.1, HP-UX 11, Solaris 9, MSVC 9.
|
Minix 3.1.8, AIX 5.1, HP-UX 11, Solaris 9, MSVC 9.
|
||||||
|
@item
|
||||||
|
This function produces wrong values on some platforms:
|
||||||
|
NetBSD 5.1, OpenBSD 4.9.
|
||||||
|
@end itemize
|
||||||
|
|
||||||
|
Portability problems not fixed by Gnulib:
|
||||||
|
@itemize
|
||||||
@end itemize
|
@end itemize
|
||||||
|
26
lib/hypotf.c
Normal file
26
lib/hypotf.c
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
/* Hypotenuse of a right-angled triangle.
|
||||||
|
Copyright (C) 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
|
||||||
|
hypotf (float x, float y)
|
||||||
|
{
|
||||||
|
return (float) hypot ((double) x, (double) y);
|
||||||
|
}
|
@@ -808,6 +808,31 @@ _GL_WARN_ON_USE (frexpl, "frexpl is unportable - "
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* Return sqrt(x^2+y^2). */
|
||||||
|
#if @GNULIB_HYPOTF@
|
||||||
|
# if @REPLACE_HYPOTF@
|
||||||
|
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||||
|
# undef hypotf
|
||||||
|
# define hypotf rpl_hypotf
|
||||||
|
# endif
|
||||||
|
_GL_FUNCDECL_RPL (hypotf, float, (float x, float y));
|
||||||
|
_GL_CXXALIAS_RPL (hypotf, float, (float x, float y));
|
||||||
|
# else
|
||||||
|
# if !@HAVE_HYPOTF@
|
||||||
|
_GL_FUNCDECL_SYS (hypotf, float, (float x, float y));
|
||||||
|
# endif
|
||||||
|
_GL_CXXALIAS_SYS (hypotf, float, (float x, float y));
|
||||||
|
# endif
|
||||||
|
_GL_CXXALIASWARN (hypotf);
|
||||||
|
#elif defined GNULIB_POSIXCHECK
|
||||||
|
# undef hypotf
|
||||||
|
# if HAVE_RAW_DECL_HYPOTF
|
||||||
|
_GL_WARN_ON_USE (hypotf, "hypotf is unportable - "
|
||||||
|
"use gnulib module hypotf for portability");
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Return x * 2^exp. */
|
/* Return x * 2^exp. */
|
||||||
#if @GNULIB_LDEXPF@
|
#if @GNULIB_LDEXPF@
|
||||||
# if !@HAVE_LDEXPF@
|
# if !@HAVE_LDEXPF@
|
||||||
|
83
m4/hypotf.m4
Normal file
83
m4/hypotf.m4
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
# hypotf.m4 serial 1
|
||||||
|
dnl Copyright (C) 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_HYPOTF],
|
||||||
|
[
|
||||||
|
AC_REQUIRE([gl_MATH_H_DEFAULTS])
|
||||||
|
AC_REQUIRE([gl_FUNC_HYPOT])
|
||||||
|
|
||||||
|
dnl Test whether hypotf() exists. Assume that hypotf(), if it exists, is
|
||||||
|
dnl defined in the same library as fmod().
|
||||||
|
save_LIBS="$LIBS"
|
||||||
|
LIBS="$LIBS $HYPOT_LIBM"
|
||||||
|
AC_CHECK_FUNCS([hypotf])
|
||||||
|
LIBS="$save_LIBS"
|
||||||
|
if test $ac_cv_func_hypotf = yes; then
|
||||||
|
HYPOTF_LIBM="$HYPOT_LIBM"
|
||||||
|
save_LIBS="$LIBS"
|
||||||
|
LIBS="$LIBS $HYPOTF_LIBM"
|
||||||
|
gl_FUNC_HYPOTF_WORKS
|
||||||
|
LIBS="$save_LIBS"
|
||||||
|
case "$gl_cv_func_hypotf_works" in
|
||||||
|
*yes) ;;
|
||||||
|
*) REPLACE_HYPOTF=1 ;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
HAVE_HYPOTF=0
|
||||||
|
fi
|
||||||
|
if test $HAVE_HYPOTF = 0 || test $REPLACE_HYPOTF = 1; then
|
||||||
|
dnl Find libraries needed to link lib/hypotf.c.
|
||||||
|
HYPOTF_LIBM="$HYPOT_LIBM"
|
||||||
|
fi
|
||||||
|
AC_SUBST([HYPOTF_LIBM])
|
||||||
|
])
|
||||||
|
|
||||||
|
dnl Test whether hypotf() works.
|
||||||
|
dnl It returns wrong values on NetBSD 5.1/x86_64 and OpenBSD 4.9/x86.
|
||||||
|
AC_DEFUN([gl_FUNC_HYPOTF_WORKS],
|
||||||
|
[
|
||||||
|
AC_REQUIRE([AC_PROG_CC])
|
||||||
|
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
|
||||||
|
AC_CACHE_CHECK([whether hypotf works], [gl_cv_func_hypotf_works],
|
||||||
|
[
|
||||||
|
AC_RUN_IFELSE(
|
||||||
|
[AC_LANG_SOURCE([[
|
||||||
|
#include <float.h>
|
||||||
|
#include <math.h>
|
||||||
|
volatile float x;
|
||||||
|
volatile float y;
|
||||||
|
volatile float z;
|
||||||
|
int main ()
|
||||||
|
{
|
||||||
|
int result = 0;
|
||||||
|
/* This test fails on NetBSD 5.1. */
|
||||||
|
{
|
||||||
|
x = FLT_MIN * 2.0f;
|
||||||
|
y = FLT_MIN * 3.0f;
|
||||||
|
z = hypotf (x, y);
|
||||||
|
if (!(z >= FLT_MIN * 2.0f && z <= FLT_MIN * 4.0f))
|
||||||
|
result |= 1;
|
||||||
|
}
|
||||||
|
/* This test fails on OpenBSD 4.9. */
|
||||||
|
{
|
||||||
|
x = FLT_MAX;
|
||||||
|
y = FLT_MAX * 0.5f;
|
||||||
|
z = hypotf (x, y);
|
||||||
|
if (!(z > 0 && z == z + z))
|
||||||
|
result |= 2;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
]])],
|
||||||
|
[gl_cv_func_hypotf_works=yes],
|
||||||
|
[gl_cv_func_hypotf_works=no],
|
||||||
|
[case "$host_os" in
|
||||||
|
netbsd* | openbsd*) gl_cv_func_hypotf_works="guessing no";;
|
||||||
|
*) gl_cv_func_hypotf_works="guessing yes";;
|
||||||
|
esac
|
||||||
|
])
|
||||||
|
])
|
||||||
|
])
|
@@ -1,4 +1,4 @@
|
|||||||
# math_h.m4 serial 71
|
# math_h.m4 serial 72
|
||||||
dnl Copyright (C) 2007-2012 Free Software Foundation, Inc.
|
dnl Copyright (C) 2007-2012 Free Software Foundation, Inc.
|
||||||
dnl This file is free software; the Free Software Foundation
|
dnl This file is free software; the Free Software Foundation
|
||||||
dnl gives unlimited permission to copy and/or distribute it,
|
dnl gives unlimited permission to copy and/or distribute it,
|
||||||
@@ -42,7 +42,7 @@ AC_DEFUN([gl_MATH_H],
|
|||||||
[acosf acosl asinf asinl atanf atanl
|
[acosf acosl asinf asinl atanf atanl
|
||||||
ceilf ceill copysign copysignf copysignl cosf cosl coshf
|
ceilf ceill copysign copysignf copysignl cosf cosl coshf
|
||||||
expf expl fabsf fabsl floorf floorl fma fmaf fmal
|
expf expl fabsf fabsl floorf floorl fma fmaf fmal
|
||||||
fmod fmodf fmodl frexpf frexpl
|
fmod fmodf fmodl frexpf frexpl hypotf
|
||||||
ldexpf ldexpl logb logf logl log10f log10l modf modff modfl powf
|
ldexpf ldexpl logb logf logl log10f log10l modf modff modfl powf
|
||||||
remainder remainderf remainderl
|
remainder remainderf remainderl
|
||||||
rint rintf rintl round roundf roundl sinf sinl sinhf sqrtf sqrtl
|
rint rintf rintl round roundf roundl sinf sinl sinhf sqrtf sqrtl
|
||||||
@@ -92,6 +92,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
|
|||||||
GNULIB_FREXPF=0; AC_SUBST([GNULIB_FREXPF])
|
GNULIB_FREXPF=0; AC_SUBST([GNULIB_FREXPF])
|
||||||
GNULIB_FREXP=0; AC_SUBST([GNULIB_FREXP])
|
GNULIB_FREXP=0; AC_SUBST([GNULIB_FREXP])
|
||||||
GNULIB_FREXPL=0; AC_SUBST([GNULIB_FREXPL])
|
GNULIB_FREXPL=0; AC_SUBST([GNULIB_FREXPL])
|
||||||
|
GNULIB_HYPOTF=0; AC_SUBST([GNULIB_HYPOTF])
|
||||||
GNULIB_ISFINITE=0; AC_SUBST([GNULIB_ISFINITE])
|
GNULIB_ISFINITE=0; AC_SUBST([GNULIB_ISFINITE])
|
||||||
GNULIB_ISINF=0; AC_SUBST([GNULIB_ISINF])
|
GNULIB_ISINF=0; AC_SUBST([GNULIB_ISINF])
|
||||||
GNULIB_ISNAN=0; AC_SUBST([GNULIB_ISNAN])
|
GNULIB_ISNAN=0; AC_SUBST([GNULIB_ISNAN])
|
||||||
@@ -154,6 +155,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
|
|||||||
HAVE_FMODF=1; AC_SUBST([HAVE_FMODF])
|
HAVE_FMODF=1; AC_SUBST([HAVE_FMODF])
|
||||||
HAVE_FMODL=1; AC_SUBST([HAVE_FMODL])
|
HAVE_FMODL=1; AC_SUBST([HAVE_FMODL])
|
||||||
HAVE_FREXPF=1; AC_SUBST([HAVE_FREXPF])
|
HAVE_FREXPF=1; AC_SUBST([HAVE_FREXPF])
|
||||||
|
HAVE_HYPOTF=1; AC_SUBST([HAVE_HYPOTF])
|
||||||
HAVE_ISNANF=1; AC_SUBST([HAVE_ISNANF])
|
HAVE_ISNANF=1; AC_SUBST([HAVE_ISNANF])
|
||||||
HAVE_ISNAND=1; AC_SUBST([HAVE_ISNAND])
|
HAVE_ISNAND=1; AC_SUBST([HAVE_ISNAND])
|
||||||
HAVE_ISNANL=1; AC_SUBST([HAVE_ISNANL])
|
HAVE_ISNANL=1; AC_SUBST([HAVE_ISNANL])
|
||||||
@@ -220,6 +222,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
|
|||||||
REPLACE_FREXP=0; AC_SUBST([REPLACE_FREXP])
|
REPLACE_FREXP=0; AC_SUBST([REPLACE_FREXP])
|
||||||
REPLACE_FREXPL=0; AC_SUBST([REPLACE_FREXPL])
|
REPLACE_FREXPL=0; AC_SUBST([REPLACE_FREXPL])
|
||||||
REPLACE_HUGE_VAL=0; AC_SUBST([REPLACE_HUGE_VAL])
|
REPLACE_HUGE_VAL=0; AC_SUBST([REPLACE_HUGE_VAL])
|
||||||
|
REPLACE_HYPOTF=0; AC_SUBST([REPLACE_HYPOTF])
|
||||||
REPLACE_ISFINITE=0; AC_SUBST([REPLACE_ISFINITE])
|
REPLACE_ISFINITE=0; AC_SUBST([REPLACE_ISFINITE])
|
||||||
REPLACE_ISINF=0; AC_SUBST([REPLACE_ISINF])
|
REPLACE_ISINF=0; AC_SUBST([REPLACE_ISINF])
|
||||||
REPLACE_ISNAN=0; AC_SUBST([REPLACE_ISNAN])
|
REPLACE_ISNAN=0; AC_SUBST([REPLACE_ISNAN])
|
||||||
|
32
modules/hypotf
Normal file
32
modules/hypotf
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
Description:
|
||||||
|
hypotf() function: length of a vector in the plane.
|
||||||
|
|
||||||
|
Files:
|
||||||
|
lib/hypotf.c
|
||||||
|
m4/hypotf.m4
|
||||||
|
m4/mathfunc.m4
|
||||||
|
|
||||||
|
Depends-on:
|
||||||
|
math
|
||||||
|
hypot [test $HAVE_HYPOTF = 0 || test $REPLACE_HYPOTF = 1]
|
||||||
|
|
||||||
|
configure.ac:
|
||||||
|
gl_FUNC_HYPOTF
|
||||||
|
if test $HAVE_HYPOTF = 0 || test $REPLACE_HYPOTF = 1; then
|
||||||
|
AC_LIBOBJ([hypotf])
|
||||||
|
fi
|
||||||
|
gl_MATH_MODULE_INDICATOR([hypotf])
|
||||||
|
|
||||||
|
Makefile.am:
|
||||||
|
|
||||||
|
Include:
|
||||||
|
<math.h>
|
||||||
|
|
||||||
|
Link:
|
||||||
|
$(HYPOTF_LIBM)
|
||||||
|
|
||||||
|
License:
|
||||||
|
LGPL
|
||||||
|
|
||||||
|
Maintainer:
|
||||||
|
Bruno Haible
|
@@ -60,6 +60,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
|
|||||||
-e 's/@''GNULIB_FREXPF''@/$(GNULIB_FREXPF)/g' \
|
-e 's/@''GNULIB_FREXPF''@/$(GNULIB_FREXPF)/g' \
|
||||||
-e 's/@''GNULIB_FREXP''@/$(GNULIB_FREXP)/g' \
|
-e 's/@''GNULIB_FREXP''@/$(GNULIB_FREXP)/g' \
|
||||||
-e 's/@''GNULIB_FREXPL''@/$(GNULIB_FREXPL)/g' \
|
-e 's/@''GNULIB_FREXPL''@/$(GNULIB_FREXPL)/g' \
|
||||||
|
-e 's/@''GNULIB_HYPOTF''@/$(GNULIB_HYPOTF)/g' \
|
||||||
-e 's/@''GNULIB_ISFINITE''@/$(GNULIB_ISFINITE)/g' \
|
-e 's/@''GNULIB_ISFINITE''@/$(GNULIB_ISFINITE)/g' \
|
||||||
-e 's/@''GNULIB_ISINF''@/$(GNULIB_ISINF)/g' \
|
-e 's/@''GNULIB_ISINF''@/$(GNULIB_ISINF)/g' \
|
||||||
-e 's/@''GNULIB_ISNAN''@/$(GNULIB_ISNAN)/g' \
|
-e 's/@''GNULIB_ISNAN''@/$(GNULIB_ISNAN)/g' \
|
||||||
@@ -122,6 +123,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
|
|||||||
-e 's|@''HAVE_FMODF''@|$(HAVE_FMODF)|g' \
|
-e 's|@''HAVE_FMODF''@|$(HAVE_FMODF)|g' \
|
||||||
-e 's|@''HAVE_FMODL''@|$(HAVE_FMODL)|g' \
|
-e 's|@''HAVE_FMODL''@|$(HAVE_FMODL)|g' \
|
||||||
-e 's|@''HAVE_FREXPF''@|$(HAVE_FREXPF)|g' \
|
-e 's|@''HAVE_FREXPF''@|$(HAVE_FREXPF)|g' \
|
||||||
|
-e 's|@''HAVE_HYPOTF''@|$(HAVE_HYPOTF)|g' \
|
||||||
-e 's|@''HAVE_ISNANF''@|$(HAVE_ISNANF)|g' \
|
-e 's|@''HAVE_ISNANF''@|$(HAVE_ISNANF)|g' \
|
||||||
-e 's|@''HAVE_ISNAND''@|$(HAVE_ISNAND)|g' \
|
-e 's|@''HAVE_ISNAND''@|$(HAVE_ISNAND)|g' \
|
||||||
-e 's|@''HAVE_ISNANL''@|$(HAVE_ISNANL)|g' \
|
-e 's|@''HAVE_ISNANL''@|$(HAVE_ISNANL)|g' \
|
||||||
@@ -189,6 +191,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
|
|||||||
-e 's|@''REPLACE_FREXP''@|$(REPLACE_FREXP)|g' \
|
-e 's|@''REPLACE_FREXP''@|$(REPLACE_FREXP)|g' \
|
||||||
-e 's|@''REPLACE_FREXPL''@|$(REPLACE_FREXPL)|g' \
|
-e 's|@''REPLACE_FREXPL''@|$(REPLACE_FREXPL)|g' \
|
||||||
-e 's|@''REPLACE_HUGE_VAL''@|$(REPLACE_HUGE_VAL)|g' \
|
-e 's|@''REPLACE_HUGE_VAL''@|$(REPLACE_HUGE_VAL)|g' \
|
||||||
|
-e 's|@''REPLACE_HYPOTF''@|$(REPLACE_HYPOTF)|g' \
|
||||||
-e 's|@''REPLACE_ISFINITE''@|$(REPLACE_ISFINITE)|g' \
|
-e 's|@''REPLACE_ISFINITE''@|$(REPLACE_ISFINITE)|g' \
|
||||||
-e 's|@''REPLACE_ISINF''@|$(REPLACE_ISINF)|g' \
|
-e 's|@''REPLACE_ISINF''@|$(REPLACE_ISINF)|g' \
|
||||||
-e 's|@''REPLACE_ISNAN''@|$(REPLACE_ISNAN)|g' \
|
-e 's|@''REPLACE_ISNAN''@|$(REPLACE_ISNAN)|g' \
|
||||||
|
@@ -155,6 +155,9 @@ SIGNATURE_CHECK (GNULIB_NAMESPACE::frexp, double, (double, int *));
|
|||||||
SIGNATURE_CHECK (GNULIB_NAMESPACE::frexpl, long double, (long double, int *));
|
SIGNATURE_CHECK (GNULIB_NAMESPACE::frexpl, long double, (long double, int *));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if GNULIB_TEST_HYPOTF
|
||||||
|
SIGNATURE_CHECK (GNULIB_NAMESPACE::hypotf, float, (float, float));
|
||||||
|
#endif
|
||||||
//SIGNATURE_CHECK (GNULIB_NAMESPACE::hypot, double, (double, double));
|
//SIGNATURE_CHECK (GNULIB_NAMESPACE::hypot, double, (double, double));
|
||||||
|
|
||||||
//SIGNATURE_CHECK (GNULIB_NAMESPACE::j0, double, (double));
|
//SIGNATURE_CHECK (GNULIB_NAMESPACE::j0, double, (double));
|
||||||
|
Reference in New Issue
Block a user