Blame acinclude.m4

Packit Service 8591b6
dnl  MPFR specific autoconf macros
Packit Service 8591b6
Packit Service 8591b6
dnl  Copyright 2000, 2002-2017 Free Software Foundation, Inc.
Packit Service 8591b6
dnl  Contributed by the AriC and Caramba projects, INRIA.
Packit Service 8591b6
dnl
Packit Service 8591b6
dnl  This file is part of the GNU MPFR Library.
Packit Service 8591b6
dnl
Packit Service 8591b6
dnl  The GNU MPFR Library is free software; you can redistribute it and/or modify
Packit Service 8591b6
dnl  it under the terms of the GNU Lesser General Public License as published
Packit Service 8591b6
dnl  by the Free Software Foundation; either version 3 of the License, or (at
Packit Service 8591b6
dnl  your option) any later version.
Packit Service 8591b6
dnl
Packit Service 8591b6
dnl  The GNU MPFR Library is distributed in the hope that it will be useful, but
Packit Service 8591b6
dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
Packit Service 8591b6
dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
Packit Service 8591b6
dnl  License for more details.
Packit Service 8591b6
dnl
Packit Service 8591b6
dnl  You should have received a copy of the GNU Lesser General Public License
Packit Service 8591b6
dnl  along with the GNU MPFR Library; see the file COPYING.LESSER.  If not, see
Packit Service 8591b6
dnl  http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
Packit Service 8591b6
dnl  51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
Packit Service 8591b6
Packit Service 8591b6
dnl  autoconf 2.60 is necessary because of the use of AC_PROG_SED.
Packit Service 8591b6
dnl  The following line allows the autoconf wrapper (when installed)
Packit Service 8591b6
dnl  to work as expected.
Packit Service 8591b6
dnl  If you change the required version, please update README.dev too!
Packit Service 8591b6
AC_PREREQ(2.60)
Packit Service 8591b6
Packit Service 8591b6
dnl ------------------------------------------------------------
Packit Service 8591b6
dnl You must put in MPFR_CONFIGS everything which configure MPFR
Packit Service 8591b6
dnl except:
Packit Service 8591b6
dnl   - Everything dealing with CC and CFLAGS in particular the ABI
Packit Service 8591b6
dnl     but the IEEE-754 specific flags must be set here.
Packit Service 8591b6
dnl   - Tests that depend on gmp.h (see MPFR_CHECK_DBL2INT_BUG as an example:
Packit Service 8591b6
dnl     a function needs to be defined and called in configure.ac).
Packit Service 8591b6
dnl   - GMP's linkage.
Packit Service 8591b6
dnl   - Libtool stuff.
Packit Service 8591b6
dnl   - Handling of special arguments of MPFR's configure.
Packit Service 8591b6
AC_DEFUN([MPFR_CONFIGS],
Packit Service 8591b6
[
Packit Service 8591b6
AC_REQUIRE([AC_OBJEXT])
Packit Service 8591b6
AC_REQUIRE([MPFR_CHECK_LIBM])
Packit Service 8591b6
AC_REQUIRE([AC_HEADER_TIME])
Packit Service 8591b6
AC_REQUIRE([AC_CANONICAL_HOST])
Packit Service 8591b6
Packit Service 8591b6
AC_CHECK_HEADER([limits.h],, AC_MSG_ERROR([limits.h not found]))
Packit Service 8591b6
AC_CHECK_HEADER([float.h],,  AC_MSG_ERROR([float.h not found]))
Packit Service 8591b6
AC_CHECK_HEADER([string.h],, AC_MSG_ERROR([string.h not found]))
Packit Service 8591b6
Packit Service 8591b6
dnl Check for locales
Packit Service 8591b6
AC_CHECK_HEADERS([locale.h])
Packit Service 8591b6
Packit Service 8591b6
dnl Check for wide characters (wchar_t and wint_t)
Packit Service 8591b6
AC_CHECK_HEADERS([wchar.h])
Packit Service 8591b6
Packit Service 8591b6
dnl Check for stdargs
Packit Service 8591b6
AC_CHECK_HEADER([stdarg.h],[AC_DEFINE([HAVE_STDARG],1,[Define if stdarg])],
Packit Service 8591b6
  [AC_CHECK_HEADER([varargs.h],,
Packit Service 8591b6
    AC_MSG_ERROR([stdarg.h or varargs.h not found]))])
Packit Service 8591b6
Packit Service 8591b6
dnl sys/fpu.h - MIPS specific
Packit Service 8591b6
AC_CHECK_HEADERS([sys/time.h sys/fpu.h])
Packit Service 8591b6
Packit Service 8591b6
dnl Android has a <locale.h>, but not the following members.
Packit Service 8591b6
AC_CHECK_MEMBERS([struct lconv.decimal_point, struct lconv.thousands_sep],,,
Packit Service 8591b6
  [#include <locale.h>])
Packit Service 8591b6
Packit Service 8591b6
dnl Check how to get `alloca'
Packit Service 8591b6
AC_FUNC_ALLOCA
Packit Service 8591b6
Packit Service 8591b6
dnl SIZE_MAX macro
Packit Service 8591b6
gl_SIZE_MAX
Packit Service 8591b6
Packit Service 8591b6
dnl va_copy macro
Packit Service 8591b6
AC_MSG_CHECKING([how to copy va_list])
Packit Service 8591b6
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Packit Service 8591b6
#include <stdarg.h>
Packit Service 8591b6
]], [[
Packit Service 8591b6
   va_list ap1, ap2;
Packit Service 8591b6
   va_copy(ap1, ap2);
Packit Service 8591b6
]])], [
Packit Service 8591b6
   AC_MSG_RESULT([va_copy])
Packit Service 8591b6
   AC_DEFINE(HAVE_VA_COPY)
Packit Service 8591b6
], [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Packit Service 8591b6
#include <stdarg.h>
Packit Service 8591b6
]], [[
Packit Service 8591b6
   va_list ap1, ap2;
Packit Service 8591b6
   __va_copy(ap1, ap2);
Packit Service 8591b6
]])], [AC_DEFINE([HAVE___VA_COPY]) AC_MSG_RESULT([__va_copy])],
Packit Service 8591b6
   [AC_MSG_RESULT([memcpy])])])
Packit Service 8591b6
Packit Service 8591b6
dnl FIXME: The functions memmove, memset and strtol are really needed by
Packit Service 8591b6
dnl MPFR, but if they are implemented as macros, this is also OK (in our
Packit Service 8591b6
dnl case).  So, we do not return an error, but their tests are currently
Packit Service 8591b6
dnl useless.
Packit Service 8591b6
dnl gettimeofday is not defined for MinGW
Packit Service 8591b6
AC_CHECK_FUNCS([memmove memset setlocale strtol gettimeofday])
Packit Service 8591b6
Packit Service 8591b6
dnl Check for IEEE-754 switches on Alpha
Packit Service 8591b6
case $host in
Packit Service 8591b6
alpha*-*-*)
Packit Service 8591b6
  saved_CFLAGS="$CFLAGS"
Packit Service 8591b6
  AC_CACHE_CHECK([for IEEE-754 switches], mpfr_cv_ieee_switches, [
Packit Service 8591b6
  if test -n "$GCC"; then
Packit Service 8591b6
    mpfr_cv_ieee_switches="-mfp-rounding-mode=d -mieee-with-inexact"
Packit Service 8591b6
  else
Packit Service 8591b6
    mpfr_cv_ieee_switches="-fprm d -ieee_with_inexact"
Packit Service 8591b6
  fi
Packit Service 8591b6
  CFLAGS="$CFLAGS $mpfr_cv_ieee_switches"
Packit Service 8591b6
  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], , mpfr_cv_ieee_switches="none")
Packit Service 8591b6
  ])
Packit Service 8591b6
  if test "$mpfr_cv_ieee_switches" = "none"; then
Packit Service 8591b6
    CFLAGS="$saved_CFLAGS"
Packit Service 8591b6
  else
Packit Service 8591b6
    CFLAGS="$saved_CFLAGS $mpfr_cv_ieee_switches"
Packit Service 8591b6
  fi
Packit Service 8591b6
esac
Packit Service 8591b6
Packit Service 8591b6
dnl check for long long
Packit Service 8591b6
AC_CHECK_TYPE([long long int],
Packit Service 8591b6
   AC_DEFINE(HAVE_LONG_LONG, 1, [Define if compiler supports long long]),,)
Packit Service 8591b6
Packit Service 8591b6
dnl intmax_t is C99
Packit Service 8591b6
AC_CHECK_TYPES([intmax_t])
Packit Service 8591b6
if test "$ac_cv_type_intmax_t" = yes; then
Packit Service 8591b6
  AC_CACHE_CHECK([for working INTMAX_MAX], mpfr_cv_have_intmax_max, [
Packit Service 8591b6
    saved_CPPFLAGS="$CPPFLAGS"
Packit Service 8591b6
    CPPFLAGS="$CPPFLAGS -I$srcdir/src"
Packit Service 8591b6
    AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Packit Service 8591b6
        [[#include "mpfr-intmax.h"]],
Packit Service 8591b6
        [[intmax_t x = INTMAX_MAX; (void) x;]]
Packit Service 8591b6
      )],
Packit Service 8591b6
      mpfr_cv_have_intmax_max=yes, mpfr_cv_have_intmax_max=no)
Packit Service 8591b6
    CPPFLAGS="$saved_CPPFLAGS"
Packit Service 8591b6
  ])
Packit Service 8591b6
  if test "$mpfr_cv_have_intmax_max" = "yes"; then
Packit Service 8591b6
    AC_DEFINE(MPFR_HAVE_INTMAX_MAX,1,[Define if you have a working INTMAX_MAX.])
Packit Service 8591b6
  fi
Packit Service 8591b6
fi
Packit Service 8591b6
Packit Service 8591b6
AC_CHECK_TYPE( [union fpc_csr],
Packit Service 8591b6
   AC_DEFINE(HAVE_FPC_CSR,1,[Define if union fpc_csr is available]), ,
Packit Service 8591b6
[
Packit Service 8591b6
#if HAVE_SYS_FPU_H
Packit Service 8591b6
#  include <sys/fpu.h>
Packit Service 8591b6
#endif
Packit Service 8591b6
])
Packit Service 8591b6
Packit Service 8591b6
dnl Check for fesetround
Packit Service 8591b6
AC_CACHE_CHECK([for fesetround], mpfr_cv_have_fesetround, [
Packit Service 8591b6
saved_LIBS="$LIBS"
Packit Service 8591b6
LIBS="$LIBS $MPFR_LIBM"
Packit Service 8591b6
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <fenv.h>]], [[fesetround(FE_TONEAREST);]])],
Packit Service 8591b6
  mpfr_cv_have_fesetround=yes, mpfr_cv_have_fesetround=no)
Packit Service 8591b6
LIBS="$saved_LIBS"
Packit Service 8591b6
])
Packit Service 8591b6
if test "$mpfr_cv_have_fesetround" = "yes"; then
Packit Service 8591b6
  AC_DEFINE(MPFR_HAVE_FESETROUND,1,[Define if you have the `fesetround' function via the <fenv.h> header file.])
Packit Service 8591b6
fi
Packit Service 8591b6
Packit Service 8591b6
dnl Check for gcc float-conversion bug; if need be, -ffloat-store is used to
Packit Service 8591b6
dnl force the conversion to the destination type when a value is stored to
Packit Service 8591b6
dnl a variable (see ISO C99 standard 5.1.2.3#13, 6.3.1.5#2, 6.3.1.8#2). This
Packit Service 8591b6
dnl is important concerning the exponent range. Note that this doesn't solve
Packit Service 8591b6
dnl the double-rounding problem.
Packit Service 8591b6
if test -n "$GCC"; then
Packit Service 8591b6
  AC_CACHE_CHECK([for gcc float-conversion bug], mpfr_cv_gcc_floatconv_bug, [
Packit Service 8591b6
  saved_LIBS="$LIBS"
Packit Service 8591b6
  LIBS="$LIBS $MPFR_LIBM"
Packit Service 8591b6
  AC_RUN_IFELSE([AC_LANG_SOURCE([[
Packit Service 8591b6
#include <float.h>
Packit Service 8591b6
#ifdef MPFR_HAVE_FESETROUND
Packit Service 8591b6
#include <fenv.h>
Packit Service 8591b6
#endif
Packit Service 8591b6
static double get_max (void);
Packit Service 8591b6
int main (void) {
Packit Service 8591b6
  double x = 0.5;
Packit Service 8591b6
  double y;
Packit Service 8591b6
  int i;
Packit Service 8591b6
  for (i = 1; i <= 11; i++)
Packit Service 8591b6
    x *= x;
Packit Service 8591b6
  if (x != 0)
Packit Service 8591b6
    return 1;
Packit Service 8591b6
#ifdef MPFR_HAVE_FESETROUND
Packit Service 8591b6
  /* Useful test for the G4 PowerPC */
Packit Service 8591b6
  fesetround(FE_TOWARDZERO);
Packit Service 8591b6
  x = y = get_max ();
Packit Service 8591b6
  x *= 2.0;
Packit Service 8591b6
  if (x != y)
Packit Service 8591b6
    return 1;
Packit Service 8591b6
#endif
Packit Service 8591b6
  return 0;
Packit Service 8591b6
}
Packit Service 8591b6
static double get_max (void) { static volatile double d = DBL_MAX; return d; }
Packit Service 8591b6
  ]])],
Packit Service 8591b6
     [mpfr_cv_gcc_floatconv_bug="no"],
Packit Service 8591b6
     [mpfr_cv_gcc_floatconv_bug="yes, use -ffloat-store"],
Packit Service 8591b6
     [mpfr_cv_gcc_floatconv_bug="cannot test, use -ffloat-store"])
Packit Service 8591b6
  LIBS="$saved_LIBS"
Packit Service 8591b6
  ])
Packit Service 8591b6
  if test "$mpfr_cv_gcc_floatconv_bug" != "no"; then
Packit Service 8591b6
    CFLAGS="$CFLAGS -ffloat-store"
Packit Service 8591b6
  fi
Packit Service 8591b6
fi
Packit Service 8591b6
Packit Service 8591b6
dnl Check if subnormal (denormalized) numbers are supported
Packit Service 8591b6
AC_CACHE_CHECK([for subnormal numbers], mpfr_cv_have_denorms, [
Packit Service 8591b6
AC_RUN_IFELSE([AC_LANG_SOURCE([[
Packit Service 8591b6
#include <stdio.h>
Packit Service 8591b6
int main (void) {
Packit Service 8591b6
  double x = 2.22507385850720138309e-308;
Packit Service 8591b6
  fprintf (stderr, "%e\n", x / 2.0);
Packit Service 8591b6
  return 2.0 * (x / 2.0) != x;
Packit Service 8591b6
}
Packit Service 8591b6
]])],
Packit Service 8591b6
   [mpfr_cv_have_denorms="yes"],
Packit Service 8591b6
   [mpfr_cv_have_denorms="no"],
Packit Service 8591b6
   [mpfr_cv_have_denorms="cannot test, assume no"])
Packit Service 8591b6
])
Packit Service 8591b6
if test "$mpfr_cv_have_denorms" = "yes"; then
Packit Service 8591b6
  AC_DEFINE(HAVE_DENORMS,1,[Define if subnormal (denormalized) floats work.])
Packit Service 8591b6
fi
Packit Service 8591b6
Packit Service 8591b6
dnl Check if signed zeros are supported. Note: the test will fail
Packit Service 8591b6
dnl if the division by 0 generates a trap.
Packit Service 8591b6
AC_CACHE_CHECK([for signed zeros], mpfr_cv_have_signedz, [
Packit Service 8591b6
AC_RUN_IFELSE([AC_LANG_SOURCE([[
Packit Service 8591b6
int main (void) {
Packit Service 8591b6
  return 1.0 / 0.0 == 1.0 / -0.0;
Packit Service 8591b6
}
Packit Service 8591b6
]])],
Packit Service 8591b6
   [mpfr_cv_have_signedz="yes"],
Packit Service 8591b6
   [mpfr_cv_have_signedz="no"],
Packit Service 8591b6
   [mpfr_cv_have_signedz="cannot test, assume no"])
Packit Service 8591b6
])
Packit Service 8591b6
if test "$mpfr_cv_have_signedz" = "yes"; then
Packit Service 8591b6
  AC_DEFINE(HAVE_SIGNEDZ,1,[Define if signed zeros are supported.])
Packit Service 8591b6
fi
Packit Service 8591b6
Packit Service 8591b6
dnl Check the FP division by 0 fails (e.g. on a non-IEEE-754 platform).
Packit Service 8591b6
dnl In such a case, MPFR_ERRDIVZERO is defined to disable the tests
Packit Service 8591b6
dnl involving a FP division by 0.
Packit Service 8591b6
dnl For the developers: to check whether all these tests are disabled,
Packit Service 8591b6
dnl configure MPFR with "-DMPFR_TEST_DIVBYZERO=1 -DMPFR_ERRDIVZERO=1".
Packit Service 8591b6
AC_CACHE_CHECK([if the FP division by 0 fails], mpfr_cv_errdivzero, [
Packit Service 8591b6
AC_RUN_IFELSE([AC_LANG_SOURCE([[
Packit Service 8591b6
int main (void) {
Packit Service 8591b6
  volatile double d = 0.0, x;
Packit Service 8591b6
  x = 0.0 / d;
Packit Service 8591b6
  x = 1.0 / d;
Packit Service 8591b6
  (void) x;
Packit Service 8591b6
  return 0;
Packit Service 8591b6
}
Packit Service 8591b6
]])],
Packit Service 8591b6
   [mpfr_cv_errdivzero="no"],
Packit Service 8591b6
   [mpfr_cv_errdivzero="yes"],
Packit Service 8591b6
   [mpfr_cv_errdivzero="cannot test, assume no"])
Packit Service 8591b6
])
Packit Service 8591b6
if test "$mpfr_cv_errdivzero" = "yes"; then
Packit Service 8591b6
  AC_DEFINE(MPFR_ERRDIVZERO,1,[Define if the FP division by 0 fails.])
Packit Service 8591b6
  AC_MSG_WARN([The floating-point division by 0 fails instead of])
Packit Service 8591b6
  AC_MSG_WARN([returning a special value: NaN or infinity. Tests])
Packit Service 8591b6
  AC_MSG_WARN([involving a FP division by 0 will be disabled.])
Packit Service 8591b6
fi
Packit Service 8591b6
Packit Service 8591b6
dnl Check whether NAN != NAN (as required by the IEEE-754 standard,
Packit Service 8591b6
dnl but not by the ISO C standard). For instance, this is false with
Packit Service 8591b6
dnl MIPSpro 7.3.1.3m under IRIX64. By default, assume this is true.
Packit Service 8591b6
AC_CACHE_CHECK([if NAN == NAN], mpfr_cv_nanisnan, [
Packit Service 8591b6
AC_RUN_IFELSE([AC_LANG_SOURCE([[
Packit Service 8591b6
#include <stdio.h>
Packit Service 8591b6
#include <math.h>
Packit Service 8591b6
#ifndef NAN
Packit Service 8591b6
# define NAN (0.0/0.0)
Packit Service 8591b6
#endif
Packit Service 8591b6
int main (void) {
Packit Service 8591b6
  double d;
Packit Service 8591b6
  d = NAN;
Packit Service 8591b6
  return d != d;
Packit Service 8591b6
}
Packit Service 8591b6
]])],
Packit Service 8591b6
   [mpfr_cv_nanisnan="yes"],
Packit Service 8591b6
   [mpfr_cv_nanisnan="no"],
Packit Service 8591b6
   [mpfr_cv_nanisnan="cannot test, assume no"])
Packit Service 8591b6
])
Packit Service 8591b6
if test "$mpfr_cv_nanisnan" = "yes"; then
Packit Service 8591b6
  AC_DEFINE(MPFR_NANISNAN,1,[Define if NAN == NAN.])
Packit Service 8591b6
  AC_MSG_WARN([The test NAN != NAN is false. The probable reason is that])
Packit Service 8591b6
  AC_MSG_WARN([your compiler optimizes floating-point expressions in an])
Packit Service 8591b6
  AC_MSG_WARN([unsafe way because some option, such as -ffast-math or])
Packit Service 8591b6
  AC_MSG_WARN([-fast (depending on the compiler), has been used.  You])
Packit Service 8591b6
  AC_MSG_WARN([should NOT use such an option, otherwise MPFR functions])
Packit Service 8591b6
  AC_MSG_WARN([such as mpfr_get_d and mpfr_set_d may return incorrect])
Packit Service 8591b6
  AC_MSG_WARN([results on special FP numbers (e.g. NaN or signed zeros).])
Packit Service 8591b6
  AC_MSG_WARN([If you did not use such an option, please send us a bug])
Packit Service 8591b6
  AC_MSG_WARN([report so that we can try to find a workaround for your])
Packit Service 8591b6
  AC_MSG_WARN([platform and/or document the behavior.])
Packit Service 8591b6
fi
Packit Service 8591b6
Packit Service 8591b6
dnl Check if the chars '0' to '9' are consecutive values
Packit Service 8591b6
AC_MSG_CHECKING([if charset has consecutive values])
Packit Service 8591b6
AC_RUN_IFELSE([AC_LANG_PROGRAM([[
Packit Service 8591b6
char *number = "0123456789";
Packit Service 8591b6
char *lower  = "abcdefghijklmnopqrstuvwxyz";
Packit Service 8591b6
char *upper  = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
Packit Service 8591b6
]],[[
Packit Service 8591b6
 int i;
Packit Service 8591b6
 unsigned char *p;
Packit Service 8591b6
 for (p = (unsigned char*) number, i = 0; i < 9; i++)
Packit Service 8591b6
   if ( (*p)+1 != *(p+1) ) return 1;
Packit Service 8591b6
 for (p = (unsigned char*) lower, i = 0; i < 25; i++)
Packit Service 8591b6
   if ( (*p)+1 != *(p+1) ) return 1;
Packit Service 8591b6
 for (p = (unsigned char*) upper, i = 0; i < 25; i++)
Packit Service 8591b6
   if ( (*p)+1 != *(p+1) ) return 1;
Packit Service 8591b6
]])], [AC_MSG_RESULT(yes)],[
Packit Service 8591b6
 AC_MSG_RESULT(no)
Packit Service 8591b6
 AC_DEFINE(MPFR_NO_CONSECUTIVE_CHARSET,1,[Charset is not consecutive])
Packit Service 8591b6
], [AC_MSG_RESULT(cannot test)])
Packit Service 8591b6
Packit Service 8591b6
dnl Must be checked with the LIBM
Packit Service 8591b6
dnl but we don't want to add the LIBM to MPFR dependency.
Packit Service 8591b6
dnl Can't use AC_CHECK_FUNCS since the function may be in LIBM but
Packit Service 8591b6
dnl not exported in math.h
Packit Service 8591b6
saved_LIBS="$LIBS"
Packit Service 8591b6
LIBS="$LIBS $MPFR_LIBM"
Packit Service 8591b6
dnl AC_CHECK_FUNCS([round trunc floor ceil nearbyint])
Packit Service 8591b6
AC_MSG_CHECKING(for math/round)
Packit Service 8591b6
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Packit Service 8591b6
#include <math.h>
Packit Service 8591b6
static int f (double (*func)(double)) { return 0; }
Packit Service 8591b6
]], [[
Packit Service 8591b6
 return f(round);
Packit Service 8591b6
]])], [
Packit Service 8591b6
   AC_MSG_RESULT(yes)
Packit Service 8591b6
   AC_DEFINE(HAVE_ROUND, 1,[Have ISO C99 round function])
Packit Service 8591b6
],[AC_MSG_RESULT(no)])
Packit Service 8591b6
Packit Service 8591b6
AC_MSG_CHECKING(for math/trunc)
Packit Service 8591b6
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Packit Service 8591b6
#include <math.h>
Packit Service 8591b6
static int f (double (*func)(double)) { return 0; }
Packit Service 8591b6
]], [[
Packit Service 8591b6
 return f(trunc);
Packit Service 8591b6
]])], [
Packit Service 8591b6
   AC_MSG_RESULT(yes)
Packit Service 8591b6
   AC_DEFINE(HAVE_TRUNC, 1,[Have ISO C99 trunc function])
Packit Service 8591b6
],[AC_MSG_RESULT(no)])
Packit Service 8591b6
Packit Service 8591b6
AC_MSG_CHECKING(for math/floor)
Packit Service 8591b6
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Packit Service 8591b6
#include <math.h>
Packit Service 8591b6
static int f (double (*func)(double)) { return 0; }
Packit Service 8591b6
]], [[
Packit Service 8591b6
 return f(floor);
Packit Service 8591b6
]])], [
Packit Service 8591b6
   AC_MSG_RESULT(yes)
Packit Service 8591b6
   AC_DEFINE(HAVE_FLOOR, 1,[Have ISO C99 floor function])
Packit Service 8591b6
],[AC_MSG_RESULT(no)])
Packit Service 8591b6
Packit Service 8591b6
AC_MSG_CHECKING(for math/ceil)
Packit Service 8591b6
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Packit Service 8591b6
#include <math.h>
Packit Service 8591b6
static int f (double (*func)(double)) { return 0; }
Packit Service 8591b6
]], [[
Packit Service 8591b6
 return f(ceil);
Packit Service 8591b6
]])], [
Packit Service 8591b6
   AC_MSG_RESULT(yes)
Packit Service 8591b6
   AC_DEFINE(HAVE_CEIL, 1,[Have ISO C99 ceil function])
Packit Service 8591b6
],[AC_MSG_RESULT(no)])
Packit Service 8591b6
Packit Service 8591b6
AC_MSG_CHECKING(for math/nearbyint)
Packit Service 8591b6
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Packit Service 8591b6
#include <math.h>
Packit Service 8591b6
static int f (double (*func)(double)) { return 0; }
Packit Service 8591b6
]], [[
Packit Service 8591b6
 return f(nearbyint);
Packit Service 8591b6
]])], [
Packit Service 8591b6
   AC_MSG_RESULT(yes)
Packit Service 8591b6
   AC_DEFINE(HAVE_NEARBYINT, 1,[Have ISO C99 nearbyint function])
Packit Service 8591b6
],[AC_MSG_RESULT(no)])
Packit Service 8591b6
Packit Service 8591b6
LIBS="$saved_LIBS"
Packit Service 8591b6
Packit Service 8591b6
dnl Now try to check the long double format
Packit Service 8591b6
MPFR_C_LONG_DOUBLE_FORMAT
Packit Service 8591b6
Packit Service 8591b6
if test "$enable_logging" = yes; then
Packit Service 8591b6
  if test "$enable_thread_safe" = yes; then
