[英]_THIS_IP_ macro in linux kernel
The following macro appears in include/linux/kernel.h 以下宏出现在include / linux / kernel.h中
#define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; })
I don't understand what the second & applied to __here would do. 我不明白第二个应用于__here会做什么。 The first takes the address of the local label, but what about the second?
第一个采用本地标签的地址,但第二个呢?
The second &
in &&
is necessary to make GCC lookup the name as a label, instead of as a variable. 第二个
&
in &&
是使GCC查找名称作为标签而不是变量的必要条件。 For example 例如
foo: ;
int foo;
void *p1 = &&foo;
void *p2 = &foo;
The second initializer refers to the int variable. 第二个初始化程序引用int变量。
I think &&
is to get the address of label. 我认为
&&
是获取标签的地址。
this is gcc extention and I don't think C99 standard supports this behavior. 这是gcc扩展,我不认为C99标准支持这种行为。
for more see this.. gcc Labels and values 更多看到这个.. gcc标签和价值观
And local label declaration 和本地标签声明
In your case , 在你的情况下,
#define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; })
In actual code _THIS_IP_
will be replaced by the code below of block scope 在实际代码中,
_THIS_IP_
将被替换为块范围的下面的代码
{ __label__ __here;
__here:
(unsigned long) &&__here;
}
You are declaring local label __here
. 您正在声明本地标签
__here
。 Hence to get the address of label we use &&
while we get the address of variable with single &
. 因此,为了获得标签的地址,我们使用
&&
同时我们获得单个&
的变量的地址。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.