David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1 | cat << EOF |
| 2 | /** |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 3 | * ${arch}${atomic}_add_unless - add unless the number is already a given value |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 4 | * @v: pointer of type ${atomic}_t |
| 5 | * @a: the amount to add to v... |
| 6 | * @u: ...unless v is equal to u. |
| 7 | * |
| 8 | * Atomically adds @a to @v, if @v was not already @u. |
| 9 | * Returns true if the addition was done. |
| 10 | */ |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 11 | static __always_inline bool |
| 12 | ${arch}${atomic}_add_unless(${atomic}_t *v, ${int} a, ${int} u) |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 13 | { |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 14 | return ${arch}${atomic}_fetch_add_unless(v, a, u) != u; |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 15 | } |
| 16 | EOF |