Linux Audio

Check our new training course

Loading...
v5.4
 1cat << EOF
 2/**
 3 * ${atomic}_fetch_add_unless - add unless the number is already a given value
 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, so long as @v was not already @u.
 9 * Returns original value of @v
10 */
11static inline ${int}
12${atomic}_fetch_add_unless(${atomic}_t *v, ${int} a, ${int} u)
13{
14	${int} c = ${atomic}_read(v);
15
16	do {
17		if (unlikely(c == u))
18			break;
19	} while (!${atomic}_try_cmpxchg(v, &c, c + a));
20
21	return c;
22}
23EOF
v6.9.4
 1cat << EOF
 2	${int} c = raw_${atomic}_read(v);
 
 
 
 
 
 
 
 
 
 
 
 
 3
 4	do {
 5		if (unlikely(c == u))
 6			break;
 7	} while (!raw_${atomic}_try_cmpxchg(v, &c, c + a));
 8
 9	return c;
 
10EOF