[libc-commits] [libc] [libc] implement quick exit function (PR #93621)

via libc-commits libc-commits at lists.llvm.org
Wed May 29 13:41:55 PDT 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 66db7c609cebb8aa7db17f83fbc9f79be0cd5af1 1bfb3baf6712864e6bbe604082c3a1b389441013 -- libc/src/stdlib/quick_exit.cpp libc/src/stdlib/quick_exit.h libc/test/src/stdlib/quick_exit_test.cpp libc/src/__support/libc_assert.h libc/src/stdlib/_Exit.cpp libc/src/stdlib/exit.cpp libc/src/unistd/_exit.cpp libc/test/IntegrationTest/test.h libc/utils/HdrGen/Main.cpp libc/src/__support/OSUtil/baremetal/exit.cpp libc/src/__support/OSUtil/exit.h libc/src/__support/OSUtil/gpu/exit.cpp libc/src/__support/OSUtil/linux/exit.cpp
``````````

</details>

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

``````````diff
diff --git a/libc/src/__support/OSUtil/baremetal/exit.cpp b/libc/src/__support/OSUtil/baremetal/exit.cpp
index c77e21ae66..608ed9ff61 100644
--- a/libc/src/__support/OSUtil/baremetal/exit.cpp
+++ b/libc/src/__support/OSUtil/baremetal/exit.cpp
@@ -16,7 +16,6 @@ namespace internal {
 
 [[noreturn]] void exit(int status) { __llvm_libc_quick_exit(status); }
 
-
-}
+} // namespace internal
 
 } // namespace LIBC_NAMESPACE
diff --git a/libc/src/__support/OSUtil/exit.h b/libc/src/__support/OSUtil/exit.h
index 5bd967ecf8..694d3c92ca 100644
--- a/libc/src/__support/OSUtil/exit.h
+++ b/libc/src/__support/OSUtil/exit.h
@@ -16,6 +16,6 @@ namespace internal {
 
 }
 
-}
+} // namespace LIBC_NAMESPACE
 
 #endif // LLVM_LIBC_SRC___SUPPORT_OSUTIL_QUICK_EXIT_H
diff --git a/libc/src/__support/OSUtil/gpu/exit.cpp b/libc/src/__support/OSUtil/gpu/exit.cpp
index e9744a6965..c99bb77c16 100644
--- a/libc/src/__support/OSUtil/gpu/exit.cpp
+++ b/libc/src/__support/OSUtil/gpu/exit.cpp
@@ -26,6 +26,5 @@ namespace internal {
   gpu::end_program();
 }
 
-
-}
+} // namespace internal
 } // namespace LIBC_NAMESPACE
diff --git a/libc/src/__support/OSUtil/linux/exit.cpp b/libc/src/__support/OSUtil/linux/exit.cpp
index 8dccfc22f3..543c86ca88 100644
--- a/libc/src/__support/OSUtil/linux/exit.cpp
+++ b/libc/src/__support/OSUtil/linux/exit.cpp
@@ -13,7 +13,6 @@
 namespace LIBC_NAMESPACE {
 namespace internal {
 
-
 // mark as no_stack_protector for x86 since TLS can be torn down before calling
 // quick_exit so that the stack protector canary cannot be loaded.
 #ifdef LIBC_TARGET_ARCH_IS_X86
@@ -27,7 +26,6 @@ exit(int status) {
   }
 }
 
-
-}
+} // namespace internal
 
 } // namespace LIBC_NAMESPACE
diff --git a/libc/src/__support/libc_assert.h b/libc/src/__support/libc_assert.h
index ca04e70249..071ac139e7 100644
--- a/libc/src/__support/libc_assert.h
+++ b/libc/src/__support/libc_assert.h
@@ -20,8 +20,8 @@
 
 #else // Not LIBC_COPT_USE_C_ASSERT
 
-#include "src/__support/OSUtil/io.h"
 #include "src/__support/OSUtil/exit.h"
+#include "src/__support/OSUtil/io.h"
 #include "src/__support/integer_to_string.h"
 #include "src/__support/macros/attributes.h" // For LIBC_INLINE
 
@@ -76,7 +76,7 @@ LIBC_INLINE void report_assertion_failure(const char *assertion,
                                                "' in function: '");            \
       LIBC_NAMESPACE::write_to_stderr(__PRETTY_FUNCTION__);                    \
       LIBC_NAMESPACE::write_to_stderr("'\n");                                  \
