1.7.9 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);
	return c.inc();

To support such thread-safe initializations, a platform vendor must provide the implementations for the following subset of constructs from the 1.7.3 Mutexes [ALPHA] and 1.7.4 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.

Non-ConfidentialPDF file icon PDF versionARM 100073_0608_00_en
Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved.