"evil" workaround to the alignment issues: embed an ALLOC_ITEM into
struct env (other structures defined have no "foreign type with pos- sible alignment constraints" members) and take care of it while dea- ling in a struct env instance
This commit is contained in:
parent
48ee59ffd0
commit
8cc7fdb834
4
check.t
4
check.t
@ -1,4 +1,4 @@
|
||||
# $MirOS: src/bin/mksh/check.t,v 1.269 2009/04/06 08:33:36 tg Exp $
|
||||
# $MirOS: src/bin/mksh/check.t,v 1.270 2009/04/07 19:43:26 tg 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: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
|
||||
@ -7,7 +7,7 @@
|
||||
# http://www.research.att.com/~gsf/public/ifs.sh
|
||||
|
||||
expected-stdout:
|
||||
@(#)MIRBSD KSH R37 2009/04/05
|
||||
@(#)MIRBSD KSH R37 2009/04/07
|
||||
description:
|
||||
Check version of shell.
|
||||
stdin:
|
||||
|
24
main.c
24
main.c
@ -13,7 +13,7 @@
|
||||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.124 2009/04/05 12:35:31 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.125 2009/04/07 19:43:27 tg Exp $");
|
||||
|
||||
extern char **environ;
|
||||
|
||||
@ -620,15 +620,23 @@ void
|
||||
newenv(int type)
|
||||
{
|
||||
struct env *ep;
|
||||
char *cp;
|
||||
|
||||
ep = alloc(sizeof (struct env), ATEMP);
|
||||
ep->type = type;
|
||||
ep->flags = 0;
|
||||
/*
|
||||
* struct env includes ALLOC_ITEM for alignment constraints
|
||||
* so first get the actually used memory, then assign it
|
||||
*/
|
||||
cp = alloc(sizeof (struct env) - ALLOC_SIZE, ATEMP);
|
||||
ep = (void *)(cp - ALLOC_SIZE); /* undo what alloc() did */
|
||||
/* initialise public members of struct env (not the ALLOC_ITEM) */
|
||||
ainit(&ep->area);
|
||||
ep->oenv = e;
|
||||
ep->loc = e->loc;
|
||||
ep->savefd = NULL;
|
||||
ep->oenv = e;
|
||||
ep->temps = NULL;
|
||||
ep->type = type;
|
||||
ep->flags = 0;
|
||||
/* jump buffer is invalid because flags == 0 */
|
||||
e = ep;
|
||||
}
|
||||
|
||||
@ -636,6 +644,7 @@ void
|
||||
quitenv(struct shf *shf)
|
||||
{
|
||||
struct env *ep = e;
|
||||
char *cp;
|
||||
int fd;
|
||||
|
||||
if (ep->oenv && ep->oenv->loc != ep->loc)
|
||||
@ -684,7 +693,10 @@ quitenv(struct shf *shf)
|
||||
reclaim();
|
||||
|
||||
e = e->oenv;
|
||||
afree(ep, ATEMP);
|
||||
|
||||
/* free the struct env - tricky due to the ALLOC_ITEM inside */
|
||||
cp = (void *)ep;
|
||||
afree(cp + ALLOC_SIZE, ATEMP);
|
||||
}
|
||||
|
||||
/* Called after a fork to cleanup stuff left over from parents environment */
|
||||
|
7
sh.h
7
sh.h
@ -102,9 +102,9 @@
|
||||
#define __SCCSID(x) __IDSTRING(sccsid,x)
|
||||
|
||||
#ifdef EXTERN
|
||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.292 2009/04/07 18:56:51 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.293 2009/04/07 19:43:28 tg Exp $");
|
||||
#endif
|
||||
#define MKSH_VERSION "R37 2009/04/05"
|
||||
#define MKSH_VERSION "R37 2009/04/07"
|
||||
|
||||
#ifndef MKSH_INCLUDES_ONLY
|
||||
|
||||
@ -445,10 +445,11 @@ EXTERN Area aperm; /* permanent object space */
|
||||
* parsing & execution environment
|
||||
*/
|
||||
extern struct env {
|
||||
ALLOC_ITEM __alloc_i; /* internal, do not touch */
|
||||
Area area; /* temporary allocation area */
|
||||
struct env *oenv; /* link to previous environment */
|
||||
struct block *loc; /* local variables and functions */
|
||||
short *savefd; /* original redirected fds */
|
||||
struct env *oenv; /* link to previous environment */
|
||||
struct temp *temps; /* temp files */
|
||||
sigjmp_buf jbuf; /* long jump back to env creator */
|
||||
short type; /* environment type - see below */
|
||||
|
Loading…
x
Reference in New Issue
Block a user