I am very new to Linux kernel. And I am using the sparse tool to clean the noise present in the code. I encountered these macros:
# 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)))
And now I want to know: how they are used by sparse to report the errors/warning?
My questions:
- I want the details how they help compiler and sparse to report the warnings.
- What are these address_space(x) context(X, x, x) and there purpose ?
- What is the purpose of __nocast, __force, __user, __safe ?