Add a couple of minibuffer completion tests
[emacs.git] / m4 / free.m4
bloba2b596d67f72df417c298901f3efad430a83287c
1 # free.m4
2 # serial 6
3 dnl Copyright (C) 2003-2005, 2009-2024 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
8 # Written by Paul Eggert and Bruno Haible.
10 AC_DEFUN([gl_FUNC_FREE],
12   AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
14   dnl In the next release of POSIX, free must preserve errno.
15   dnl https://www.austingroupbugs.net/view.php?id=385
16   dnl https://sourceware.org/bugzilla/show_bug.cgi?id=17924
17   dnl So far, we know of three platforms that do this:
18   dnl * glibc >= 2.33, thanks to the fix for this bug:
19   dnl   <https://sourceware.org/bugzilla/show_bug.cgi?id=17924>
20   dnl * OpenBSD >= 4.5, thanks to this commit:
21   dnl   <https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libc/stdlib/malloc.c.diff?r1=1.100&r2=1.101&f=h>
22   dnl * Solaris, because its malloc() implementation is based on brk(),
23   dnl   not mmap(); hence its free() implementation makes no system calls.
24   dnl For other platforms, you can only be sure if they state it in their
25   dnl documentation, or by code inspection of the free() implementation in libc.
26   AC_CACHE_CHECK([whether free is known to preserve errno],
27     [gl_cv_func_free_preserves_errno],
28     [AC_COMPILE_IFELSE(
29        [AC_LANG_PROGRAM(
30           [[#include <stdlib.h>
31           ]],
32           [[#if 2 < __GLIBC__ + (33 <= __GLIBC_MINOR__)
33             #elif defined __OpenBSD__
34             #elif defined __sun
35             #else
36               #error "'free' is not known to preserve errno"
37             #endif
38           ]])],
39        [gl_cv_func_free_preserves_errno=yes],
40        [gl_cv_func_free_preserves_errno=no])
41     ])
43   case $gl_cv_func_free_preserves_errno in
44    *yes)
45     AC_DEFINE([HAVE_FREE_POSIX], [1],
46       [Define if the 'free' function is guaranteed to preserve errno.])
47     ;;
48    *) REPLACE_FREE=1 ;;
49   esac
52 # Prerequisites of lib/free.c.
53 AC_DEFUN([gl_PREREQ_FREE], [:])