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 compute sizes by the new tsize() function.



details:   https://anonhg.NetBSD.org/src/rev/9f4214a4a5eb
branches:  trunk
changeset: 747814:9f4214a4a5eb
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Oct 02 21:04:03 2009 +0000

description:
compute sizes by the new tsize() function.

diffstat:

 usr.bin/xlint/lint1/decl.c     |  12 +++++++-----
 usr.bin/xlint/lint1/externs1.h |   3 ++-
 usr.bin/xlint/lint1/tree.c     |  25 ++++++++++++++++---------
 3 files changed, 25 insertions(+), 15 deletions(-)

diffs (115 lines):

diff -r 3081f1272dc6 -r 9f4214a4a5eb usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c        Fri Oct 02 20:45:06 2009 +0000
+++ b/usr.bin/xlint/lint1/decl.c        Fri Oct 02 21:04:03 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.49 2009/10/02 20:45:06 christos Exp $ */
+/* $NetBSD: decl.c,v 1.50 2009/10/02 21:04:03 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.49 2009/10/02 20:45:06 christos Exp $");
+__RCSID("$NetBSD: decl.c,v 1.50 2009/10/02 21:04:03 christos Exp $");
 #endif
 
 #include <sys/param.h>
@@ -497,14 +497,16 @@
        case STRUCT:
                sp = tp->t_str;
                sp->size = 0;
-               for (mem = sp->memb; mem != NULL; mem = mem->s_nxt)
-                       sp->size += size(mem->s_type->t_tspec);
+               for (mem = sp->memb; mem != NULL; mem = mem->s_nxt) {
+                       size_t x = (size_t)tsize(mem->s_type);
+                       sp->size += x;
+               }
                break;
        case UNION:
                sp = tp->t_str;
                sp->size = 0;
                for (mem = sp->memb; mem != NULL; mem = mem->s_nxt) {
-                       size_t x = size(mem->s_type->t_tspec);
+                       size_t x = (size_t)tsize(mem->s_type);
                        if (x > sp->size)
                                sp->size = x;
                }
diff -r 3081f1272dc6 -r 9f4214a4a5eb usr.bin/xlint/lint1/externs1.h
--- a/usr.bin/xlint/lint1/externs1.h    Fri Oct 02 20:45:06 2009 +0000
+++ b/usr.bin/xlint/lint1/externs1.h    Fri Oct 02 21:04:03 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: externs1.h,v 1.28 2009/10/02 15:03:45 christos Exp $   */
+/*     $NetBSD: externs1.h,v 1.29 2009/10/02 21:04:03 christos Exp $   */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -210,6 +210,7 @@
 extern void    chkmisc(tnode_t *, int, int, int, int, int, int);
 extern int     conaddr(tnode_t *, sym_t **, ptrdiff_t *);
 extern strg_t  *catstrg(strg_t *, strg_t *);
+extern  int64_t tsize(type_t *);
 
 /*
  * func.c
diff -r 3081f1272dc6 -r 9f4214a4a5eb usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Fri Oct 02 20:45:06 2009 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Fri Oct 02 21:04:03 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.61 2009/10/02 19:02:16 christos Exp $       */
+/*     $NetBSD: tree.c,v 1.62 2009/10/02 21:04:03 christos Exp $       */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.61 2009/10/02 19:02:16 christos Exp $");
+__RCSID("$NetBSD: tree.c,v 1.62 2009/10/02 21:04:03 christos Exp $");
 #endif
 
 #include <stdlib.h>
@@ -3030,14 +3030,26 @@
        return (getcnode(tn->tn_type, v));
 }
 
+
 /*
  * Create a constant node for sizeof.
  */
 tnode_t *
 bldszof(type_t *tp)
 {
+       tspec_t st;
+#if SIZEOF_IS_ULONG
+       st = ULONG;
+#else
+       st = UINT;
+#endif
+       return getinode(st, tsize(tp) / CHAR_BIT);
+}
+
+int64_t
+tsize(type_t *tp)
+{
        int     elem, elsz;
-       tspec_t st;
 
        elem = 1;
        while (tp->t_tspec == ARRAY) {
@@ -3088,12 +3100,7 @@
                break;
        }
 
-#if SIZEOF_IS_ULONG
-       st = ULONG;
-#else
-       st = UINT;
-#endif
-       return (getinode(st, (int64_t)(elem * elsz / CHAR_BIT)));
+       return (int64_t)(elem * elsz);
 }
 
 /*



Home | Main Index | Thread Index | Old Index