Skip to content

Commit f3cf53a

Browse files
committed
[libc][darwin] add internal::exit
Signed-off-by: Shreeyash Pandey <[email protected]>
1 parent 7fe0c00 commit f3cf53a

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
lines changed

libc/config/darwin/aarch64/entrypoints.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ if(LLVM_LIBC_FULL_BUILD)
111111
libc.src.setjmp.setjmp
112112
libc.src.setjmp.siglongjmp
113113
libc.src.setjmp.sigsetjmp
114+
libc.src.stdlib._Exit
114115
)
115116
endif()
116117

libc/src/__support/OSUtil/darwin/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@ endif()
44

55
add_subdirectory(${LIBC_TARGET_ARCHITECTURE})
66

7-
add_header_library(
7+
add_object_library(
88
darwin_util
9+
SRCS
10+
exit.cpp
911
HDRS
1012
io.h
1113
syscall.h
1214
DEPENDS
13-
.${LIBC_TARGET_ARCHITECTURE}.darwin_util
15+
.${LIBC_TARGET_ARCHITECTURE}.darwin_${LIBC_TARGET_ARCHITECTURE}_util
1416
libc.src.__support.common
1517
libc.src.__support.CPP.string_view
18+
libc.include.sys_syscall
1619
)

libc/src/__support/OSUtil/darwin/aarch64/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
add_header_library(
2-
darwin_util
2+
darwin_aarch64_util
33
HDRS
44
syscall.h
55
DEPENDS
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//===------------ MacOS implementation of an exit function ------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "src/__support/OSUtil/darwin/syscall.h" // syscall_impl
10+
#include "src/__support/common.h"
11+
#include "src/__support/macros/config.h"
12+
#include "sys/syscall.h" // For syscall numbers.
13+
14+
namespace LIBC_NAMESPACE_DECL {
15+
namespace internal {
16+
17+
__attribute__((noreturn)) void exit(int status) {
18+
for (;;) {
19+
LIBC_NAMESPACE::syscall_impl<long>(SYS_exit, status);
20+
}
21+
}
22+
23+
} // namespace internal
24+
} // namespace LIBC_NAMESPACE_DECL

0 commit comments

Comments
 (0)