Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/xlint/lint1 Always use our own align macro and expla...



details:   https://anonhg.NetBSD.org/src/rev/2c9a650fc1f5
branches:  trunk
changeset: 766495:2c9a650fc1f5
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Jun 24 01:10:31 2011 +0000

description:
Always use our own align macro and explain a bit more why this is bogus.

diffstat:

 usr.bin/xlint/lint1/decl.c  |  12 ++++++------
 usr.bin/xlint/lint1/lint1.h |  18 ++++++++++++++----
 usr.bin/xlint/lint1/mem1.c  |   6 +++---
 3 files changed, 23 insertions(+), 13 deletions(-)

diffs (97 lines):

diff -r 95759df8d6a2 -r 2c9a650fc1f5 usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c        Fri Jun 24 01:03:08 2011 +0000
+++ b/usr.bin/xlint/lint1/decl.c        Fri Jun 24 01:10:31 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.52 2011/05/24 12:49:11 joerg Exp $ */
+/* $NetBSD: decl.c,v 1.53 2011/06/24 01:10:31 christos Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: decl.c,v 1.52 2011/05/24 12:49:11 joerg Exp $");
+__RCSID("$NetBSD: decl.c,v 1.53 2011/06/24 01:10:31 christos Exp $");
 #endif
 
 #include <sys/param.h>
@@ -926,15 +926,15 @@
        } else if (t == FUNC) {
                /* compiler takes alignment of function */
                error(14);
-               a = ALIGN(1) * CHAR_BIT;
+               a = WORST_ALIGN(1) * CHAR_BIT;
        } else {
                if ((a = size(t)) == 0) {
                        a = CHAR_BIT;
-               } else if (a > ALIGN(1) * CHAR_BIT) {
-                       a = ALIGN(1) * CHAR_BIT;
+               } else if (a > WORST_ALIGN(1) * CHAR_BIT) {
+                       a = WORST_ALIGN(1) * CHAR_BIT;
                }
        }
-       if (a < CHAR_BIT || a > ALIGN(1) * CHAR_BIT)
+       if (a < CHAR_BIT || a > WORST_ALIGN(1) * CHAR_BIT)
                LERROR("getbound()");
        return (a);
 }
diff -r 95759df8d6a2 -r 2c9a650fc1f5 usr.bin/xlint/lint1/lint1.h
--- a/usr.bin/xlint/lint1/lint1.h       Fri Jun 24 01:03:08 2011 +0000
+++ b/usr.bin/xlint/lint1/lint1.h       Fri Jun 24 01:10:31 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lint1.h,v 1.24 2009/10/02 19:01:14 christos Exp $ */
+/* $NetBSD: lint1.h,v 1.25 2011/06/24 01:10:31 christos Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,9 +35,19 @@
 #include "lint.h"
 #include "op.h"
 
-/* XXX - works for most systems, but the whole ALIGN thing needs to go away */
-#ifndef ALIGN
-#define ALIGN(x) (((x) + 7) & ~7)
+/*
+ * XXX - Super conservative so that works for most systems, but we should
+ * not depend on the host settings but the target settings in determining
+ * the alignment. The only valid use for this is in mem1.c; uses in decl.c
+ * are bogus.
+ */
+#ifndef WORST_ALIGN
+#ifdef _LP64
+# define AVAL  15
+#else
+# define AVAL  7
+#endif
+#define WORST_ALIGN(x) (((x) + AVAL) & ~AVAL)
 #endif
 
 /*
diff -r 95759df8d6a2 -r 2c9a650fc1f5 usr.bin/xlint/lint1/mem1.c
--- a/usr.bin/xlint/lint1/mem1.c        Fri Jun 24 01:03:08 2011 +0000
+++ b/usr.bin/xlint/lint1/mem1.c        Fri Jun 24 01:10:31 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mem1.c,v 1.14 2011/01/17 03:04:10 christos Exp $       */
+/*     $NetBSD: mem1.c,v 1.15 2011/06/24 01:10:31 christos Exp $       */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: mem1.c,v 1.14 2011/01/17 03:04:10 christos Exp $");
+__RCSID("$NetBSD: mem1.c,v 1.15 2011/06/24 01:10:31 christos Exp $");
 #endif
 
 #include <sys/types.h>
@@ -192,7 +192,7 @@
        void    *p;
        size_t  t = 0;
 
-       s = ALIGN(s);
+       s = WORST_ALIGN(s);
        if ((mb = *mbp) == NULL || mb->nfree < s) {
                if ((mb = frmblks) == NULL || mb->size < s) {
                        if (s > mblklen) {



Home | Main Index | Thread Index | Old Index