Re: [PATCH] compiler*.h: Add '__' prefix and suffix to all __attribute__ #defines

From: Miguel Ojeda
Date: Mon Oct 28 2019 - 13:37:33 EST


On Mon, Oct 28, 2019 at 12:43 PM Joe Perches <joe@xxxxxxxxxxx> wrote:
>
> diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
> index 72393a..b8c2145 100644
> --- a/include/linux/compiler_types.h
> +++ b/include/linux/compiler_types.h
> @@ -5,27 +5,27 @@
> #ifndef __ASSEMBLY__
>
> #ifdef __CHECKER__
> -# define __user __attribute__((noderef, address_space(1)))
> -# define __kernel __attribute__((address_space(0)))
> -# define __safe __attribute__((safe))
> -# define __force __attribute__((force))
> -# define __nocast __attribute__((nocast))
> -# define __iomem __attribute__((noderef, address_space(2)))
> -# define __must_hold(x) __attribute__((context(x,1,1)))
> -# define __acquires(x) __attribute__((context(x,0,1)))
> -# define __releases(x) __attribute__((context(x,1,0)))
> -# define __acquire(x) __context__(x,1)
> -# define __release(x) __context__(x,-1)
> +# define __user __attribute__((__noderef__, __address_space__(1)))
> +# define __kernel __attribute__((__address_space__(0)))
> +# define __safe __attribute__((__safe__))
> +# define __force __attribute__((__force__))
> +# define __nocast __attribute__((__nocast__))
> +# define __iomem __attribute__((__noderef__, __address_space__(2)))
> +# define __must_hold(x) __attribute__((__context__(x, 1, 1)))
> +# define __acquires(x) __attribute__((__context__(x, 0, 1)))
> +# define __releases(x) __attribute__((__context__(x, 1, 0)))
> +# define __acquire(x) __context__(x, 1)
> +# define __release(x) __context__(x, -1)
> # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
> -# define __percpu __attribute__((noderef, address_space(3)))
> -# define __rcu __attribute__((noderef, address_space(4)))
> -# define __private __attribute__((noderef))
> +# define __percpu __attribute__((__noderef__, __address_space__(3)))
> +# define __rcu __attribute__((__noderef__, __address_space__(4)))
> +# define __private __attribute__((__noderef__))

Just in case: for these ones (i.e. __CHECKER__), did you check if
sparse handles this syntax? (I don't recall myself if it does).

Other than that, thanks for the cleanup too! I can pick it up in the
the compiler-attributes tree and put it in -next.

Cheers,
Miguel