Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/xlint Replace u_quad_t with uint64_t and quad_t with...



details:   https://anonhg.NetBSD.org/src/rev/01d699b28b2e
branches:  trunk
changeset: 521768:01d699b28b2e
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Tue Feb 05 03:04:26 2002 +0000

description:
Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions.  These types are more
portable, and a little more sane to do autoconf tests for.

diffstat:

 usr.bin/xlint/common/lint.h    |   3 +-
 usr.bin/xlint/common/param.h   |  15 +------------
 usr.bin/xlint/lint1/cgram.y    |  19 +++++++++--------
 usr.bin/xlint/lint1/emit1.c    |   6 ++--
 usr.bin/xlint/lint1/externs1.h |  10 ++++----
 usr.bin/xlint/lint1/lint1.h    |   4 +-
 usr.bin/xlint/lint1/scan.l     |  36 ++++++++++++++++----------------
 usr.bin/xlint/lint1/tree.c     |  46 +++++++++++++++++++++---------------------
 8 files changed, 64 insertions(+), 75 deletions(-)

diffs (truncated from 480 to 300 lines):

diff -r ddab0c0e6104 -r 01d699b28b2e usr.bin/xlint/common/lint.h
--- a/usr.bin/xlint/common/lint.h       Tue Feb 05 01:55:49 2002 +0000
+++ b/usr.bin/xlint/common/lint.h       Tue Feb 05 03:04:26 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lint.h,v 1.3 2002/01/31 22:44:00 tv Exp $      */
+/*     $NetBSD: lint.h,v 1.4 2002/02/05 03:04:26 thorpej Exp $ */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -40,6 +40,7 @@
 #include <sys/types.h>
 #include <stddef.h>
 #include <err.h>
+#include <inttypes.h>
 #include <stdio.h>
 
 #include "param.h"
diff -r ddab0c0e6104 -r 01d699b28b2e usr.bin/xlint/common/param.h
--- a/usr.bin/xlint/common/param.h      Tue Feb 05 01:55:49 2002 +0000
+++ b/usr.bin/xlint/common/param.h      Tue Feb 05 03:04:26 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: param.h,v 1.1 2002/01/18 20:39:24 thorpej Exp $        */
+/*     $NetBSD: param.h,v 1.2 2002/02/05 03:04:26 thorpej Exp $        */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -66,19 +66,6 @@
  */
 #define WCHAR  INT
 
