54 lines · cpp
1//===----------------------------------------------------------------------===//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 "__cxxabi_config.h"10#include "cxxabi.h"11 12// Tell the implementation that we're building the actual implementation13// (and not testing it)14#define BUILDING_CXA_GUARD15#include "cxa_guard_impl.h"16 17/*18 This implementation must be careful to not call code external to this file19 which will turn around and try to call __cxa_guard_acquire reentrantly.20 For this reason, the headers of this file are as restricted as possible.21 Previous implementations of this code for __APPLE__ have used22 std::__libcpp_mutex_lock and the abort_message utility without problem. This23 implementation also uses std::__libcpp_condvar_wait which has tested24 to not be a problem.25*/26 27namespace __cxxabiv1 {28 29#if defined(_LIBCXXABI_GUARD_ABI_ARM)30using guard_type = uint32_t;31#else32using guard_type = uint64_t;33#endif34 35extern "C"36{37_LIBCXXABI_FUNC_VIS int __cxa_guard_acquire(guard_type* raw_guard_object) {38 SelectedImplementation imp(raw_guard_object);39 return static_cast<int>(imp.cxa_guard_acquire());40}41 42_LIBCXXABI_FUNC_VIS void __cxa_guard_release(guard_type *raw_guard_object) {43 SelectedImplementation imp(raw_guard_object);44 imp.cxa_guard_release();45}46 47_LIBCXXABI_FUNC_VIS void __cxa_guard_abort(guard_type *raw_guard_object) {48 SelectedImplementation imp(raw_guard_object);49 imp.cxa_guard_abort();50}51} // extern "C"52 53} // __cxxabiv154