Add IP_PROTOCOL from Linux 6.4 to bits/in.h
[glibc.git] / malloc / tst-mallocalign1.c
blob0708dc0ce0dec892027e388aaea91724fb17d270
1 /* Verify that MALLOC_ALIGNMENT is honored by malloc.
2 Copyright (C) 2012-2023 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 <https://www.gnu.org/licenses/>. */
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <inttypes.h>
22 #include <malloc-size.h>
23 #include <support/check.h>
25 static void *
26 test (size_t s)
28 void *p = malloc (s);
30 printf ("malloc: %zu, %p: %zu\n", s, p,
31 ((uintptr_t) p) & MALLOC_ALIGN_MASK);
32 return p;
35 #define ALIGNED(p) (((uintptr_t) p & MALLOC_ALIGN_MASK) == 0)
37 static int
38 do_test (void)
40 void *p;
42 p = test (2);
43 TEST_VERIFY (ALIGNED (p));
44 free (p);
46 p = test (8);
47 TEST_VERIFY (ALIGNED (p));
48 free (p);
50 p = test (13);
51 TEST_VERIFY (ALIGNED (p));
52 free (p);
54 p = test (16);
55 TEST_VERIFY (ALIGNED (p));
56 free (p);
58 p = test (23);
59 TEST_VERIFY (ALIGNED (p));
60 free (p);
62 p = test (43);
63 TEST_VERIFY (ALIGNED (p));
64 free (p);
66 p = test (123);
67 TEST_VERIFY (ALIGNED (p));
68 free (p);
70 return 0;
73 #include <support/test-driver.c>