Skip to content

Commit 2cc72b0

Browse files
haoluo1022Nobody
authored andcommitted
compiler_types: Refactor the use of btf_type_tag attribute.
Previous patches have introduced the compiler attribute btf_type_tag for __user and __percpu. The availability of this attribute depends on some CONFIGs and compiler support. This patch refactors the use of btf_type_tag by introducing BTF_TYPE_TAG, which hides all the dependencies. No functional change. Suggested-by: Andrii Nakryiko <[email protected]> Cc: Yonghong Song <[email protected]> Signed-off-by: Hao Luo <[email protected]>
1 parent dd8c038 commit 2cc72b0

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

include/linux/compiler_types.h

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44

55
#ifndef __ASSEMBLY__
66

7+
#if defined(CONFIG_DEBUG_INFO_BTF) && defined(CONFIG_PAHOLE_HAS_BTF_TAG) && \
8+
__has_attribute(btf_type_tag)
9+
# define BTF_TYPE_TAG(value) __attribute__((btf_type_tag(#value)))
10+
#else
11+
# define BTF_TYPE_TAG(value) /* nothing */
12+
#endif
13+
714
#ifdef __CHECKER__
815
/* address spaces */
916
# define __kernel __attribute__((address_space(0)))
@@ -31,19 +38,11 @@ static inline void __chk_io_ptr(const volatile void __iomem *ptr) { }
3138
# define __kernel
3239
# ifdef STRUCTLEAK_PLUGIN
3340
# define __user __attribute__((user))
34-
# elif defined(CONFIG_DEBUG_INFO_BTF) && defined(CONFIG_PAHOLE_HAS_BTF_TAG) && \
35-
__has_attribute(btf_type_tag)
36-
# define __user __attribute__((btf_type_tag("user")))
3741
# else
38-
# define __user
42+
# define __user BTF_TYPE_TAG(user)
3943
# endif
4044
# define __iomem
41-
# if defined(CONFIG_DEBUG_INFO_BTF) && defined(CONFIG_PAHOLE_HAS_BTF_TAG) && \
42-
__has_attribute(btf_type_tag)
43-
# define __percpu __attribute__((btf_type_tag("percpu")))
44-
# else
45-
# define __percpu
46-
# endif
45+
# define __percpu BTF_TYPE_TAG(percpu)
4746
# define __rcu
4847
# define __chk_user_ptr(x) (void)0
4948
# define __chk_io_ptr(x) (void)0

0 commit comments

Comments
 (0)