# malloc.m4
-# serial 42
+# serial 43
dnl Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl This file is offered as-is, without any warranty.
m4_version_prereq([2.73], [], [
+# Modules that use this macro directly or indirectly should depend
+# on extensions-aix, so that _LINUX_SOURCE_COMPAT gets defined
+# before this macro gets invoked. This helps on AIX 7.2 and earlier
+# if !(__VEC__ || __AIXVEC), and doesn't hurt otherwise.
+#
# This is copied from upstream Autoconf here:
# https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/functions.m4?id=1f38316f6af7bf63e5e7dd187ff6456e07ad743e#n971
# _AC_FUNC_MALLOC_IF(IF-WORKS, IF-NOT[, UNKNOWN-ASSUME])
])# _AC_FUNC_MALLOC_IF
])
+# gl_FUNC_MALLOC_0_NONNULL
+# ------------------------
+# If 'malloc (0)' returns nonnull define HAVE_MALLOC_0_NONNULL.
+# Also, set ac_cv_func_malloc_0_nonnull to a string that ends in
+# "yes", otherwise set it to something else. If unknown whether
+# malloc (0) works, guess as normal for cross-builds.
+AC_DEFUN([gl_FUNC_MALLOC_0_NONNULL],
+[
+ _AC_FUNC_MALLOC_IF(
+ [AC_DEFINE([HAVE_MALLOC_0_NONNULL], [1],
+ [Define to 1 if malloc (0) returns nonnull.])],
+ [],
+ ["$gl_cross_guess_normal"])
+])
+
# gl_FUNC_MALLOC_GNU
# ------------------
# Test whether malloc (0) is compatible with GNU libc.
[
AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
AC_REQUIRE([gl_FUNC_MALLOC_POSIX])
+ AC_REQUIRE([gl_FUNC_MALLOC_0_NONNULL])
- dnl Through the dependency on module extensions-aix, _LINUX_SOURCE_COMPAT
- dnl gets defined already before this macro gets invoked. This helps
- dnl if !(__VEC__ || __AIXVEC), and doesn't hurt otherwise.
-
- _AC_FUNC_MALLOC_IF(
- [AC_DEFINE([HAVE_MALLOC_0_NONNULL], [1],
- [Define to 1 if malloc (0) returns nonnull.])
- REPLACE_MALLOC_FOR_MALLOC_GNU=$REPLACE_MALLOC_FOR_MALLOC_POSIX],
- [REPLACE_MALLOC_FOR_MALLOC_GNU=1],
- ["$gl_cross_guess_normal"])
+ AS_CASE([$ac_cv_func_malloc_0_nonnull],
+ [*yes],
+ [REPLACE_MALLOC_FOR_MALLOC_GNU=$REPLACE_MALLOC_FOR_MALLOC_POSIX],
+ [REPLACE_MALLOC_FOR_MALLOC_GNU=1])
])
# gl_FUNC_MALLOC_PTRDIFF