2 dnl Copyright (C) 2007, 2010-2011 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_TRUNCF],
9 m4_divert_text([DEFAULTS], [gl_truncf_required=plain])
10 AC_REQUIRE([gl_MATH_H_DEFAULTS])
11 dnl Persuade glibc <math.h> to declare truncf().
12 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
13 dnl Test whether truncf() is declared.
14 AC_CHECK_DECLS([truncf], , , [#include <math.h>])
15 if test "$ac_cv_have_decl_truncf" = yes; then
16 dnl Test whether truncf() can be used without libm.
20 [[#ifndef __NO_MATH_INLINES
21 # define __NO_MATH_INLINES 1 /* for glibc */
27 if test "$TRUNCF_LIBM" = "?"; then
32 [[#ifndef __NO_MATH_INLINES
33 # define __NO_MATH_INLINES 1 /* for glibc */
41 if test "$TRUNCF_LIBM" = "?"; then
44 m4_ifdef([gl_FUNC_TRUNCF_IEEE], [
45 if test $gl_truncf_required = ieee && test $REPLACE_TRUNCF = 0; then
46 AC_CACHE_CHECK([whether truncf works according to ISO C 99 with IEC 60559],
47 [gl_cv_func_truncf_ieee],
50 LIBS="$LIBS $TRUNCF_LIBM"
53 #ifndef __NO_MATH_INLINES
54 # define __NO_MATH_INLINES 1 /* for glibc */
57 ]gl_FLOAT_MINUS_ZERO_CODE[
58 ]gl_FLOAT_SIGNBIT_CODE[
61 /* Test whether truncf (-0.0f) is -0.0f. */
62 if (signbitf (minus_zerof) && !signbitf (truncf (minus_zerof)))
67 [gl_cv_func_truncf_ieee=yes],
68 [gl_cv_func_truncf_ieee=no],
69 [gl_cv_func_truncf_ieee="guessing no"])
72 case "$gl_cv_func_truncf_ieee" in
74 *) REPLACE_TRUNCF=1 ;;
81 if test $HAVE_DECL_TRUNCF = 0 || test $REPLACE_TRUNCF = 1; then
85 AC_SUBST([TRUNCF_LIBM])