diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-02-27 18:41:59 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-02-27 18:41:59 +0000 |
commit | 574f2f43948bb21d6e4187936ba5a5afccba25f6 (patch) | |
tree | 0b39aca564149e5ad30b3cc791228655ff1b1827 /shell | |
parent | fe66a0eca1bfeae0abc0fc1e7d3709f271e05e82 (diff) | |
download | busybox-w32-574f2f43948bb21d6e4187936ba5a5afccba25f6.tar.gz busybox-w32-574f2f43948bb21d6e4187936ba5a5afccba25f6.tar.bz2 busybox-w32-574f2f43948bb21d6e4187936ba5a5afccba25f6.zip |
*: add optimization barrier to all "G trick" locations
Diffstat (limited to 'shell')
-rw-r--r-- | shell/Kbuild | 7 | ||||
-rw-r--r-- | shell/ash.c | 24 | ||||
-rw-r--r-- | shell/ash_ptr_hack.c | 16 | ||||
-rw-r--r-- | shell/hush.c | 5 | ||||
-rw-r--r-- | shell/msh.c | 2 |
5 files changed, 36 insertions, 18 deletions
diff --git a/shell/Kbuild b/shell/Kbuild index 36a8ffd3a..deedc24f3 100644 --- a/shell/Kbuild +++ b/shell/Kbuild | |||
@@ -5,8 +5,7 @@ | |||
5 | # Licensed under the GPL v2, see the file LICENSE in this tarball. | 5 | # Licensed under the GPL v2, see the file LICENSE in this tarball. |
6 | 6 | ||
7 | lib-y:= | 7 | lib-y:= |
8 | lib-$(CONFIG_ASH) += ash.o | 8 | lib-$(CONFIG_ASH) += ash.o ash_ptr_hack.o |
9 | lib-$(CONFIG_HUSH) += hush.o | 9 | lib-$(CONFIG_HUSH) += hush.o |
10 | lib-$(CONFIG_MSH) += msh.o | 10 | lib-$(CONFIG_MSH) += msh.o |
11 | |||
12 | lib-$(CONFIG_CTTYHACK) += cttyhack.o | 11 | lib-$(CONFIG_CTTYHACK) += cttyhack.o |
diff --git a/shell/ash.c b/shell/ash.c index 9c762e2ed..9b1a73024 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -202,9 +202,8 @@ struct globals_misc { | |||
202 | /* indicates specified signal received */ | 202 | /* indicates specified signal received */ |
203 | char gotsig[NSIG - 1]; | 203 | char gotsig[NSIG - 1]; |
204 | }; | 204 | }; |
205 | /* Make it reside in writable memory, yet make compiler understand that it is not going to change. */ | 205 | extern struct globals_misc *const ash_ptr_to_globals_misc; |
206 | static struct globals_misc *const ptr_to_globals_misc __attribute__ ((section (".data"))); | 206 | #define G_misc (*ash_ptr_to_globals_misc) |
207 | #define G_misc (*ptr_to_globals_misc) | ||
208 | #define rootpid (G_misc.rootpid ) | 207 | #define rootpid (G_misc.rootpid ) |
209 | #define shlvl (G_misc.shlvl ) | 208 | #define shlvl (G_misc.shlvl ) |
210 | #define minusc (G_misc.minusc ) | 209 | #define minusc (G_misc.minusc ) |
@@ -223,7 +222,8 @@ static struct globals_misc *const ptr_to_globals_misc __attribute__ ((section (" | |||
223 | #define sigmode (G_misc.sigmode ) | 222 | #define sigmode (G_misc.sigmode ) |
224 | #define gotsig (G_misc.gotsig ) | 223 | #define gotsig (G_misc.gotsig ) |
225 | #define INIT_G_misc() do { \ | 224 | #define INIT_G_misc() do { \ |
226 | (*(struct globals_misc**)&ptr_to_globals_misc) = xzalloc(sizeof(G_misc)); \ | 225 | (*(struct globals_misc**)&ash_ptr_to_globals_misc) = xzalloc(sizeof(G_misc)); \ |
226 | barrier(); \ | ||
227 | curdir = nullstr; \ | 227 | curdir = nullstr; \ |
228 | physdir = nullstr; \ | 228 | physdir = nullstr; \ |
229 | } while (0) | 229 | } while (0) |
@@ -1147,9 +1147,8 @@ struct globals_memstack { | |||
1147 | int herefd; // = -1; | 1147 | int herefd; // = -1; |
1148 | struct stack_block stackbase; | 1148 | struct stack_block stackbase; |
1149 | }; | 1149 | }; |
1150 | /* Make it reside in writable memory, yet make compiler understand that it is not going to change. */ | 1150 | extern struct globals_memstack *const ash_ptr_to_globals_memstack; |
1151 | static struct globals_memstack *const ptr_to_globals_memstack __attribute__ ((section (".data"))); | 1151 | #define G_memstack (*ash_ptr_to_globals_memstack) |
1152 | #define G_memstack (*ptr_to_globals_memstack) | ||
1153 | #define g_stackp (G_memstack.g_stackp ) | 1152 | #define g_stackp (G_memstack.g_stackp ) |
1154 | #define markp (G_memstack.markp ) | 1153 | #define markp (G_memstack.markp ) |
1155 | #define g_stacknxt (G_memstack.g_stacknxt ) | 1154 | #define g_stacknxt (G_memstack.g_stacknxt ) |
@@ -1158,7 +1157,8 @@ static struct globals_memstack *const ptr_to_globals_memstack __attribute__ ((se | |||
1158 | #define herefd (G_memstack.herefd ) | 1157 | #define herefd (G_memstack.herefd ) |
1159 | #define stackbase (G_memstack.stackbase ) | 1158 | #define stackbase (G_memstack.stackbase ) |
1160 | #define INIT_G_memstack() do { \ | 1159 | #define INIT_G_memstack() do { \ |
1161 | (*(struct globals_memstack**)&ptr_to_globals_memstack) = xzalloc(sizeof(G_memstack)); \ | 1160 | (*(struct globals_memstack**)&ash_ptr_to_globals_memstack) = xzalloc(sizeof(G_memstack)); \ |
1161 | barrier(); \ | ||
1162 | g_stackp = &stackbase; \ | 1162 | g_stackp = &stackbase; \ |
1163 | g_stacknxt = stackbase.space; \ | 1163 | g_stacknxt = stackbase.space; \ |
1164 | g_stacknleft = MINSIZE; \ | 1164 | g_stacknleft = MINSIZE; \ |
@@ -1778,9 +1778,8 @@ struct globals_var { | |||
1778 | struct var *vartab[VTABSIZE]; | 1778 | struct var *vartab[VTABSIZE]; |
1779 | struct var varinit[ARRAY_SIZE(varinit_data)]; | 1779 | struct var varinit[ARRAY_SIZE(varinit_data)]; |
1780 | }; | 1780 | }; |
1781 | /* Make it reside in writable memory, yet make compiler understand that it is not going to change. */ | 1781 | extern struct globals_var *const ash_ptr_to_globals_var; |
1782 | static struct globals_var *const ptr_to_globals_var __attribute__ ((section (".data"))); | 1782 | #define G_var (*ash_ptr_to_globals_var) |
1783 | #define G_var (*ptr_to_globals_var) | ||
1784 | #define shellparam (G_var.shellparam ) | 1783 | #define shellparam (G_var.shellparam ) |
1785 | #define redirlist (G_var.redirlist ) | 1784 | #define redirlist (G_var.redirlist ) |
1786 | #define g_nullredirs (G_var.g_nullredirs ) | 1785 | #define g_nullredirs (G_var.g_nullredirs ) |
@@ -1789,7 +1788,8 @@ static struct globals_var *const ptr_to_globals_var __attribute__ ((section (".d | |||
1789 | #define varinit (G_var.varinit ) | 1788 | #define varinit (G_var.varinit ) |
1790 | #define INIT_G_var() do { \ | 1789 | #define INIT_G_var() do { \ |
1791 | int i; \ | 1790 | int i; \ |
1792 | (*(struct globals_var**)&ptr_to_globals_var) = xzalloc(sizeof(G_var)); \ | 1791 | (*(struct globals_var**)&ash_ptr_to_globals_var) = xzalloc(sizeof(G_var)); \ |
1792 | barrier(); \ | ||
1793 | for (i = 0; i < ARRAY_SIZE(varinit_data); i++) { \ | 1793 | for (i = 0; i < ARRAY_SIZE(varinit_data); i++) { \ |
1794 | varinit[i].flags = varinit_data[i].flags; \ | 1794 | varinit[i].flags = varinit_data[i].flags; \ |
1795 | varinit[i].text = varinit_data[i].text; \ | 1795 | varinit[i].text = varinit_data[i].text; \ |
diff --git a/shell/ash_ptr_hack.c b/shell/ash_ptr_hack.c new file mode 100644 index 000000000..490b73b6d --- /dev/null +++ b/shell/ash_ptr_hack.c | |||
@@ -0,0 +1,16 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
2 | /* | ||
3 | * Copyright (C) 2008 by Denys Vlasenko <vda.linux@googlemail.com> | ||
4 | * | ||
5 | * Licensed under GPLv2, see file LICENSE in this tarball for details. | ||
6 | */ | ||
7 | |||
8 | /* We cheat here. They are declared as const ptr in ash.c, | ||
9 | * but here we make them live in R/W memory */ | ||
10 | struct globals_misc; | ||
11 | struct globals_memstack; | ||
12 | struct globals_var; | ||
13 | |||
14 | struct globals_misc *ash_ptr_to_globals_misc; | ||
15 | struct globals_memstack *ash_ptr_to_globals_memstack; | ||
16 | struct globals_var *ash_ptr_to_globals_var; | ||
diff --git a/shell/hush.c b/shell/hush.c index d9ef2390e..b44f35bdd 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -460,6 +460,9 @@ enum { run_list_level = 0 }; | |||
460 | #endif | 460 | #endif |
461 | #define charmap (G.charmap ) | 461 | #define charmap (G.charmap ) |
462 | #define user_input_buf (G.user_input_buf ) | 462 | #define user_input_buf (G.user_input_buf ) |
463 | #define INIT_G() do { \ | ||
464 | SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ | ||
465 | } while (0) | ||
463 | 466 | ||
464 | 467 | ||
465 | #define B_CHUNK 100 | 468 | #define B_CHUNK 100 |
@@ -3778,7 +3781,7 @@ int hush_main(int argc, char **argv) | |||
3778 | char **e; | 3781 | char **e; |
3779 | struct variable *cur_var; | 3782 | struct variable *cur_var; |
3780 | 3783 | ||
3781 | PTR_TO_GLOBALS = xzalloc(sizeof(G)); | 3784 | INIT_G(); |
3782 | 3785 | ||
3783 | /* Deal with HUSH_VERSION */ | 3786 | /* Deal with HUSH_VERSION */ |
3784 | shell_ver = const_shell_ver; /* copying struct here */ | 3787 | shell_ver = const_shell_ver; /* copying struct here */ |
diff --git a/shell/msh.c b/shell/msh.c index 917b08a1e..569011bbd 100644 --- a/shell/msh.c +++ b/shell/msh.c | |||
@@ -705,7 +705,7 @@ struct globals { | |||
705 | #define child_cmd (G.child_cmd ) | 705 | #define child_cmd (G.child_cmd ) |
706 | #define iostack (G.iostack ) | 706 | #define iostack (G.iostack ) |
707 | #define INIT_G() do { \ | 707 | #define INIT_G() do { \ |
708 | PTR_TO_GLOBALS = xzalloc(sizeof(G)); \ | 708 | SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ |
709 | global_env.linep = line; \ | 709 | global_env.linep = line; \ |
710 | global_env.iobase = iostack; \ | 710 | global_env.iobase = iostack; \ |
711 | global_env.iop = iostack - 1; \ | 711 | global_env.iop = iostack - 1; \ |