/src/llvm-project-18.1.8.src/libcxxabi/src/cxa_guard.cpp
Line | Count | Source (jump to first uncovered line) |
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 | 18 | _LIBCXXABI_FUNC_VIS int __cxa_guard_acquire(guard_type* raw_guard_object) { |
38 | 18 | SelectedImplementation imp(raw_guard_object); |
39 | 18 | return static_cast<int>(imp.cxa_guard_acquire()); |
40 | 18 | } |
41 | | |
42 | 18 | _LIBCXXABI_FUNC_VIS void __cxa_guard_release(guard_type *raw_guard_object) { |
43 | 18 | SelectedImplementation imp(raw_guard_object); |
44 | 18 | imp.cxa_guard_release(); |
45 | 18 | } |
46 | | |
47 | 0 | _LIBCXXABI_FUNC_VIS void __cxa_guard_abort(guard_type *raw_guard_object) { |
48 | 0 | SelectedImplementation imp(raw_guard_object); |
49 | 0 | imp.cxa_guard_abort(); |
50 | 0 | } |
51 | | } // extern "C" |
52 | | |
53 | | } // __cxxabiv1 |