2022-01-04 21:13:25 +00:00
|
|
|
# realloc.m4 serial 26
|
2022-01-01 07:45:51 +00:00
|
|
|
dnl Copyright (C) 2007, 2009-2022 Free Software Foundation, Inc.
|
Update from Gnulib
Make the following changes by hand, and run 'admin/merge-gnulib'.
* .gitignore: Add lib/malloc/*.gl.h.
* admin/merge-gnulib: Copy lib/af_alg.h and lib/save-cwd.h
directly from Gnulib, without worrying about Gnulib modules,
as these files are special cases.
(AVOIDED_MODULES): Remove malloc-posix.
* lib/malloc.c, lib/realloc.c, m4/malloc.m4, m4/realloc.m4:
* m4/year2038.m4: New files, copied from Gnulib.
* lib/malloca.c, lib/malloca.h:
* m4/close-stream.m4, m4/glibc21.m4, m4/malloca.m4:
Remove. These are either no longer present in Gnulib, or are no
longer needed by modules that Emacs uses.
* oldXMenu/AddPane.c, oldXmenu/Addsel.c: Include XmenuInt.h first;
needed for new Gnulib.
* src/xmenu.c: Call emacs_abort, not abort.
2021-10-04 19:11:39 +00:00
|
|
|
dnl This file is free software; the Free Software Foundation
|
|
|
|
dnl gives unlimited permission to copy and/or distribute it,
|
|
|
|
dnl with or without modifications, as long as this notice is preserved.
|
|
|
|
|
|
|
|
# This is adapted with modifications from upstream Autoconf here:
|
|
|
|
# https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/functions.m4?id=v2.70#n1455
|
|
|
|
AC_DEFUN([_AC_FUNC_REALLOC_IF],
|
|
|
|
[
|
|
|
|
AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles
|
|
|
|
AC_CACHE_CHECK([whether realloc (0, 0) returns nonnull],
|
|
|
|
[ac_cv_func_realloc_0_nonnull],
|
|
|
|
[AC_RUN_IFELSE(
|
|
|
|
[AC_LANG_PROGRAM(
|
|
|
|
[[#include <stdlib.h>
|
|
|
|
]],
|
|
|
|
[[void *p = realloc (0, 0);
|
|
|
|
int result = !p;
|
|
|
|
free (p);
|
|
|
|
return result;]])
|
|
|
|
],
|
|
|
|
[ac_cv_func_realloc_0_nonnull=yes],
|
|
|
|
[ac_cv_func_realloc_0_nonnull=no],
|
|
|
|
[case "$host_os" in
|
|
|
|
# Guess yes on platforms where we know the result.
|
|
|
|
*-gnu* | freebsd* | netbsd* | openbsd* | bitrig* \
|
|
|
|
| gnu* | *-musl* | midnightbsd* \
|
|
|
|
| hpux* | solaris* | cygwin* | mingw* | msys* )
|
|
|
|
ac_cv_func_realloc_0_nonnull="guessing yes" ;;
|
|
|
|
# If we don't know, obey --enable-cross-guesses.
|
|
|
|
*) ac_cv_func_realloc_0_nonnull="$gl_cross_guess_normal" ;;
|
|
|
|
esac
|
|
|
|
])
|
|
|
|
])
|
|
|
|
AS_CASE([$ac_cv_func_realloc_0_nonnull], [*yes], [$1], [$2])
|
|
|
|
])# AC_FUNC_REALLOC
|
|
|
|
|
|
|
|
# gl_FUNC_REALLOC_GNU
|
|
|
|
# -------------------
|
|
|
|
# Replace realloc if it is not compatible with GNU libc.
|
|
|
|
AC_DEFUN([gl_FUNC_REALLOC_GNU],
|
|
|
|
[
|
|
|
|
AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
|
|
|
|
AC_REQUIRE([gl_FUNC_REALLOC_POSIX])
|
2022-01-04 21:13:25 +00:00
|
|
|
if test $REPLACE_REALLOC_FOR_REALLOC_GNU = 0; then
|
|
|
|
_AC_FUNC_REALLOC_IF([], [REPLACE_REALLOC_FOR_REALLOC_GNU=1])
|
Update from Gnulib
Make the following changes by hand, and run 'admin/merge-gnulib'.
* .gitignore: Add lib/malloc/*.gl.h.
* admin/merge-gnulib: Copy lib/af_alg.h and lib/save-cwd.h
directly from Gnulib, without worrying about Gnulib modules,
as these files are special cases.
(AVOIDED_MODULES): Remove malloc-posix.
* lib/malloc.c, lib/realloc.c, m4/malloc.m4, m4/realloc.m4:
* m4/year2038.m4: New files, copied from Gnulib.
* lib/malloca.c, lib/malloca.h:
* m4/close-stream.m4, m4/glibc21.m4, m4/malloca.m4:
Remove. These are either no longer present in Gnulib, or are no
longer needed by modules that Emacs uses.
* oldXMenu/AddPane.c, oldXmenu/Addsel.c: Include XmenuInt.h first;
needed for new Gnulib.
* src/xmenu.c: Call emacs_abort, not abort.
2021-10-04 19:11:39 +00:00
|
|
|
fi
|
|
|
|
])# gl_FUNC_REALLOC_GNU
|
|
|
|
|
|
|
|
# gl_FUNC_REALLOC_POSIX
|
|
|
|
# ---------------------
|
|
|
|
# Test whether 'realloc' is POSIX compliant (sets errno to ENOMEM when it
|
|
|
|
# fails, and doesn't mess up with ptrdiff_t overflow),
|
|
|
|
# and replace realloc if it is not.
|
|
|
|
AC_DEFUN([gl_FUNC_REALLOC_POSIX],
|
|
|
|
[
|
|
|
|
AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
|
|
|
|
AC_REQUIRE([gl_FUNC_MALLOC_POSIX])
|
2022-01-04 21:13:25 +00:00
|
|
|
if test $REPLACE_MALLOC_FOR_MALLOC_POSIX = 1; then
|
|
|
|
REPLACE_REALLOC_FOR_REALLOC_POSIX=1
|
Update from Gnulib
Make the following changes by hand, and run 'admin/merge-gnulib'.
* .gitignore: Add lib/malloc/*.gl.h.
* admin/merge-gnulib: Copy lib/af_alg.h and lib/save-cwd.h
directly from Gnulib, without worrying about Gnulib modules,
as these files are special cases.
(AVOIDED_MODULES): Remove malloc-posix.
* lib/malloc.c, lib/realloc.c, m4/malloc.m4, m4/realloc.m4:
* m4/year2038.m4: New files, copied from Gnulib.
* lib/malloca.c, lib/malloca.h:
* m4/close-stream.m4, m4/glibc21.m4, m4/malloca.m4:
Remove. These are either no longer present in Gnulib, or are no
longer needed by modules that Emacs uses.
* oldXMenu/AddPane.c, oldXmenu/Addsel.c: Include XmenuInt.h first;
needed for new Gnulib.
* src/xmenu.c: Call emacs_abort, not abort.
2021-10-04 19:11:39 +00:00
|
|
|
fi
|
|
|
|
])
|