1# float_h.m4 serial 12 2dnl Copyright (C) 2007, 2009-2020 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* | dragonfly*) 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_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 [FLOAT_H=float.h]) 37 ;; 38 esac 39 ;; 40 linux*) 41 case "$host_cpu" in 42 powerpc*) 43 FLOAT_H=float.h 44 ;; 45 esac 46 ;; 47 esac 48 case "$host_os" in 49 aix* | freebsd* | dragonfly* | linux*) 50 if test -n "$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([[ 63int i = -1; 64volatile long double ld; 65int 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*) gl_cv_func_itold_works="guessing yes" ;; 89 *) gl_cv_func_itold_works="guessing yes" ;; 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. 98 FLOAT_H=float.h 99 ;; 100 esac 101 102 if test -n "$FLOAT_H"; then 103 gl_NEXT_HEADERS([float.h]) 104 fi 105 AC_SUBST([FLOAT_H]) 106 AM_CONDITIONAL([GL_GENERATE_FLOAT_H], [test -n "$FLOAT_H"]) 107 AC_SUBST([REPLACE_ITOLD]) 108]) 109