1 /* 'libstdc++-v3/libsupc++/guard.cc' for offload devices, until we have
2 libstdc++-v3/libsupc++ proper.
4 Copyright (C) 2002-2024 Free Software Foundation, Inc.
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 Under Section 7 of GPL version 3, you are granted additional
19 permissions described in the GCC Runtime Library Exception, version
20 3.1, as published by the Free Software Foundation.
22 You should have received a copy of the GNU General Public License and
23 a copy of the GCC Runtime Library Exception along with this program;
24 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
25 <http://www.gnu.org/licenses/>. */
27 #if defined __AMDGCN__
28 #elif defined __nvptx__
33 #include "../../libstdc++-v3/config/cpu/generic/cxxabi_tweaks.h"
35 /* Copy'n'paste/edit from 'libstdc++-v3/libsupc++/cxxabi.h'. */
38 __cxa_guard_acquire(__guard
*);
41 __cxa_guard_release(__guard
*);
44 __cxa_guard_abort(__guard
*);
46 /* Copy'n'paste/edit from 'libstdc++-v3/libsupc++/guard.cc'. */
48 #undef _GLIBCXX_GUARD_TEST_AND_ACQUIRE
49 #undef _GLIBCXX_GUARD_SET_AND_RELEASE
50 #define _GLIBCXX_GUARD_SET_AND_RELEASE(G) _GLIBCXX_GUARD_SET (G)
53 init_in_progress_flag(__guard
* g
)
54 { return ((char *)g
)[1]; }
57 set_init_in_progress_flag(__guard
* g
, int v
)
58 { ((char *)g
)[1] = v
; }
61 throw_recursive_init_exception(void)
63 // Use __builtin_trap so we don't require abort().
67 // acquire() is a helper function used to acquire guard if thread support is
68 // not compiled in or is compiled in but not enabled at run-time.
72 // Quit if the object is already initialized.
73 if (_GLIBCXX_GUARD_TEST(g
))
76 if (init_in_progress_flag(g
))
77 throw_recursive_init_exception();
79 set_init_in_progress_flag(g
, 1);
83 int __cxa_guard_acquire (__guard
*g
)
88 void __cxa_guard_abort (__guard
*g
)
90 set_init_in_progress_flag(g
, 0);
93 void __cxa_guard_release (__guard
*g
)
95 set_init_in_progress_flag(g
, 0);
96 _GLIBCXX_GUARD_SET_AND_RELEASE (g
);