mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
Rewrite code using atomic_fcmpset_int() in the LinuxKPI.
Suggested by: mjg@ MFC after: 1 week Sponsored by: Mellanox Technologies Sponsored by: Limelight Networks
This commit is contained in:
parent
e6e028d01f
commit
17e2a84e9a
1 changed files with 7 additions and 6 deletions
|
|
@ -239,15 +239,16 @@ static inline int
|
|||
atomic_dec_if_positive(atomic_t *v)
|
||||
{
|
||||
int retval;
|
||||
int curr;
|
||||
int old;
|
||||
|
||||
do {
|
||||
curr = atomic_read(v);
|
||||
retval = curr - 1;
|
||||
old = atomic_read(v);
|
||||
for (;;) {
|
||||
retval = old - 1;
|
||||
if (unlikely(retval < 0))
|
||||
break;
|
||||
} while (!likely(atomic_cmpset_int(&v->counter, curr, retval)));
|
||||
|
||||
if (likely(atomic_fcmpset_int(&v->counter, &old, retval)))
|
||||
break;
|
||||
}
|
||||
return (retval);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue