Debian Codegraph @

m4/float_h.m4

raw
1 # float_h.m4 serial 14
2 dnl Copyright (C) 2007, 2009-2024 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.
6
7 AC_DEFUN([gl_FLOAT_H],
8 [
9 AC_REQUIRE([AC_PROG_CC])
10 AC_REQUIRE([AC_CANONICAL_HOST])
11 GL_GENERATE_FLOAT_H=false
12 REPLACE_FLOAT_LDBL=0
13 case "$host_os" in
14 aix* | beos* | openbsd* | mirbsd* | irix*)
15 GL_GENERATE_FLOAT_H=true
16 ;;
17 freebsd* | dragonfly*)
18 case "$host_cpu" in
19 changequote(,)dnl
20 i[34567]86 )
21 changequote([,])dnl
22 GL_GENERATE_FLOAT_H=true
23 ;;
24 x86_64 )
25 # On x86_64 systems, the C compiler may still be generating
26 # 32-bit code.
27 AC_COMPILE_IFELSE(
28 [AC_LANG_SOURCE(
29 [[#if defined __LP64__ || defined __x86_64__ || defined __amd64__
30 int ok;
31 #else
32 error fail
33 #endif
34 ]])],
35 [],
36 [GL_GENERATE_FLOAT_H=true])
37 ;;
38 esac
39 ;;
40 linux*)
41 case "$host_cpu" in
42 powerpc*)
43 GL_GENERATE_FLOAT_H=true
44 ;;
45 esac
46 ;;
47 esac
48 case "$host_os" in
49 aix* | freebsd* | dragonfly* | linux*)
50 if $GL_GENERATE_FLOAT_H; then
51 REPLACE_FLOAT_LDBL=1
52 fi
53 ;;
54 esac
55
56 dnl Test against glibc-2.7 Linux/SPARC64 bug.
57 REPLACE_ITOLD=0
58 AC_CACHE_CHECK([whether conversion from 'int' to 'long double' works],
59 [gl_cv_func_itold_works],
60 [
61 AC_RUN_IFELSE(
62 [AC_LANG_SOURCE([[
63 int i = -1;
64 volatile long double ld;
65 int main ()
66 {
67 ld += i * 1.0L;
68 if (ld > 0)
69 return 1;
70 return 0;
71 }]])],
72 [gl_cv_func_itold_works=yes],
73 [gl_cv_func_itold_works=no],
74 [case "$host" in
75 sparc*-*-linux*)
76 AC_COMPILE_IFELSE(
77 [AC_LANG_SOURCE(
78 [[#if defined __LP64__ || defined __arch64__
79 int ok;
80 #else
81 error fail
82 #endif
83 ]])],
84 [gl_cv_func_itold_works="guessing no"],
85 [gl_cv_func_itold_works="guessing yes"])
86 ;;
87 # Guess yes on native Windows.
88 mingw* | windows*)
89 gl_cv_func_itold_works="guessing yes" ;;
90 *)
91 gl_cv_func_itold_works="guessing yes" ;;
92 esac
93 ])
94 ])
95 case "$gl_cv_func_itold_works" in
96 *no)
97 REPLACE_ITOLD=1
98 dnl We add the workaround to <float.h> but also to <math.h>,
99 dnl to increase the chances that the fix function gets pulled in.
100 GL_GENERATE_FLOAT_H=true
101 ;;
102 esac
103
104 if $GL_GENERATE_FLOAT_H; then
105 gl_NEXT_HEADERS([float.h])
106 fi
107 AC_SUBST([REPLACE_ITOLD])
108 ])