asmlinkage

すぐ忘れるからメモ。


Linuxカーネル(2.6.30-rc8-tip)だとinclude/linux/linkage.hにあって

#include <linux/compiler.h>
#include <asm/linkage.h>

#ifdef __cplusplus
#define CPP_ASMLINKAGE extern "C"
#else
#define CPP_ASMLINKAGE
#endif

#ifndef asmlinkage
#define asmlinkage CPP_ASMLINKAGE
#endif


む。空だ。
x86_64だと空なのか?へー。
眠いから深追いしねい。


x86_32だとarch/x86/include/asm/linkage.hにあって

#ifdef CONFIG_X86_32
#define asmlinkage CPP_ASMLINKAGE __attribute__((regparm(0)))


asmlinkageはregparmという属性に展開される。
gcc-infoによるとregparmとは下のとおり。

`regparm (NUMBER)'
On the Intel 386, the `regparm' attribute causes the compiler to
pass up to NUMBER integer arguments in registers EAX, EDX, and ECX
instead of on the stack. Functions that take a variable number of
arguments will continue to be passed all of their arguments on the
stack.

NUMBERでレジスタ渡しをする引数の数を設定しているらしい。
ここではregparm(0)だから、レジスタ渡しの引数は0個。
つまりすべての引数はスタック渡しにしなさいと命令してるわけね。


[参考]