1 /* Test stdc_first_leading_one functions and macros.
2 Copyright (C) 2024 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 <tst-stdbit.h>
21 static const struct stdbit_test inputs
[] =
24 { 0x1ULL
, 8, 16, 32, 64 },
25 { 0x2ULL
, 7, 15, 31, 63 },
26 { 0x3ULL
, 7, 15, 31, 63 },
27 { 0x4ULL
, 6, 14, 30, 62 },
28 { 0x5ULL
, 6, 14, 30, 62 },
29 { 0x6ULL
, 6, 14, 30, 62 },
30 { 0x7ULL
, 6, 14, 30, 62 },
31 { 0x8ULL
, 5, 13, 29, 61 },
32 { 0x9ULL
, 5, 13, 29, 61 },
33 { 0xaULL
, 5, 13, 29, 61 },
34 { 0xbULL
, 5, 13, 29, 61 },
35 { 0xcULL
, 5, 13, 29, 61 },
36 { 0xdULL
, 5, 13, 29, 61 },
37 { 0xeULL
, 5, 13, 29, 61 },
38 { 0xfULL
, 5, 13, 29, 61 },
39 { 0x10ULL
, 4, 12, 28, 60 },
40 { 0x11ULL
, 4, 12, 28, 60 },
41 { 0x12ULL
, 4, 12, 28, 60 },
42 { 0x1fULL
, 4, 12, 28, 60 },
43 { 0x20ULL
, 3, 11, 27, 59 },
44 { 0x7fULL
, 2, 10, 26, 58 },
45 { 0x80ULL
, 1, 9, 25, 57 },
46 { 0x81ULL
, 1, 9, 25, 57 },
47 { 0x9aULL
, 1, 9, 25, 57 },
48 { 0xf3ULL
, 1, 9, 25, 57 },
49 { 0xffULL
, 1, 9, 25, 57 },
50 { 0x100ULL
, 0, 8, 24, 56 },
51 { 0x101ULL
, 8, 8, 24, 56 },
52 { 0x102ULL
, 7, 8, 24, 56 },
53 { 0x1feULL
, 1, 8, 24, 56 },
54 { 0x1ffULL
, 1, 8, 24, 56 },
55 { 0x200ULL
, 0, 7, 23, 55 },
56 { 0x234ULL
, 3, 7, 23, 55 },
57 { 0x4567ULL
, 2, 2, 18, 50 },
58 { 0x7fffULL
, 1, 2, 18, 50 },
59 { 0x8000ULL
, 0, 1, 17, 49 },
60 { 0x8001ULL
, 8, 1, 17, 49 },
61 { 0xfffeULL
, 1, 1, 17, 49 },
62 { 0xffffULL
, 1, 1, 17, 49 },
63 { 0x10000ULL
, 0, 0, 16, 48 },
64 { 0x10001ULL
, 8, 16, 16, 48 },
65 { 0xfedcba98ULL
, 1, 1, 1, 33 },
66 { 0xfffffefeULL
, 1, 1, 1, 33 },
67 { 0xffffffffULL
, 1, 1, 1, 33 },
68 { 0x100000000ULL
, 0, 0, 0, 32 },
69 { 0x100000001ULL
, 8, 16, 32, 32 },
70 { 0x123456789ULL
, 1, 2, 3, 32 },
71 { 0x123456789abcdefULL
, 1, 1, 1, 8 },
72 { 0x789abcdef0123456ULL
, 2, 3, 1, 2 },
73 { 0x8000000000000000ULL
, 0, 0, 0, 1 },
74 { 0x8000000000000001ULL
, 8, 16, 32, 1 },
75 { 0xfffffffffffffffeULL
, 1, 1, 1, 1 },
76 { 0xffffffffffffffffULL
, 1, 1, 1, 1 },
79 TEST_STDBIT_UI_TOPLEVEL (stdc_first_leading_one
);
84 TEST_STDBIT_UI (stdc_first_leading_one
, inputs
);
88 #include <support/test-driver.c>