diff options
author | Lorenz <12514511+RincewindsHat@users.noreply.github.com> | 2023-03-11 10:34:47 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-11 10:34:47 (GMT) |
commit | 75342b53853a898bdd93c7d3da9374115bab6b6d (patch) | |
tree | 0c0af2b796bcdd8ddd42187beb5badb420db8dea /gl/m4/free.m4 | |
parent | 6bbe0b7b0f609ecab831dec9be7690842bf0a0fc (diff) | |
parent | 357787868b5201ec3e874e7a225b1c944cbbdb4d (diff) | |
download | monitoring-plugins-75342b53853a898bdd93c7d3da9374115bab6b6d.tar.gz |
Merge branch 'master' into patch-1refs/pull/1842/head
Diffstat (limited to 'gl/m4/free.m4')
-rw-r--r-- | gl/m4/free.m4 | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/gl/m4/free.m4 b/gl/m4/free.m4 new file mode 100644 index 0000000..0389dea --- /dev/null +++ b/gl/m4/free.m4 | |||
@@ -0,0 +1,52 @@ | |||
1 | # free.m4 serial 6 | ||
2 | # Copyright (C) 2003-2005, 2009-2023 Free Software Foundation, Inc. | ||
3 | # This file is free software; the Free Software Foundation | ||
4 | # gives unlimited permission to copy and/or distribute it, | ||
5 | # with or without modifications, as long as this notice is preserved. | ||
6 | |||
7 | # Written by Paul Eggert and Bruno Haible. | ||
8 | |||
9 | AC_DEFUN([gl_FUNC_FREE], | ||
10 | [ | ||
11 | AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) | ||
12 | |||
13 | dnl In the next release of POSIX, free must preserve errno. | ||
14 | dnl https://www.austingroupbugs.net/view.php?id=385 | ||
15 | dnl https://sourceware.org/bugzilla/show_bug.cgi?id=17924 | ||
16 | dnl So far, we know of three platforms that do this: | ||
17 | dnl * glibc >= 2.33, thanks to the fix for this bug: | ||
18 | dnl <https://sourceware.org/bugzilla/show_bug.cgi?id=17924> | ||
19 | dnl * OpenBSD >= 4.5, thanks to this commit: | ||
20 | dnl <https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libc/stdlib/malloc.c.diff?r1=1.100&r2=1.101&f=h> | ||
21 | dnl * Solaris, because its malloc() implementation is based on brk(), | ||
22 | dnl not mmap(); hence its free() implementation makes no system calls. | ||
23 | dnl For other platforms, you can only be sure if they state it in their | ||
24 | dnl documentation, or by code inspection of the free() implementation in libc. | ||
25 | AC_CACHE_CHECK([whether free is known to preserve errno], | ||
26 | [gl_cv_func_free_preserves_errno], | ||
27 | [AC_COMPILE_IFELSE( | ||
28 | [AC_LANG_PROGRAM( | ||
29 | [[#include <stdlib.h> | ||
30 | ]], | ||
31 | [[#if 2 < __GLIBC__ + (33 <= __GLIBC_MINOR__) | ||
32 | #elif defined __OpenBSD__ | ||
33 | #elif defined __sun | ||
34 | #else | ||
35 | #error "'free' is not known to preserve errno" | ||
36 | #endif | ||
37 | ]])], | ||
38 | [gl_cv_func_free_preserves_errno=yes], | ||
39 | [gl_cv_func_free_preserves_errno=no]) | ||
40 | ]) | ||
41 | |||
42 | case $gl_cv_func_free_preserves_errno in | ||
43 | *yes) | ||
44 | AC_DEFINE([HAVE_FREE_POSIX], [1], | ||
45 | [Define if the 'free' function is guaranteed to preserve errno.]) | ||
46 | ;; | ||
47 | *) REPLACE_FREE=1 ;; | ||
48 | esac | ||
49 | ]) | ||
50 | |||
51 | # Prerequisites of lib/free.c. | ||
52 | AC_DEFUN([gl_PREREQ_FREE], [:]) | ||