* 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. */
| 368 | * zero if the compare failed, nonzero otherwise. |
| 369 | */ |
| 370 | static __inline int |
| 371 | atomic_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 |
no outgoing calls
no test coverage detected