2 dnl Copyright (C) 2012 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
7 AC_DEFUN([gl_FUNC_HYPOTF],
9 AC_REQUIRE([gl_MATH_H_DEFAULTS])
10 AC_REQUIRE([gl_FUNC_HYPOT])
12 dnl Test whether hypotf() exists. Assume that hypotf(), if it exists, is
13 dnl defined in the same library as hypot().
15 LIBS="$LIBS $HYPOT_LIBM"
16 AC_CHECK_FUNCS([hypotf])
18 if test $ac_cv_func_hypotf = yes; then
19 HYPOTF_LIBM="$HYPOT_LIBM"
21 LIBS="$LIBS $HYPOTF_LIBM"
24 case "$gl_cv_func_hypotf_works" in
26 *) REPLACE_HYPOTF=1 ;;
31 if test $HAVE_HYPOTF = 0 || test $REPLACE_HYPOTF = 1; then
32 dnl Find libraries needed to link lib/hypotf.c.
33 HYPOTF_LIBM="$HYPOT_LIBM"
35 AC_SUBST([HYPOTF_LIBM])
38 dnl Test whether hypotf() works.
39 dnl It returns wrong values on NetBSD 5.1/x86_64 and OpenBSD 4.9/x86.
40 AC_DEFUN([gl_FUNC_HYPOTF_WORKS],
42 AC_REQUIRE([AC_PROG_CC])
43 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
44 AC_CACHE_CHECK([whether hypotf works], [gl_cv_func_hypotf_works],
56 /* This test fails on NetBSD 5.1. */
61 if (!(z >= FLT_MIN * 2.0f && z <= FLT_MIN * 4.0f))
64 /* This test fails on OpenBSD 4.9. */
69 if (!(z > 0 && z == z + z))
75 [gl_cv_func_hypotf_works=yes],
76 [gl_cv_func_hypotf_works=no],
78 netbsd* | openbsd*) gl_cv_func_hypotf_works="guessing no";;
79 *) gl_cv_func_hypotf_works="guessing yes";;