beta-0.89.2
[luatex.git] / source / libs / gmp / m4 / gmp-alloca.m4
blob2fc59023a88d519eb72d46029f44039f8a92551f
1 # Autoconf macros for the GNU MP Library.
2 # Copyright (C) 2000-2014 Free Software Foundation, Inc.
4 # Copyright (C) 2014 Peter Breitenlohner <tex-live@tug.org>
5 # Extracted from gmp-6.0.0/acinclude.m4 and adapted for TeX Live.
7 # This file is free software; the copyright holders
8 # give unlimited permission to copy and/or distribute it,
9 # with or without modifications, as long as this notice is preserved.
11 # GMP_FUNC_ALLOCA
12 # ---------------
13 # Determine whether "alloca" is available.  This is AC_FUNC_ALLOCA from
14 # autoconf, but changed so it doesn't use alloca.c if alloca() isn't
15 # available, and also to use gmp-impl.h for the conditionals detecting
16 # compiler builtin alloca's.
18 AC_DEFUN([GMP_FUNC_ALLOCA], [dnl
19 AC_REQUIRE([KPSE_GMP_H])
20 _GMP_HEADER_ALLOCA
21 AC_CACHE_CHECK([for alloca (via gmp-impl.h)],
22                [gmp_cv_func_alloca],
23 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include "gmp-tmp.h"
24 #include "$srcdir/gmp-]gmp_version[/gmp-impl.h"]],
25                                     [[char *p = (char *) alloca (1);]])],
26   [gmp_cv_func_alloca=yes],
27   [gmp_cv_func_alloca=no])])
28 if test "x$gmp_cv_func_alloca" = xyes; then
29   AC_DEFINE([HAVE_ALLOCA], 1, [Define to 1 if alloca() works (via gmp-impl.h).])
30   AC_DEFINE([WANT_TMP_ALLOCA])
31 else
32   AC_DEFINE([WANT_TMP_REENTRANT])
34 AH_VERBATIM([WANT_TMP],
35 [/* Define one of these to 1 for the temporary memory allocation method. */
36 #undef WANT_TMP_ALLOCA
37 #undef WANT_TMP_REENTRANT])
38 ]) # GMP_FUNC_ALLOCA
40 # _GMP_HEADER_ALLOCA
41 # ------------------
42 # Internal subroutine
43 m4_define([_GMP_HEADER_ALLOCA],
44 [# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
45 # for constant arguments.  Useless!
46 AC_CACHE_CHECK([for working alloca.h],
47                [gmp_cv_header_alloca],
48 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <alloca.h>]],
49                                     [[char *p = (char *) alloca (2 * sizeof (int));]])],
50   [gmp_cv_header_alloca=yes],
51   [gmp_cv_header_alloca=no])])
52 if test "x$gmp_cv_header_alloca" = xyes; then
53   AC_DEFINE([HAVE_ALLOCA_H], 1,
54   [Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).])
56 ]) # _GMP_HEADER_ALLOCA