Lines Matching refs:val

56 static bool qemu_lockcnt_cmpxchg_or_wait(QemuLockCnt *lockcnt, int *val,  in qemu_lockcnt_cmpxchg_or_wait()  argument
60 if ((*val & QEMU_LOCKCNT_STATE_MASK) == QEMU_LOCKCNT_STATE_FREE) { in qemu_lockcnt_cmpxchg_or_wait()
61 int expected = *val; in qemu_lockcnt_cmpxchg_or_wait()
64 *val = qatomic_cmpxchg(&lockcnt->count, expected, new_if_free); in qemu_lockcnt_cmpxchg_or_wait()
65 if (*val == expected) { in qemu_lockcnt_cmpxchg_or_wait()
67 *val = new_if_free; in qemu_lockcnt_cmpxchg_or_wait()
78 while ((*val & QEMU_LOCKCNT_STATE_MASK) != QEMU_LOCKCNT_STATE_FREE) { in qemu_lockcnt_cmpxchg_or_wait()
79 if ((*val & QEMU_LOCKCNT_STATE_MASK) == QEMU_LOCKCNT_STATE_LOCKED) { in qemu_lockcnt_cmpxchg_or_wait()
80 int expected = *val; in qemu_lockcnt_cmpxchg_or_wait()
84 *val = qatomic_cmpxchg(&lockcnt->count, expected, new); in qemu_lockcnt_cmpxchg_or_wait()
85 if (*val == expected) { in qemu_lockcnt_cmpxchg_or_wait()
86 *val = new; in qemu_lockcnt_cmpxchg_or_wait()
91 if ((*val & QEMU_LOCKCNT_STATE_MASK) == QEMU_LOCKCNT_STATE_WAITING) { in qemu_lockcnt_cmpxchg_or_wait()
93 trace_lockcnt_futex_wait(lockcnt, *val); in qemu_lockcnt_cmpxchg_or_wait()
94 qemu_futex_wait(&lockcnt->count, *val); in qemu_lockcnt_cmpxchg_or_wait()
95 *val = qatomic_read(&lockcnt->count); in qemu_lockcnt_cmpxchg_or_wait()
96 trace_lockcnt_futex_wait_resume(lockcnt, *val); in qemu_lockcnt_cmpxchg_or_wait()
113 int val = qatomic_read(&lockcnt->count); in qemu_lockcnt_inc() local
117 if (val >= QEMU_LOCKCNT_COUNT_STEP) { in qemu_lockcnt_inc()
118 int expected = val; in qemu_lockcnt_inc()
119 val = qatomic_cmpxchg(&lockcnt->count, val, in qemu_lockcnt_inc()
120 val + QEMU_LOCKCNT_COUNT_STEP); in qemu_lockcnt_inc()
121 if (val == expected) { in qemu_lockcnt_inc()
126 if (qemu_lockcnt_cmpxchg_or_wait(lockcnt, &val, QEMU_LOCKCNT_COUNT_STEP, in qemu_lockcnt_inc()
155 int val = qatomic_read(&lockcnt->count); in qemu_lockcnt_dec_and_lock() local
160 if (val >= 2 * QEMU_LOCKCNT_COUNT_STEP) { in qemu_lockcnt_dec_and_lock()
161 int expected = val; in qemu_lockcnt_dec_and_lock()
162 val = qatomic_cmpxchg(&lockcnt->count, val, in qemu_lockcnt_dec_and_lock()
163 val - QEMU_LOCKCNT_COUNT_STEP); in qemu_lockcnt_dec_and_lock()
164 if (val == expected) { in qemu_lockcnt_dec_and_lock()
171 if (qemu_lockcnt_cmpxchg_or_wait(lockcnt, &val, locked_state, &waited)) { in qemu_lockcnt_dec_and_lock()
204 int val = qatomic_read(&lockcnt->count); in qemu_lockcnt_dec_if_lock() local
208 while (val < 2 * QEMU_LOCKCNT_COUNT_STEP) { in qemu_lockcnt_dec_if_lock()
212 if (qemu_lockcnt_cmpxchg_or_wait(lockcnt, &val, locked_state, &waited)) { in qemu_lockcnt_dec_if_lock()
238 int val = qatomic_read(&lockcnt->count); in qemu_lockcnt_lock() local
246 while (!qemu_lockcnt_cmpxchg_or_wait(lockcnt, &val, val + step, &waited)) { in qemu_lockcnt_lock()
258 int expected, new, val; in qemu_lockcnt_inc_and_unlock() local
260 val = qatomic_read(&lockcnt->count); in qemu_lockcnt_inc_and_unlock()
262 expected = val; in qemu_lockcnt_inc_and_unlock()
263 new = (val + QEMU_LOCKCNT_COUNT_STEP) & ~QEMU_LOCKCNT_STATE_MASK; in qemu_lockcnt_inc_and_unlock()
264 trace_lockcnt_unlock_attempt(lockcnt, val, new); in qemu_lockcnt_inc_and_unlock()
265 val = qatomic_cmpxchg(&lockcnt->count, val, new); in qemu_lockcnt_inc_and_unlock()
266 } while (val != expected); in qemu_lockcnt_inc_and_unlock()
268 trace_lockcnt_unlock_success(lockcnt, val, new); in qemu_lockcnt_inc_and_unlock()
269 if (val & QEMU_LOCKCNT_STATE_WAITING) { in qemu_lockcnt_inc_and_unlock()
276 int expected, new, val; in qemu_lockcnt_unlock() local
278 val = qatomic_read(&lockcnt->count); in qemu_lockcnt_unlock()
280 expected = val; in qemu_lockcnt_unlock()
281 new = val & ~QEMU_LOCKCNT_STATE_MASK; in qemu_lockcnt_unlock()
282 trace_lockcnt_unlock_attempt(lockcnt, val, new); in qemu_lockcnt_unlock()
283 val = qatomic_cmpxchg(&lockcnt->count, val, new); in qemu_lockcnt_unlock()
284 } while (val != expected); in qemu_lockcnt_unlock()
286 trace_lockcnt_unlock_success(lockcnt, val, new); in qemu_lockcnt_unlock()
287 if (val & QEMU_LOCKCNT_STATE_WAITING) { in qemu_lockcnt_unlock()
336 int val = qatomic_read(&lockcnt->count); in qemu_lockcnt_dec_and_lock() local
337 while (val > 1) { in qemu_lockcnt_dec_and_lock()
338 int old = qatomic_cmpxchg(&lockcnt->count, val, val - 1); in qemu_lockcnt_dec_and_lock()
339 if (old != val) { in qemu_lockcnt_dec_and_lock()
340 val = old; in qemu_lockcnt_dec_and_lock()
365 int val = qatomic_read(&lockcnt->count); in qemu_lockcnt_dec_if_lock() local
366 if (val > 1) { in qemu_lockcnt_dec_if_lock()