annotate libcxxabi/src/cxa_guard.cpp @ 207:2e18cbf3894f

LLVM12
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Jun 2021 06:07:14 +0900
parents 1d019706d866
children c4bab56944e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 //===---------------------------- cxa_guard.cpp ---------------------------===//
anatofuz
parents:
diff changeset
2 //
anatofuz
parents:
diff changeset
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
anatofuz
parents:
diff changeset
4 // See https://llvm.org/LICENSE.txt for license information.
anatofuz
parents:
diff changeset
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
anatofuz
parents:
diff changeset
6 //
anatofuz
parents:
diff changeset
7 //===----------------------------------------------------------------------===//
anatofuz
parents:
diff changeset
8
anatofuz
parents:
diff changeset
9 #include "__cxxabi_config.h"
anatofuz
parents:
diff changeset
10 #include "cxxabi.h"
anatofuz
parents:
diff changeset
11
anatofuz
parents:
diff changeset
12 // Tell the implementation that we're building the actual implementation
anatofuz
parents:
diff changeset
13 // (and not testing it)
anatofuz
parents:
diff changeset
14 #define BUILDING_CXA_GUARD
anatofuz
parents:
diff changeset
15 #include "cxa_guard_impl.h"
anatofuz
parents:
diff changeset
16
anatofuz
parents:
diff changeset
17 /*
anatofuz
parents:
diff changeset
18 This implementation must be careful to not call code external to this file
anatofuz
parents:
diff changeset
19 which will turn around and try to call __cxa_guard_acquire reentrantly.
anatofuz
parents:
diff changeset
20 For this reason, the headers of this file are as restricted as possible.
anatofuz
parents:
diff changeset
21 Previous implementations of this code for __APPLE__ have used
anatofuz
parents:
diff changeset
22 std::__libcpp_mutex_lock and the abort_message utility without problem. This
anatofuz
parents:
diff changeset
23 implementation also uses std::__libcpp_condvar_wait which has tested
anatofuz
parents:
diff changeset
24 to not be a problem.
anatofuz
parents:
diff changeset
25 */
anatofuz
parents:
diff changeset
26
anatofuz
parents:
diff changeset
27 namespace __cxxabiv1 {
anatofuz
parents:
diff changeset
28
anatofuz
parents:
diff changeset
29 #if defined(_LIBCXXABI_GUARD_ABI_ARM)
anatofuz
parents:
diff changeset
30 using guard_type = uint32_t;
anatofuz
parents:
diff changeset
31 #else
anatofuz
parents:
diff changeset
32 using guard_type = uint64_t;
anatofuz
parents:
diff changeset
33 #endif
anatofuz
parents:
diff changeset
34
anatofuz
parents:
diff changeset
35 extern "C"
anatofuz
parents:
diff changeset
36 {
anatofuz
parents:
diff changeset
37 _LIBCXXABI_FUNC_VIS int __cxa_guard_acquire(guard_type* raw_guard_object) {
anatofuz
parents:
diff changeset
38 SelectedImplementation imp(raw_guard_object);
anatofuz
parents:
diff changeset
39 return static_cast<int>(imp.cxa_guard_acquire());
anatofuz
parents:
diff changeset
40 }
anatofuz
parents:
diff changeset
41
anatofuz
parents:
diff changeset
42 _LIBCXXABI_FUNC_VIS void __cxa_guard_release(guard_type *raw_guard_object) {
anatofuz
parents:
diff changeset
43 SelectedImplementation imp(raw_guard_object);
anatofuz
parents:
diff changeset
44 imp.cxa_guard_release();
anatofuz
parents:
diff changeset
45 }
anatofuz
parents:
diff changeset
46
anatofuz
parents:
diff changeset
47 _LIBCXXABI_FUNC_VIS void __cxa_guard_abort(guard_type *raw_guard_object) {
anatofuz
parents:
diff changeset
48 SelectedImplementation imp(raw_guard_object);
anatofuz
parents:
diff changeset
49 imp.cxa_guard_abort();
anatofuz
parents:
diff changeset
50 }
anatofuz
parents:
diff changeset
51 } // extern "C"
anatofuz
parents:
diff changeset
52
anatofuz
parents:
diff changeset
53 } // __cxxabiv1