aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorYU Jincheng <shana@zju.edu.cn>2021-09-29 17:37:26 +0800
committerDenys Vlasenko <vda.linux@googlemail.com>2021-10-07 15:22:35 +0200
commit1f925038ab9c6bd8f6b3cd40ed7aab0ef10d898e (patch)
treea625455a60081738812f469de6a02010f0c5b252 /shell
parent17e6fb06b3d36eae11575b226858e8474e2b46d3 (diff)
downloadbusybox-w32-1f925038ab9c6bd8f6b3cd40ed7aab0ef10d898e.tar.gz
busybox-w32-1f925038ab9c6bd8f6b3cd40ed7aab0ef10d898e.tar.bz2
busybox-w32-1f925038ab9c6bd8f6b3cd40ed7aab0ef10d898e.zip
*: generalize "const trick"
While at it, change all "__asm__" to "asm" Co-authored-by: canyie <31466456+canyie@users.noreply.github.com> Signed-off-by: YU Jincheng <shana@zju.edu.cn> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
-rw-r--r--shell/ash.c23
1 files changed, 3 insertions, 20 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 4bf0615ea..7b85981ec 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -303,20 +303,6 @@ typedef long arith_t;
303# error "Do not even bother, ash will not run on NOMMU machine" 303# error "Do not even bother, ash will not run on NOMMU machine"
304#endif 304#endif
305 305
306/* We use a trick to have more optimized code (fewer pointer reloads):
307 * ash.c: extern struct globals *const ash_ptr_to_globals;
308 * ash_ptr_hack.c: struct globals *ash_ptr_to_globals;
309 * This way, compiler in ash.c knows the pointer can not change.
310 *
311 * However, this may break on weird arches or toolchains. In this case,
312 * set "-DBB_GLOBAL_CONST=''" in CONFIG_EXTRA_CFLAGS to disable
313 * this optimization.
314 */
315#ifndef BB_GLOBAL_CONST
316# define BB_GLOBAL_CONST const
317#endif
318
319
320/* ============ Hash table sizes. Configurable. */ 306/* ============ Hash table sizes. Configurable. */
321 307
322#define VTABSIZE 39 308#define VTABSIZE 39
@@ -518,8 +504,7 @@ extern struct globals_misc *BB_GLOBAL_CONST ash_ptr_to_globals_misc;
518#define random_gen (G_misc.random_gen ) 504#define random_gen (G_misc.random_gen )
519#define backgndpid (G_misc.backgndpid ) 505#define backgndpid (G_misc.backgndpid )
520#define INIT_G_misc() do { \ 506#define INIT_G_misc() do { \
521 (*(struct globals_misc**)not_const_pp(&ash_ptr_to_globals_misc)) = xzalloc(sizeof(G_misc)); \ 507 ASSIGN_CONST_PTR(ash_ptr_to_globals_misc, xzalloc(sizeof(G_misc))); \
522 barrier(); \
523 savestatus = -1; \ 508 savestatus = -1; \
524 curdir = nullstr; \ 509 curdir = nullstr; \
525 physdir = nullstr; \ 510 physdir = nullstr; \
@@ -1597,8 +1582,7 @@ extern struct globals_memstack *BB_GLOBAL_CONST ash_ptr_to_globals_memstack;
1597#define g_stacknleft (G_memstack.g_stacknleft) 1582#define g_stacknleft (G_memstack.g_stacknleft)
1598#define stackbase (G_memstack.stackbase ) 1583#define stackbase (G_memstack.stackbase )
1599#define INIT_G_memstack() do { \ 1584#define INIT_G_memstack() do { \
1600 (*(struct globals_memstack**)not_const_pp(&ash_ptr_to_globals_memstack)) = xzalloc(sizeof(G_memstack)); \ 1585 ASSIGN_CONST_PTR(ash_ptr_to_globals_memstack, xzalloc(sizeof(G_memstack))); \
1601 barrier(); \
1602 g_stackp = &stackbase; \ 1586 g_stackp = &stackbase; \
1603 g_stacknxt = stackbase.space; \ 1587 g_stacknxt = stackbase.space; \
1604 g_stacknleft = MINSIZE; \ 1588 g_stacknleft = MINSIZE; \
@@ -2229,8 +2213,7 @@ extern struct globals_var *BB_GLOBAL_CONST ash_ptr_to_globals_var;
2229#endif 2213#endif
2230#define INIT_G_var() do { \ 2214#define INIT_G_var() do { \
2231 unsigned i; \ 2215 unsigned i; \
2232 (*(struct globals_var**)not_const_pp(&ash_ptr_to_globals_var)) = xzalloc(sizeof(G_var)); \ 2216 ASSIGN_CONST_PTR(ash_ptr_to_globals_var, xzalloc(sizeof(G_var))); \
2233 barrier(); \
2234 for (i = 0; i < ARRAY_SIZE(varinit_data); i++) { \ 2217 for (i = 0; i < ARRAY_SIZE(varinit_data); i++) { \
2235 varinit[i].flags = varinit_data[i].flags; \ 2218 varinit[i].flags = varinit_data[i].flags; \
2236 varinit[i].var_text = varinit_data[i].var_text; \ 2219 varinit[i].var_text = varinit_data[i].var_text; \