-#ifndef __GNUC__
-#ifndef lint
-#ifndef QUAD_MAX       /* necessary for mkdep */
-#define QUAD_MAX       LONG_MAX
-#define QUAD_MIN       LONG_MIN
-#define UQUAD_MAX      ULONG_MAX
-#endif
-typedef        long    quad_t;
-typedef        u_long  u_quad_t;
-#endif
-#endif
-
-
 /*
  * long double only in ANSI C.
  *
diff -r ddab0c0e6104 -r 01d699b28b2e usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y       Tue Feb 05 01:55:49 2002 +0000
+++ b/usr.bin/xlint/lint1/cgram.y       Tue Feb 05 03:04:26 2002 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.23 2002/01/31 19:36:53 tv Exp $ */
+/* $NetBSD: cgram.y,v 1.24 2002/02/05 03:04:27 thorpej Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.23 2002/01/31 19:36:53 tv Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.24 2002/02/05 03:04:27 thorpej Exp $");
 #endif
 
 #include <stdlib.h>
@@ -1641,18 +1641,18 @@
        return (0);
 }
 
-static inline int uq_gt(u_quad_t, u_quad_t);
-static inline int q_gt(quad_t, quad_t);
+static inline int uq_gt(uint64_t, uint64_t);
+static inline int q_gt(int64_t, int64_t);
 
 static inline int
-uq_gt(u_quad_t a, u_quad_t b)
+uq_gt(uint64_t a, uint64_t b)
 {
 
        return (a > b);
 }
 
 static inline int
-q_gt(quad_t a, quad_t b)
+q_gt(int64_t a, int64_t b)
 {
 
        return (a > b);
@@ -1692,13 +1692,14 @@
        } else {
                i = (int)v->v_quad;
                if (isutyp(t)) {
-                       if (uq_gt((u_quad_t)v->v_quad, (u_quad_t)INT_MAX)) {
+                       if (uq_gt((uint64_t)v->v_quad,
+                                 (uint64_t)INT_MAX)) {
                                /* integral constant too large */
                                warning(56);
                        }
                } else {
-                       if (q_gt(v->v_quad, (quad_t)INT_MAX) ||
-                           q_lt(v->v_quad, (quad_t)INT_MIN)) {
+                       if (q_gt(v->v_quad, (int64_t)INT_MAX) ||
+                           q_lt(v->v_quad, (int64_t)INT_MIN)) {
                                /* integral constant too large */
                                warning(56);
                        }
diff -r ddab0c0e6104 -r 01d699b28b2e usr.bin/xlint/lint1/emit1.c
--- a/usr.bin/xlint/lint1/emit1.c       Tue Feb 05 01:55:49 2002 +0000
+++ b/usr.bin/xlint/lint1/emit1.c       Tue Feb 05 03:04:26 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: emit1.c,v 1.11 2002/01/31 19:36:54 tv Exp $ */
+/* $NetBSD: emit1.c,v 1.12 2002/02/05 03:04:27 thorpej Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -34,7 +34,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: emit1.c,v 1.11 2002/01/31 19:36:54 tv Exp $");
+__RCSID("$NetBSD: emit1.c,v 1.12 2002/02/05 03:04:27 thorpej Exp $");
 #endif
 
 #include <ctype.h>
@@ -395,7 +395,7 @@
 {
        tnode_t *args, *arg;
        int     narg, n, i;
-       quad_t  q;
+       int64_t q;
        tspec_t t;
 
        /* reset buffer */
diff -r ddab0c0e6104 -r 01d699b28b2e usr.bin/xlint/lint1/externs1.h
--- a/usr.bin/xlint/lint1/externs1.h    Tue Feb 05 01:55:49 2002 +0000
+++ b/usr.bin/xlint/lint1/externs1.h    Tue Feb 05 03:04:26 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: externs1.h,v 1.13 2002/01/18 21:01:39 thorpej Exp $    */
+/*     $NetBSD: externs1.h,v 1.14 2002/02/05 03:04:28 thorpej Exp $    */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -70,12 +70,12 @@
 extern pos_t   csrc_pos;
 extern symt_t  symtyp;
 extern FILE    *yyin;
-extern u_quad_t qbmasks[], qlmasks[], qumasks[];
+extern uint64_t qbmasks[], qlmasks[], qumasks[];
 
 extern void    initscan(void);
-extern int     sign(quad_t, tspec_t, int);
-extern int     msb(quad_t, tspec_t, int);
-extern quad_t  xsign(quad_t, tspec_t, int);
+extern int     sign(int64_t, tspec_t, int);
+extern int     msb(int64_t, tspec_t, int);
+extern int64_t xsign(int64_t, tspec_t, int);
 extern void    clrwflgs(void);
 extern sym_t   *getsym(sbuf_t *);
 extern void    cleanup(void);
diff -r ddab0c0e6104 -r 01d699b28b2e usr.bin/xlint/lint1/lint1.h
--- a/usr.bin/xlint/lint1/lint1.h       Tue Feb 05 01:55:49 2002 +0000
+++ b/usr.bin/xlint/lint1/lint1.h       Tue Feb 05 03:04:26 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lint1.h,v 1.12 2002/01/31 19:33:27 tv Exp $ */
+/* $NetBSD: lint1.h,v 1.13 2002/02/05 03:04:29 thorpej Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -92,7 +92,7 @@
        int     v_ansiu;                /* set if an integer constant is
                                           unsigned in ANSI C */
        union {
-               quad_t  _v_quad;        /* integers */
+               int64_t _v_quad;        /* integers */
                ldbl_t  _v_ldbl;        /* floats */
        } v_u;
 } val_t;
diff -r ddab0c0e6104 -r 01d699b28b2e usr.bin/xlint/lint1/scan.l
--- a/usr.bin/xlint/lint1/scan.l        Tue Feb 05 01:55:49 2002 +0000
+++ b/usr.bin/xlint/lint1/scan.l        Tue Feb 05 03:04:26 2002 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: scan.l,v 1.26 2002/01/31 22:30:21 tv Exp $ */
+/* $NetBSD: scan.l,v 1.27 2002/02/05 03:04:29 thorpej Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: scan.l,v 1.26 2002/01/31 22:30:21 tv Exp $");
+__RCSID("$NetBSD: scan.l,v 1.27 2002/02/05 03:04:29 thorpej Exp $");
 #endif
 
 #include <stdlib.h>
@@ -243,13 +243,13 @@
 static sym_t   *symtab[HSHSIZ1];
 
 /* bit i of the entry with index i is set */
-u_quad_t qbmasks[sizeof(u_quad_t) * CHAR_BIT];
+uint64_t qbmasks[sizeof(uint64_t) * CHAR_BIT];
 
 /* least significant i bits are set in the entry with index i */
-u_quad_t qlmasks[sizeof(u_quad_t) * CHAR_BIT + 1];
+uint64_t qlmasks[sizeof(uint64_t) * CHAR_BIT + 1];
 
 /* least significant i bits are not set in the entry with index i */
-u_quad_t qumasks[sizeof(u_quad_t) * CHAR_BIT + 1];
+uint64_t qumasks[sizeof(uint64_t) * CHAR_BIT + 1];
 
 /* free list for sbuf structures */
 static sbuf_t   *sbfrlst;
@@ -268,7 +268,7 @@
        struct  kwtab *kw;
        sym_t   *sym;
        int     h, i;
-       u_quad_t uq;
+       uint64_t uq;
 
        for (kw = kwtab; kw->kw_name != NULL; kw++) {
                if (kw->kw_stdc && tflag)
@@ -293,14 +293,14 @@
        }
 
        /* initialize bit-masks for quads */
-       for (i = 0; i < sizeof (u_quad_t) * CHAR_BIT; i++) {
-               qbmasks[i] = (u_quad_t)1 << i;
-               uq = ~(u_quad_t)0 << i;
+       for (i = 0; i < sizeof (uint64_t) * CHAR_BIT; i++) {
+               qbmasks[i] = (uint64_t)1 << i;
+               uq = ~(uint64_t)0 << i;
                qumasks[i] = uq;
                qlmasks[i] = ~uq;
        }
        qumasks[i] = 0;
-       qlmasks[i] = ~(u_quad_t)0;
+       qlmasks[i] = ~(uint64_t)0;
 }
 
 /*
@@ -455,7 +455,7 @@
        char    c, *eptr;
        tspec_t typ;
        u_long  ul = 0;
-       u_quad_t uq = 0;
+       uint64_t uq = 0;
        int     ansiu;
        static  tspec_t contypes[2][3] = {
                { INT,  LONG,  QUAD },
@@ -586,15 +586,15 @@
                if (isutyp(typ)) {
                        uq = ul;
                } else {
-                       uq = (quad_t)(long)ul;
+                       uq = (int64_t)(long)ul;
                }
        }
 
-       uq = (u_quad_t)xsign((quad_t)uq, typ, -1);
+       uq = (uint64_t)xsign((int64_t)uq, typ, -1);
 
        (yylval.y_val = xcalloc(1, sizeof (val_t)))->v_tspec = typ;
        yylval.y_val->v_ansiu = ansiu;
-       yylval.y_val->v_quad = (quad_t)uq;
+       yylval.y_val->v_quad = (int64_t)uq;
 
        return (T_CON);
 }
@@ -606,7 +606,7 @@
  * to the width of type t.
  */
 int
-sign(quad_t q, tspec_t t, int len)
+sign(int64_t q, tspec_t t, int len)
 {
 
        if (t == PTR || isutyp(t))
@@ -615,7 +615,7 @@
 }
 
 int
-msb(quad_t q, tspec_t t, int len)
+msb(int64_t q, tspec_t t, int len)
 {
 
        if (len <= 0)
@@ -626,8 +626,8 @@
 /*
  * Extends the sign of q.
  */
-quad_t
-xsign(quad_t q, tspec_t t, int len)
+int64_t
+xsign(int64_t q, tspec_t t, int len)
 {
 
        if (len <= 0)
diff -r ddab0c0e6104 -r 01d699b28b2e usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Tue Feb 05 01:55:49 2002 +0000



Home | Main Index | Thread Index | Old Index