-      LIBC_NAMESPACE::internal::exit(0xFF);                                        \
+      LIBC_NAMESPACE::internal::exit(0xFF);                                    \
     }                                                                          \
   } while (false)
 #endif // NDEBUG
diff --git a/libc/src/stdlib/quick_exit.cpp b/libc/src/stdlib/quick_exit.cpp
index 5b14683a0d..ae31398951 100644
--- a/libc/src/stdlib/quick_exit.cpp
+++ b/libc/src/stdlib/quick_exit.cpp
@@ -1,4 +1,5 @@
-//===-- Implementation of quick_exit --------------------------------------------===//
+//===-- Implementation of quick_exit
+//--------------------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -10,7 +11,7 @@
 #include "src/__support/OSUtil/exit.h"
 #include "src/__support/common.h"
 
-//extern "C" void __cxa_finalize(void *);
+// extern "C" void __cxa_finalize(void *);
 
 namespace LIBC_NAMESPACE {
 
@@ -19,7 +20,5 @@ namespace LIBC_NAMESPACE {
   exit(status);
 }
 
-
-}
- // namespace LIBC_NAMESPACE
-
+} // namespace LIBC_NAMESPACE
+  // namespace LIBC_NAMESPACE
diff --git a/libc/test/IntegrationTest/test.h b/libc/test/IntegrationTest/test.h
index 14e6f22f0e..5be66d9edf 100644
--- a/libc/test/IntegrationTest/test.h
+++ b/libc/test/IntegrationTest/test.h
@@ -9,8 +9,8 @@
 #ifndef LLVM_LIBC_UTILS_INTEGRATION_TEST_TEST_H
 #define LLVM_LIBC_UTILS_INTEGRATION_TEST_TEST_H
 
-#include "src/__support/OSUtil/io.h"
 #include "src/__support/OSUtil/exit.h"
+#include "src/__support/OSUtil/io.h"
 
 #define __AS_STRING(val) #val
 #define __CHECK_TRUE(file, line, val, should_exit)                             \
@@ -18,7 +18,7 @@
     LIBC_NAMESPACE::write_to_stderr(file ":" __AS_STRING(                      \
         line) ": Expected '" #val "' to be true, but is false\n");             \
     if (should_exit)                                                           \
-      LIBC_NAMESPACE::internal::exit(127);                                         \
+      LIBC_NAMESPACE::internal::exit(127);                                     \
   }
 
 #define __CHECK_FALSE(file, line, val, should_exit)                            \
@@ -26,7 +26,7 @@
     LIBC_NAMESPACE::write_to_stderr(file ":" __AS_STRING(                      \
         line) ": Expected '" #val "' to be false, but is true\n");             \
     if (should_exit)                                                           \
-      LIBC_NAMESPACE::internal::exit(127);                                         \
+      LIBC_NAMESPACE::internal::exit(127);                                     \
   }
 
 #define __CHECK_EQ(file, line, val1, val2, should_exit)                        \
@@ -34,7 +34,7 @@
     LIBC_NAMESPACE::write_to_stderr(file ":" __AS_STRING(                      \
         line) ": Expected '" #val1 "' to be equal to '" #val2 "'\n");          \
     if (should_exit)                                                           \
-      LIBC_NAMESPACE::internal::exit(127);                                         \
+      LIBC_NAMESPACE::internal::exit(127);                                     \
   }
 
 #define __CHECK_NE(file, line, val1, val2, should_exit)                        \
@@ -42,7 +42,7 @@
     LIBC_NAMESPACE::write_to_stderr(file ":" __AS_STRING(                      \
         line) ": Expected '" #val1 "' to not be equal to '" #val2 "'\n");      \
     if (should_exit)                                                           \
-      LIBC_NAMESPACE::internal::exit(127);                                         \
+      LIBC_NAMESPACE::internal::exit(127);                                     \
   }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/libc/utils/HdrGen/Main.cpp b/libc/utils/HdrGen/Main.cpp
index 92269dd70a..d3418f206b 100644
--- a/libc/utils/HdrGen/Main.cpp
+++ b/libc/utils/HdrGen/Main.cpp
@@ -65,4 +65,3 @@ int main(int argc, char *argv[]) {
   llvm::cl::ParseCommandLineOptions(argc, argv);
   return TableGenMain(argv[0], &llvm_libc::HeaderGeneratorMain);
 }
-

``````````

</details>


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


More information about the libc-commits mailing list