[英]What does FAST_FUNC do in busybox?
我在阅读一些代码时发现了这一点:
char* FAST_FUNC bb_simplify_path(const char *path)
这里char*
是一个返回类型,但我不了解FAST_FUNC
的作用。 这个FAST_FUNC
在很多地方都使用过。
通常, FAST_FUNC
在busybox中做什么?
从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
基本上,它会激活与体系结构相关的函数注释,从而加快函数调用的速度。 实际的注释取决于平台(因此为#if
),但是取决于x86 / x86_64(此处当前唯一实现的平台),它会激活带注释功能的“ stdcall”调用约定。 stdcall
使某些函数的参数可以在寄存器中而不是在堆栈中传递,这消除了函数调用序列中的一些内存访问。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.