SPRAB89A September 2011 – March 2014
The guard variable is a one-byte field stored in the first byte of a 32-bit container. A non-zero value of the guard variable indicates that initialization is complete. This follows the IA-64 scheme, except the container is 32 bits instead of 64.
This is a reference implementation of the helper function _ _cxa_guard_acquire, which reads the guard variable and returns 1 if the initialization is not yet complete, 0 otherwise:
int __cxa_guard_acquire(unsigned int *guard)
{
char *first_byte = (char *)guard;
return (*first_byte == 0) ? 1 : 0;
}
This is a reference implementation of the helper function _ _cxa_guard_release, which modifies the guard object to signal that initialization is complete:
void __cxa_guard_release(unsigned int *guard)
{
char *first_byte = (char *)guard;
*first_byte = 1;
}