2 dnl Copyright (C) 2007-2008, 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_TRUNCL],
9 m4_divert_text([DEFAULTS], [gl_truncl_required=plain])
10 AC_REQUIRE([gl_MATH_H_DEFAULTS])
11 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
12 dnl Persuade glibc <math.h> to declare truncl().
13 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
14 dnl Test whether truncl() is declared.
15 AC_CHECK_DECLS([truncl], , , [#include <math.h>])
16 if test "$ac_cv_have_decl_truncl" = yes; then
17 dnl Test whether truncl() can be used without libm.
21 [[#ifndef __NO_MATH_INLINES
22 # define __NO_MATH_INLINES 1 /* for glibc */
28 if test "$TRUNCL_LIBM" = "?"; then
33 [[#ifndef __NO_MATH_INLINES
34 # define __NO_MATH_INLINES 1 /* for glibc */
42 if test "$TRUNCL_LIBM" = "?"; then
45 dnl Test whether truncl() works. It crashes on OSF/1 4.0d.
47 LIBS="$LIBS $TRUNCL_LIBM"
48 AC_CACHE_CHECK([whether truncl works], [gl_cv_func_truncl_works],
59 [gl_cv_func_truncl_works=yes],
60 [gl_cv_func_truncl_works=no],
62 osf4*) gl_cv_func_truncl_works="guessing no";;
63 *) gl_cv_func_truncl_works="guessing yes";;
68 case "$gl_cv_func_truncl_works" in
70 *) REPLACE_TRUNCL=1 ;;
72 m4_ifdef([gl_FUNC_TRUNCL_IEEE], [
73 if test $gl_truncl_required = ieee && test $REPLACE_TRUNCL = 0; then
74 AC_CACHE_CHECK([whether truncl works according to ISO C 99 with IEC 60559],
75 [gl_cv_func_truncl_ieee],
78 LIBS="$LIBS $TRUNCL_LIBM"
81 #ifndef __NO_MATH_INLINES
82 # define __NO_MATH_INLINES 1 /* for glibc */
85 ]gl_LONG_DOUBLE_MINUS_ZERO_CODE[
86 ]gl_LONG_DOUBLE_SIGNBIT_CODE[
89 /* Test whether truncl (-0.3L) is -0.0L. */
90 if (signbitl (minus_zerol) && !signbitl (truncl (-0.3L)))
95 [gl_cv_func_truncl_ieee=yes],
96 [gl_cv_func_truncl_ieee=no],
97 [gl_cv_func_truncl_ieee="guessing no"])
100 case "$gl_cv_func_truncl_ieee" in
102 *) REPLACE_TRUNCL=1 ;;
109 if test $HAVE_DECL_TRUNCL = 0 || test $REPLACE_TRUNCL = 1; then
113 AC_SUBST([TRUNCL_LIBM])