1 /* Test of calloc function.
2 Copyright (C) 2024-2025 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
28 /* Work around clang bug
29 <https://github.com/llvm/llvm-project/issues/114772>. */
30 void *(*volatile my_calloc
) (size_t, size_t) = calloc
;
32 #define calloc my_calloc
37 /* Check that calloc sets errno when it fails.
38 Do this only in 64-bit processes, because there are many bi-arch systems
39 nowadays where a 32-bit process can actually allocate 2 GiB of RAM. */
40 if (sizeof (size_t) >= 8)
45 p
= calloc (SIZE_MAX
/ 20, 2);
47 ASSERT (errno
== ENOMEM
);
50 p
= calloc (SIZE_MAX
/ 6, 2);
52 ASSERT (errno
== ENOMEM
);
54 return test_exit_status
;
58 fputs ("Skipping test: size_t is not 64-bits wide\n", stderr
);