Packit Service 8591b6
    AC_MSG_ERROR([Enable either `Logging' or `thread-safe', not both])
Packit Service 8591b6
  else
Packit Service 8591b6
    enable_thread_safe=no
Packit Service 8591b6
  fi
Packit Service 8591b6
fi
Packit Service 8591b6
Packit Service 8591b6
dnl Check if thread-local variables are supported.
Packit Service 8591b6
dnl At least two problems can occur in practice:
Packit Service 8591b6
dnl 1. The compilation fails, e.g. because the compiler doesn't know
Packit Service 8591b6
dnl    about the __thread keyword.
Packit Service 8591b6
dnl 2. The compilation succeeds, but the system doesn't support TLS or
Packit Service 8591b6
dnl    there is some ld configuration problem. One of the effects can
Packit Service 8591b6
dnl    be that thread-local variables always evaluate to 0. So, it is
Packit Service 8591b6
dnl    important to run the test below.
Packit Service 8591b6
if test "$enable_thread_safe" != no; then
Packit Service 8591b6
AC_MSG_CHECKING(for TLS support using C11)
Packit Service 8591b6
saved_CPPFLAGS="$CPPFLAGS"
Packit Service 8591b6
CPPFLAGS="$CPPFLAGS -I$srcdir/src"
Packit Service 8591b6
AC_RUN_IFELSE([AC_LANG_SOURCE([[
Packit Service 8591b6
#define MPFR_USE_THREAD_SAFE 1
Packit Service 8591b6
#define MPFR_USE_C11_THREAD_SAFE 1
Packit Service 8591b6
#include "mpfr-thread.h"
Packit Service 8591b6
MPFR_THREAD_ATTR int x = 17;
Packit Service 8591b6
int main (void) {
Packit Service 8591b6
  return x != 17;
Packit Service 8591b6
}
Packit Service 8591b6
  ]])],
Packit Service 8591b6
     [AC_MSG_RESULT(yes)
Packit Service 8591b6
      AC_DEFINE([MPFR_USE_THREAD_SAFE],1,[Build MPFR as thread safe])
Packit Service 8591b6
      AC_DEFINE([MPFR_USE_C11_THREAD_SAFE],1,[Build MPFR as thread safe using C11])
Packit Service 8591b6
      tls_c11_support=yes
Packit Service 8591b6
     ],
Packit Service 8591b6
     [AC_MSG_RESULT(no)
Packit Service 8591b6
     ],
Packit Service 8591b6
     [AC_MSG_RESULT([cannot test, assume no])
Packit Service 8591b6
     ])
Packit Service 8591b6
CPPFLAGS="$saved_CPPFLAGS"
Packit Service 8591b6
Packit Service 8591b6
if test "$tls_c11_support" != "yes"
Packit Service 8591b6
then
Packit Service 8591b6
Packit Service 8591b6
 AC_MSG_CHECKING(for TLS support)
Packit Service 8591b6
 saved_CPPFLAGS="$CPPFLAGS"
Packit Service 8591b6
 CPPFLAGS="$CPPFLAGS -I$srcdir/src"
Packit Service 8591b6
 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Packit Service 8591b6
 #define MPFR_USE_THREAD_SAFE 1
Packit Service 8591b6
 #include "mpfr-thread.h"
Packit Service 8591b6
 MPFR_THREAD_ATTR int x = 17;
Packit Service 8591b6
 int main (void) {
Packit Service 8591b6
   return x != 17;
Packit Service 8591b6
 }
Packit Service 8591b6
   ]])],
Packit Service 8591b6
      [AC_MSG_RESULT(yes)
Packit Service 8591b6
       AC_DEFINE([MPFR_USE_THREAD_SAFE],1,[Build MPFR as thread safe])
Packit Service 8591b6
      ],
Packit Service 8591b6
      [AC_MSG_RESULT(no)
Packit Service 8591b6
       if test "$enable_thread_safe" = yes; then
Packit Service 8591b6
         AC_MSG_ERROR([please configure with --disable-thread-safe])
Packit Service 8591b6
       fi
Packit Service 8591b6
      ],
Packit Service 8591b6
      [if test "$enable_thread_safe" = yes; then
Packit Service 8591b6
         AC_MSG_RESULT([cannot test, assume yes])
Packit Service 8591b6
         AC_DEFINE([MPFR_USE_THREAD_SAFE],1,[Build MPFR as thread safe])
Packit Service 8591b6
       else
Packit Service 8591b6
         AC_MSG_RESULT([cannot test, assume no])
Packit Service 8591b6
       fi
Packit Service 8591b6
      ])
Packit Service 8591b6
 CPPFLAGS="$saved_CPPFLAGS"
Packit Service 8591b6
 fi
Packit Service 8591b6
fi
Packit Service 8591b6
])
Packit Service 8591b6
dnl end of MPFR_CONFIGS
Packit Service 8591b6
Packit Service 8591b6
Packit Service 8591b6
dnl MPFR_CHECK_GMP
Packit Service 8591b6
dnl --------------
Packit Service 8591b6
dnl Check GMP library vs header. Useful if the user provides --with-gmp
Packit Service 8591b6
dnl with a directory containing a GMP version that doesn't have the
Packit Service 8591b6
dnl correct ABI: the previous tests won't trigger the error if the same
Packit Service 8591b6
dnl GMP version with the right ABI is installed on the system, as this
Packit Service 8591b6
dnl library is automatically selected by the linker, while the header
Packit Service 8591b6
dnl (which depends on the ABI) of the --with-gmp include directory is
Packit Service 8591b6
dnl used.
Packit Service 8591b6
dnl Note: if the error is changed to a warning due to that fact that
Packit Service 8591b6
dnl libtool is not used, then the same thing should be done for the
Packit Service 8591b6
dnl other tests based on GMP.
Packit Service 8591b6
AC_DEFUN([MPFR_CHECK_GMP], [
Packit Service 8591b6
AC_REQUIRE([MPFR_CONFIGS])dnl
Packit Service 8591b6
AC_CACHE_CHECK([for GMP library vs header correctness], mpfr_cv_check_gmp, [
Packit Service 8591b6
AC_RUN_IFELSE([AC_LANG_PROGRAM([[
Packit Service 8591b6
#include <stdio.h>
Packit Service 8591b6
#include <limits.h>
Packit Service 8591b6
#include <gmp.h>
Packit Service 8591b6
]], [[
Packit Service 8591b6
  fprintf (stderr, "GMP_NAIL_BITS     = %d\n", (int) GMP_NAIL_BITS);
Packit Service 8591b6
  fprintf (stderr, "GMP_NUMB_BITS     = %d\n", (int) GMP_NUMB_BITS);
Packit Service 8591b6
  fprintf (stderr, "mp_bits_per_limb  = %d\n", (int) mp_bits_per_limb);
Packit Service 8591b6
  fprintf (stderr, "sizeof(mp_limb_t) = %d\n", (int) sizeof(mp_limb_t));
Packit Service 8591b6
  if (GMP_NAIL_BITS != 0)
Packit Service 8591b6
    {
Packit Service 8591b6
      fprintf (stderr, "GMP_NAIL_BITS != 0\n");
Packit Service 8591b6
      return 1;
Packit Service 8591b6
    }
Packit Service 8591b6
  if (GMP_NUMB_BITS != mp_bits_per_limb)
Packit Service 8591b6
    {
Packit Service 8591b6
      fprintf (stderr, "GMP_NUMB_BITS != mp_bits_per_limb\n");
Packit Service 8591b6
      return 2;
Packit Service 8591b6
    }
Packit Service 8591b6
  if (GMP_NUMB_BITS != sizeof(mp_limb_t) * CHAR_BIT)
Packit Service 8591b6
    {
Packit Service 8591b6
      fprintf (stderr, "GMP_NUMB_BITS != sizeof(mp_limb_t) * CHAR_BIT\n");
Packit Service 8591b6
      return 3;
Packit Service 8591b6
    }
Packit Service 8591b6
  return 0;
Packit Service 8591b6
]])], [mpfr_cv_check_gmp="yes"],
Packit Service 8591b6
      [mpfr_cv_check_gmp="no (exit status is $?)"],
Packit Service 8591b6
      [mpfr_cv_check_gmp="cannot test, assume yes"])
Packit Service 8591b6
])
Packit Service 8591b6
case $mpfr_cv_check_gmp in
Packit Service 8591b6
no*)
Packit Service 8591b6
  AC_MSG_ERROR([bad GMP library or header - ABI problem?
Packit Service 8591b6
See 'config.log' for details.])
Packit Service 8591b6
esac
Packit Service 8591b6
])
Packit Service 8591b6
Packit Service 8591b6
Packit Service 8591b6
dnl MPFR_CHECK_DBL2INT_BUG
Packit Service 8591b6
dnl ----------------------
Packit Service 8591b6
dnl Check for double-to-integer conversion bug
Packit Service 8591b6
dnl https://gforge.inria.fr/tracker/index.php?func=detail&aid=14435
Packit Service 8591b6
dnl For the exit status, the lowest values (including some values after 128)
Packit Service 8591b6
dnl are reserved for various system errors. So, let's use the largest values
Packit Service 8591b6
dnl below 255 for errors in the test itself.
Packit Service 8591b6
dnl The following problem has been seen under Solaris in config.log,
Packit Service 8591b6
dnl i.e. the failure to link with libgmp wasn't detected in the first
Packit Service 8591b6
dnl test:
Packit Service 8591b6
dnl   configure: checking if gmp.h version and libgmp version are the same
Packit Service 8591b6
dnl   configure: gcc -o conftest -Wall -Wmissing-prototypes [...]
Packit Service 8591b6
dnl   configure: $? = 0
Packit Service 8591b6
dnl   configure: ./conftest
Packit Service 8591b6
dnl   ld.so.1: conftest: fatal: libgmp.so.10: open failed: No such file [...]
Packit Service 8591b6
dnl   configure: $? = 0
Packit Service 8591b6
dnl   configure: result: yes
Packit Service 8591b6
dnl   configure: checking for double-to-integer conversion bug
Packit Service 8591b6
dnl   configure: gcc -o conftest -Wall -Wmissing-prototypes [...]
Packit Service 8591b6
dnl   configure: $? = 0
Packit Service 8591b6
dnl   configure: ./conftest
Packit Service 8591b6
dnl   ld.so.1: conftest: fatal: libgmp.so.10: open failed: No such file [...]
Packit Service 8591b6
dnl   ./configure[1680]: eval: line 1: 1971: Killed
Packit Service 8591b6
dnl   configure: $? = 9
Packit Service 8591b6
dnl   configure: program exited with status 9
Packit Service 8591b6
AC_DEFUN([MPFR_CHECK_DBL2INT_BUG], [
Packit Service 8591b6
AC_REQUIRE([MPFR_CONFIGS])dnl
Packit Service 8591b6
AC_CACHE_CHECK([for double-to-integer conversion bug], mpfr_cv_dbl_int_bug, [
Packit Service 8591b6
AC_RUN_IFELSE([AC_LANG_PROGRAM([[
Packit Service 8591b6
#include <gmp.h>
Packit Service 8591b6
]], [[
Packit Service 8591b6
  double d;
Packit Service 8591b6
  mp_limb_t u;
Packit Service 8591b6
  int i;
Packit Service 8591b6
Packit Service 8591b6
  d = 1.0;
Packit Service 8591b6
  for (i = 0; i < GMP_NUMB_BITS - 1; i++)
Packit Service 8591b6
    d = d + d;
Packit Service 8591b6
  u = (mp_limb_t) d;
Packit Service 8591b6
  for (; i > 0; i--)
Packit Service 8591b6
    {
Packit Service 8591b6
      if (u & 1)
Packit Service 8591b6
        break;
Packit Service 8591b6
      u = u >> 1;
Packit Service 8591b6
    }
Packit Service 8591b6
  return (i == 0 && u == 1UL) ? 0 : 254 - i;
Packit Service 8591b6
]])], [mpfr_cv_dbl_int_bug="no"],
Packit Service 8591b6
      [mpfr_cv_dbl_int_bug="yes or failed to exec (exit status is $?)"],
Packit Service 8591b6
      [mpfr_cv_dbl_int_bug="cannot test, assume not present"])
Packit Service 8591b6
])
Packit Service 8591b6
case $mpfr_cv_dbl_int_bug in
Packit Service 8591b6
yes*)
Packit Service 8591b6
  AC_MSG_ERROR([double-to-integer conversion is incorrect.
Packit Service 8591b6
You need to use another compiler (or lower the optimization level).])
Packit Service 8591b6
esac
Packit Service 8591b6
])
Packit Service 8591b6
Packit Service 8591b6
dnl MPFR_PARSE_DIRECTORY
Packit Service 8591b6
dnl Input:  $1 = a string to a relative or absolute directory
Packit Service 8591b6
dnl Output: $2 = the variable to set with the absolute directory
Packit Service 8591b6
AC_DEFUN([MPFR_PARSE_DIRECTORY],
Packit Service 8591b6
[
Packit Service 8591b6
 dnl Check if argument is a directory
Packit Service 8591b6
 if test -d $1 ; then
Packit Service 8591b6
    dnl Get the absolute path of the directory
Packit Service 8591b6
    dnl in case of relative directory.
Packit Service 8591b6
    dnl If realpath is not a valid command,
Packit Service 8591b6
    dnl an error is produced and we keep the given path.
Packit Service 8591b6
    local_tmp=`realpath $1 2>/dev/null`
Packit Service 8591b6
    if test "$local_tmp" != "" ; then
Packit Service 8591b6
       if test -d "$local_tmp" ; then
Packit Service 8591b6
           $2="$local_tmp"
Packit Service 8591b6
       else
Packit Service 8591b6
           $2=$1
Packit Service 8591b6
       fi
Packit Service 8591b6
    else
Packit Service 8591b6
       $2=$1
Packit Service 8591b6
    fi
Packit Service 8591b6
    dnl Check for space in the directory
Packit Service 8591b6
    if test `echo $1|cut -d' ' -f1` != $1 ; then
Packit Service 8591b6
        AC_MSG_ERROR($1 directory shall not contain any space.)
Packit Service 8591b6
    fi
Packit Service 8591b6
 else
Packit Service 8591b6
    AC_MSG_ERROR($1 shall be a valid directory)
Packit Service 8591b6
 fi
Packit Service 8591b6
])
Packit Service 8591b6
Packit Service 8591b6
Packit Service 8591b6
dnl  MPFR_C_LONG_DOUBLE_FORMAT
Packit Service 8591b6
dnl  -------------------------
Packit Service 8591b6
dnl  Determine the format of a long double.
Packit Service 8591b6
dnl
Packit Service 8591b6
dnl  The object file is grepped, so as to work when cross compiling.  A
Packit Service 8591b6
dnl  start and end sequence is included to avoid false matches, and
Packit Service 8591b6
dnl  allowance is made for the desired data crossing an "od -b" line
Packit Service 8591b6
dnl  boundary.  The test number is a small integer so it should appear
Packit Service 8591b6
dnl  exactly, no rounding or truncation etc.
Packit Service 8591b6
dnl
Packit Service 8591b6
dnl  "od -b" is supported even by Unix V7, and the awk script used doesn't
Packit Service 8591b6
dnl  have functions or anything, so even an "old" awk should suffice.
Packit Service 8591b6
dnl
Packit Service 8591b6
dnl  The 10-byte IEEE extended format is generally padded to either 12 or 16
Packit Service 8591b6
dnl  bytes for alignment purposes.  The SVR4 i386 ABI is 12 bytes, or i386
Packit Service 8591b6
dnl  gcc -m128bit-long-double selects 16 bytes.  IA-64 is 16 bytes in LP64
Packit Service 8591b6
dnl  mode, or 12 bytes in ILP32 mode.  The first 10 bytes is the relevant
Packit Service 8591b6
dnl  part in all cases (big and little endian).
Packit Service 8591b6
dnl
Packit Service 8591b6
dnl  Enhancements:
Packit Service 8591b6
dnl
Packit Service 8591b6
dnl  Could match more formats, but no need to worry until there's code
Packit Service 8591b6
dnl  wanting to use them.
Packit Service 8591b6
dnl
Packit Service 8591b6
dnl  Don't want to duplicate the double matching from GMP_C_DOUBLE_FORMAT,
Packit Service 8591b6
dnl  perhaps we should merge with that macro, to match data formats
Packit Service 8591b6
dnl  irrespective of the C type in question.  Or perhaps just let the code
Packit Service 8591b6
dnl  use DOUBLE macros when sizeof(double)==sizeof(long double).
Packit Service 8591b6
Packit Service 8591b6
AC_DEFUN([MPFR_C_LONG_DOUBLE_FORMAT],
Packit Service 8591b6
[AC_REQUIRE([AC_PROG_CC])
Packit Service 8591b6
AC_REQUIRE([AC_PROG_AWK])
Packit Service 8591b6
AC_REQUIRE([AC_OBJEXT])
Packit Service 8591b6
AC_CHECK_TYPES([long double])
Packit Service 8591b6
AC_CACHE_CHECK([format of `long double' floating point],
Packit Service 8591b6
                mpfr_cv_c_long_double_format,
Packit Service 8591b6
[mpfr_cv_c_long_double_format=unknown
Packit Service 8591b6
if test "$ac_cv_type_long_double" != yes; then
Packit Service 8591b6
  mpfr_cv_c_long_double_format="not available"
Packit Service 8591b6
else
Packit Service 8591b6
  cat >conftest.c <<\EOF
Packit Service 8591b6
[
Packit Service 8591b6
/* "before" is 16 bytes to ensure there's no padding between it and "x".
Packit Service 8591b6
   We're not expecting any "long double" bigger than 16 bytes or with
Packit Service 8591b6
   alignment requirements stricter than 16 bytes.  */
Packit Service 8591b6
struct {
Packit Service 8591b6
  char         before[16];
Packit Service 8591b6
  long double  x;
Packit Service 8591b6
  char         after[8];
Packit Service 8591b6
} foo = {
Packit Service 8591b6
  { '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
Packit Service 8591b6
    '\001', '\043', '\105', '\147', '\211', '\253', '\315', '\357' },
Packit Service 8591b6
  -123456789.0,
Packit Service 8591b6
  { '\376', '\334', '\272', '\230', '\166', '\124', '\062', '\020' }
Packit Service 8591b6
};
Packit Service 8591b6
]
Packit Service 8591b6
EOF
Packit Service 8591b6
  mpfr_compile="$CC $CFLAGS $CPPFLAGS -c conftest.c >&AS_MESSAGE_LOG_FD 2>&1"
Packit Service 8591b6
  if AC_TRY_EVAL(mpfr_compile); then
Packit Service 8591b6
    cat >conftest.awk <<\EOF
Packit Service 8591b6
[
Packit Service 8591b6
BEGIN {
Packit Service 8591b6
  found = 0
Packit Service 8591b6
}
Packit Service 8591b6
Packit Service 8591b6
# got[] holds a sliding window of bytes read the input.  got[0] is the most
Packit Service 8591b6
# recent byte read, and got[31] the oldest byte read, so when looking to
Packit Service 8591b6
# match some data the indices are "reversed".
Packit Service 8591b6
#
Packit Service 8591b6
{
Packit Service 8591b6
  for (f = 2; f <= NF; f++)
Packit Service 8591b6
    {
Packit Service 8591b6
      # new byte, shift others up
Packit Service 8591b6
      for (i = 31; i >= 0; i--)
Packit Service 8591b6
        got[i+1] = got[i];
Packit Service 8591b6
      got[0] = $f;
Packit Service 8591b6
Packit Service 8591b6
      # end sequence
Packit Service 8591b6
      if (got[7] != "376") continue
Packit Service 8591b6
      if (got[6] != "334") continue
Packit Service 8591b6
      if (got[5] != "272") continue
Packit Service 8591b6
      if (got[4] != "230") continue
Packit Service 8591b6
      if (got[3] != "166") continue
Packit Service 8591b6
      if (got[2] != "124") continue
Packit Service 8591b6
      if (got[1] != "062") continue
Packit Service 8591b6
      if (got[0] != "020") continue
Packit Service 8591b6
Packit Service 8591b6
      # start sequence, with 8-byte body
Packit Service 8591b6
      if (got[23] == "001" && \
Packit Service 8591b6
          got[22] == "043" && \
Packit Service 8591b6
          got[21] == "105" && \
Packit Service 8591b6
          got[20] == "147" && \
Packit Service 8591b6
          got[19] == "211" && \
Packit Service 8591b6
          got[18] == "253" && \
Packit Service 8591b6
          got[17] == "315" && \
Packit Service 8591b6
          got[16] == "357")
Packit Service 8591b6
        {
Packit Service 8591b6
          saw = " (" got[15] \
Packit Service 8591b6
                 " " got[14] \
Packit Service 8591b6
                 " " got[13] \
Packit Service 8591b6
                 " " got[12] \
Packit Service 8591b6
                 " " got[11] \
Packit Service 8591b6
                 " " got[10] \
Packit Service 8591b6
                 " " got[9]  \
Packit Service 8591b6
                 " " got[8] ")"
Packit Service 8591b6
Packit Service 8591b6
          if (got[15] == "301" && \
Packit Service 8591b6
              got[14] == "235" && \
Packit Service 8591b6
              got[13] == "157" && \
Packit Service 8591b6
              got[12] == "064" && \
Packit Service 8591b6
              got[11] == "124" && \
Packit Service 8591b6
              got[10] == "000" && \
Packit Service 8591b6
              got[9] ==  "000" && \
Packit Service 8591b6
              got[8] ==  "000")
Packit Service 8591b6
            {
Packit Service 8591b6
              print "IEEE double, big endian"
Packit Service 8591b6
              found = 1
Packit Service 8591b6
              exit
Packit Service 8591b6
            }
Packit Service 8591b6
Packit Service 8591b6
          if (got[15] == "000" && \
Packit Service 8591b6
              got[14] == "000" && \
Packit Service 8591b6
              got[13] == "000" && \
Packit Service 8591b6
              got[12] == "124" && \
Packit Service 8591b6
              got[11] == "064" && \
Packit Service 8591b6
              got[10] == "157" && \
Packit Service 8591b6
              got[9] ==  "235" && \
Packit Service 8591b6
              got[8] ==  "301")
Packit Service 8591b6
            {
Packit Service 8591b6
              print "IEEE double, little endian"
Packit Service 8591b6
              found = 1
Packit Service 8591b6
              exit
Packit Service 8591b6
            }
Packit Service 8591b6
        }
Packit Service 8591b6
Packit Service 8591b6
      # start sequence, with 12-byte body
Packit Service 8591b6
      if (got[27] == "001" && \
Packit Service 8591b6
          got[26] == "043" && \
Packit Service 8591b6
          got[25] == "105" && \
Packit Service 8591b6
          got[24] == "147" && \
Packit Service 8591b6
          got[23] == "211" && \
Packit Service 8591b6
          got[22] == "253" && \
Packit Service 8591b6
          got[21] == "315" && \
Packit Service 8591b6
          got[20] == "357")
Packit Service 8591b6
        {
Packit Service 8591b6
          saw = " (" got[19] \
Packit Service 8591b6
                 " " got[18] \
Packit Service 8591b6
                 " " got[17] \
Packit Service 8591b6
                 " " got[16] \
Packit Service 8591b6
                 " " got[15] \
Packit Service 8591b6
                 " " got[14] \
Packit Service 8591b6
                 " " got[13] \
Packit Service 8591b6
                 " " got[12] \
Packit Service 8591b6
                 " " got[11] \
Packit Service 8591b6
                 " " got[10] \
Packit Service 8591b6
                 " " got[9]  \
Packit Service 8591b6
                 " " got[8] ")"
Packit Service 8591b6
Packit Service 8591b6
          if (got[19] == "000" && \
Packit Service 8591b6
              got[18] == "000" && \
Packit Service 8591b6
              got[17] == "000" && \
Packit Service 8591b6
              got[16] == "000" && \
Packit Service 8591b6
              got[15] == "240" && \
Packit Service 8591b6
              got[14] == "242" && \
Packit Service 8591b6
              got[13] == "171" && \
Packit Service 8591b6
              got[12] == "353" && \
Packit Service 8591b6
              got[11] == "031" && \
Packit Service 8591b6
              got[10] == "300")
Packit Service 8591b6
            {
Packit Service 8591b6
              print "IEEE extended, little endian"
Packit Service 8591b6
              found = 1
Packit Service 8591b6
              exit
Packit Service 8591b6
            }
Packit Service 8591b6
Packit Service 8591b6
          if (got[19] == "300" && \
Packit Service 8591b6
              got[18] == "031" && \
Packit Service 8591b6
              got[17] == "000" && \
Packit Service 8591b6
              got[16] == "000" && \
Packit Service 8591b6
              got[15] == "353" && \
Packit Service 8591b6
              got[14] == "171" && \
Packit Service 8591b6
              got[13] == "242" && \
Packit Service 8591b6
              got[12] == "240" && \
Packit Service 8591b6
              got[11] == "000" && \
Packit Service 8591b6
              got[10] == "000" && \
Packit Service 8591b6
              got[09] == "000" && \
Packit Service 8591b6
              got[08] == "000")
Packit Service 8591b6
            {
Packit Service 8591b6
              # format found on m68k
Packit Service 8591b6
              print "IEEE extended, big endian"
Packit Service 8591b6
              found = 1
Packit Service 8591b6
              exit
Packit Service 8591b6
            }
Packit Service 8591b6
        }
Packit Service 8591b6
Packit Service 8591b6
      # start sequence, with 16-byte body
Packit Service 8591b6
      if (got[31] == "001" && \
Packit Service 8591b6
          got[30] == "043" && \
Packit Service 8591b6
          got[29] == "105" && \
Packit Service 8591b6
          got[28] == "147" && \
Packit Service 8591b6
          got[27] == "211" && \
Packit Service 8591b6
          got[26] == "253" && \
Packit Service 8591b6
          got[25] == "315" && \
Packit Service 8591b6
          got[24] == "357")
Packit Service 8591b6
        {
Packit Service 8591b6
          saw = " (" got[23] \
Packit Service 8591b6
                 " " got[22] \
Packit Service 8591b6
                 " " got[21] \
Packit Service 8591b6
                 " " got[20] \
Packit Service 8591b6
                 " " got[19] \
Packit Service 8591b6
                 " " got[18] \
Packit Service 8591b6
                 " " got[17] \
Packit Service 8591b6
                 " " got[16] \
Packit Service 8591b6
                 " " got[15] \
Packit Service 8591b6
                 " " got[14] \
Packit Service 8591b6
                 " " got[13] \
Packit Service 8591b6
                 " " got[12] \
Packit Service 8591b6
                 " " got[11] \
Packit Service 8591b6
                 " " got[10] \
Packit Service 8591b6
                 " " got[9]  \
Packit Service 8591b6
                 " " got[8] ")"
Packit Service 8591b6
Packit Service 8591b6
          if (got[23] == "000" && \
Packit Service 8591b6
              got[22] == "000" && \
Packit Service 8591b6
              got[21] == "000" && \
Packit Service 8591b6
              got[20] == "000" && \
Packit Service 8591b6
              got[19] == "240" && \
Packit Service 8591b6
              got[18] == "242" && \
Packit Service 8591b6
              got[17] == "171" && \
Packit Service 8591b6
              got[16] == "353" && \
Packit Service 8591b6
              got[15] == "031" && \
Packit Service 8591b6
              got[14] == "300")
Packit Service 8591b6
            {
Packit Service 8591b6
              print "IEEE extended, little endian"
Packit Service 8591b6
              found = 1
Packit Service 8591b6
              exit
Packit Service 8591b6
            }
Packit Service 8591b6
Packit Service 8591b6
          if (got[23] == "300" && \
Packit Service 8591b6
              got[22] == "031" && \
Packit Service 8591b6
              got[21] == "326" && \
Packit Service 8591b6
              got[20] == "363" && \
Packit Service 8591b6
              got[19] == "105" && \
Packit Service 8591b6
              got[18] == "100" && \
Packit Service 8591b6
              got[17] == "000" && \
Packit Service 8591b6
              got[16] == "000" && \
Packit Service 8591b6
              got[15] == "000" && \
Packit Service 8591b6
              got[14] == "000" && \
Packit Service 8591b6
              got[13] == "000" && \
Packit Service 8591b6
              got[12] == "000" && \
Packit Service 8591b6
              got[11] == "000" && \
Packit Service 8591b6
              got[10] == "000" && \
Packit Service 8591b6
              got[9]  == "000" && \
Packit Service 8591b6
              got[8]  == "000")
Packit Service 8591b6
            {
Packit Service 8591b6
              # format used on HP 9000/785 under HP-UX
Packit Service 8591b6
              print "IEEE quad, big endian"
Packit Service 8591b6
              found = 1
Packit Service 8591b6
              exit
Packit Service 8591b6
            }
Packit Service 8591b6
Packit Service 8591b6
          if (got[23] == "000" && \
Packit Service 8591b6
              got[22] == "000" && \
Packit Service 8591b6
              got[21] == "000" && \
Packit Service 8591b6
              got[20] == "000" && \
Packit Service 8591b6
              got[19] == "000" && \
Packit Service 8591b6
              got[18] == "000" && \
Packit Service 8591b6
              got[17] == "000" && \
Packit Service 8591b6
              got[16] == "000" && \
Packit Service 8591b6
              got[15] == "000" && \
Packit Service 8591b6
              got[14] == "000" && \
Packit Service 8591b6
              got[13] == "100" && \
Packit Service 8591b6
              got[12] == "105" && \
Packit Service 8591b6
              got[11] == "363" && \
Packit Service 8591b6
              got[10] == "326" && \
Packit Service 8591b6
              got[9]  == "031" && \
Packit Service 8591b6
	      got[8]  == "300")
Packit Service 8591b6
            {
Packit Service 8591b6
              print "IEEE quad, little endian"
Packit Service 8591b6
              found = 1
Packit Service 8591b6
              exit
Packit Service 8591b6
            }
Packit Service 8591b6
Packit Service 8591b6
          if (got[23] == "301" && \
Packit Service 8591b6
              got[22] == "235" && \
Packit Service 8591b6
              got[21] == "157" && \
Packit Service 8591b6
              got[20] == "064" && \
Packit Service 8591b6
              got[19] == "124" && \
Packit Service 8591b6
              got[18] == "000" && \
Packit Service 8591b6
              got[17] == "000" && \
Packit Service 8591b6
              got[16] == "000" && \
Packit Service 8591b6
              got[15] == "000" && \
Packit Service 8591b6
              got[14] == "000" && \
Packit Service 8591b6
              got[13] == "000" && \
Packit Service 8591b6
              got[12] == "000" && \
Packit Service 8591b6
              got[11] == "000" && \
Packit Service 8591b6
              got[10] == "000" && \
Packit Service 8591b6
              got[9]  == "000" && \
Packit Service 8591b6
              got[8]  == "000")
Packit Service 8591b6
            {
Packit Service 8591b6
              # format used on 32-bit PowerPC (Mac OS X and Debian GNU/Linux)
Packit Service 8591b6
              print "possibly double-double, big endian"
Packit Service 8591b6
              found = 1
Packit Service 8591b6
              exit
Packit Service 8591b6
            }
Packit Service 8591b6
        }
Packit Service 8591b6
    }
Packit Service 8591b6
}
Packit Service 8591b6
Packit Service 8591b6
END {
Packit Service 8591b6
  if (! found)
Packit Service 8591b6
    print "unknown", saw
Packit Service 8591b6
}
Packit Service 8591b6
]
Packit Service 8591b6
EOF
Packit Service 8591b6
    mpfr_cv_c_long_double_format=`od -b conftest.$OBJEXT | $AWK -f conftest.awk`
Packit Service 8591b6
    case $mpfr_cv_c_long_double_format in
Packit Service 8591b6
    unknown*)
Packit Service 8591b6
      echo "cannot match anything, conftest.$OBJEXT contains" >&AS_MESSAGE_LOG_FD
Packit Service 8591b6
      od -b conftest.$OBJEXT >&AS_MESSAGE_LOG_FD
Packit Service 8591b6
      ;;
Packit Service 8591b6
    esac
Packit Service 8591b6
  else
Packit Service 8591b6
    AC_MSG_WARN([oops, cannot compile test program])
Packit Service 8591b6
  fi
Packit Service 8591b6
fi
Packit Service 8591b6
rm -f conftest*
Packit Service 8591b6
])
Packit Service 8591b6
Packit Service 8591b6
AH_VERBATIM([HAVE_LDOUBLE],
Packit Service 8591b6
[/* Define one of the following to 1 for the format of a `long double'.
Packit Service 8591b6
   If your format is not among these choices, or you don't know what it is,
Packit Service 8591b6
   then leave all undefined.
Packit Service 8591b6
   IEEE_EXT is the 10-byte IEEE extended precision format.
Packit Service 8591b6
   IEEE_QUAD is the 16-byte IEEE quadruple precision format.
Packit Service 8591b6
   LITTLE or BIG is the endianness.  */
Packit Service 8591b6
#undef HAVE_LDOUBLE_IEEE_EXT_LITTLE
Packit Service 8591b6
#undef HAVE_LDOUBLE_IEEE_QUAD_BIG])
Packit Service 8591b6
Packit Service 8591b6
case $mpfr_cv_c_long_double_format in
Packit Service 8591b6
  "IEEE extended, little endian")
Packit Service 8591b6
    AC_DEFINE(HAVE_LDOUBLE_IEEE_EXT_LITTLE, 1)
Packit Service 8591b6
    ;;
Packit Service 8591b6
  "IEEE quad, big endian")
Packit Service 8591b6
    AC_DEFINE(HAVE_LDOUBLE_IEEE_QUAD_BIG, 1)
Packit Service 8591b6
    ;;
Packit Service 8591b6
  "IEEE quad, little endian")
Packit Service 8591b6
    AC_DEFINE(HAVE_LDOUBLE_IEEE_QUAD_LITTLE, 1)
Packit Service 8591b6
    ;;
Packit Service 8591b6
  "possibly double-double, big endian")
Packit Service 8591b6
    AC_MSG_WARN([This format is known on GCC/PowerPC platforms,])
Packit Service 8591b6
    AC_MSG_WARN([but due to GCC PR26374, we can't test further.])
Packit Service 8591b6
    AC_MSG_WARN([You can safely ignore this warning, though.])
Packit Service 8591b6
    # Since we are not sure, we do not want to define a macro.
Packit Service 8591b6
    ;;
Packit Service 8591b6
  unknown* | "not available")
Packit Service 8591b6
    ;;
Packit Service 8591b6
  *)
Packit Service 8591b6
    AC_MSG_WARN([oops, unrecognised float format: $mpfr_cv_c_long_double_format])
Packit Service 8591b6
    ;;
Packit Service 8591b6
esac
Packit Service 8591b6
])
Packit Service 8591b6
Packit Service 8591b6
Packit Service 8591b6
dnl  MPFR_CHECK_LIBM
Packit Service 8591b6
dnl  ---------------
Packit Service 8591b6
dnl  Determine a math library -lm to use.
Packit Service 8591b6
Packit Service 8591b6
AC_DEFUN([MPFR_CHECK_LIBM],
Packit Service 8591b6
[AC_REQUIRE([AC_CANONICAL_HOST])
Packit Service 8591b6
AC_SUBST(MPFR_LIBM,'')
Packit Service 8591b6
case $host in
Packit Service 8591b6
  *-*-beos* | *-*-cygwin* | *-*-pw32*)
Packit Service 8591b6
    # According to libtool AC CHECK LIBM, these systems don't have libm
Packit Service 8591b6
    ;;
Packit Service 8591b6
  *-*-solaris*)
Packit Service 8591b6
    # On Solaris the math functions new in C99 are in -lm9x.
Packit Service 8591b6
    # FIXME: Do we need -lm9x as well as -lm, or just instead of?
Packit Service 8591b6
    AC_CHECK_LIB(m9x, main, MPFR_LIBM="-lm9x")
Packit Service 8591b6
    AC_CHECK_LIB(m,   main, MPFR_LIBM="$MPFR_LIBM -lm")
Packit Service 8591b6
    ;;
Packit Service 8591b6
  *-ncr-sysv4.3*)
Packit Service 8591b6
    # FIXME: What does -lmw mean?  Libtool AC CHECK LIBM does it this way.
Packit Service 8591b6
    AC_CHECK_LIB(mw, _mwvalidcheckl, MPFR_LIBM="-lmw")
Packit Service 8591b6
    AC_CHECK_LIB(m, main, MPFR_LIBM="$MPFR_LIBM -lm")
Packit Service 8591b6
    ;;
Packit Service 8591b6
  *)
Packit Service 8591b6
    AC_CHECK_LIB(m, main, MPFR_LIBM="-lm")
Packit Service 8591b6
    ;;
Packit Service 8591b6
esac
Packit Service 8591b6
])
Packit Service 8591b6
Packit Service 8591b6
Packit Service 8591b6
dnl  MPFR_LD_SEARCH_PATHS_FIRST
Packit Service 8591b6
dnl  --------------------------
Packit Service 8591b6
Packit Service 8591b6
AC_DEFUN([MPFR_LD_SEARCH_PATHS_FIRST],
Packit Service 8591b6
[case "$LD $LDFLAGS" in
Packit Service 8591b6
  *-Wl,-search_paths_first*) ;;
Packit Service 8591b6
  *) AC_MSG_CHECKING([if the compiler understands -Wl,-search_paths_first])
