Lines Matching +full:lock +full:- +full:state
2 * Copyright 2010-2012 PathScale, Inc. All rights reserved.
29 * guard.cc: Functions for thread-safe static initialisation.
37 * Statics that require initialisation are protected by a 64-bit value. Any
38 * platform that can do 32-bit atomic test and set operations can use this
39 * value as a low-overhead lock. Because statics (in most sane code) are
40 * accessed far more times than they are initialised, this lock implementation
57 // x86 and ARM are the most common little-endian CPUs, so let's have a
66 * The Itanium C++ ABI defines guard words that are 64-bit (32-bit on AArch32)
71 * On many 32-bit platforms, 64-bit atomics are unavailable (or slow) and so we
72 * treat the two halves of the 64-bit word as independent values and establish
74 * lock word is in the locked state. This means that we can do double-checked
76 * transition the lock word from the unlocked to locked state, and then
82 * The state of the guard variable when an attempt is made to lock it.
87 * The lock is not held but is not needed because initialisation is
93 * Initialisation is not done but the lock is held by the caller.
98 * Attempting to acquire the lock failed.
106 * used to indicate the locked state is `1<<LockedBit`, the bit used to
107 * indicate the initialised state is `1<<InitBit`.
113 * The value indicating that the lock bit is set (and no other bits).
132 * Release the lock and set the initialised state. In the single-word
145 * Try to acquire the lock. This has a tri-state return, indicating
146 * either that the lock was acquired, it wasn't acquired because it was
153 // Try to acquire the lock, assuming that we are in the state where in try_lock()
154 // the lock is not held and the variable is not initialised (so the in try_lock()
182 * Class encapsulating using two 32-bit atomic values to represent a 64-bit
189 * The value of `lock_word` when the lock is held.
208 * The word used for the lock.
214 * Try to acquire the lock. This has a tri-state return, indicating
215 * either that the lock was acquired, it wasn't acquired because it was
222 // Try to acquire the lock in try_lock()
227 // lock and initialised bits together. Instead, we have an in try_lock()
229 // with the lock held. in try_lock()
233 // the lock and notify the caller that initialisation is in try_lock()
244 * Set the initialised state and release the lock. In this
246 * set while the lock is held.
268 "Single-word 32-bit guard must be 32 bits");
270 "Single-word 64-bit guard must be 64 bits");
272 "Double-word guard must be 64 bits");
276 * The Arm PCS defines a variant of the Itanium ABI with 32-bit lock words.
282 * On little-endian 64-bit platforms the guard word is a single 64-bit
283 * atomic with the lock in the high bit and the initialised flag in the low
289 * On bit-endian 64-bit platforms, the guard word is a single 64-bit atomic
290 * with the lock in the low bit and the initialised bit in the highest
298 * 32-bit platforms use the same layout as 64-bit.
303 * 32-bit platforms use the same layout as 64-bit.
312 * Acquires a lock on a guard, returning 0 if the object has already been
320 if (guard_object->is_initialised()) in __cxa_guard_acquire()
324 // Spin trying to acquire the lock. If we fail to acquire the lock the in __cxa_guard_acquire()
330 // Try to acquire the lock. in __cxa_guard_acquire()
331 switch (guard_object->try_lock()) in __cxa_guard_acquire()
333 // If we failed to acquire the lock but another thread has in __cxa_guard_acquire()
334 // initialised the lock while we were waiting, return immediately in __cxa_guard_acquire()
338 // If we acquired the lock, return immediately to start in __cxa_guard_acquire()
342 // If we didn't acquire the lock, pause and retry. in __cxa_guard_acquire()
351 * Releases the lock without marking the object as initialised. This function
356 guard_object->unlock(false); in __cxa_guard_abort()
365 guard_object->unlock(true); in __cxa_guard_release()