[英]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.