reduce stack usage a bit (several candidates for more, including $CC itself…)

This commit is contained in:
tg 2012-01-29 01:41:15 +00:00
parent 8b023994de
commit bee3bbaaf8
5 changed files with 36 additions and 18 deletions

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.513 2012/01/14 19:20:17 tg Exp $ # $MirOS: src/bin/mksh/check.t,v 1.514 2012/01/29 01:41:09 tg Exp $
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $ # $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $ # $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $ # $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
@ -29,7 +29,7 @@
# http://www.freebsd.org/cgi/cvsweb.cgi/src/tools/regression/bin/test/regress.sh?rev=HEAD # http://www.freebsd.org/cgi/cvsweb.cgi/src/tools/regression/bin/test/regress.sh?rev=HEAD
expected-stdout: expected-stdout:
@(#)MIRBSD KSH R40 2012/01/04 @(#)MIRBSD KSH R40 2012/01/28
description: description:
Check version of shell. Check version of shell.
stdin: stdin:

4
edit.c

@ -25,7 +25,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.226 2011/12/29 23:36:10 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/edit.c,v 1.227 2012/01/29 01:41:12 tg Exp $");
/* /*
* in later versions we might use libtermcap for this, but since external * in later versions we might use libtermcap for this, but since external
@ -1802,7 +1802,7 @@ static int
x_search_hist(int c) x_search_hist(int c)
{ {
int offset = -1; /* offset of match in xbuf, else -1 */ int offset = -1; /* offset of match in xbuf, else -1 */
char pat[256 + 1]; /* pattern buffer */ char pat[80 + 1]; /* pattern buffer */
char *p = pat; char *p = pat;
unsigned char f; unsigned char f;

@ -38,7 +38,7 @@
#endif #endif
#endif #endif
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.206 2011/12/29 22:54:19 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.207 2012/01/29 01:41:13 tg Exp $");
#if HAVE_KILLPG #if HAVE_KILLPG
/* /*
@ -1759,11 +1759,11 @@ c_wait(const char **wp)
return (rv); return (rv);
} }
static char REPLY[] = "REPLY";
int int
c_read(const char **wp) c_read(const char **wp)
{ {
#define is_ifsws(c) (ctype((c), C_IFS) && ctype((c), C_IFSWS)) #define is_ifsws(c) (ctype((c), C_IFS) && ctype((c), C_IFSWS))
static char REPLY[] = "REPLY";
int c, fd = 0, rv = 0, lastparm = 0; int c, fd = 0, rv = 0, lastparm = 0;
bool savehist = false, intoarray = false, aschars = false; bool savehist = false, intoarray = false, aschars = false;
bool rawmode = false, expanding = false; bool rawmode = false, expanding = false;

38
main.c

@ -4,7 +4,8 @@
/* $OpenBSD: table.c,v 1.13 2009/01/17 22:06:44 millert Exp $ */ /* $OpenBSD: table.c,v 1.13 2009/01/17 22:06:44 millert Exp $ */
/*- /*-
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 * Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
* 2011, 2012
* Thorsten Glaser <tg@mirbsd.org> * Thorsten Glaser <tg@mirbsd.org>
* *
* Provided that these terms and disclaimer and all copyright notices * Provided that these terms and disclaimer and all copyright notices
@ -33,7 +34,7 @@
#include <locale.h> #include <locale.h>
#endif #endif
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.201 2011/11/08 22:07:14 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/main.c,v 1.202 2012/01/29 01:41:14 tg Exp $");
extern char **environ; extern char **environ;
@ -45,6 +46,7 @@ extern char **environ;
#define MKSH_DEFAULT_TMPDIR "/tmp" #define MKSH_DEFAULT_TMPDIR "/tmp"
#endif #endif
static int main_init(int, const char *[], Source **, struct block **);
void chvt_reinit(void); void chvt_reinit(void);
static void reclaim(void); static void reclaim(void);
static void remove_temps(struct temp *); static void remove_temps(struct temp *);
@ -155,8 +157,8 @@ static const char *empty_argv[] = {
"mksh", NULL "mksh", NULL
}; };
int static int
main(int argc, const char *argv[]) main_init(int argc, const char *argv[], Source **sp, struct block **lp)
{ {
int argi, i; int argi, i;
Source *s = NULL; Source *s = NULL;
@ -594,15 +596,31 @@ main(int argc, const char *argv[])
alarm_init(); alarm_init();
if (Flag(FAS_BUILTIN)) *sp = s;
return (shcomexec(l->argv)); *lp = l;
/* doesn't return */
shell(s, true);
/* NOTREACHED */
return (0); return (0);
} }
/* this indirection barrier reduces stack usage during normal operation */
int
main(int argc, const char *argv[])
{
int rv;
Source *s;
struct block *l;
if ((rv = main_init(argc, argv, &s, &l)) == 0) {
if (Flag(FAS_BUILTIN)) {
rv = shcomexec(l->argv);
} else {
shell(s, true);
/* NOTREACHED */
}
}
return (rv);
}
int int
include(const char *name, int argc, const char **argv, int intr_ok) include(const char *name, int argc, const char **argv, int intr_ok)
{ {

4
sh.h

@ -152,9 +152,9 @@
#endif #endif
#ifdef EXTERN #ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.519 2012/01/04 19:09:36 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/sh.h,v 1.520 2012/01/29 01:41:15 tg Exp $");
#endif #endif
#define MKSH_VERSION "R40 2012/01/04" #define MKSH_VERSION "R40 2012/01/28"
/* arithmetic types: C implementation */ /* arithmetic types: C implementation */
#if !HAVE_CAN_INTTYPES #if !HAVE_CAN_INTTYPES