You copied the Doc URL to your clipboard.

Guard variables [ALPHA]

To ensure thread-safety of certain initializations, the compiler calls out to helper functions in the libc++abi library.


This topic describes an [ALPHA] feature. See Support level definitions.

For example, in the following code snippet, the compiler must ensure that the Counter c is constructed exactly once, even when multiple threads call getCount().

class Counter {
	Counter(int x) : _m(x) {}
	int inc() {return _m++;}
	int _m;

int getCount() {
	static Counter c(42);

To support such thread-safe initializations, a platform vendor must provide the implementations for the following subset of constructs from the Mutexes [ALPHA] and Condition variables [ALPHA] sections of the API:


struct __ARM_TPL_mutex_t{
	_Atomic uintptr_t data;
struct __ARM_TPL_condvar_t{
	_Atomic uintptr_t data;


int __ARM_TPL_mutex_lock(__ARM_TPL_mutex_t* __m);
int __ARM_TPL_mutex_unlock(__ARM_TPL_mutex_t* __m);
int __ARM_TPL_condvar_broadcast(__ARM_TPL_condvar_t* __cv);
int __ARM_TPL_condvar_wait(__ARM_TPL_condvar_t* __cv, __ARM_TPL_mutex_t* __m);

The ABI functions __cxa_guard_acquire(), __cxa_guard_release(), and __cxa_guard_abort() need not be re-implemented under this scheme.