1 /* Test of <stddef.h> substitute.
2 Copyright (C) 2009-2016 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 <http://www.gnu.org/licenses/>. */
17 /* Written by Eric Blake <ebb9@byu.net>, 2009. */
25 /* Check that appropriate types are defined. */
31 /* Check that NULL can be passed through varargs as a pointer type,
33 verify (sizeof NULL == sizeof (void *));
35 /* Check that offsetof produces integer constants with correct type. */
41 /* Solaris 10 has a bug where offsetof is under-parenthesized, and
42 cannot be used as an arbitrary expression. However, since it is
43 unlikely to bite real code, we ignore that short-coming. */
44 /* verify (sizeof offsetof (struct d, e) == sizeof (size_t)); */
45 verify (sizeof (offsetof (struct d, e)) == sizeof (size_t));
46 verify (offsetof (struct d, e) < -1); /* Must be unsigned. */
47 verify (offsetof (struct d, f) == 1);
49 /* Check max_align_t's alignment. */
50 verify (alignof (double) <= alignof (max_align_t));
51 verify (alignof (int) <= alignof (max_align_t));
52 verify (alignof (long double) <= alignof (max_align_t));
53 verify (alignof (long int) <= alignof (max_align_t));
54 verify (alignof (ptrdiff_t) <= alignof (max_align_t));
55 verify (alignof (size_t) <= alignof (max_align_t));
56 verify (alignof (wchar_t) <= alignof (max_align_t));
57 verify (alignof (struct d) <= alignof (max_align_t));
58 #if defined __GNUC__ || defined __IBM__ALIGNOF__
59 verify (__alignof__ (double) <= __alignof__ (max_align_t));
60 verify (__alignof__ (int) <= __alignof__ (max_align_t));
61 verify (__alignof__ (long double) <= __alignof__ (max_align_t));
62 verify (__alignof__ (long int) <= __alignof__ (max_align_t));
63 verify (__alignof__ (ptrdiff_t) <= __alignof__ (max_align_t));
64 verify (__alignof__ (size_t) <= __alignof__ (max_align_t));
65 verify (__alignof__ (wchar_t) <= __alignof__ (max_align_t));
66 verify (__alignof__ (struct d) <= __alignof__ (max_align_t));