diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2015-10-09 16:42:57 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2015-10-09 16:42:57 +0200 |
commit | 550bf5b4a418378cd8f9fbbf5252fe57acdacb5a (patch) | |
tree | 7ed13e04cf415be6830363953220d7cffd4580b8 /libbb/xfunc_die.c | |
parent | 4cd99e7c6c1af77721b890ed5ae26d747796c4bd (diff) | |
download | busybox-w32-550bf5b4a418378cd8f9fbbf5252fe57acdacb5a.tar.gz busybox-w32-550bf5b4a418378cd8f9fbbf5252fe57acdacb5a.tar.bz2 busybox-w32-550bf5b4a418378cd8f9fbbf5252fe57acdacb5a.zip |
remove global "jmp_buf die_jmp" from !FEATURE_PREFER_APPLETS builds
function old new delta
xfunc_has_died - 21 +21
sleep_much - 12 +12
sleep10 - 9 +9
die_func - 4 +4
fflush_stdout_and_exit 35 36 +1
builtin_type 121 119 -2
die_sleep 4 - -4
xfunc_die 60 24 -36
hush_main 1128 1011 -117
die_jmp 156 - -156
------------------------------------------------------------------------------
(add/remove: 4/2 grow/shrink: 1/3 up/down: 47/-315) Total: -268 bytes
text data bss dec hex filename
939992 992 17652 958636 ea0ac busybox_old
939880 992 17496 958368 e9fa0 busybox_unstripped
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb/xfunc_die.c')
-rw-r--r-- | libbb/xfunc_die.c | 26 |
1 files changed, 4 insertions, 22 deletions
diff --git a/libbb/xfunc_die.c b/libbb/xfunc_die.c index 204e5e49d..73f7998e5 100644 --- a/libbb/xfunc_die.c +++ b/libbb/xfunc_die.c | |||
@@ -7,34 +7,16 @@ | |||
7 | * Licensed under GPLv2, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2, see file LICENSE in this source tree. |
8 | */ | 8 | */ |
9 | 9 | ||
10 | /* Keeping it separate allows to NOT suck in stdio for VERY small applets. | 10 | /* Keeping it separate allows to NOT pull in stdio for VERY small applets. |
11 | * Try building busybox with only "true" enabled... */ | 11 | * Try building busybox with only "true" enabled... */ |
12 | 12 | ||
13 | #include "libbb.h" | 13 | #include "libbb.h" |
14 | 14 | ||
15 | int die_sleep; | 15 | void (*die_func)(void); |
16 | #if ENABLE_FEATURE_PREFER_APPLETS || ENABLE_HUSH | ||
17 | jmp_buf die_jmp; | ||
18 | #endif | ||
19 | 16 | ||
20 | void FAST_FUNC xfunc_die(void) | 17 | void FAST_FUNC xfunc_die(void) |
21 | { | 18 | { |
22 | if (die_sleep) { | 19 | if (die_func) |
23 | if ((ENABLE_FEATURE_PREFER_APPLETS || ENABLE_HUSH) | 20 | die_func(); |
24 | && die_sleep < 0 | ||
25 | ) { | ||
26 | /* Special case. We arrive here if NOFORK applet | ||
27 | * calls xfunc, which then decides to die. | ||
28 | * We don't die, but jump instead back to caller. | ||
29 | * NOFORK applets still cannot carelessly call xfuncs: | ||
30 | * p = xmalloc(10); | ||
31 | * q = xmalloc(10); // BUG! if this dies, we leak p! | ||
32 | */ | ||
33 | /* -2222 means "zero" (longjmp can't pass 0) | ||
34 | * run_nofork_applet() catches -2222. */ | ||
35 | longjmp(die_jmp, xfunc_error_retval ? xfunc_error_retval : -2222); | ||
36 | } | ||
37 | sleep(die_sleep); | ||
38 | } | ||
39 | exit(xfunc_error_retval); | 21 | exit(xfunc_error_retval); |
40 | } | 22 | } |