diff options
author | Ron Yorston <rmy@pobox.com> | 2024-08-16 11:19:01 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2024-08-16 11:19:01 +0100 |
commit | 2b00b4311ecf4c6f6331f8c969934fa792f7e15c (patch) | |
tree | 78450c22447a1e60cce970b98016ae8de7107336 | |
parent | 6481bb22b5e6d60909d09cf6179412c4f34b9b3c (diff) | |
download | busybox-w32-2b00b4311ecf4c6f6331f8c969934fa792f7e15c.tar.gz busybox-w32-2b00b4311ecf4c6f6331f8c969934fa792f7e15c.tar.bz2 busybox-w32-2b00b4311ecf4c6f6331f8c969934fa792f7e15c.zip |
win32: code shrink
Add the FAST_FUNC qualifier to several Windows-specific functions.
This has no effect in 64-bit builds but saves 336 bytes for 32-bit.
-rw-r--r-- | include/mingw.h | 34 | ||||
-rw-r--r-- | libbb/get_last_path_component.c | 2 | ||||
-rw-r--r-- | win32/mingw.c | 26 | ||||
-rw-r--r-- | win32/process.c | 4 | ||||
-rw-r--r-- | win32/winansi.c | 2 |
5 files changed, 34 insertions, 34 deletions
diff --git a/include/mingw.h b/include/mingw.h index 104ca3b2e..adb810ec5 100644 --- a/include/mingw.h +++ b/include/mingw.h | |||
@@ -633,27 +633,27 @@ ULONGLONG CompatGetTickCount64(void); | |||
633 | ssize_t get_random_bytes(void *buf, ssize_t count); | 633 | ssize_t get_random_bytes(void *buf, ssize_t count); |
634 | int enumerate_links(const char *file, char *name); | 634 | int enumerate_links(const char *file, char *name); |
635 | 635 | ||
636 | int unc_root_len(const char *dir); | 636 | int unc_root_len(const char *dir) FAST_FUNC; |
637 | int root_len(const char *path); | 637 | int root_len(const char *path) FAST_FUNC; |
638 | const char *get_system_drive(void); | 638 | const char *get_system_drive(void) FAST_FUNC; |
639 | int chdir_system_drive(void); | 639 | int chdir_system_drive(void); |
640 | char *xabsolute_path(char *path); | 640 | char *xabsolute_path(char *path) FAST_FUNC; |
641 | char *get_drive_cwd(const char *path, char *buffer, int size); | 641 | char *get_drive_cwd(const char *path, char *buffer, int size) FAST_FUNC; |
642 | void fix_path_case(char *path); | 642 | void fix_path_case(char *path) FAST_FUNC; |
643 | void make_sparse(int fd, off_t start, off_t end); | 643 | void make_sparse(int fd, off_t start, off_t end) FAST_FUNC; |
644 | int terminal_mode(int reset); | 644 | int terminal_mode(int reset) FAST_FUNC; |
645 | int unix_path(const char *path); | 645 | int unix_path(const char *path) FAST_FUNC; |
646 | int has_path(const char *file); | 646 | int has_path(const char *file) FAST_FUNC; |
647 | int is_relative_path(const char *path); | 647 | int is_relative_path(const char *path) FAST_FUNC; |
648 | char *get_last_slash(const char *path); | 648 | char *get_last_slash(const char *path) FAST_FUNC; |
649 | const char *applet_to_exe(const char *name); | 649 | const char *applet_to_exe(const char *name) FAST_FUNC; |
650 | char *get_user_name(void); | 650 | char *get_user_name(void); |
651 | char *quote_arg(const char *arg); | 651 | char *quote_arg(const char *arg) FAST_FUNC; |
652 | char *find_first_executable(const char *name); | 652 | char *find_first_executable(const char *name) FAST_FUNC; |
653 | char *xappendword(const char *str, const char *word); | 653 | char *xappendword(const char *str, const char *word) FAST_FUNC; |
654 | int windows_env(void); | 654 | int windows_env(void); |
655 | void change_critical_error_dialogs(const char *newval) FAST_FUNC; | 655 | void change_critical_error_dialogs(const char *newval) FAST_FUNC; |
656 | char *exe_relative_path(const char *tail); | 656 | char *exe_relative_path(const char *tail) FAST_FUNC; |
657 | enum { | 657 | enum { |
658 | ELEVATED_PRIVILEGE = 1, | 658 | ELEVATED_PRIVILEGE = 1, |
659 | ADMIN_ENABLED = 2 | 659 | ADMIN_ENABLED = 2 |
diff --git a/libbb/get_last_path_component.c b/libbb/get_last_path_component.c index 9d017ab7f..46a87d7fc 100644 --- a/libbb/get_last_path_component.c +++ b/libbb/get_last_path_component.c | |||
@@ -24,7 +24,7 @@ const char* FAST_FUNC bb_basename(const char *name) | |||
24 | } | 24 | } |
25 | 25 | ||
26 | #if ENABLE_PLATFORM_MINGW32 | 26 | #if ENABLE_PLATFORM_MINGW32 |
27 | char *get_last_slash(const char *path) | 27 | char * FAST_FUNC get_last_slash(const char *path) |
28 | { | 28 | { |
29 | const char *start = path + root_len(path); | 29 | const char *start = path + root_len(path); |
30 | char *slash = strrchr(start, '/'); | 30 | char *slash = strrchr(start, '/'); |
diff --git a/win32/mingw.c b/win32/mingw.c index dfe38734a..c14ad1f1f 100644 --- a/win32/mingw.c +++ b/win32/mingw.c | |||
@@ -2255,7 +2255,7 @@ int enumerate_links(const char *file, char *name) | |||
2255 | 2255 | ||
2256 | /* Return the length of the root of a UNC path, i.e. the '//host/share' | 2256 | /* Return the length of the root of a UNC path, i.e. the '//host/share' |
2257 | * component, or 0 if the path doesn't look like that. */ | 2257 | * component, or 0 if the path doesn't look like that. */ |
2258 | int unc_root_len(const char *dir) | 2258 | int FAST_FUNC unc_root_len(const char *dir) |
2259 | { | 2259 | { |
2260 | const char *s = dir + 2; | 2260 | const char *s = dir + 2; |
2261 | int len; | 2261 | int len; |
@@ -2276,7 +2276,7 @@ int unc_root_len(const char *dir) | |||
2276 | 2276 | ||
2277 | /* Return the length of the root of a path, i.e. either the drive or | 2277 | /* Return the length of the root of a path, i.e. either the drive or |
2278 | * UNC '//host/share', or 0 if the path doesn't look like that. */ | 2278 | * UNC '//host/share', or 0 if the path doesn't look like that. */ |
2279 | int root_len(const char *path) | 2279 | int FAST_FUNC root_len(const char *path) |
2280 | { | 2280 | { |
2281 | if (path == NULL) | 2281 | if (path == NULL) |
2282 | return 0; | 2282 | return 0; |
@@ -2285,7 +2285,7 @@ int root_len(const char *path) | |||
2285 | return unc_root_len(path); | 2285 | return unc_root_len(path); |
2286 | } | 2286 | } |
2287 | 2287 | ||
2288 | const char *get_system_drive(void) | 2288 | const char * FAST_FUNC get_system_drive(void) |
2289 | { | 2289 | { |
2290 | static const char *drive = NULL; | 2290 | static const char *drive = NULL; |
2291 | char sysdir[PATH_MAX]; | 2291 | char sysdir[PATH_MAX]; |
@@ -2320,7 +2320,7 @@ int chdir_system_drive(void) | |||
2320 | * an allocated string containing the resolved path. Die on failure, | 2320 | * an allocated string containing the resolved path. Die on failure, |
2321 | * which is most likely because the file doesn't exist. | 2321 | * which is most likely because the file doesn't exist. |
2322 | */ | 2322 | */ |
2323 | char *xabsolute_path(char *path) | 2323 | char * FAST_FUNC xabsolute_path(char *path) |
2324 | { | 2324 | { |
2325 | char *rpath; | 2325 | char *rpath; |
2326 | 2326 | ||
@@ -2332,7 +2332,7 @@ char *xabsolute_path(char *path) | |||
2332 | bb_perror_msg_and_die("can't open '%s'", path); | 2332 | bb_perror_msg_and_die("can't open '%s'", path); |
2333 | } | 2333 | } |
2334 | 2334 | ||
2335 | char *get_drive_cwd(const char *path, char *buffer, int size) | 2335 | char * FAST_FUNC get_drive_cwd(const char *path, char *buffer, int size) |
2336 | { | 2336 | { |
2337 | char drive[3] = { *path, ':', '\0' }; | 2337 | char drive[3] = { *path, ':', '\0' }; |
2338 | DWORD ret; | 2338 | DWORD ret; |
@@ -2343,7 +2343,7 @@ char *get_drive_cwd(const char *path, char *buffer, int size) | |||
2343 | return bs_to_slash(buffer); | 2343 | return bs_to_slash(buffer); |
2344 | } | 2344 | } |
2345 | 2345 | ||
2346 | void fix_path_case(char *path) | 2346 | void FAST_FUNC fix_path_case(char *path) |
2347 | { | 2347 | { |
2348 | char resolved[PATH_MAX]; | 2348 | char resolved[PATH_MAX]; |
2349 | int len; | 2349 | int len; |
@@ -2365,7 +2365,7 @@ void fix_path_case(char *path) | |||
2365 | } | 2365 | } |
2366 | } | 2366 | } |
2367 | 2367 | ||
2368 | void make_sparse(int fd, off_t start, off_t end) | 2368 | void FAST_FUNC make_sparse(int fd, off_t start, off_t end) |
2369 | { | 2369 | { |
2370 | DWORD dwTemp; | 2370 | DWORD dwTemp; |
2371 | HANDLE fh; | 2371 | HANDLE fh; |
@@ -2410,7 +2410,7 @@ void *get_proc_addr(const char *dll, const char *function, | |||
2410 | return proc->pfunction; | 2410 | return proc->pfunction; |
2411 | } | 2411 | } |
2412 | 2412 | ||
2413 | int unix_path(const char *path) | 2413 | int FAST_FUNC unix_path(const char *path) |
2414 | { | 2414 | { |
2415 | int i; | 2415 | int i; |
2416 | char *p = xstrdup(path); | 2416 | char *p = xstrdup(path); |
@@ -2423,7 +2423,7 @@ int unix_path(const char *path) | |||
2423 | 2423 | ||
2424 | /* Return true if file is referenced using a path. This means a path | 2424 | /* Return true if file is referenced using a path. This means a path |
2425 | * look-up isn't required. */ | 2425 | * look-up isn't required. */ |
2426 | int has_path(const char *file) | 2426 | int FAST_FUNC has_path(const char *file) |
2427 | { | 2427 | { |
2428 | return strchr(file, '/') || strchr(file, '\\') || | 2428 | return strchr(file, '/') || strchr(file, '\\') || |
2429 | has_dos_drive_prefix(file); | 2429 | has_dos_drive_prefix(file); |
@@ -2438,7 +2438,7 @@ int has_path(const char *file) | |||
2438 | * Paths of the form /dir/file or c:dir/file aren't relative by this | 2438 | * Paths of the form /dir/file or c:dir/file aren't relative by this |
2439 | * definition. | 2439 | * definition. |
2440 | */ | 2440 | */ |
2441 | int is_relative_path(const char *path) | 2441 | int FAST_FUNC is_relative_path(const char *path) |
2442 | { | 2442 | { |
2443 | return !is_dir_sep(path[0]) && !has_dos_drive_prefix(path); | 2443 | return !is_dir_sep(path[0]) && !has_dos_drive_prefix(path); |
2444 | } | 2444 | } |
@@ -2451,7 +2451,7 @@ int is_relative_path(const char *path) | |||
2451 | * matches the file name from bb_busybox_exec_path (with appropriate | 2451 | * matches the file name from bb_busybox_exec_path (with appropriate |
2452 | * allowance for 'busybox*.exe'). | 2452 | * allowance for 'busybox*.exe'). |
2453 | */ | 2453 | */ |
2454 | const char *applet_to_exe(const char *name) | 2454 | const char * FAST_FUNC applet_to_exe(const char *name) |
2455 | { | 2455 | { |
2456 | const char *exefile = bb_basename(bb_busybox_exec_path); | 2456 | const char *exefile = bb_basename(bb_busybox_exec_path); |
2457 | const char *exesuff = is_prefixed_with_case(exefile, name); | 2457 | const char *exesuff = is_prefixed_with_case(exefile, name); |
@@ -2469,7 +2469,7 @@ const char *applet_to_exe(const char *name) | |||
2469 | * call should use a NULL pointer for str, subsequent calls should | 2469 | * call should use a NULL pointer for str, subsequent calls should |
2470 | * pass an allocated string which will be freed. | 2470 | * pass an allocated string which will be freed. |
2471 | */ | 2471 | */ |
2472 | char *xappendword(const char *str, const char *word) | 2472 | char * FAST_FUNC xappendword(const char *str, const char *word) |
2473 | { | 2473 | { |
2474 | char *newstr = str ? xasprintf("%s %s", str, word) : xstrdup(word); | 2474 | char *newstr = str ? xasprintf("%s %s", str, word) : xstrdup(word); |
2475 | free((void *)str); | 2475 | free((void *)str); |
@@ -2509,7 +2509,7 @@ change_critical_error_dialogs(const char *newval) | |||
2509 | 0 : SEM_FAILCRITICALERRORS); | 2509 | 0 : SEM_FAILCRITICALERRORS); |
2510 | } | 2510 | } |
2511 | 2511 | ||
2512 | char *exe_relative_path(const char *tail) | 2512 | char * FAST_FUNC exe_relative_path(const char *tail) |
2513 | { | 2513 | { |
2514 | char *exepath = xstrdup(bb_busybox_exec_path); | 2514 | char *exepath = xstrdup(bb_busybox_exec_path); |
2515 | char *relpath = concat_path_file(dirname(exepath), tail); | 2515 | char *relpath = concat_path_file(dirname(exepath), tail); |
diff --git a/win32/process.c b/win32/process.c index 57e410a73..097a1d71c 100644 --- a/win32/process.c +++ b/win32/process.c | |||
@@ -113,7 +113,7 @@ parse_interpreter(const char *cmd, interp_t *interp) | |||
113 | * See https://docs.microsoft.com/en-us/cpp/cpp/main-function-command-line-args?view=vs-2019#parsing-c-command-line-arguments | 113 | * See https://docs.microsoft.com/en-us/cpp/cpp/main-function-command-line-args?view=vs-2019#parsing-c-command-line-arguments |
114 | * (Parsing C++ Command-Line Arguments) | 114 | * (Parsing C++ Command-Line Arguments) |
115 | */ | 115 | */ |
116 | char * | 116 | char * FAST_FUNC |
117 | quote_arg(const char *arg) | 117 | quote_arg(const char *arg) |
118 | { | 118 | { |
119 | char *r = xmalloc(2 * strlen(arg) + 3); // max-esc, enclosing DQ, \0 | 119 | char *r = xmalloc(2 * strlen(arg) + 3); // max-esc, enclosing DQ, \0 |
@@ -150,7 +150,7 @@ quote_arg(const char *arg) | |||
150 | return xrealloc(r, d - r); | 150 | return xrealloc(r, d - r); |
151 | } | 151 | } |
152 | 152 | ||
153 | char * | 153 | char * FAST_FUNC |
154 | find_first_executable(const char *name) | 154 | find_first_executable(const char *name) |
155 | { | 155 | { |
156 | char *path = getenv("PATH"); | 156 | char *path = getenv("PATH"); |
diff --git a/win32/winansi.c b/win32/winansi.c index 2b450aff0..12892e697 100644 --- a/win32/winansi.c +++ b/win32/winansi.c | |||
@@ -83,7 +83,7 @@ static int is_wine(void) | |||
83 | #define ENABLE_VIRTUAL_TERMINAL_INPUT 0x0200 | 83 | #define ENABLE_VIRTUAL_TERMINAL_INPUT 0x0200 |
84 | #endif | 84 | #endif |
85 | 85 | ||
86 | int terminal_mode(int reset) | 86 | int FAST_FUNC terminal_mode(int reset) |
87 | { | 87 | { |
88 | static int mode = -1; | 88 | static int mode = -1; |
89 | 89 | ||