blob: 2ff598a3f9ecebaea65eaefe22b0f66c1acc0d65 [file] [log] [blame]
David Brazdil0f672f62019-12-10 10:32:29 +00001cat << EOF
2/**
Olivier Deprez157378f2022-04-04 15:47:50 +02003 * ${arch}${atomic}_add_unless - add unless the number is already a given value
David Brazdil0f672f62019-12-10 10:32:29 +00004 * @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 Deprez157378f2022-04-04 15:47:50 +020011static __always_inline bool
12${arch}${atomic}_add_unless(${atomic}_t *v, ${int} a, ${int} u)
David Brazdil0f672f62019-12-10 10:32:29 +000013{
Olivier Deprez157378f2022-04-04 15:47:50 +020014 return ${arch}${atomic}_fetch_add_unless(v, a, u) != u;
David Brazdil0f672f62019-12-10 10:32:29 +000015}
16EOF