Ami*_*rma 9 c linux macros gcc gcc-warning
我是Linux内核的新手.我正在使用稀疏工具来清除代码中存在的噪音.我遇到了这些宏:
# 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)))
Run Code Online (Sandbox Code Playgroud)
现在我想知道:稀疏如何使用它们来报告错误/警告?
我的问题:
我认为所有这些宏只在稀疏的上下文中有意义(这里的联机文章- 你可以找到所有这些属性的描述和那里的稀疏警告).如果您在复制的源文件中查看上面有一个__CHECKER__用于启用它们的大宏.
我不确定gcc在这一点上是否会对它们做任何事情 - 我认为它会默默地忽略它们......在2004年的一封电子邮件中,Linus Torvalds说:
这一点很重要:对于gcc,稀疏注释是没有意义的.它们仍然可以用来告诉程序员 "嘿,你得到的指针不是一个普通的指针",但是最后,除非你使用稀疏,否则它们实际上并没有做任何事情.
为此目的打开了一些门票 - http://www.spinics.net/lists/linux-sparse/msg03366.html.