2 Copyright (C) 2013-2015 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
25 static int errors
= 0;
28 merror (const char *msg
)
31 printf ("Error: %s\n", msg
);
38 unsigned long pagesize
= getpagesize ();
44 /* An attempt to allocate a huge value should return NULL and set
51 merror ("pvalloc (-1) succeeded.");
53 if (p
== NULL
&& save
!= ENOMEM
)
54 merror ("pvalloc (-1) errno is not set correctly");
60 /* Test to expose integer overflow in malloc internals from BZ #15855. */
61 p
= pvalloc (-pagesize
);
66 merror ("pvalloc (-pagesize) succeeded.");
68 if (p
== NULL
&& save
!= ENOMEM
)
69 merror ("pvalloc (-pagesize) errno is not set correctly");
73 /* A zero-sized allocation should succeed with glibc, returning a
78 merror ("pvalloc (0) failed.");
82 /* Check the alignment of the returned pointer is correct. */
86 merror ("pvalloc (32) failed.");
88 ptrval
= (unsigned long) p
;
90 if ((ptrval
& (pagesize
- 1)) != 0)
91 merror ("returned pointer is not page aligned.");
98 #define TEST_FUNCTION do_test ()
99 #include "../test-skeleton.c"