[apparmor] [PATCH 04/12] libapparmor: Temporarily duplicate the parser's atomic ops
Seth Arnold
seth.arnold at canonical.com
Sat Feb 14 01:50:37 UTC 2015
On Wed, Dec 10, 2014 at 04:12:25PM -0600, Tyler Hicks wrote:
> The parser's copy of the two atomic operations will be removed once the
> new API's (aa_match, aa_features, aa_policy_cache, aa_kernel_interface)
> are moved from the parser to libapparmor.
>
> Signed-off-by: Tyler Hicks <tyhicks at canonical.com>
Acked-by: Seth Arnold <seth.arnold at canonical.com>
Thanks
> ---
> libraries/libapparmor/src/private.c | 10 ++++++++++
> libraries/libapparmor/src/private.h | 4 ++++
> 2 files changed, 14 insertions(+)
>
> diff --git a/libraries/libapparmor/src/private.c b/libraries/libapparmor/src/private.c
> index 1143a34..255585f 100644
> --- a/libraries/libapparmor/src/private.c
> +++ b/libraries/libapparmor/src/private.c
> @@ -52,6 +52,16 @@ static struct ignored_suffix_t ignored_suffixes[] = {
> { NULL, 0, 0 }
> };
>
> +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;
> +}
> +
> int _aa_is_blacklisted(const char *name, const char *path)
> {
> int name_len;
> diff --git a/libraries/libapparmor/src/private.h b/libraries/libapparmor/src/private.h
> index 3007294..2ef3088 100644
> --- a/libraries/libapparmor/src/private.h
> +++ b/libraries/libapparmor/src/private.h
> @@ -17,10 +17,14 @@
> #ifndef _AA_PRIVATE_H
> #define _AA_PRIVATE_H 1
>
> +#include <stdbool.h>
> #include <sys/apparmor_private.h>
>
> #define autofree __attribute((cleanup(_aa_autofree)))
> #define autoclose __attribute((cleanup(_aa_autoclose)))
> #define autofclose __attribute((cleanup(_aa_autofclose)))
>
> +void atomic_inc(unsigned int *v);
> +bool atomic_dec_and_test(unsigned int *v);
> +
> #endif /* _AA_PRIVATE_H */
> --
> 2.1.0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20150213/ad16c9b0/attachment.pgp>
More information about the AppArmor
mailing list