Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/sh Rename ALIGN to SHELL_ALIGN and simplify macro so tha...



details:   https://anonhg.NetBSD.org/src/rev/b59617d71fdd
branches:  trunk
changeset: 537668:b59617d71fdd
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Oct 04 13:15:51 2002 +0000

description:
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.

diffstat:

 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(-)

diffs (124 lines):

diff -r d114f98309a6 -r b59617d71fdd bin/sh/machdep.h
--- a/bin/sh/machdep.h  Fri Oct 04 11:42:38 2002 +0000
+++ b/bin/sh/machdep.h  Fri Oct 04 13:15:51 2002 +0000
@@ -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 -r d114f98309a6 -r b59617d71fdd bin/sh/memalloc.c
--- a/bin/sh/memalloc.c Fri Oct 04 11:42:38 2002 +0000
+++ b/bin/sh/memalloc.c Fri Oct 04 13:15:51 2002 +0000
@@ -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 @@
 {
        char *p;
 
-       nbytes = ALIGN(nbytes);
+       nbytes = SHELL_ALIGN(nbytes);
        if (nbytes > stacknleft) {
                int blocksize;
                struct stack_block *sp;
@@ -220,7 +220,7 @@
 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 @@
 grabstackblock(len)
        int len;
 {
-       len = ALIGN(len);
+       len = SHELL_ALIGN(len);
        stacknxt += len;
        stacknleft -= len;
 }
diff -r d114f98309a6 -r b59617d71fdd bin/sh/mknodes.c
--- a/bin/sh/mknodes.c  Fri Oct 04 11:42:38 2002 +0000
+++ b/bin/sh/mknodes.c  Fri Oct 04 13:15:51 2002 +0000
@@ -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 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 @@
 
        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 -r d114f98309a6 -r b59617d71fdd bin/sh/nodes.c.pat
--- a/bin/sh/nodes.c.pat        Fri Oct 04 11:42:38 2002 +0000
+++ b/bin/sh/nodes.c.pat        Fri Oct 04 13:15:51 2002 +0000
@@ -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 @@
        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 @@
        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;



Home | Main Index | Thread Index | Old Index