|
8 | 8 |
|
9 | 9 | #include "test/UnitTest/Test.h"
|
10 | 10 |
|
11 |
| -#include <stdbit.h> |
12 |
| - |
13 | 11 | /*
|
14 | 12 | * The intent of this test is validate that:
|
15 |
| - * 1. We provide the definition of the various type generic macros of stdbit.h. |
| 13 | + * 1. We provide the definition of the various type generic macros of stdbit.h |
| 14 | + * (the macros are transitively included from stdbit-macros.h by stdbit.h). |
16 | 15 | * 2. It dispatches to the correct underlying function.
|
17 | 16 | * Because unit tests build without public packaging, the object files produced
|
18 | 17 | * do not contain non-namespaced symbols.
|
19 | 18 | */
|
20 | 19 |
|
21 |
| -unsigned char stdc_leading_zeros_uc(unsigned char) { return 0xAA; } |
22 |
| -unsigned short stdc_leading_zeros_us(unsigned short) { return 0xAB; } |
23 |
| -unsigned stdc_leading_zeros_ui(unsigned) { return 0xAC; } |
24 |
| -unsigned long stdc_leading_zeros_ul(unsigned long) { return 0xAD; } |
25 |
| -unsigned long long stdc_leading_zeros_ull(unsigned long long) { return 0xAF; } |
26 |
| -unsigned char stdc_leading_ones_uc(unsigned char) { return 0xBA; } |
27 |
| -unsigned short stdc_leading_ones_us(unsigned short) { return 0xBB; } |
28 |
| -unsigned stdc_leading_ones_ui(unsigned) { return 0xBC; } |
29 |
| -unsigned long stdc_leading_ones_ul(unsigned long) { return 0xBD; } |
30 |
| -unsigned long long stdc_leading_ones_ull(unsigned long long) { return 0xBF; } |
| 20 | +/* |
| 21 | + * Declare these BEFORE including stdbit-macros.h so that this test may still be |
| 22 | + * run even if a given target doesn't yet have these individual entrypoints |
| 23 | + * enabled. |
| 24 | + */ |
| 25 | +extern "C" { |
| 26 | +unsigned char stdc_leading_zeros_uc(unsigned char) noexcept { return 0xAA; } |
| 27 | +unsigned short stdc_leading_zeros_us(unsigned short) noexcept { return 0xAB; } |
| 28 | +unsigned stdc_leading_zeros_ui(unsigned) noexcept { return 0xAC; } |
| 29 | +unsigned long stdc_leading_zeros_ul(unsigned long) noexcept { return 0xAD; } |
| 30 | +unsigned long long stdc_leading_zeros_ull(unsigned long long) noexcept { |
| 31 | + return 0xAF; |
| 32 | +} |
| 33 | +unsigned char stdc_leading_ones_uc(unsigned char) noexcept { return 0xBA; } |
| 34 | +unsigned short stdc_leading_ones_us(unsigned short) noexcept { return 0xBB; } |
| 35 | +unsigned stdc_leading_ones_ui(unsigned) noexcept { return 0xBC; } |
| 36 | +unsigned long stdc_leading_ones_ul(unsigned long) noexcept { return 0xBD; } |
| 37 | +unsigned long long stdc_leading_ones_ull(unsigned long long) noexcept { |
| 38 | + return 0xBF; |
| 39 | +} |
| 40 | +} |
| 41 | + |
| 42 | +#include "include/llvm-libc-macros/stdbit-macros.h" |
31 | 43 |
|
32 | 44 | TEST(LlvmLibcStdbitTest, TypeGenericMacroLeadingZeros) {
|
33 | 45 | EXPECT_EQ(stdc_leading_zeros(static_cast<unsigned char>(0U)),
|
|
0 commit comments