简体   繁体   中英

What does FAST_FUNC do in busybox?

I found this while reading some code:

char* FAST_FUNC bb_simplify_path(const char *path)

Here char* is a return type, but I don't understand the role of FAST_FUNC . This FAST_FUNC is used in many places.

In general what does FAST_FUNC do in busybox?

From 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

Basically, it activates an architecture-dependent function annotation that speeds up function calls. The actual annotation depends on the platform (hence the #if ), but on x86/x86_64 (the only platforms currently implemented here), it activates "stdcall" calling conventions on the annotated function. stdcall enables some of the function's arguments to be passed in registers instead of the stack, which eliminates a few memory accesses from the function call calling sequence.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM