I've decided that every time I rant about something on the list, I need to
provide a patch to make up for it, so here's an #ifdefectomy for awk.c.
In gcc 4.3.3, this bloats the code by one byte, and does so in the function
"fsrealloc" which I didn't even _touch_. I boggled at this a bit, and did
this little bit of black magic to take a closer look:
diff -u <(scripts/showasm busybox_old fsrealloc | cut -b 11-) \
<(scripts/showasm busybox_unstripped fsrealloc | cut -b 11-) | less
For some reason, the optimizer is spilling r13 into a global instead of being
able to cache it in edx. I have NO idea why, looks like a bug in gcc to be
honest, and I suspect different gcc versions will behave differently here.
Possibly the above bit of black magic should become a "scripts/bloatcheckdiff"
or similar, with fsrealloc becoming $1 and probably the "cut -b 11-" replaced
with something less hackish...
Rob
--
GPLv3: as worthy a successor as The Phantom Menace, as timely as Duke Nukem
Forever, and as welcome as New Coke.
diff --git a/editors/awk.c b/editors/awk.c
index fb3bf6b..51de3a8 100644
--- a/editors/awk.c
+++ b/editors/awk.c
@@ -524,9 +524,7 @@ static const char EMSG_TOO_FEW_ARGS[] ALIGN1 = "Too few arguments for builtin";
static const char EMSG_NOT_ARRAY[] ALIGN1 = "Not an array";
static const char EMSG_POSSIBLE_ERROR[] ALIGN1 = "Possible syntax error";
static const char EMSG_UNDEF_FUNC[] ALIGN1 = "Call to undefined function";
-#if !ENABLE_FEATURE_AWK_LIBM
static const char EMSG_NO_MATH[] ALIGN1 = "Math support is not compiled in";
-#endif
static void zero_out_var(var *vp)
{
@@ -697,8 +695,7 @@ static ALWAYS_INLINE int isalnum_(int c)
static double my_strtod(char **pp)
{
char *cp = *pp;
-#if ENABLE_DESKTOP
- if (cp[0] == '0') {
+ if (ENABLE_DESKTOP && cp[0] == '0') {
/* Might be hex or octal integer: 0x123abc or 07777 */
char c = (cp[1] | 0x20);
if (c == 'x' || isdigit(cp[1])) {
@@ -715,7 +712,6 @@ static double my_strtod(char **pp)
*/
}
}
-#endif
return strtod(cp, pp);
}
@@ -2164,11 +2160,9 @@ static NOINLINE var *exec_builtin(node *op, var *res)
switch (info) {
case B_a2:
-#if ENABLE_FEATURE_AWK_LIBM
- setvar_i(res, atan2(getvar_i(av[0]), getvar_i(av[1])));
-#else
- syntax_error(EMSG_NO_MATH);
-#endif
+ if (ENABLE_FEATURE_AWK_LIBM)
+ setvar_i(res, atan2(getvar_i(av[0]), getvar_i(av[1])));
+ else syntax_error(EMSG_NO_MATH);
break;
case B_sp: {
@@ -2651,35 +2645,40 @@ static var *evaluate(node *op, var *res)
case F_rn:
R_d = (double)rand() / (double)RAND_MAX;
break;
-#if ENABLE_FEATURE_AWK_LIBM
+
case F_co:
- R_d = cos(L_d);
- break;
+ if (ENABLE_FEATURE_AWK_LIBM) {
+ R_d = cos(L_d);
+ break;
+ }
case F_ex:
- R_d = exp(L_d);
- break;
+ if (ENABLE_FEATURE_AWK_LIBM) {
+ R_d = exp(L_d);
+ break;
+ }
case F_lg:
- R_d = log(L_d);
- break;
+ if (ENABLE_FEATURE_AWK_LIBM) {
+ R_d = log(L_d);
+ break;
+ }
case F_si:
- R_d = sin(L_d);
- break;
+ if (ENABLE_FEATURE_AWK_LIBM) {
+ R_d = sin(L_d);
+ break;
+ }
case F_sq:
- R_d = sqrt(L_d);
- break;
-#else
- case F_co:
- case F_ex:
- case F_lg:
- case F_si:
- case F_sq:
+ if (ENABLE_FEATURE_AWK_LIBM) {
+ R_d = sqrt(L_d);
+ break;
+ }
+
syntax_error(EMSG_NO_MATH);
break;
-#endif
+
case F_sr:
R_d = (double)seed;
seed = op1 ? (unsigned)L_d : (unsigned)time(NULL);
@@ -2830,11 +2829,8 @@ static var *evaluate(node *op, var *res)
L_d /= R_d;
break;
case '&':
-#if ENABLE_FEATURE_AWK_LIBM
- L_d = pow(L_d, R_d);
-#else
- syntax_error(EMSG_NO_MATH);
-#endif
+ if (ENABLE_FEATURE_AWK_LIBM) L_d = pow(L_d, R_d);
+ else syntax_error(EMSG_NO_MATH);
break;
case '%':
if (R_d == 0)
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox