beta-0.89.2
[luatex.git] / source / libs / mpfr / m4 / mpfr-check-printf-spec.m4
blobab76ffbeeee3aff70c1237c095a97452c72de79d
1 # Autoconf macros for the GNU MPFR Library.
2 # Copyright (C) 2000-2013 Free Software Foundation, Inc.
3 # Contributed by the AriC and Caramel projects, INRIA.
5 # Copyright (C) 2014 Peter Breitenlohner <tex-live@tug.org>
6 # Extracted from mpfr-3.1.2/acinclude.m4 and adapted for TeX Live.
8 # This file is free software; the copyright holders
9 # give unlimited permission to copy and/or distribute it,
10 # with or without modifications, as long as this notice is preserved.
12 # MPFR_CHECK_PRINTF_SPEC
13 # ----------------------
14 # Check if gmp_printf supports some optional length modifiers.
15 # Defined symbols are negative to shorten the gcc command line.
16 AC_DEFUN([MPFR_CHECK_PRINTF_SPEC], [
17 AC_REQUIRE([MPFR_CONFIGS])dnl
18 if test "x$ac_cv_type_intmax_t" = xyes; then
19  MPFR_FUNC_GMP_PRINTF_SPEC([jd], [intmax_t], [
20 #ifdef HAVE_INTTYPES_H
21 # include <inttypes.h>
22 #endif
23 #ifdef HAVE_STDINT_H
24 # include <stdint.h>
25 #endif
26          ], ,
27          [AC_DEFINE([NPRINTF_J], 1, [gmp_printf cannot read intmax_t])])
30 MPFR_FUNC_GMP_PRINTF_SPEC([hhd], [char], , ,
31          [AC_DEFINE([NPRINTF_HH], 1, [gmp_printf cannot use `hh' length modifier])])
33 MPFR_FUNC_GMP_PRINTF_SPEC([lld], [long long int], , ,
34          [AC_DEFINE([NPRINTF_LL], 1, [gmp_printf cannot read long long int])])
36 MPFR_FUNC_GMP_PRINTF_SPEC([Lf], [long double], , ,
37          [AC_DEFINE([NPRINTF_L], 1, [gmp_printf cannot read long double])])
39 MPFR_FUNC_GMP_PRINTF_SPEC([td], [ptrdiff_t], [
40 #if defined (__cplusplus)
41 #include <cstddef>
42 #else
43 #include <stddef.h>
44 #endif
45     ], ,
46     [AC_DEFINE([NPRINTF_T], 1, [gmp_printf cannot read ptrdiff_t])])
47 ]) # MPFR_CHECK_PRINTF_SPEC
50 # MPFR_FUNC_GMP_PRINTF_SPEC(SPEC, TYPE, [INCLUDES], [IF-TRUE], [IF-FALSE])
51 # ------------------------------------------------------------------------
52 # Check if gmp_sprintf supports the conversion specification 'spec'
53 # with type 'type'.
54 # Expand 'if-true' if printf supports 'spec', 'if-false' otherwise.
55 m4_define([MPFR_FUNC_GMP_PRINTF_SPEC], [
56 AC_MSG_CHECKING([if gmp_printf supports "%$1"])
57 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
58 #include <stdio.h>
60 #include <gmp.h>
61 ]], [[
62   char s[256];
63   $2 a = 17;
65   if (gmp_sprintf (s, "(%0.0$1)(%d)", a, 42) == -1) return 1;
66   return (strcmp (s, "(17)(42)") != 0);
67 ]])],
68   [AC_MSG_RESULT([yes])
69   $4],
70   [AC_MSG_RESULT([no])
71   $5])
72 ]) # MPFR_FUNC_GMP_PRINTF_SPEC