c - FAST_FUNC在busybox中做什么?

标签 c 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 允许将函数的某些参数传递到寄存器而不是堆栈中,从而消除了函数调用调用序列中的一些内存访问。

关于c - FAST_FUNC在busybox中做什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27286568/

相关文章:

c - 什么是虚拟内存?

linux - 不同进程的 %cpu 通过 busybox 和 procps-ng 的 top 输出

将空指针转换为结构体

c - realloc 不适用于二维指针数组

c - C 中的数字金字塔

linux - 如何进行增量时间跳跃以避免数据丢失

linux - 如何检测getty respawn?

regex - grep 两个分隔符之间的子字符串

ssl - 如何在运行 Go 的 Busybox Docker 容器中进行 HTTPS 调用?

c - 我如何免费包含数据集和linked_data的数据库