From b9d3050e201add911cbe41fe98d12ac399bf82d5 Mon Sep 17 00:00:00 2001 From: christos Date: Fri, 4 Oct 2002 13:15:51 +0000 Subject: [PATCH] Rename ALIGN to SHELL_ALIGN and simplify macro so that it does not have side effects, and add double to it, so that it aligns doubles correctly too. This is just a workaround to fix the sparc64 problem where ALIGN() is now defined in some include file to be 16 instead of 8. Thanks to martin for debugging this. --- bin/sh/machdep.h | 12 +++--------- bin/sh/memalloc.c | 10 +++++----- bin/sh/mknodes.c | 7 ++++--- bin/sh/nodes.c.pat | 7 ++++--- 4 files changed, 16 insertions(+), 20 deletions(-) diff --git a/bin/sh/machdep.h b/bin/sh/machdep.h index c9452eb455db..fcfffcf9ae89 100644 --- a/bin/sh/machdep.h +++ b/bin/sh/machdep.h @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.h,v 1.8 1995/05/11 21:29:21 christos Exp $ */ +/* $NetBSD: machdep.h,v 1.9 2002/10/04 13:15:51 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -43,11 +43,5 @@ * in some way. The following macro will get this right on many machines. */ -#ifndef ALIGN -union align { - int i; - char *cp; -}; - -#define ALIGN(nbytes) (((nbytes) + sizeof(union align) - 1) & ~(sizeof(union align) - 1)) -#endif +#define SHELL_SIZE (sizeof(union {int i; char *cp; double d; }) - 1) +#define SHELL_ALIGN(nbytes) (((nbytes) + SHELL_SIZE) & ~SHELL_SIZE) diff --git a/bin/sh/memalloc.c b/bin/sh/memalloc.c index 6b207948e648..ab1491e48d5b 100644 --- a/bin/sh/memalloc.c +++ b/bin/sh/memalloc.c @@ -1,4 +1,4 @@ -/* $NetBSD: memalloc.c,v 1.23 2000/11/01 19:56:01 christos Exp $ */ +/* $NetBSD: memalloc.c,v 1.24 2002/10/04 13:15:51 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)memalloc.c 8.3 (Berkeley) 5/4/95"; #else -__RCSID("$NetBSD: memalloc.c,v 1.23 2000/11/01 19:56:01 christos Exp $"); +__RCSID("$NetBSD: memalloc.c,v 1.24 2002/10/04 13:15:51 christos Exp $"); #endif #endif /* not lint */ @@ -139,7 +139,7 @@ stalloc(nbytes) { char *p; - nbytes = ALIGN(nbytes); + nbytes = SHELL_ALIGN(nbytes); if (nbytes > stacknleft) { int blocksize; struct stack_block *sp; @@ -220,7 +220,7 @@ popstackmark(mark) void growstackblock() { char *p; - int newlen = ALIGN(stacknleft * 2 + 100); + int newlen = SHELL_ALIGN(stacknleft * 2 + 100); char *oldspace = stacknxt; int oldlen = stacknleft; struct stack_block *sp; @@ -264,7 +264,7 @@ void grabstackblock(len) int len; { - len = ALIGN(len); + len = SHELL_ALIGN(len); stacknxt += len; stacknleft -= len; } diff --git a/bin/sh/mknodes.c b/bin/sh/mknodes.c index 9bc6f0724ad3..6f0559cf78d2 100644 --- a/bin/sh/mknodes.c +++ b/bin/sh/mknodes.c @@ -1,4 +1,4 @@ -/* $NetBSD: mknodes.c,v 1.19 2002/05/25 23:09:06 wiz Exp $ */ +/* $NetBSD: mknodes.c,v 1.20 2002/10/04 13:15:51 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -47,7 +47,7 @@ static const char copyright[] = static char sccsid[] = "@(#)mknodes.c 8.2 (Berkeley) 5/4/95"; #else static const char rcsid[] = - "$NetBSD: mknodes.c,v 1.19 2002/05/25 23:09:06 wiz Exp $"; + "$NetBSD: mknodes.c,v 1.20 2002/10/04 13:15:51 christos Exp $"; #endif #endif /* not lint */ @@ -292,7 +292,8 @@ outsizes(cfile) fprintf(cfile, "static const short nodesize[%d] = {\n", ntypes); for (i = 0 ; i < ntypes ; i++) { - fprintf(cfile, " ALIGN(sizeof (struct %s)),\n", nodestr[i]->tag); + fprintf(cfile, " SHELL_ALIGN(sizeof (struct %s)),\n", + nodestr[i]->tag); } fprintf(cfile, "};\n"); } diff --git a/bin/sh/nodes.c.pat b/bin/sh/nodes.c.pat index 3b6c87529280..c04e0fbe51b4 100644 --- a/bin/sh/nodes.c.pat +++ b/bin/sh/nodes.c.pat @@ -1,4 +1,4 @@ -/* $NetBSD: nodes.c.pat,v 1.8 1997/04/11 23:03:09 christos Exp $ */ +/* $NetBSD: nodes.c.pat,v 1.9 2002/10/04 13:15:51 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -100,7 +100,7 @@ sizenodelist(lp) struct nodelist *lp; { while (lp) { - funcblocksize += ALIGN(sizeof(struct nodelist)); + funcblocksize += SHELL_ALIGN(sizeof(struct nodelist)); calcsize(lp->n); lp = lp->next; } @@ -129,7 +129,8 @@ copynodelist(lp) lpp = &start; while (lp) { *lpp = funcblock; - funcblock = (char *) funcblock + ALIGN(sizeof(struct nodelist)); + funcblock = (char *) funcblock + + SHELL_ALIGN(sizeof(struct nodelist)); (*lpp)->n = copynode(lp->n); lp = lp->next; lpp = &(*lpp)->next;