1*c05d8e5dSAndroid Build Coastguard Worker //===---------------------------- cxa_guard.cpp ---------------------------===// 2*c05d8e5dSAndroid Build Coastguard Worker // 3*c05d8e5dSAndroid Build Coastguard Worker // The LLVM Compiler Infrastructure 4*c05d8e5dSAndroid Build Coastguard Worker // 5*c05d8e5dSAndroid Build Coastguard Worker // This file is dual licensed under the MIT and the University of Illinois Open 6*c05d8e5dSAndroid Build Coastguard Worker // Source Licenses. See LICENSE.TXT for details. 7*c05d8e5dSAndroid Build Coastguard Worker // 8*c05d8e5dSAndroid Build Coastguard Worker //===----------------------------------------------------------------------===// 9*c05d8e5dSAndroid Build Coastguard Worker 10*c05d8e5dSAndroid Build Coastguard Worker #include "__cxxabi_config.h" 11*c05d8e5dSAndroid Build Coastguard Worker #include "cxxabi.h" 12*c05d8e5dSAndroid Build Coastguard Worker 13*c05d8e5dSAndroid Build Coastguard Worker // Tell the implementation that we're building the actual implementation 14*c05d8e5dSAndroid Build Coastguard Worker // (and not testing it) 15*c05d8e5dSAndroid Build Coastguard Worker #define BUILDING_CXA_GUARD 16*c05d8e5dSAndroid Build Coastguard Worker #include "cxa_guard_impl.h" 17*c05d8e5dSAndroid Build Coastguard Worker 18*c05d8e5dSAndroid Build Coastguard Worker /* 19*c05d8e5dSAndroid Build Coastguard Worker This implementation must be careful to not call code external to this file 20*c05d8e5dSAndroid Build Coastguard Worker which will turn around and try to call __cxa_guard_acquire reentrantly. 21*c05d8e5dSAndroid Build Coastguard Worker For this reason, the headers of this file are as restricted as possible. 22*c05d8e5dSAndroid Build Coastguard Worker Previous implementations of this code for __APPLE__ have used 23*c05d8e5dSAndroid Build Coastguard Worker std::__libcpp_mutex_lock and the abort_message utility without problem. This 24*c05d8e5dSAndroid Build Coastguard Worker implementation also uses std::__libcpp_condvar_wait which has tested 25*c05d8e5dSAndroid Build Coastguard Worker to not be a problem. 26*c05d8e5dSAndroid Build Coastguard Worker */ 27*c05d8e5dSAndroid Build Coastguard Worker 28*c05d8e5dSAndroid Build Coastguard Worker namespace __cxxabiv1 { 29*c05d8e5dSAndroid Build Coastguard Worker 30*c05d8e5dSAndroid Build Coastguard Worker #if defined(_LIBCXXABI_GUARD_ABI_ARM) 31*c05d8e5dSAndroid Build Coastguard Worker using guard_type = uint32_t; 32*c05d8e5dSAndroid Build Coastguard Worker #else 33*c05d8e5dSAndroid Build Coastguard Worker using guard_type = uint64_t; 34*c05d8e5dSAndroid Build Coastguard Worker #endif 35*c05d8e5dSAndroid Build Coastguard Worker 36*c05d8e5dSAndroid Build Coastguard Worker extern "C" 37*c05d8e5dSAndroid Build Coastguard Worker { __cxa_guard_acquire(guard_type * raw_guard_object)38*c05d8e5dSAndroid Build Coastguard Worker_LIBCXXABI_FUNC_VIS int __cxa_guard_acquire(guard_type* raw_guard_object) { 39*c05d8e5dSAndroid Build Coastguard Worker SelectedImplementation imp(raw_guard_object); 40*c05d8e5dSAndroid Build Coastguard Worker return static_cast<int>(imp.cxa_guard_acquire()); 41*c05d8e5dSAndroid Build Coastguard Worker } 42*c05d8e5dSAndroid Build Coastguard Worker __cxa_guard_release(guard_type * raw_guard_object)43*c05d8e5dSAndroid Build Coastguard Worker_LIBCXXABI_FUNC_VIS void __cxa_guard_release(guard_type *raw_guard_object) { 44*c05d8e5dSAndroid Build Coastguard Worker SelectedImplementation imp(raw_guard_object); 45*c05d8e5dSAndroid Build Coastguard Worker imp.cxa_guard_release(); 46*c05d8e5dSAndroid Build Coastguard Worker } 47*c05d8e5dSAndroid Build Coastguard Worker __cxa_guard_abort(guard_type * raw_guard_object)48*c05d8e5dSAndroid Build Coastguard Worker_LIBCXXABI_FUNC_VIS void __cxa_guard_abort(guard_type *raw_guard_object) { 49*c05d8e5dSAndroid Build Coastguard Worker SelectedImplementation imp(raw_guard_object); 50*c05d8e5dSAndroid Build Coastguard Worker imp.cxa_guard_abort(); 51*c05d8e5dSAndroid Build Coastguard Worker } 52*c05d8e5dSAndroid Build Coastguard Worker } // extern "C" 53*c05d8e5dSAndroid Build Coastguard Worker 54*c05d8e5dSAndroid Build Coastguard Worker } // __cxxabiv1 55