Blame m4/float_h.m4

Packit 33f14e
# float_h.m4 serial 9
Packit 33f14e
dnl Copyright (C) 2007, 2009-2017 Free Software Foundation, Inc.
Packit 33f14e
dnl This file is free software; the Free Software Foundation
Packit 33f14e
dnl gives unlimited permission to copy and/or distribute it,
Packit 33f14e
dnl with or without modifications, as long as this notice is preserved.
Packit 33f14e
Packit 33f14e
AC_DEFUN([gl_FLOAT_H],
Packit 33f14e
[
Packit 33f14e
  AC_REQUIRE([AC_PROG_CC])
Packit 33f14e
  AC_REQUIRE([AC_CANONICAL_HOST])
Packit 33f14e
  FLOAT_H=
Packit 33f14e
  REPLACE_FLOAT_LDBL=0
Packit 33f14e
  case "$host_os" in
Packit 33f14e
    aix* | beos* | openbsd* | mirbsd* | irix*)
Packit 33f14e
      FLOAT_H=float.h
Packit 33f14e
      ;;
Packit 33f14e
    freebsd*)
Packit 33f14e
      case "$host_cpu" in
Packit 33f14e
changequote(,)dnl
Packit 33f14e
        i[34567]86 )
Packit 33f14e
changequote([,])dnl
Packit 33f14e
          FLOAT_H=float.h
Packit 33f14e
          ;;
Packit 33f14e
        x86_64 )
Packit 33f14e
          # On x86_64 systems, the C compiler may still be generating
Packit 33f14e
          # 32-bit code.
Packit 33f14e
          AC_EGREP_CPP([yes],
Packit 33f14e
            [#if defined __LP64__ || defined __x86_64__ || defined __amd64__
Packit 33f14e
             yes
Packit 33f14e
             #endif],
Packit 33f14e
            [],
Packit 33f14e
            [FLOAT_H=float.h])
Packit 33f14e
          ;;
Packit 33f14e
      esac
Packit 33f14e
      ;;
Packit 33f14e
    linux*)
Packit 33f14e
      case "$host_cpu" in
Packit 33f14e
        powerpc*)
Packit 33f14e
          FLOAT_H=float.h
Packit 33f14e
          ;;
Packit 33f14e
      esac
Packit 33f14e
      ;;
Packit 33f14e
  esac
Packit 33f14e
  case "$host_os" in
Packit 33f14e
    aix* | freebsd* | linux*)
Packit 33f14e
      if test -n "$FLOAT_H"; then
Packit 33f14e
        REPLACE_FLOAT_LDBL=1
Packit 33f14e
      fi
Packit 33f14e
      ;;
Packit 33f14e
  esac
Packit 33f14e
Packit 33f14e
  dnl Test against glibc-2.7 Linux/SPARC64 bug.
Packit 33f14e
  REPLACE_ITOLD=0
Packit 33f14e
  AC_CACHE_CHECK([whether conversion from 'int' to 'long double' works],
Packit 33f14e
    [gl_cv_func_itold_works],
Packit 33f14e
    [
Packit 33f14e
      AC_RUN_IFELSE(
Packit 33f14e
        [AC_LANG_SOURCE([[
Packit 33f14e
int i = -1;
Packit 33f14e
volatile long double ld;
Packit 33f14e
int main ()
Packit 33f14e
{
Packit 33f14e
  ld += i * 1.0L;
Packit 33f14e
  if (ld > 0)
Packit 33f14e
    return 1;
Packit 33f14e
  return 0;
Packit 33f14e
}]])],
Packit 33f14e
        [gl_cv_func_itold_works=yes],
Packit 33f14e
        [gl_cv_func_itold_works=no],
Packit 33f14e
        [case "$host" in
Packit 33f14e
           sparc*-*-linux*)
Packit 33f14e
             AC_EGREP_CPP([yes],
Packit 33f14e
               [#if defined __LP64__ || defined __arch64__
Packit 33f14e
                yes
Packit 33f14e
                #endif],
Packit 33f14e
               [gl_cv_func_itold_works="guessing no"],
Packit 33f14e
               [gl_cv_func_itold_works="guessing yes"])
Packit 33f14e
             ;;
Packit 33f14e
           *) gl_cv_func_itold_works="guessing yes" ;;
Packit 33f14e
         esac
Packit 33f14e
        ])
Packit 33f14e
    ])
Packit 33f14e
  case "$gl_cv_func_itold_works" in
Packit 33f14e
    *no)
Packit 33f14e
      REPLACE_ITOLD=1
Packit 33f14e
      dnl We add the workaround to <float.h> but also to <math.h>,
Packit 33f14e
      dnl to increase the chances that the fix function gets pulled in.
Packit 33f14e
      FLOAT_H=float.h
Packit 33f14e
      ;;
Packit 33f14e
  esac
Packit 33f14e
Packit 33f14e
  if test -n "$FLOAT_H"; then
Packit 33f14e
    gl_NEXT_HEADERS([float.h])
Packit 33f14e
  fi
Packit 33f14e
  AC_SUBST([FLOAT_H])
Packit 33f14e
  AM_CONDITIONAL([GL_GENERATE_FLOAT_H], [test -n "$FLOAT_H"])
Packit 33f14e
  AC_SUBST([REPLACE_ITOLD])
Packit 33f14e
])