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