Packit Service 8591b6
     saved_LDFLAGS="$LDFLAGS"
Packit Service 8591b6
     LDFLAGS="-Wl,-search_paths_first $LDFLAGS"
Packit Service 8591b6
     AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
Packit Service 8591b6
       [AC_MSG_RESULT(yes)],
Packit Service 8591b6
       [AC_MSG_RESULT(no)]
Packit Service 8591b6
        LDFLAGS="$saved_LDFLAGS")
Packit Service 8591b6
     ;;
Packit Service 8591b6
 esac
Packit Service 8591b6
])
Packit Service 8591b6
Packit Service 8591b6
Packit Service 8591b6
dnl  GMP_C_ATTRIBUTE_MODE
Packit Service 8591b6
dnl  --------------------
Packit Service 8591b6
dnl  Introduced in gcc 2.2, but perhaps not in all Apple derived versions.
Packit Service 8591b6
dnl  Needed for mpfr-longlong.h; this is currently necessary for s390.
Packit Service 8591b6
dnl
Packit Service 8591b6
dnl  TODO: Replace this with a cleaner type size detection, as this
Packit Service 8591b6
dnl  solution only works with gcc and assumes CHAR_BIT == 8. Probably use
Packit Service 8591b6
dnl  <stdint.h>, and <http://gcc.gnu.org/viewcvs/trunk/config/stdint.m4>
Packit Service 8591b6
dnl  as a fallback.
Packit Service 8591b6
Packit Service 8591b6
AC_DEFUN([GMP_C_ATTRIBUTE_MODE],
Packit Service 8591b6
[AC_CACHE_CHECK([whether gcc __attribute__ ((mode (XX))) works],
Packit Service 8591b6
               gmp_cv_c_attribute_mode,
Packit Service 8591b6
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[typedef int SItype __attribute__ ((mode (SI)));]], [[]])],
Packit Service 8591b6
 gmp_cv_c_attribute_mode=yes, gmp_cv_c_attribute_mode=no)
