[libc-commits] [libc] eb323d8 - [libc][darwin] add internal::exit (#166357)

via libc-commits libc-commits at lists.llvm.org
Fri Nov 28 06:10:06 PST 2025


Author: Shreeyash Pandey
Date: 2025-11-28T19:40:01+05:30
New Revision: eb323d86561db72d6d71ce2c403da70f16ff7f17

URL: https://github.com/llvm/llvm-project/commit/eb323d86561db72d6d71ce2c403da70f16ff7f17
DIFF: https://github.com/llvm/llvm-project/commit/eb323d86561db72d6d71ce2c403da70f16ff7f17.diff

LOG: [libc][darwin] add internal::exit (#166357)

Add internal::exit for MacOS/Darwin

Added: 
    libc/src/__support/OSUtil/darwin/exit.cpp

Modified: 
    libc/config/darwin/aarch64/entrypoints.txt
    libc/src/__support/OSUtil/darwin/CMakeLists.txt
    libc/src/__support/OSUtil/darwin/aarch64/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/libc/config/darwin/aarch64/entrypoints.txt b/libc/config/darwin/aarch64/entrypoints.txt
index e3c6c2b30c415..3909417f9730d 100644
--- a/libc/config/darwin/aarch64/entrypoints.txt
+++ b/libc/config/darwin/aarch64/entrypoints.txt
@@ -111,6 +111,7 @@ if(LLVM_LIBC_FULL_BUILD)
     libc.src.setjmp.setjmp
     libc.src.setjmp.siglongjmp
     libc.src.setjmp.sigsetjmp
+    libc.src.stdlib._Exit
   )
 endif()
 

diff  --git a/libc/src/__support/OSUtil/darwin/CMakeLists.txt b/libc/src/__support/OSUtil/darwin/CMakeLists.txt
index 4241bb37684f7..9e69bf7d0cbab 100644
--- a/libc/src/__support/OSUtil/darwin/CMakeLists.txt
+++ b/libc/src/__support/OSUtil/darwin/CMakeLists.txt
@@ -4,13 +4,16 @@ endif()
 
 add_subdirectory(${LIBC_TARGET_ARCHITECTURE})
 
-add_header_library(
+add_object_library(
   darwin_util
+  SRCS
+    exit.cpp
   HDRS
     io.h
     syscall.h
   DEPENDS
-    .${LIBC_TARGET_ARCHITECTURE}.darwin_util
+  .${LIBC_TARGET_ARCHITECTURE}.darwin_${LIBC_TARGET_ARCHITECTURE}_util
     libc.src.__support.common
     libc.src.__support.CPP.string_view
+    libc.include.sys_syscall
 )

diff  --git a/libc/src/__support/OSUtil/darwin/aarch64/CMakeLists.txt b/libc/src/__support/OSUtil/darwin/aarch64/CMakeLists.txt
index 5ab95b01758c8..b36fe22017f34 100644
--- a/libc/src/__support/OSUtil/darwin/aarch64/CMakeLists.txt
+++ b/libc/src/__support/OSUtil/darwin/aarch64/CMakeLists.txt
@@ -1,5 +1,5 @@
 add_header_library(
-  darwin_util
+  darwin_aarch64_util
   HDRS
     syscall.h
   DEPENDS

diff  --git a/libc/src/__support/OSUtil/darwin/exit.cpp b/libc/src/__support/OSUtil/darwin/exit.cpp
new file mode 100644
index 0000000000000..7439db2ef38b0
--- /dev/null
+++ b/libc/src/__support/OSUtil/darwin/exit.cpp
@@ -0,0 +1,24 @@
+//===------------ MacOS implementation of an exit function ------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/__support/OSUtil/darwin/syscall.h" // syscall_impl
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+#include "sys/syscall.h" // For syscall numbers.
+
+namespace LIBC_NAMESPACE_DECL {
+namespace internal {
+
+[[noreturn]] void exit(int status) {
+  for (;;) {
+    LIBC_NAMESPACE::syscall_impl<long>(SYS_exit, status);
+  }
+}
+
+} // namespace internal
+} // namespace LIBC_NAMESPACE_DECL


        


More information about the libc-commits mailing list