1 /* Test integer width macros.
2 Copyright (C) 2016 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/>. */
22 #define CHECK_WIDTH(TYPE, MAX, WIDTH) \
25 if ((MAX >> ((TYPE) -1 < 0 ? (WIDTH - 2) : (WIDTH - 1))) != 1) \
27 puts ("bad width of " #TYPE); \
31 puts ("width of " #TYPE " OK"); \
40 # error "missing CHAR_WIDTH"
42 CHECK_WIDTH (char, CHAR_MAX
, CHAR_WIDTH
);
44 # error "missing SCHAR_WIDTH"
46 CHECK_WIDTH (signed char, SCHAR_MAX
, SCHAR_WIDTH
);
48 # error "missing UCHAR_WIDTH"
50 CHECK_WIDTH (unsigned char, UCHAR_MAX
, UCHAR_WIDTH
);
52 # error "missing SHRT_WIDTH"
54 CHECK_WIDTH (signed short, SHRT_MAX
, SHRT_WIDTH
);
56 # error "missing USHRT_WIDTH"
58 CHECK_WIDTH (unsigned short, USHRT_MAX
, USHRT_WIDTH
);
60 # error "missing INT_WIDTH"
62 CHECK_WIDTH (signed int, INT_MAX
, INT_WIDTH
);
64 # error "missing UINT_WIDTH"
66 CHECK_WIDTH (unsigned int, UINT_MAX
, UINT_WIDTH
);
68 # error "missing LONG_WIDTH"
70 CHECK_WIDTH (signed long, LONG_MAX
, LONG_WIDTH
);
72 # error "missing ULONG_WIDTH"
74 CHECK_WIDTH (unsigned long, ULONG_MAX
, ULONG_WIDTH
);
76 # error "missing LLONG_WIDTH"
78 CHECK_WIDTH (signed long long, LLONG_MAX
, LLONG_WIDTH
);
80 # error "missing ULLONG_WIDTH"
82 CHECK_WIDTH (unsigned long long, ULLONG_MAX
, ULLONG_WIDTH
);
86 #define TEST_FUNCTION do_test ()
87 #include "../test-skeleton.c"