* Atomically add the value of v to the integer pointed to by p and return * the previous value of *p. */
| 481 | * the previous value of *p. |
| 482 | */ |
| 483 | static __inline uint32_t |
| 484 | atomic_fetchadd_32(__volatile uint32_t *p, uint32_t v) |
| 485 | { |
| 486 | uint32_t value, temp; |
| 487 | |
| 488 | __asm __volatile ( |
| 489 | "1:\tll %0, %1\n\t" /* load old value */ |
| 490 | "addu %2, %3, %0\n\t" /* calculate new value */ |
| 491 | "sc %2, %1\n\t" /* attempt to store */ |
| 492 | "beqz %2, 1b\n\t" /* spin if failed */ |
| 493 | : "=&r" (value), "=m" (*p), "=&r" (temp) |
| 494 | : "r" (v), "m" (*p)); |
| 495 | return (value); |
| 496 | } |
| 497 | |
| 498 | #if defined(__mips_n64) || defined(__mips_n32) |
| 499 | /* |
no outgoing calls
no test coverage detected