1/* Test stdc_bit_ceil functions and macros.
2 Copyright (C) 2024 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
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.
9
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.
14
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/>. */
18
19#include <tst-stdbit.h>
20
21static const struct stdbit_test inputs[] =
22 {
23 { 0ULL, 0x1, 0x1, 0x1, 0x1ULL },
24 { 0x1ULL, 0x1, 0x1, 0x1, 0x1ULL },
25 { 0x2ULL, 0x2, 0x2, 0x2, 0x2ULL },
26 { 0x3ULL, 0x4, 0x4, 0x4, 0x4ULL },
27 { 0x4ULL, 0x4, 0x4, 0x4, 0x4ULL },
28 { 0x5ULL, 0x8, 0x8, 0x8, 0x8ULL },
29 { 0x6ULL, 0x8, 0x8, 0x8, 0x8ULL },
30 { 0x7ULL, 0x8, 0x8, 0x8, 0x8ULL },
31 { 0x8ULL, 0x8, 0x8, 0x8, 0x8ULL },
32 { 0x9ULL, 0x10, 0x10, 0x10, 0x10ULL },
33 { 0xaULL, 0x10, 0x10, 0x10, 0x10ULL },
34 { 0xbULL, 0x10, 0x10, 0x10, 0x10ULL },
35 { 0xcULL, 0x10, 0x10, 0x10, 0x10ULL },
36 { 0xdULL, 0x10, 0x10, 0x10, 0x10ULL },
37 { 0xeULL, 0x10, 0x10, 0x10, 0x10ULL },
38 { 0xfULL, 0x10, 0x10, 0x10, 0x10ULL },
39 { 0x10ULL, 0x10, 0x10, 0x10, 0x10ULL },
40 { 0x11ULL, 0x20, 0x20, 0x20, 0x20ULL },
41 { 0x12ULL, 0x20, 0x20, 0x20, 0x20ULL },
42 { 0x1fULL, 0x20, 0x20, 0x20, 0x20ULL },
43 { 0x20ULL, 0x20, 0x20, 0x20, 0x20ULL },
44 { 0x7fULL, 0x80, 0x80, 0x80, 0x80ULL },
45 { 0x80ULL, 0x80, 0x80, 0x80, 0x80ULL },
46 { 0x81ULL, 0, 0x100, 0x100, 0x100ULL },
47 { 0x9aULL, 0, 0x100, 0x100, 0x100ULL },
48 { 0xf3ULL, 0, 0x100, 0x100, 0x100ULL },
49 { 0xffULL, 0, 0x100, 0x100, 0x100ULL },
50 { 0x100ULL, 0x1, 0x100, 0x100, 0x100ULL },
51 { 0x101ULL, 0x1, 0x200, 0x200, 0x200ULL },
52 { 0x102ULL, 0x2, 0x200, 0x200, 0x200ULL },
53 { 0x1feULL, 0, 0x200, 0x200, 0x200ULL },
54 { 0x1ffULL, 0, 0x200, 0x200, 0x200ULL },
55 { 0x200ULL, 0x1, 0x200, 0x200, 0x200ULL },
56 { 0x234ULL, 0x40, 0x400, 0x400, 0x400ULL },
57 { 0x4567ULL, 0x80, 0x8000, 0x8000, 0x8000ULL },
58 { 0x7fffULL, 0, 0x8000, 0x8000, 0x8000ULL },
59 { 0x8000ULL, 0x1, 0x8000, 0x8000, 0x8000ULL },
60 { 0x8001ULL, 0x1, 0, 0x10000, 0x10000ULL },
61 { 0xfffeULL, 0, 0, 0x10000, 0x10000ULL },
62 { 0xffffULL, 0, 0, 0x10000, 0x10000ULL },
63 { 0x10000ULL, 0x1, 0x1, 0x10000, 0x10000ULL },
64 { 0x10001ULL, 0x1, 0x1, 0x20000, 0x20000ULL },
65 { 0xfedcba98ULL, 0, 0, 0, 0x100000000ULL },
66 { 0xfffffefeULL, 0, 0, 0, 0x100000000ULL },
67 { 0xffffffffULL, 0, 0, 0, 0x100000000ULL },
68 { 0x100000000ULL, 0x1, 0x1, 0x1, 0x100000000ULL },
69 { 0x100000001ULL, 0x1, 0x1, 0x1, 0x200000000ULL },
70 { 0x123456789ULL, 0, 0x8000, 0x40000000, 0x200000000ULL },
71 { 0x123456789abcdefULL, 0, 0, 0, 0x200000000000000ULL },
72 { 0x789abcdef0123456ULL, 0x80, 0x4000, 0, 0x8000000000000000ULL },
73 { 0x8000000000000000ULL, 0x1, 0x1, 0x1, 0x8000000000000000ULL },
74 { 0x8000000000000001ULL, 0x1, 0x1, 0x1, 0ULL },
75 { 0xfffffffffffffffeULL, 0, 0, 0, 0ULL },
76 { 0xffffffffffffffffULL, 0, 0, 0, 0ULL },
77 };
78
79TEST_STDBIT_SAME_TOPLEVEL (stdc_bit_ceil);
80
81static int
82do_test (void)
83{
84 TEST_STDBIT_SAME (stdc_bit_ceil, inputs);
85 return 0;
86}
87
88#include <support/test-driver.c>
89

source code of glibc/stdlib/tst-stdc_bit_ceil.c