1# float_h.m4 serial 9
2dnl Copyright (C) 2007, 2009-2012 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FLOAT_H],
8[
9  AC_REQUIRE([AC_PROG_CC])
10  AC_REQUIRE([AC_CANONICAL_HOST])
11  FLOAT_H=
12  REPLACE_FLOAT_LDBL=0
13  case "$host_os" in
14    aix* | beos* | openbsd* | mirbsd* | irix*)
15      FLOAT_H=float.h
16      ;;
17    freebsd*)
18      case "$host_cpu" in
19changequote(,)dnl
20        i[34567]86 )
21changequote([,])dnl
22          FLOAT_H=float.h
23          ;;
24        x86_64 )
25          # On x86_64 systems, the C compiler may still be generating
26          # 32-bit code.
27          AC_EGREP_CPP([yes],
28            [#if defined __LP64__ || defined __x86_64__ || defined __amd64__
29             yes
30             #endif],
31            [],
32            [FLOAT_H=float.h])
33          ;;
34      esac
35      ;;
36    linux*)
37      case "$host_cpu" in
38        powerpc*)
39          FLOAT_H=float.h
40          ;;
41      esac
42      ;;
43  esac
44  case "$host_os" in
45    aix* | freebsd* | linux*)
46      if test -n "$FLOAT_H"; then
47        REPLACE_FLOAT_LDBL=1
48      fi
49      ;;
50  esac
51
52  dnl Test against glibc-2.7 Linux/SPARC64 bug.
53  REPLACE_ITOLD=0
54  AC_CACHE_CHECK([whether conversion from 'int' to 'long double' works],
55    [gl_cv_func_itold_works],
56    [
57      AC_RUN_IFELSE(
58        [AC_LANG_SOURCE([[
59int i = -1;
60volatile long double ld;
61int main ()
62{
63  ld += i * 1.0L;
64  if (ld > 0)
65    return 1;
66  return 0;
67}]])],
68        [gl_cv_func_itold_works=yes],
69        [gl_cv_func_itold_works=no],
70        [case "$host" in
71           sparc*-*-linux*)
72             AC_EGREP_CPP([yes],
73               [#if defined __LP64__ || defined __arch64__
74                yes
75                #endif],
76               [gl_cv_func_itold_works="guessing no"],
77               [gl_cv_func_itold_works="guessing yes"])
78             ;;
79           *) gl_cv_func_itold_works="guessing yes" ;;
80         esac
81        ])
82    ])
83  case "$gl_cv_func_itold_works" in
84    *no)
85      REPLACE_ITOLD=1
86      dnl We add the workaround to <float.h> but also to <math.h>,
87      dnl to increase the chances that the fix function gets pulled in.
88      FLOAT_H=float.h
89      ;;
90  esac
91
92  if test -n "$FLOAT_H"; then
93    gl_NEXT_HEADERS([float.h])
94  fi
95  AC_SUBST([FLOAT_H])
96  AM_CONDITIONAL([GL_GENERATE_FLOAT_H], [test -n "$FLOAT_H"])
97  AC_SUBST([REPLACE_ITOLD])
98])
99