summaryrefslogtreecommitdiff
path: root/Build/source/libs/gmp/m4/gmp-alloca.m4
blob: 2fc59023a88d519eb72d46029f44039f8a92551f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Autoconf macros for the GNU MP Library.
# Copyright (C) 2000-2014 Free Software Foundation, Inc.
#
# Copyright (C) 2014 Peter Breitenlohner <tex-live@tug.org>
# Extracted from gmp-6.0.0/acinclude.m4 and adapted for TeX Live.
#
# This file is free software; the copyright holders
# give unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.

# GMP_FUNC_ALLOCA
# ---------------
# Determine whether "alloca" is available.  This is AC_FUNC_ALLOCA from
# autoconf, but changed so it doesn't use alloca.c if alloca() isn't
# available, and also to use gmp-impl.h for the conditionals detecting
# compiler builtin alloca's.

AC_DEFUN([GMP_FUNC_ALLOCA], [dnl
AC_REQUIRE([KPSE_GMP_H])
_GMP_HEADER_ALLOCA
AC_CACHE_CHECK([for alloca (via gmp-impl.h)],
               [gmp_cv_func_alloca],
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include "gmp-tmp.h"
#include "$srcdir/gmp-]gmp_version[/gmp-impl.h"]],
                                    [[char *p = (char *) alloca (1);]])],
  [gmp_cv_func_alloca=yes],
  [gmp_cv_func_alloca=no])])
if test "x$gmp_cv_func_alloca" = xyes; then
  AC_DEFINE([HAVE_ALLOCA], 1, [Define to 1 if alloca() works (via gmp-impl.h).])
  AC_DEFINE([WANT_TMP_ALLOCA])
else
  AC_DEFINE([WANT_TMP_REENTRANT])
fi
AH_VERBATIM([WANT_TMP],
[/* Define one of these to 1 for the temporary memory allocation method. */
#undef WANT_TMP_ALLOCA
#undef WANT_TMP_REENTRANT])
]) # GMP_FUNC_ALLOCA

# _GMP_HEADER_ALLOCA
# ------------------
# Internal subroutine
m4_define([_GMP_HEADER_ALLOCA],
[# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
# for constant arguments.  Useless!
AC_CACHE_CHECK([for working alloca.h],
               [gmp_cv_header_alloca],
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <alloca.h>]],
                                    [[char *p = (char *) alloca (2 * sizeof (int));]])],
  [gmp_cv_header_alloca=yes],
  [gmp_cv_header_alloca=no])])
if test "x$gmp_cv_header_alloca" = xyes; then
  AC_DEFINE([HAVE_ALLOCA_H], 1,
  [Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).])
fi
]) # _GMP_HEADER_ALLOCA