MCPcopy Create free account
hub / github.com/F-Stack/f-stack / atomic_cmpset_32

Function atomic_cmpset_32

freebsd/mips/include/atomic.h:370–390  ·  view source on GitHub ↗

* Atomically compare the value stored at *p with cmpval and if the * two values are equal, update the value of *p with newval. Returns * zero if the compare failed, nonzero otherwise. */

Source from the content-addressed store, hash-verified

368 * zero if the compare failed, nonzero otherwise.
369 */
370static __inline int
371atomic_cmpset_32(__volatile uint32_t *p, uint32_t cmpval, uint32_t newval)
372{
373 int ret;
374
375 __asm __volatile (
376 "1:\tll %0, %4\n\t" /* load old value */
377 "bne %0, %2, 2f\n\t" /* compare */
378 "move %0, %3\n\t" /* value to store */
379 "sc %0, %1\n\t" /* attempt to store */
380 "beqz %0, 1b\n\t" /* if it failed, spin */
381 "j 3f\n\t"
382 "2:\n\t"
383 "li %0, 0\n\t"
384 "3:\n"
385 : "=&r" (ret), "=m" (*p)
386 : "r" (cmpval), "r" (newval), "m" (*p)
387 : "memory");
388
389 return ret;
390}
391
392/*
393 * Atomically compare the value stored at *p with cmpval and if the

Callers 8

ar933x_bus_setsigFunction · 0.50
oct16550_bus_getsigFunction · 0.50
oct16550_bus_setsigFunction · 0.50
platform_start_apFunction · 0.50
mtk_uart_bus_getsigFunction · 0.50
platform_start_apFunction · 0.50
syscall_thread_drainFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected