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