1 //===-- Implementation of abort -------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "src/__support/common.h"
10 #include "src/signal/raise.h"
11 #include "src/stdlib/_Exit.h"
13 #include "src/stdlib/abort.h"
15 namespace LIBC_NAMESPACE
{
17 LLVM_LIBC_FUNCTION(void, 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 LIBC_NAMESPACE::raise(SIGABRT
);
26 LIBC_NAMESPACE::raise(SIGKILL
);
27 LIBC_NAMESPACE::_Exit(127);
30 } // namespace LIBC_NAMESPACE