summaryrefslogtreecommitdiffstats
path: root/gl/m4/realloc.m4
diff options
context:
space:
mode:
authorLorenz <12514511+RincewindsHat@users.noreply.github.com>2023-03-11 10:34:47 (GMT)
committerGitHub <noreply@github.com>2023-03-11 10:34:47 (GMT)
commit75342b53853a898bdd93c7d3da9374115bab6b6d (patch)
tree0c0af2b796bcdd8ddd42187beb5badb420db8dea /gl/m4/realloc.m4
parent6bbe0b7b0f609ecab831dec9be7690842bf0a0fc (diff)
parent357787868b5201ec3e874e7a225b1c944cbbdb4d (diff)
downloadmonitoring-plugins-75342b53853a898bdd93c7d3da9374115bab6b6d.tar.gz
Merge branch 'master' into patch-1refs/pull/1842/head
Diffstat (limited to 'gl/m4/realloc.m4')
-rw-r--r--gl/m4/realloc.m463
1 files changed, 63 insertions, 0 deletions
diff --git a/gl/m4/realloc.m4 b/gl/m4/realloc.m4
new file mode 100644
index 0000000..d22138f
--- /dev/null
+++ b/gl/m4/realloc.m4
@@ -0,0 +1,63 @@
1# realloc.m4 serial 26
2dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7# This is adapted with modifications from upstream Autoconf here:
8# https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/functions.m4?id=v2.70#n1455
9AC_DEFUN([_AC_FUNC_REALLOC_IF],
10[
11 AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles
12 AC_CACHE_CHECK([whether realloc (0, 0) returns nonnull],
13 [ac_cv_func_realloc_0_nonnull],
14 [AC_RUN_IFELSE(
15 [AC_LANG_PROGRAM(
16 [[#include <stdlib.h>
17 ]],
18 [[void *p = realloc (0, 0);
19 int result = !p;
20 free (p);
21 return result;]])
22 ],
23 [ac_cv_func_realloc_0_nonnull=yes],
24 [ac_cv_func_realloc_0_nonnull=no],
25 [case "$host_os" in
26 # Guess yes on platforms where we know the result.
27 *-gnu* | freebsd* | netbsd* | openbsd* | bitrig* \
28 | gnu* | *-musl* | midnightbsd* \
29 | hpux* | solaris* | cygwin* | mingw* | msys* )
30 ac_cv_func_realloc_0_nonnull="guessing yes" ;;
31 # If we don't know, obey --enable-cross-guesses.
32 *) ac_cv_func_realloc_0_nonnull="$gl_cross_guess_normal" ;;
33 esac
34 ])
35 ])
36 AS_CASE([$ac_cv_func_realloc_0_nonnull], [*yes], [$1], [$2])
37])# AC_FUNC_REALLOC
38
39# gl_FUNC_REALLOC_GNU
40# -------------------
41# Replace realloc if it is not compatible with GNU libc.
42AC_DEFUN([gl_FUNC_REALLOC_GNU],
43[
44 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
45 AC_REQUIRE([gl_FUNC_REALLOC_POSIX])
46 if test $REPLACE_REALLOC_FOR_REALLOC_GNU = 0; then
47 _AC_FUNC_REALLOC_IF([], [REPLACE_REALLOC_FOR_REALLOC_GNU=1])
48 fi
49])# gl_FUNC_REALLOC_GNU
50
51# gl_FUNC_REALLOC_POSIX
52# ---------------------
53# Test whether 'realloc' is POSIX compliant (sets errno to ENOMEM when it
54# fails, and doesn't mess up with ptrdiff_t overflow),
55# and replace realloc if it is not.
56AC_DEFUN([gl_FUNC_REALLOC_POSIX],
57[
58 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
59 AC_REQUIRE([gl_FUNC_MALLOC_POSIX])
60 if test $REPLACE_MALLOC_FOR_MALLOC_POSIX = 1; then
61 REPLACE_REALLOC_FOR_REALLOC_POSIX=1
62 fi
63])