brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.7 KiB · 4141e03 Raw
78 lines · plain
1// -*- C++ -*-2//===----------------------------------------------------------------------===//3//4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.5// See https://llvm.org/LICENSE.txt for license information.6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception7//8//===----------------------------------------------------------------------===//9 10#include <exception>11#include <stdio.h>12#include <stdlib.h>13 14_LIBCPP_CRT_FUNC void __cdecl __ExceptionPtrCreate(void*);15_LIBCPP_CRT_FUNC void __cdecl __ExceptionPtrDestroy(void*);16_LIBCPP_CRT_FUNC void __cdecl __ExceptionPtrCopy(void*, const void*);17_LIBCPP_CRT_FUNC void __cdecl __ExceptionPtrAssign(void*, const void*);18_LIBCPP_CRT_FUNC bool __cdecl __ExceptionPtrCompare(const void*, const void*);19_LIBCPP_CRT_FUNC bool __cdecl __ExceptionPtrToBool(const void*);20_LIBCPP_CRT_FUNC void __cdecl __ExceptionPtrSwap(void*, void*);21_LIBCPP_CRT_FUNC void __cdecl __ExceptionPtrCurrentException(void*);22[[noreturn]] _LIBCPP_CRT_FUNC void __cdecl __ExceptionPtrRethrow(const void*);23_LIBCPP_CRT_FUNC void __cdecl __ExceptionPtrCopyException(void*, const void*, const void*);24 25namespace std {26 27exception_ptr::exception_ptr() noexcept { __ExceptionPtrCreate(this); }28exception_ptr::exception_ptr(nullptr_t) noexcept { __ExceptionPtrCreate(this); }29 30exception_ptr::exception_ptr(const exception_ptr& __other) noexcept { __ExceptionPtrCopy(this, &__other); }31exception_ptr& exception_ptr::operator=(const exception_ptr& __other) noexcept {32  __ExceptionPtrAssign(this, &__other);33  return *this;34}35 36exception_ptr& exception_ptr::operator=(nullptr_t) noexcept {37  exception_ptr dummy;38  __ExceptionPtrAssign(this, &dummy);39  return *this;40}41 42exception_ptr::~exception_ptr() noexcept { __ExceptionPtrDestroy(this); }43 44exception_ptr::operator bool() const noexcept { return __ExceptionPtrToBool(this); }45 46bool operator==(const exception_ptr& __x, const exception_ptr& __y) noexcept {47  return __ExceptionPtrCompare(&__x, &__y);48}49 50void swap(exception_ptr& lhs, exception_ptr& rhs) noexcept { __ExceptionPtrSwap(&rhs, &lhs); }51 52exception_ptr __copy_exception_ptr(void* __except, const void* __ptr) {53  exception_ptr __ret = nullptr;54  if (__ptr)55    __ExceptionPtrCopyException(&__ret, __except, __ptr);56  return __ret;57}58 59exception_ptr current_exception() noexcept {60  exception_ptr __ret;61  __ExceptionPtrCurrentException(&__ret);62  return __ret;63}64 65[[noreturn]] void rethrow_exception(exception_ptr p) { __ExceptionPtrRethrow(&p); }66 67nested_exception::nested_exception() noexcept : __ptr_(current_exception()) {}68 69nested_exception::~nested_exception() noexcept {}70 71[[noreturn]] void nested_exception::rethrow_nested() const {72  if (__ptr_ == nullptr)73    terminate();74  rethrow_exception(__ptr_);75}76 77} // namespace std78