aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-01-28 20:41:23 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2018-01-28 20:41:23 +0100
commit6f9442ff30f2fa7b66395935b0f59b01ecc89f0e (patch)
tree58fcee93b06a807e14a09811f4e04e9c095c8390
parentf19e3c1c6c96e3c709ac732ff70c586521f792d3 (diff)
downloadbusybox-w32-6f9442ff30f2fa7b66395935b0f59b01ecc89f0e.tar.gz
busybox-w32-6f9442ff30f2fa7b66395935b0f59b01ecc89f0e.tar.bz2
busybox-w32-6f9442ff30f2fa7b66395935b0f59b01ecc89f0e.zip
ash: make it possible to disable "const global ptr" optimization
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--shell/ash.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 6b7386f79..4c1b5e409 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -263,6 +263,19 @@ typedef long arith_t;
263# error "Do not even bother, ash will not run on NOMMU machine" 263# error "Do not even bother, ash will not run on NOMMU machine"
264#endif 264#endif
265 265
266/* We use a trick to have more optimized code (fewer pointer reloads):
267 * ash.c: extern struct globals *const ash_ptr_to_globals;
268 * ash_ptr_hack.c: struct globals *ash_ptr_to_globals;
269 * This way, compiler in ash.c knows the pointer can not change.
270 *
271 * However, this may break on weird arches or toolchains. In this case,
272 * set "-DBB_GLOBAL_CONST=''" in CONFIG_EXTRA_CFLAGS to disable
273 * this optimization.
274 */
275#ifndef BB_GLOBAL_CONST
276# define BB_GLOBAL_CONST const
277#endif
278
266 279
267/* ============ Hash table sizes. Configurable. */ 280/* ============ Hash table sizes. Configurable. */
268 281
@@ -400,7 +413,7 @@ struct globals_misc {
400#endif 413#endif
401 pid_t backgndpid; /* pid of last background process */ 414 pid_t backgndpid; /* pid of last background process */
402}; 415};
403extern struct globals_misc *const ash_ptr_to_globals_misc; 416extern struct globals_misc *BB_GLOBAL_CONST ash_ptr_to_globals_misc;
404#define G_misc (*ash_ptr_to_globals_misc) 417#define G_misc (*ash_ptr_to_globals_misc)
405#define exitstatus (G_misc.exitstatus ) 418#define exitstatus (G_misc.exitstatus )
406#define back_exitstatus (G_misc.back_exitstatus ) 419#define back_exitstatus (G_misc.back_exitstatus )
@@ -1473,7 +1486,7 @@ struct globals_memstack {
1473 size_t g_stacknleft; // = MINSIZE; 1486 size_t g_stacknleft; // = MINSIZE;
1474 struct stack_block stackbase; 1487 struct stack_block stackbase;
1475}; 1488};
1476extern struct globals_memstack *const ash_ptr_to_globals_memstack; 1489extern struct globals_memstack *BB_GLOBAL_CONST ash_ptr_to_globals_memstack;
1477#define G_memstack (*ash_ptr_to_globals_memstack) 1490#define G_memstack (*ash_ptr_to_globals_memstack)
1478#define g_stackp (G_memstack.g_stackp ) 1491#define g_stackp (G_memstack.g_stackp )
1479#define g_stacknxt (G_memstack.g_stacknxt ) 1492#define g_stacknxt (G_memstack.g_stacknxt )
@@ -2062,7 +2075,7 @@ struct globals_var {
2062 int lineno; 2075 int lineno;
2063 char linenovar[sizeof("LINENO=") + sizeof(int)*3]; 2076 char linenovar[sizeof("LINENO=") + sizeof(int)*3];
2064}; 2077};
2065extern struct globals_var *const ash_ptr_to_globals_var; 2078extern struct globals_var *BB_GLOBAL_CONST ash_ptr_to_globals_var;
2066#define G_var (*ash_ptr_to_globals_var) 2079#define G_var (*ash_ptr_to_globals_var)
2067#define shellparam (G_var.shellparam ) 2080#define shellparam (G_var.shellparam )
2068//#define redirlist (G_var.redirlist ) 2081//#define redirlist (G_var.redirlist )