[libc-commits] [libc] [libc][stdbit][c23] adds implementation of `stdc_bit_ceil` functions (PR #84657)

via libc-commits libc-commits at lists.llvm.org
Sat Mar 9 15:28:38 PST 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 0baef3b18cdbbdcf9f07c10607407ad0fb541449 6d82de97ec6af956cd54f0721fa13279421c244d -- libc/src/stdbit/stdc_bit_ceil_uc.cpp libc/src/stdbit/stdc_bit_ceil_uc.h libc/src/stdbit/stdc_bit_ceil_ui.cpp libc/src/stdbit/stdc_bit_ceil_ui.h libc/src/stdbit/stdc_bit_ceil_ul.cpp libc/src/stdbit/stdc_bit_ceil_ul.h libc/src/stdbit/stdc_bit_ceil_ull.cpp libc/src/stdbit/stdc_bit_ceil_ull.h libc/src/stdbit/stdc_bit_ceil_us.cpp libc/src/stdbit/stdc_bit_ceil_us.h libc/test/src/stdbit/stdc_bit_ceil_uc_test.cpp libc/test/src/stdbit/stdc_bit_ceil_ui_test.cpp libc/test/src/stdbit/stdc_bit_ceil_ul_test.cpp libc/test/src/stdbit/stdc_bit_ceil_ull_test.cpp libc/test/src/stdbit/stdc_bit_ceil_us_test.cpp libc/include/llvm-libc-macros/stdbit-macros.h libc/src/__support/CPP/bit.h libc/test/include/stdbit_test.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/libc/include/llvm-libc-macros/stdbit-macros.h b/libc/include/llvm-libc-macros/stdbit-macros.h
index 50ce272860..f349b55156 100644
--- a/libc/include/llvm-libc-macros/stdbit-macros.h
+++ b/libc/include/llvm-libc-macros/stdbit-macros.h
@@ -200,9 +200,7 @@ inline unsigned char stdc_bit_ceil(unsigned char x) {
 inline unsigned short stdc_bit_ceil(unsigned short x) {
   return stdc_bit_ceil_us(x);
 }
-inline unsigned stdc_bit_ceil(unsigned x) {
-  return stdc_bit_ceil_ui(x);
-}
+inline unsigned stdc_bit_ceil(unsigned x) { return stdc_bit_ceil_ui(x); }
 inline unsigned long stdc_bit_ceil(unsigned long x) {
   return stdc_bit_ceil_ul(x);
 }
@@ -302,12 +300,12 @@ inline unsigned long long stdc_bit_ceil(unsigned long long x) {
       unsigned long: stdc_bit_floor_ul,                                        \
       unsigned long long: stdc_bit_floor_ull)(x)
 #define stdc_bit_ceil(x)
-  _Generic((x),                                                                \
-      unsigned char: stdc_bit_ceil_ui,                                         \
-      unsigned short: stdc_bit_ceil_us,                                        \
-      unsigned: stdc_bit_ceil_ui,                                              \
-      unsigned long: stdc_bit_ceil_ul,                                         \
-      unsigned long long: stdc_bit_ceil_ull)(x)
+_Generic((x),
+    unsigned char: stdc_bit_ceil_ui,
+    unsigned short: stdc_bit_ceil_us,
+    unsigned: stdc_bit_ceil_ui,
+    unsigned long: stdc_bit_ceil_ul,
+    unsigned long long: stdc_bit_ceil_ull)(x)
 #endif // __cplusplus
 
 #endif // __LLVM_LIBC_MACROS_STDBIT_MACROS_H
diff --git a/libc/src/stdbit/stdc_bit_ceil_ull.cpp b/libc/src/stdbit/stdc_bit_ceil_ull.cpp
index 8d97ba05c7..0989f36ab7 100644
--- a/libc/src/stdbit/stdc_bit_ceil_ull.cpp
+++ b/libc/src/stdbit/stdc_bit_ceil_ull.cpp
@@ -14,7 +14,7 @@
 namespace LIBC_NAMESPACE {
 
 LLVM_LIBC_FUNCTION(unsigned long long, stdc_bit_ceil_ull,
-		   (unsigned long long value)) {
+                   (unsigned long long value)) {
   return cpp::bit_ceil(value);
 }
 
diff --git a/libc/test/src/stdbit/stdc_bit_ceil_ui_test.cpp b/libc/test/src/stdbit/stdc_bit_ceil_ui_test.cpp
index 82015a342a..b71d3c07bf 100644
--- a/libc/test/src/stdbit/stdc_bit_ceil_ui_test.cpp
+++ b/libc/test/src/stdbit/stdc_bit_ceil_ui_test.cpp
@@ -16,18 +16,15 @@ TEST(LlvmLibcStdcBitceilUiTest, Zero) {
 
 TEST(LlvmLibcStdcBitceilUiTest, Ones) {
   for (unsigned i = 0U; i != UINT_WIDTH; ++i)
-    EXPECT_EQ(LIBC_NAMESPACE::stdc_bit_ceil_ui(1U << i),
-              1U << i);
+    EXPECT_EQ(LIBC_NAMESPACE::stdc_bit_ceil_ui(1U << i), 1U << i);
 }
 
 TEST(LlvmLibcStdcBitceilUiTest, OneLessThanPowsTwo) {
   for (unsigned i = 2U; i != UINT_WIDTH; ++i)
-    EXPECT_EQ(LIBC_NAMESPACE::stdc_bit_ceil_ui((1U << i) - 1),
-              1U << i);
+    EXPECT_EQ(LIBC_NAMESPACE::stdc_bit_ceil_ui((1U << i) - 1), 1U << i);
 }
 
 TEST(LlvmLibcStdcBitceilUiTest, OneMoreThanPowsTwo) {
   for (unsigned i = 2U; i != UINT_WIDTH; ++i)
-    EXPECT_EQ(LIBC_NAMESPACE::stdc_bit_ceil_ui((1U << i) + 1),
-              1U << (i + 1));
+    EXPECT_EQ(LIBC_NAMESPACE::stdc_bit_ceil_ui((1U << i) + 1), 1U << (i + 1));
 }
diff --git a/libc/test/src/stdbit/stdc_bit_ceil_ul_test.cpp b/libc/test/src/stdbit/stdc_bit_ceil_ul_test.cpp
index aa70596946..2acf138334 100644
--- a/libc/test/src/stdbit/stdc_bit_ceil_ul_test.cpp
+++ b/libc/test/src/stdbit/stdc_bit_ceil_ul_test.cpp
@@ -16,18 +16,15 @@ TEST(LlvmLibcStdcBitceilUlTest, Zero) {
 
 TEST(LlvmLibcStdcBitceilUlTest, Ones) {
   for (unsigned i = 0U; i != ULONG_WIDTH; ++i)
-    EXPECT_EQ(LIBC_NAMESPACE::stdc_bit_ceil_ul(1UL << i),
-              1UL << i);
+    EXPECT_EQ(LIBC_NAMESPACE::stdc_bit_ceil_ul(1UL << i), 1UL << i);
 }
 
 TEST(LlvmLibcStdcBitceilUlTest, OneLessThanPowsTwo) {
   for (unsigned i = 2U; i != ULONG_WIDTH; ++i)
-    EXPECT_EQ(LIBC_NAMESPACE::stdc_bit_ceil_ul((1UL << i) - 1),
-              1UL << i);
+    EXPECT_EQ(LIBC_NAMESPACE::stdc_bit_ceil_ul((1UL << i) - 1), 1UL << i);
 }
 
 TEST(LlvmLibcStdcBitceilUlTest, OneMoreThanPowsTwo) {
   for (unsigned i = 2U; i != ULONG_WIDTH; ++i)
-    EXPECT_EQ(LIBC_NAMESPACE::stdc_bit_ceil_ul((1UL << i) + 1),
-              1UL << (i + 1));
+    EXPECT_EQ(LIBC_NAMESPACE::stdc_bit_ceil_ul((1UL << i) + 1), 1UL << (i + 1));
 }
diff --git a/libc/test/src/stdbit/stdc_bit_ceil_ull_test.cpp b/libc/test/src/stdbit/stdc_bit_ceil_ull_test.cpp
index b8141dc3dc..4d91a78092 100644
--- a/libc/test/src/stdbit/stdc_bit_ceil_ull_test.cpp
+++ b/libc/test/src/stdbit/stdc_bit_ceil_ull_test.cpp
@@ -16,14 +16,12 @@ TEST(LlvmLibcStdcBitceilUllTest, Zero) {
 
 TEST(LlvmLibcStdcBitceilUllTest, Ones) {
   for (unsigned i = 0U; i != ULLONG_WIDTH; ++i)
-    EXPECT_EQ(LIBC_NAMESPACE::stdc_bit_ceil_ull(1ULL << i),
-              1ULL << i);
+    EXPECT_EQ(LIBC_NAMESPACE::stdc_bit_ceil_ull(1ULL << i), 1ULL << i);
 }
 
 TEST(LlvmLibcStdcBitceilUllTest, OneLessThanPowsTwo) {
   for (unsigned i = 2U; i != ULLONG_WIDTH; ++i)
-    EXPECT_EQ(LIBC_NAMESPACE::stdc_bit_ceil_ull((1ULL << i) - 1),
-              1ULL << i);
+    EXPECT_EQ(LIBC_NAMESPACE::stdc_bit_ceil_ull((1ULL << i) - 1), 1ULL << i);
 }
 
 TEST(LlvmLibcStdcBitceilUllTest, OneMoreThanPowsTwo) {

``````````

</details>


https://github.com/llvm/llvm-project/pull/84657


More information about the libc-commits mailing list