^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) cat << EOF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * ${arch}${atomic}_add_unless - add unless the number is already a given value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * @v: pointer of type ${atomic}_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * @a: the amount to add to v...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * @u: ...unless v is equal to u.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * Atomically adds @a to @v, if @v was not already @u.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * Returns true if the addition was done.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) static __always_inline bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) ${arch}${atomic}_add_unless(${atomic}_t *v, ${int} a, ${int} u)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) return ${arch}${atomic}_fetch_add_unless(v, a, u) != u;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) EOF