diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-06-27 00:23:18 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-06-27 00:23:18 +0000 |
commit | 843cbd54d1703e54234a2496efc920f56cd3f318 (patch) | |
tree | c3737a883814db25432c6047593f16d067feb1df | |
parent | 9092f754bd4afc5f0928ee3041abb950f749b9e1 (diff) | |
download | busybox-w32-843cbd54d1703e54234a2496efc920f56cd3f318.tar.gz busybox-w32-843cbd54d1703e54234a2496efc920f56cd3f318.tar.bz2 busybox-w32-843cbd54d1703e54234a2496efc920f56cd3f318.zip |
ash: move stuff out of data/bss
text data bss dec hex filename
807939 611 6900 815450 c715a busybox_old
807935 611 6884 815430 c7146 busybox_unstripped
-rw-r--r-- | shell/ash.c | 123 |
1 files changed, 58 insertions, 65 deletions
diff --git a/shell/ash.c b/shell/ash.c index dd20fe338..4a3d2d48e 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -110,27 +110,6 @@ static const char *const optletters_optnames[] = { | |||
110 | 110 | ||
111 | enum { NOPTS = ARRAY_SIZE(optletters_optnames) }; | 111 | enum { NOPTS = ARRAY_SIZE(optletters_optnames) }; |
112 | 112 | ||
113 | static char optlist[NOPTS] ALIGN1; | ||
114 | |||
115 | #define eflag optlist[0] | ||
116 | #define fflag optlist[1] | ||
117 | #define Iflag optlist[2] | ||
118 | #define iflag optlist[3] | ||
119 | #define mflag optlist[4] | ||
120 | #define nflag optlist[5] | ||
121 | #define sflag optlist[6] | ||
122 | #define xflag optlist[7] | ||
123 | #define vflag optlist[8] | ||
124 | #define Cflag optlist[9] | ||
125 | #define aflag optlist[10] | ||
126 | #define bflag optlist[11] | ||
127 | #define uflag optlist[12] | ||
128 | #define viflag optlist[13] | ||
129 | #if DEBUG | ||
130 | #define nolog optlist[14] | ||
131 | #define debug optlist[15] | ||
132 | #endif | ||
133 | |||
134 | 113 | ||
135 | /* ============ Misc data */ | 114 | /* ============ Misc data */ |
136 | 115 | ||
@@ -183,10 +162,30 @@ struct globals_misc { | |||
183 | #define EXEXIT 4 /* exit the shell */ | 162 | #define EXEXIT 4 /* exit the shell */ |
184 | #define EXSIG 5 /* trapped signal in wait(1) */ | 163 | #define EXSIG 5 /* trapped signal in wait(1) */ |
185 | 164 | ||
186 | /* trap handler commands */ | ||
187 | smallint isloginsh; | 165 | smallint isloginsh; |
188 | char *trap[NSIG]; | ||
189 | char nullstr[1]; /* zero length string */ | 166 | char nullstr[1]; /* zero length string */ |
167 | |||
168 | char optlist[NOPTS]; | ||
169 | #define eflag optlist[0] | ||
170 | #define fflag optlist[1] | ||
171 | #define Iflag optlist[2] | ||
172 | #define iflag optlist[3] | ||
173 | #define mflag optlist[4] | ||
174 | #define nflag optlist[5] | ||
175 | #define sflag optlist[6] | ||
176 | #define xflag optlist[7] | ||
177 | #define vflag optlist[8] | ||
178 | #define Cflag optlist[9] | ||
179 | #define aflag optlist[10] | ||
180 | #define bflag optlist[11] | ||
181 | #define uflag optlist[12] | ||
182 | #define viflag optlist[13] | ||
183 | #if DEBUG | ||
184 | #define nolog optlist[14] | ||
185 | #define debug optlist[15] | ||
186 | #endif | ||
187 | |||
188 | /* trap handler commands */ | ||
190 | /* | 189 | /* |
191 | * Sigmode records the current value of the signal handlers for the various | 190 | * Sigmode records the current value of the signal handlers for the various |
192 | * modes. A value of zero means that the current handler is not known. | 191 | * modes. A value of zero means that the current handler is not known. |
@@ -201,6 +200,7 @@ struct globals_misc { | |||
201 | 200 | ||
202 | /* indicates specified signal received */ | 201 | /* indicates specified signal received */ |
203 | char gotsig[NSIG - 1]; | 202 | char gotsig[NSIG - 1]; |
203 | char *trap[NSIG]; | ||
204 | }; | 204 | }; |
205 | extern struct globals_misc *const ash_ptr_to_globals_misc; | 205 | extern struct globals_misc *const ash_ptr_to_globals_misc; |
206 | #define G_misc (*ash_ptr_to_globals_misc) | 206 | #define G_misc (*ash_ptr_to_globals_misc) |
@@ -217,10 +217,11 @@ extern struct globals_misc *const ash_ptr_to_globals_misc; | |||
217 | //#define exsig (G_misc.exsig ) | 217 | //#define exsig (G_misc.exsig ) |
218 | #define pendingsig (G_misc.pendingsig ) | 218 | #define pendingsig (G_misc.pendingsig ) |
219 | #define isloginsh (G_misc.isloginsh) | 219 | #define isloginsh (G_misc.isloginsh) |
220 | #define trap (G_misc.trap ) | ||
221 | #define nullstr (G_misc.nullstr ) | 220 | #define nullstr (G_misc.nullstr ) |
221 | #define optlist (G_misc.optlist ) | ||
222 | #define sigmode (G_misc.sigmode ) | 222 | #define sigmode (G_misc.sigmode ) |
223 | #define gotsig (G_misc.gotsig ) | 223 | #define gotsig (G_misc.gotsig ) |
224 | #define trap (G_misc.trap ) | ||
224 | #define INIT_G_misc() do { \ | 225 | #define INIT_G_misc() do { \ |
225 | (*(struct globals_misc**)&ash_ptr_to_globals_misc) = xzalloc(sizeof(G_misc)); \ | 226 | (*(struct globals_misc**)&ash_ptr_to_globals_misc) = xzalloc(sizeof(G_misc)); \ |
226 | barrier(); \ | 227 | barrier(); \ |
@@ -237,11 +238,10 @@ extern struct globals_misc *const ash_ptr_to_globals_misc; | |||
237 | * much more efficient and portable. (But hacking the kernel is so much | 238 | * much more efficient and portable. (But hacking the kernel is so much |
238 | * more fun than worrying about efficiency and portability. :-)) | 239 | * more fun than worrying about efficiency and portability. :-)) |
239 | */ | 240 | */ |
240 | #define INT_OFF \ | 241 | #define INT_OFF do { \ |
241 | do { \ | 242 | suppressint++; \ |
242 | suppressint++; \ | 243 | xbarrier(); \ |
243 | xbarrier(); \ | 244 | } while (0) |
244 | } while (0) | ||
245 | 245 | ||
246 | /* | 246 | /* |
247 | * Called to raise an exception. Since C doesn't include exceptions, we | 247 | * Called to raise an exception. Since C doesn't include exceptions, we |
@@ -311,30 +311,27 @@ force_int_on(void) | |||
311 | } | 311 | } |
312 | #define FORCE_INT_ON force_int_on() | 312 | #define FORCE_INT_ON force_int_on() |
313 | #else | 313 | #else |
314 | #define INT_ON \ | 314 | #define INT_ON do { \ |
315 | do { \ | 315 | xbarrier(); \ |
316 | xbarrier(); \ | 316 | if (--suppressint == 0 && intpending) \ |
317 | if (--suppressint == 0 && intpending) \ | 317 | raise_interrupt(); \ |
318 | raise_interrupt(); \ | 318 | } while (0) |
319 | } while (0) | 319 | #define FORCE_INT_ON do { \ |
320 | #define FORCE_INT_ON \ | 320 | xbarrier(); \ |
321 | do { \ | 321 | suppressint = 0; \ |
322 | xbarrier(); \ | 322 | if (intpending) \ |
323 | suppressint = 0; \ | 323 | raise_interrupt(); \ |
324 | if (intpending) \ | 324 | } while (0) |
325 | raise_interrupt(); \ | ||
326 | } while (0) | ||
327 | #endif /* ASH_OPTIMIZE_FOR_SIZE */ | 325 | #endif /* ASH_OPTIMIZE_FOR_SIZE */ |
328 | 326 | ||
329 | #define SAVE_INT(v) ((v) = suppressint) | 327 | #define SAVE_INT(v) ((v) = suppressint) |
330 | 328 | ||
331 | #define RESTORE_INT(v) \ | 329 | #define RESTORE_INT(v) do { \ |
332 | do { \ | 330 | xbarrier(); \ |
333 | xbarrier(); \ | 331 | suppressint = (v); \ |
334 | suppressint = (v); \ | 332 | if (suppressint == 0 && intpending) \ |
335 | if (suppressint == 0 && intpending) \ | 333 | raise_interrupt(); \ |
336 | raise_interrupt(); \ | 334 | } while (0) |
337 | } while (0) | ||
338 | 335 | ||
339 | /* | 336 | /* |
340 | * Ignore a signal. Only one usage site - in forkchild() | 337 | * Ignore a signal. Only one usage site - in forkchild() |
@@ -985,9 +982,7 @@ struct strlist { | |||
985 | char *text; | 982 | char *text; |
986 | }; | 983 | }; |
987 | 984 | ||
988 | #if ENABLE_ASH_ALIAS | ||
989 | struct alias; | 985 | struct alias; |
990 | #endif | ||
991 | 986 | ||
992 | struct strpush { | 987 | struct strpush { |
993 | struct strpush *prev; /* preceding string on stack */ | 988 | struct strpush *prev; /* preceding string on stack */ |
@@ -1452,21 +1447,19 @@ _STPUTC(int c, char *p) | |||
1452 | 1447 | ||
1453 | #define STARTSTACKSTR(p) ((p) = stackblock()) | 1448 | #define STARTSTACKSTR(p) ((p) = stackblock()) |
1454 | #define STPUTC(c, p) ((p) = _STPUTC((c), (p))) | 1449 | #define STPUTC(c, p) ((p) = _STPUTC((c), (p))) |
1455 | #define CHECKSTRSPACE(n, p) \ | 1450 | #define CHECKSTRSPACE(n, p) do { \ |
1456 | do { \ | 1451 | char *q = (p); \ |
1457 | char *q = (p); \ | 1452 | size_t l = (n); \ |
1458 | size_t l = (n); \ | 1453 | size_t m = sstrend - q; \ |
1459 | size_t m = sstrend - q; \ | 1454 | if (l > m) \ |
1460 | if (l > m) \ | 1455 | (p) = makestrspace(l, q); \ |
1461 | (p) = makestrspace(l, q); \ | 1456 | } while (0) |
1462 | } while (0) | ||
1463 | #define USTPUTC(c, p) (*(p)++ = (c)) | 1457 | #define USTPUTC(c, p) (*(p)++ = (c)) |
1464 | #define STACKSTRNUL(p) \ | 1458 | #define STACKSTRNUL(p) do { \ |
1465 | do { \ | 1459 | if ((p) == sstrend) \ |
1466 | if ((p) == sstrend) \ | 1460 | (p) = growstackstr(); \ |
1467 | (p) = growstackstr(); \ | 1461 | *(p) = '\0'; \ |
1468 | *(p) = '\0'; \ | 1462 | } while (0) |
1469 | } while (0) | ||
1470 | #define STUNPUTC(p) (--(p)) | 1463 | #define STUNPUTC(p) (--(p)) |
1471 | #define STTOPC(p) ((p)[-1]) | 1464 | #define STTOPC(p) ((p)[-1]) |
1472 | #define STADJUST(amount, p) ((p) += (amount)) | 1465 | #define STADJUST(amount, p) ((p) += (amount)) |