mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-31 14:25:52 +00:00
parser: Add support for atomic inc and dec
These operations will be used for grabbing and releasing references to objects. They leverage the GCC builtins for atomic operations. Signed-off-by: Tyler Hicks <tyhicks@canonical.com> Acked-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
10
parser/lib.c
10
parser/lib.c
@@ -57,6 +57,16 @@ void __autofclose(FILE **f)
|
||||
}
|
||||
}
|
||||
|
||||
void atomic_inc(unsigned int *v)
|
||||
{
|
||||
__sync_add_and_fetch(v, 1);
|
||||
}
|
||||
|
||||
bool atomic_dec_and_test(unsigned int *v)
|
||||
{
|
||||
return __sync_sub_and_fetch(v, 1) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* dirat_for_each: iterate over a directory calling cb for each entry
|
||||
* @dir: already opened directory (MAY BE NULL)
|
||||
|
Reference in New Issue
Block a user