| 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-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #include "__cxxabi_config.h" |
| 10 | #include "cxxabi.h" |
| 11 | |
| 12 | // Tell the implementation that we're building the actual implementation |
| 13 | // (and not testing it) |
| 14 | #define BUILDING_CXA_GUARD |
| 15 | #include "cxa_guard_impl.h" |
| 16 | |
| 17 | /* |
| 18 | This implementation must be careful to not call code external to this file |
| 19 | 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 used |
| 22 | std::__libcpp_mutex_lock and the abort_message utility without problem. This |
| 23 | implementation also uses std::__libcpp_condvar_wait which has tested |
| 24 | to not be a problem. |
| 25 | */ |
| 26 | |
| 27 | namespace __cxxabiv1 { |
| 28 | |
| 29 | #if defined(_LIBCXXABI_GUARD_ABI_ARM) |
| 30 | using guard_type = uint32_t; |
| 31 | #else |
| 32 | using guard_type = uint64_t; |
| 33 | #endif |
| 34 | |
| 35 | extern "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 | } // __cxxabiv1 |
| 54 | |