diff options
author | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2023-01-31 14:46:01 +0100 |
---|---|---|
committer | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2023-01-31 14:46:01 +0100 |
commit | e8bd88d1fcded01ccd066572eeaae1b507989cb3 (patch) | |
tree | c8e7be6c07c6f635f6e803e6a6ba9e7a95fee7c0 /gl/m4/realloc.m4 | |
parent | 2ad962c13473607ca0d974bfaa516a0ed53ec73d (diff) | |
download | monitoring-plugins-e8bd88d1fcded01ccd066572eeaae1b507989cb3.tar.gz |
Sync with the latest Gnulib code 668c0b8ffa
Diffstat (limited to 'gl/m4/realloc.m4')
-rw-r--r-- | gl/m4/realloc.m4 | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/gl/m4/realloc.m4 b/gl/m4/realloc.m4 new file mode 100644 index 00000000..d22138fc --- /dev/null +++ b/gl/m4/realloc.m4 | |||
@@ -0,0 +1,63 @@ | |||
1 | # realloc.m4 serial 26 | ||
2 | dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc. | ||
3 | dnl This file is free software; the Free Software Foundation | ||
4 | dnl gives unlimited permission to copy and/or distribute it, | ||
5 | dnl 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 | ||
9 | AC_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. | ||
42 | AC_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. | ||
56 | AC_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 | ]) | ||