xref: /openbsd-src/gnu/llvm/libcxxabi/src/cxa_noexception.cpp (revision 8f1d572453a8bab44a2fe956e25efc4124e87e82)
1*8f1d5724Srobert //===----------------------------------------------------------------------===//
279c2e3e6Spatrick //
379c2e3e6Spatrick // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
479c2e3e6Spatrick // See https://llvm.org/LICENSE.txt for license information.
579c2e3e6Spatrick // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
679c2e3e6Spatrick //
779c2e3e6Spatrick //
879c2e3e6Spatrick //  This file implements the "Exception Handling APIs"
979c2e3e6Spatrick //  https://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html
1079c2e3e6Spatrick //
1179c2e3e6Spatrick //===----------------------------------------------------------------------===//
1279c2e3e6Spatrick 
1379c2e3e6Spatrick // Support functions for the no-exceptions libc++ library
1479c2e3e6Spatrick 
1579c2e3e6Spatrick #include "cxxabi.h"
1679c2e3e6Spatrick 
1779c2e3e6Spatrick #include <exception>        // for std::terminate
1879c2e3e6Spatrick #include "cxa_exception.h"
1979c2e3e6Spatrick #include "cxa_handlers.h"
2079c2e3e6Spatrick 
2179c2e3e6Spatrick namespace __cxxabiv1 {
2279c2e3e6Spatrick 
2379c2e3e6Spatrick extern "C" {
2479c2e3e6Spatrick 
2579c2e3e6Spatrick void
__cxa_increment_exception_refcount(void * thrown_object)2679c2e3e6Spatrick __cxa_increment_exception_refcount(void *thrown_object) throw() {
2779c2e3e6Spatrick     if (thrown_object != nullptr)
2879c2e3e6Spatrick         std::terminate();
2979c2e3e6Spatrick }
3079c2e3e6Spatrick 
3179c2e3e6Spatrick void
__cxa_decrement_exception_refcount(void * thrown_object)3279c2e3e6Spatrick __cxa_decrement_exception_refcount(void *thrown_object) throw() {
3379c2e3e6Spatrick     if (thrown_object != nullptr)
3479c2e3e6Spatrick       std::terminate();
3579c2e3e6Spatrick }
3679c2e3e6Spatrick 
3779c2e3e6Spatrick 
__cxa_current_primary_exception()3879c2e3e6Spatrick void *__cxa_current_primary_exception() throw() { return nullptr; }
3979c2e3e6Spatrick 
4079c2e3e6Spatrick void
__cxa_rethrow_primary_exception(void * thrown_object)4179c2e3e6Spatrick __cxa_rethrow_primary_exception(void* thrown_object) {
4279c2e3e6Spatrick     if (thrown_object != nullptr)
4379c2e3e6Spatrick       std::terminate();
4479c2e3e6Spatrick }
4579c2e3e6Spatrick 
4679c2e3e6Spatrick bool
__cxa_uncaught_exception()4779c2e3e6Spatrick __cxa_uncaught_exception() throw() { return false; }
4879c2e3e6Spatrick 
4979c2e3e6Spatrick unsigned int
__cxa_uncaught_exceptions()5079c2e3e6Spatrick __cxa_uncaught_exceptions() throw() { return 0; }
5179c2e3e6Spatrick 
5279c2e3e6Spatrick }  // extern "C"
5379c2e3e6Spatrick 
5479c2e3e6Spatrick // provide dummy implementations for the 'no exceptions' case.
__getExceptionClass(const _Unwind_Exception *)5579c2e3e6Spatrick uint64_t __getExceptionClass  (const _Unwind_Exception*)           { return 0; }
__setExceptionClass(_Unwind_Exception *,uint64_t)5679c2e3e6Spatrick void     __setExceptionClass  (      _Unwind_Exception*, uint64_t) {}
__isOurExceptionClass(const _Unwind_Exception *)5779c2e3e6Spatrick bool     __isOurExceptionClass(const _Unwind_Exception*)           { return false; }
5879c2e3e6Spatrick 
5979c2e3e6Spatrick }  // abi
60