]>
Commit | Line | Data |
---|---|---|
dc6c21da TT |
1 | # float_h.m4 serial 13 |
2 | dnl Copyright (C) 2007, 2009-2022 Free Software Foundation, Inc. | |
88b48903 WN |
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]) | |
dc6c21da | 11 | GL_GENERATE_FLOAT_H=false |
88b48903 WN |
12 | REPLACE_FLOAT_LDBL=0 |
13 | case "$host_os" in | |
14 | aix* | beos* | openbsd* | mirbsd* | irix*) | |
dc6c21da | 15 | GL_GENERATE_FLOAT_H=true |
88b48903 | 16 | ;; |
c0c3707f | 17 | freebsd* | dragonfly*) |
88b48903 WN |
18 | case "$host_cpu" in |
19 | changequote(,)dnl | |
20 | i[34567]86 ) | |
21 | changequote([,])dnl | |
dc6c21da | 22 | GL_GENERATE_FLOAT_H=true |
88b48903 WN |
23 | ;; |
24 | x86_64 ) | |
25 | # On x86_64 systems, the C compiler may still be generating | |
26 | # 32-bit code. | |
c0c3707f CB |
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 | ]])], | |
88b48903 | 35 | [], |
dc6c21da | 36 | [GL_GENERATE_FLOAT_H=true]) |
88b48903 WN |
37 | ;; |
38 | esac | |
39 | ;; | |
40 | linux*) | |
41 | case "$host_cpu" in | |
42 | powerpc*) | |
dc6c21da | 43 | GL_GENERATE_FLOAT_H=true |
88b48903 WN |
44 | ;; |
45 | esac | |
46 | ;; | |
47 | esac | |
48 | case "$host_os" in | |
c0c3707f | 49 | aix* | freebsd* | dragonfly* | linux*) |
dc6c21da | 50 | if $GL_GENERATE_FLOAT_H; then |
88b48903 WN |
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*) | |
c0c3707f CB |
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 | ]])], | |
88b48903 WN |
84 | [gl_cv_func_itold_works="guessing no"], |
85 | [gl_cv_func_itold_works="guessing yes"]) | |
86 | ;; | |
c0c3707f CB |
87 | # Guess yes on native Windows. |
88 | mingw*) gl_cv_func_itold_works="guessing yes" ;; | |
89 | *) gl_cv_func_itold_works="guessing yes" ;; | |
88b48903 WN |
90 | esac |
91 | ]) | |
92 | ]) | |
93 | case "$gl_cv_func_itold_works" in | |
94 | *no) | |
95 | REPLACE_ITOLD=1 | |
96 | dnl We add the workaround to <float.h> but also to <math.h>, | |
97 | dnl to increase the chances that the fix function gets pulled in. | |
dc6c21da | 98 | GL_GENERATE_FLOAT_H=true |
88b48903 WN |
99 | ;; |
100 | esac | |
101 | ||
dc6c21da | 102 | if $GL_GENERATE_FLOAT_H; then |
88b48903 WN |
103 | gl_NEXT_HEADERS([float.h]) |
104 | fi | |
88b48903 WN |
105 | AC_SUBST([REPLACE_ITOLD]) |
106 | ]) |