diff options
author | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2022-08-23 19:42:51 +0200 |
---|---|---|
committer | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2022-09-14 11:08:55 +0200 |
commit | 868beb15ae02c352005a2df8857f4ebb9bd758fd (patch) | |
tree | 0dc6e6a91c4ef0f131ca82a777e6ac2ad193c399 /gl/m4/realloc.m4 | |
parent | b89aee56964f7d933f2da5f371e32b4d7db9410b (diff) | |
download | monitoring-plugins-868beb15ae02c352005a2df8857f4ebb9bd758fd.tar.gz |
Sync with the latest Gnulib code (d27c820595)
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..86e57c25 --- /dev/null +++ b/gl/m4/realloc.m4 | |||
@@ -0,0 +1,63 @@ | |||
1 | # realloc.m4 serial 26 | ||
2 | dnl Copyright (C) 2007, 2009-2022 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 | ]) | ||