diff options
author | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2021-11-17 01:05:54 +0100 |
---|---|---|
committer | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2022-07-24 19:35:11 +0200 |
commit | a405fc138596f552581d2011fd6de02d5c8186c4 (patch) | |
tree | 4c084700b5cb5e9fcedf982a2d921bbc41d9935a /gl/m4/realloc.m4 | |
parent | 9f2a9ca3d72023ff9b5707d1872c54d65edc9017 (diff) | |
download | monitoring-plugins-a405fc138596f552581d2011fd6de02d5c8186c4.tar.gz |
Sync with the latest Gnulib code (1a268176f)
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..0abc4185 --- /dev/null +++ b/gl/m4/realloc.m4 | |||
@@ -0,0 +1,63 @@ | |||
1 | # realloc.m4 serial 24 | ||
2 | dnl Copyright (C) 2007, 2009-2021 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 = 0; then | ||
47 | _AC_FUNC_REALLOC_IF([], [REPLACE_REALLOC=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 = 1; then | ||
61 | REPLACE_REALLOC=1 | ||
62 | fi | ||
63 | ]) | ||