Packit Service 8591b6
])
Packit Service 8591b6
if test $gmp_cv_c_attribute_mode = yes; then
Packit Service 8591b6
 AC_DEFINE(HAVE_ATTRIBUTE_MODE, 1,
Packit Service 8591b6
 [Define to 1 if the compiler accepts gcc style __attribute__ ((mode (XX)))])
Packit Service 8591b6
fi
Packit Service 8591b6
])
Packit Service 8591b6
Packit Service 8591b6
Packit Service 8591b6
dnl  MPFR_FUNC_GMP_PRINTF_SPEC
Packit Service 8591b6
dnl  ------------------------------------
Packit Service 8591b6
dnl  MPFR_FUNC_GMP_PRINTF_SPEC(spec, type, [includes], [if-true], [if-false])
Packit Service 8591b6
dnl  Check if gmp_sprintf supports the conversion specification 'spec'
Packit Service 8591b6
dnl  with type 'type'.
Packit Service 8591b6
dnl  Expand 'if-true' if printf supports 'spec', 'if-false' otherwise.
Packit Service 8591b6
Packit Service 8591b6
AC_DEFUN([MPFR_FUNC_GMP_PRINTF_SPEC],[
Packit Service 8591b6
AC_MSG_CHECKING(if gmp_printf supports "%$1")
Packit Service 8591b6
AC_RUN_IFELSE([AC_LANG_PROGRAM([[
Packit Service 8591b6
#include <stdio.h>
Packit Service 8591b6
#include <string.h>
Packit Service 8591b6
$3
Packit Service 8591b6
#include <gmp.h>
Packit Service 8591b6
]], [[
Packit Service 8591b6
  char s[256];
Packit Service 8591b6
  $2 a = 17;
Packit Service 8591b6
Packit Service 8591b6
  if (gmp_sprintf (s, "(%0.0$1)(%d)", a, 42) == -1) return 1;
Packit Service 8591b6
  return (strcmp (s, "(17)(42)") != 0);
Packit Service 8591b6
]])],
Packit Service 8591b6
  [AC_MSG_RESULT(yes)
Packit Service 8591b6
  $4],
Packit Service 8591b6
  [AC_MSG_RESULT(no)
Packit Service 8591b6
  $5],
Packit Service 8591b6
  [AC_MSG_RESULT(cross-compiling, assuming yes)
Packit Service 8591b6
  $4])
Packit Service 8591b6
])
Packit Service 8591b6
Packit Service 8591b6
Packit Service 8591b6
dnl MPFR_CHECK_PRINTF_SPEC
Packit Service 8591b6
dnl ----------------------
Packit Service 8591b6
dnl Check if gmp_printf supports some optional length modifiers.
Packit Service 8591b6
dnl Defined symbols are negative to shorten the gcc command line.
Packit Service 8591b6
Packit Service 8591b6
AC_DEFUN([MPFR_CHECK_PRINTF_SPEC], [
Packit Service 8591b6
AC_REQUIRE([MPFR_CONFIGS])dnl
Packit Service 8591b6
if test "$ac_cv_type_intmax_t" = yes; then
Packit Service 8591b6
 MPFR_FUNC_GMP_PRINTF_SPEC([jd], [intmax_t], [
Packit Service 8591b6
#ifdef HAVE_INTTYPES_H
Packit Service 8591b6
# include <inttypes.h>
Packit Service 8591b6
#endif
Packit Service 8591b6
#ifdef HAVE_STDINT_H
Packit Service 8591b6
# include <stdint.h>
Packit Service 8591b6
#endif
Packit Service 8591b6
         ],,
Packit Service 8591b6
         [AC_DEFINE([NPRINTF_J], 1, [gmp_printf cannot read intmax_t])])
Packit Service 8591b6
fi
Packit Service 8591b6
Packit Service 8591b6
MPFR_FUNC_GMP_PRINTF_SPEC([hhd], [char], [
Packit Service 8591b6
#include <gmp.h>
Packit Service 8591b6
         ],,
Packit Service 8591b6
         [AC_DEFINE([NPRINTF_HH], 1, [gmp_printf cannot use `hh' length modifier])])
Packit Service 8591b6
Packit Service 8591b6
MPFR_FUNC_GMP_PRINTF_SPEC([lld], [long long int], [
Packit Service 8591b6
#include <gmp.h>
Packit Service 8591b6
         ],,
Packit Service 8591b6
         [AC_DEFINE([NPRINTF_LL], 1, [gmp_printf cannot read long long int])])
Packit Service 8591b6
Packit Service 8591b6
MPFR_FUNC_GMP_PRINTF_SPEC([Lf], [long double], [
Packit Service 8591b6
#include <gmp.h>
Packit Service 8591b6
         ],,
Packit Service 8591b6
         [AC_DEFINE([NPRINTF_L], 1, [gmp_printf cannot read long double])])
Packit Service 8591b6
Packit Service 8591b6
MPFR_FUNC_GMP_PRINTF_SPEC([td], [ptrdiff_t], [
Packit Service 8591b6
#if defined (__cplusplus)
Packit Service 8591b6
#include <cstddef>
Packit Service 8591b6
#else
Packit Service 8591b6
#include <stddef.h>
Packit Service 8591b6
#endif
Packit Service 8591b6
#include <gmp.h>
Packit Service 8591b6
    ],,
Packit Service 8591b6
    [AC_DEFINE([NPRINTF_T], 1, [gmp_printf cannot read ptrdiff_t])])
Packit Service 8591b6
])