GCC __attribute__ meaning (reference for https://gcc.gnu.org/onlinedocs/gcc-3.2/gcc/Function-Att)

来源:互联网 发布:权志龙水原希子 知乎 编辑:程序博客网 时间:2024/05/19 20:41
busybox/src/include/platform.h
/* FAST_FUNC is a qualifier which (possibly) makes function call faster * and/or smaller by using modified ABI. It is usually only needed * on non-static, busybox internal functions. Recent versions of gcc * optimize statics automatically. FAST_FUNC on static is required * only if you need to match a function pointer's type */#if __GNUC_PREREQ(3,0) && defined(i386) /* || defined(__x86_64__)? *//* stdcall makes callee to pop arguments from stack, not caller */# define FAST_FUNC __attribute__((regparm(3),stdcall))/* #elif ... - add your favorite arch today! */#else# define FAST_FUNC#endif
busybox中经常有这种声明:再看FAST_FUNC属性函数的定义格式: 
在gcc编译器中
__attribute__((regparm(3),stdcall))的含义是:
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. 
stdcall
On the Intel 386, the stdcall attribute causes the compiler to assume that the called function will pop off the stack space used to pass arguments, unless it takes a variable number of arguments.
1 0