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

Add internal::exit for MacOS/Darwin
This commit is contained in:
Shreeyash Pandey
2025-11-28 19:40:01 +05:30
committed by GitHub
parent 4769122b22
commit eb323d8656
4 changed files with 31 additions and 3 deletions

View File

@@ -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()

View File

@@ -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
)

View File

@@ -1,5 +1,5 @@
add_header_library(
darwin_util
darwin_aarch64_util
HDRS
syscall.h
DEPENDS

View File

@@ -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