1 //===-- Implementation of abort -------------------------------------------===//
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/common.h"
10 #include "src/signal/raise.h"
11 #include "src/stdlib/_Exit.h"
12 
13 #include "src/stdlib/abort.h"
14 
15 namespace __llvm_libc {
16 
LLVM_LIBC_ENTRYPOINT(abort)17 void LLVM_LIBC_ENTRYPOINT(abort)() {
18   // TODO: When sigprocmask and sigaction land:
19   // Unblock SIGABRT, raise it, if it was ignored or the handler returned,
20   // change its action to SIG_DFL, raise it again.
21   // TODO: When C11 mutexes land:
22   // Acquire recursive mutex (in case the current signal handler for SIGABRT
23   // itself calls abort we don't want to deadlock on the same thread trying
24   // to acquire it's own mutex.)
25   __llvm_libc::raise(SIGABRT);
26   __llvm_libc::raise(SIGKILL);
27   __llvm_libc::_Exit(127);
28 }
29 
30 } // namespace __llvm_libc
31