CVS commit: src/usr.bin/xlint/common

2021-08-03 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Aug  3 17:27:48 UTC 2021

Modified Files:
src/usr.bin/xlint/common: param.h

Log Message:
lint: reduce number of negations in preprocessor condition

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/xlint/common/param.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/xlint/common/param.h
diff -u src/usr.bin/xlint/common/param.h:1.8 src/usr.bin/xlint/common/param.h:1.9
--- src/usr.bin/xlint/common/param.h:1.8	Wed Dec 30 11:43:13 2020
+++ src/usr.bin/xlint/common/param.h	Tue Aug  3 17:27:48 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.8 2020/12/30 11:43:13 rillig Exp $	*/
+/*	$NetBSD: param.h,v 1.9 2021/08/03 17:27:48 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -63,7 +63,7 @@
 /*
  * The sparc64 long double code generation is broken in old gcc.
  */
-#if !defined(__sparc64__) || !defined(__GNUC__) || __GNUC__ > 2
+#if !(defined(__sparc64__) && defined(__GNUC__) && __GNUC__ <= 2)
 typedef	long double ldbl_t;
 #else
 typedef	double	ldbl_t;



CVS commit: src/usr.bin/xlint/common

2021-08-03 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Aug  3 17:20:02 UTC 2021

Modified Files:
src/usr.bin/xlint/common: mem.c

Log Message:
lint: make memory management code easier to read

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/xlint/common/mem.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/xlint/common/mem.c
diff -u src/usr.bin/xlint/common/mem.c:1.15 src/usr.bin/xlint/common/mem.c:1.16
--- src/usr.bin/xlint/common/mem.c:1.15	Sun Aug  1 18:13:53 2021
+++ src/usr.bin/xlint/common/mem.c	Tue Aug  3 17:20:02 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: mem.c,v 1.15 2021/08/01 18:13:53 rillig Exp $	*/
+/*	$NetBSD: mem.c,v 1.16 2021/08/03 17:20:02 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: mem.c,v 1.15 2021/08/01 18:13:53 rillig Exp $");
+__RCSID("$NetBSD: mem.c,v 1.16 2021/08/03 17:20:02 rillig Exp $");
 #endif
 
 #include 
@@ -46,53 +46,41 @@ __RCSID("$NetBSD: mem.c,v 1.15 2021/08/0
 
 #include "lint.h"
 
-static void __attribute__((noreturn))
-nomem(void)
+static void *
+not_null(void *ptr)
 {
 
-	errx(1, "virtual memory exhausted");
+	if (ptr == NULL)
+		errx(1, "virtual memory exhausted");
+	return ptr;
 }
 
 void *
 xmalloc(size_t s)
 {
-	void	*p;
 
-	if ((p = malloc(s)) == NULL)
-		nomem();
-	return p;
+	return not_null(malloc(s));
 }
 
 void *
 xcalloc(size_t n, size_t s)
 {
-	void	*p;
 
-	if ((p = calloc(n, s)) == NULL)
-		nomem();
-	return p;
+	return not_null(calloc(n, s));
 }
 
 void *
 xrealloc(void *p, size_t s)
 {
-	void *n;
 
-	if ((n = realloc(p, s)) == NULL) {
-		free(p);
-		nomem();
-	}
-	return n;
+	return not_null(realloc(p, s));
 }
 
 char *
 xstrdup(const char *s)
 {
-	char	*s2;
 
-	if ((s2 = strdup(s)) == NULL)
-		nomem();
-	return s2;
+	return not_null(strdup(s));
 }
 
 char *
@@ -106,6 +94,6 @@ xasprintf(const char *fmt, ...)
 	e = vasprintf(, fmt, ap);
 	va_end(ap);
 	if (e < 0)
-		nomem();
+		not_null(NULL);
 	return str;
 }



CVS commit: src/usr.bin/xlint/common

2021-06-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Jun 30 10:56:24 UTC 2021

Modified Files:
src/usr.bin/xlint/common: inittyp.c

Log Message:
lint: fix bit-size of long double _Complex in portable mode

C99 6.2.5p13 says that LCOMPLEX has the same representation and
alignment requirements as an array type containing exactly two LDOUBLE.

When support for _Complex was added to lint in inittyp.c 1.10 from
2008-09-27, there was no explanation for making the bit-size of LCOMPLEX
different from what C99 says, so it was probably a mistake that went
unnoticed for more than 12 years.  It's an edge case anyway.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/usr.bin/xlint/common/inittyp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/xlint/common/inittyp.c
diff -u src/usr.bin/xlint/common/inittyp.c:1.23 src/usr.bin/xlint/common/inittyp.c:1.24
--- src/usr.bin/xlint/common/inittyp.c:1.23	Tue Jun 29 21:33:09 2021
+++ src/usr.bin/xlint/common/inittyp.c	Wed Jun 30 10:56:24 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: inittyp.c,v 1.23 2021/06/29 21:33:09 rillig Exp $	*/
+/*	$NetBSD: inittyp.c,v 1.24 2021/06/30 10:56:24 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: inittyp.c,v 1.23 2021/06/29 21:33:09 rillig Exp $");
+__RCSID("$NetBSD: inittyp.c,v 1.24 2021/06/30 10:56:24 rillig Exp $");
 #endif
 
 #include 
@@ -115,13 +115,8 @@ inittyp(void)
 		0, 0, 1, 1, 1, 1, "float _Complex"),
 		typeinfo(DCOMPLEX, DCOMPLEX, DCOMPLEX, DOUBLE_SIZE * 2, 64 * 2,
 		0, 0, 1, 1, 1, 1, "double _Complex"),
-		/*
-		* XXX: with -p, LCOMPLEX.tt_portable_size_in_bits !=
-		*  2 * LDOUBLE.tt_portable_size_in_bits.
-		*  This may or may not have been intentional.
-		*/
 		typeinfo(LCOMPLEX, LCOMPLEX, LCOMPLEX,
-		LDOUBLE_SIZE * 2, 64 * 2,
+		LDOUBLE_SIZE * 2, 80 * 2,
 		0, 0, 1, 1, 1, 1, "long double _Complex"),
 		typeinfo(VOID, VOID, VOID, -1, -1,
 		0, 0, 0, 0, 0, 0, "void"),



CVS commit: src/usr.bin/xlint/common

2021-06-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jun  4 20:54:18 UTC 2021

Modified Files:
src/usr.bin/xlint/common: tyname.c

Log Message:
lint: fix typo in comment


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/usr.bin/xlint/common/tyname.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/xlint/common/tyname.c
diff -u src/usr.bin/xlint/common/tyname.c:1.40 src/usr.bin/xlint/common/tyname.c:1.41
--- src/usr.bin/xlint/common/tyname.c:1.40	Sun Apr 18 17:47:32 2021
+++ src/usr.bin/xlint/common/tyname.c	Fri Jun  4 20:54:18 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tyname.c,v 1.40 2021/04/18 17:47:32 rillig Exp $	*/
+/*	$NetBSD: tyname.c,v 1.41 2021/06/04 20:54:18 rillig Exp $	*/
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tyname.c,v 1.40 2021/04/18 17:47:32 rillig Exp $");
+__RCSID("$NetBSD: tyname.c,v 1.41 2021/06/04 20:54:18 rillig Exp $");
 #endif
 
 #include 
@@ -197,7 +197,7 @@ sametype(const type_t *t1, const type_t 
 	if (t1->t_tspec != t2->t_tspec)
 		return false;
 
-	/* Ignore const/void */
+	/* Ignore const/volatile */
 
 	switch (t = t1->t_tspec) {
 	case BOOL:



CVS commit: src/usr.bin/xlint/common

2021-03-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 20 18:59:00 UTC 2021

Modified Files:
src/usr.bin/xlint/common: inittyp.c

Log Message:
lint: use macro for encoding type information

In lint's strict bool mode, initialization must be of the correct type.
This affects the bool fields in ttab_t, which are initialized with int.
To keep the code brief, preserve these ints and let a macro do the
actual work of converting them to bool.

No change to the generated binary.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/usr.bin/xlint/common/inittyp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/xlint/common/inittyp.c
diff -u src/usr.bin/xlint/common/inittyp.c:1.20 src/usr.bin/xlint/common/inittyp.c:1.21
--- src/usr.bin/xlint/common/inittyp.c:1.20	Sun Feb 28 18:51:51 2021
+++ src/usr.bin/xlint/common/inittyp.c	Sat Mar 20 18:59:00 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: inittyp.c,v 1.20 2021/02/28 18:51:51 rillig Exp $	*/
+/*	$NetBSD: inittyp.c,v 1.21 2021/03/20 18:59:00 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: inittyp.c,v 1.20 2021/02/28 18:51:51 rillig Exp $");
+__RCSID("$NetBSD: inittyp.c,v 1.21 2021/03/20 18:59:00 rillig Exp $");
 #endif
 
 #include 
@@ -58,101 +58,85 @@ inittyp(void)
 		tspec_t	it_tspec;
 		ttab_t	it_ttab;
 	} ittab[NTSPEC] = {
-		{ SIGNED,   { 0, 0,
-  SIGNED, UNSIGN,
-  0, 0, 0, 0, 0, 0, "signed" } },
-		{ UNSIGN,   { 0, 0,
-  SIGNED, UNSIGN,
-  0, 0, 0, 0, 0, 0, "unsigned" } },
-		{ BOOL,	{ CHAR_SIZE, 1,
-  BOOL, BOOL,
-  1, 1, 0, 1, 1, 0, "_Bool" } },
-		{ CHAR,	{ CHAR_SIZE, 8,
-  SCHAR, UCHAR,
-  1, 0, 0, 1, 1, 0, "char" } },
-		{ SCHAR,{ CHAR_SIZE, 8,
-  SCHAR, UCHAR,
-  1, 0, 0, 1, 1, 0, "signed char" } },
-		{ UCHAR,{ CHAR_SIZE, 8,
-  SCHAR, UCHAR,
-  1, 1, 0, 1, 1, 0, "unsigned char" } },
-		{ SHORT,{ SHORT_SIZE, 16,
-  SHORT, USHORT,
-  1, 0, 0, 1, 1, 0, "short" } },
-		{ USHORT,   { SHORT_SIZE, 16,
-  SHORT, USHORT,
-  1, 1, 0, 1, 1, 0, "unsigned short" } },
-		{ INT,  { INT_SIZE, INT_RSIZE * 8,
-  INT, UINT,
-  1, 0, 0, 1, 1, 0, "int" } },
-		{ UINT, { INT_SIZE, INT_RSIZE * 8,
-  INT, UINT,
-  1, 1, 0, 1, 1, 0, "unsigned int" } },
-		{ LONG, { LONG_SIZE, 32,
-  LONG, ULONG,
-  1, 0, 0, 1, 1, 0, "long" } },
-		{ ULONG,{ LONG_SIZE, 32,
-  LONG, ULONG,
-  1, 1, 0, 1, 1, 0, "unsigned long" } },
-		{ QUAD, { QUAD_SIZE, 64,
-  QUAD, UQUAD,
-  1, 0, 0, 1, 1, 0, "long long" } },
-		{ UQUAD,{ QUAD_SIZE, 64,
-  QUAD, UQUAD,
-  1, 1, 0, 1, 1, 0, "unsigned long long" } },
+#define typeinfo( \
+	tspec, signed_type, unsigned_type, \
+	size_in_bits, portable_size_in_bits, \
+	in, un, fl, ar, sc, co, name) \
+	{ \
+	tspec, { \
+		size_in_bits, portable_size_in_bits, \
+		signed_type, unsigned_type, \
+		(in) > 0, (un) > 0, (fl) > 0, (ar) > 0, (sc) > 0, (co) > 0, \
+		name, \
+	} \
+	}
+		typeinfo(SIGNED, SIGNED, UNSIGN, 0, 0,
+		0, 0, 0, 0, 0, 0, "signed"),
+		typeinfo(UNSIGN, SIGNED, UNSIGN, 0, 0,
+		0, 0, 0, 0, 0, 0, "unsigned"),
+		typeinfo(BOOL, BOOL, BOOL, CHAR_SIZE, 1,
+		1, 1, 0, 1, 1, 0, "_Bool"),
+		typeinfo(CHAR, SCHAR, UCHAR, CHAR_SIZE, 8,
+		1, 0, 0, 1, 1, 0, "char"),
+		typeinfo(SCHAR, SCHAR, UCHAR, CHAR_SIZE, 8,
+		1, 0, 0, 1, 1, 0, "signed char"),
+		typeinfo(UCHAR, SCHAR, UCHAR, CHAR_SIZE, 8,
+		1, 1, 0, 1, 1, 0, "unsigned char"),
+		typeinfo(SHORT, SHORT, USHORT, SHORT_SIZE, 16,
+		1, 0, 0, 1, 1, 0, "short"),
+		typeinfo(USHORT, SHORT, USHORT, SHORT_SIZE, 16,
+		1, 1, 0, 1, 1, 0, "unsigned short"),
+		typeinfo(INT, INT, UINT, INT_SIZE, INT_RSIZE * 8,
+		1, 0, 0, 1, 1, 0, "int"),
+		typeinfo(UINT, INT, UINT, INT_SIZE, INT_RSIZE * 8,
+		1, 1, 0, 1, 1, 0, "unsigned int"),
+		typeinfo(LONG, LONG, ULONG, LONG_SIZE, 32,
+		1, 0, 0, 1, 1, 0, "long"),
+		typeinfo(ULONG, LONG, ULONG, LONG_SIZE, 32,
+		1, 1, 0, 1, 1, 0, "unsigned long"),
+		typeinfo(QUAD, QUAD, UQUAD, QUAD_SIZE, 64,
+		1, 0, 0, 1, 1, 0, "long long"),
+		typeinfo(UQUAD, QUAD, UQUAD, QUAD_SIZE, 64,
+		1, 1, 0, 1, 1, 0, "unsigned long long"),
 #ifdef INT128_SIZE
-		{ INT128,   { INT128_SIZE, 128,
-  INT128, UINT128,
-  1, 0, 0, 1, 1, 0, "__int128_t" } },
-		{ UINT128,  { INT128_SIZE, 128,
-  INT128, UINT128,
-  1, 1, 0, 1, 1, 0, "__uint128_t" } },
+		typeinfo(INT128, INT128, UINT128, INT128_SIZE, 128,
+		1, 0, 0, 1, 1, 0, "__int128_t"),
+		typeinfo(UINT128, INT128, UINT128, INT128_SIZE, 128,
+		1, 1, 0, 1, 1, 0, "__uint128_t"),
 #endif
-
-		{ FLOAT,{ FLOAT_SIZE, 32,
-  FLOAT, FLOAT,
-			

CVS commit: src/usr.bin/xlint/common

2021-02-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Feb 28 02:37:04 UTC 2021

Modified Files:
src/usr.bin/xlint/common: tyname.c

Log Message:
lint: extract type_name_of_array from type_name

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/usr.bin/xlint/common/tyname.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/xlint/common/tyname.c
diff -u src/usr.bin/xlint/common/tyname.c:1.32 src/usr.bin/xlint/common/tyname.c:1.33
--- src/usr.bin/xlint/common/tyname.c:1.32	Sun Feb 28 02:29:28 2021
+++ src/usr.bin/xlint/common/tyname.c	Sun Feb 28 02:37:04 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tyname.c,v 1.32 2021/02/28 02:29:28 rillig Exp $	*/
+/*	$NetBSD: tyname.c,v 1.33 2021/02/28 02:37:04 rillig Exp $	*/
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tyname.c,v 1.32 2021/02/28 02:29:28 rillig Exp $");
+__RCSID("$NetBSD: tyname.c,v 1.33 2021/02/28 02:37:04 rillig Exp $");
 #endif
 
 #include 
@@ -314,6 +314,23 @@ type_name_of_enum(buffer *buf, const typ
 #endif
 }
 
+static void
+type_name_of_array(buffer *buf, const type_t *tp)
+{
+	buf_add(buf, " of ");
+	buf_add(buf, type_name(tp->t_subt));
+	buf_add(buf, "[");
+#ifdef t_str /* lint1 */
+	if (tp->t_incomplete_array)
+		buf_add(buf, "unknown_size");
+	else
+		buf_add_int(buf, tp->t_dim);
+#else
+	buf_add_int(buf, tp->t_dim);
+#endif
+	buf_add(buf, "]");
+}
+
 const char *
 type_name(const type_t *tp)
 {
@@ -379,23 +396,11 @@ type_name(const type_t *tp)
 		type_name_of_struct_or_union(, tp);
 		break;
 	case ARRAY:
-		buf_add(, " of ");
-		buf_add(, type_name(tp->t_subt));
-		buf_add(, "[");
-#ifdef t_str /* lint1 */
-		if (tp->t_incomplete_array)
-			buf_add(, "unknown_size");
-		else
-			buf_add_int(, tp->t_dim);
-#else
-		buf_add_int(, tp->t_dim);
-#endif
-		buf_add(, "]");
+		type_name_of_array(, tp);
 		break;
 	case FUNC:
 		type_name_of_function(, tp);
 		break;
-
 	default:
 		LERROR("type_name(%d)", t);
 	}



CVS commit: src/usr.bin/xlint/common

2021-01-26 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Jan 26 18:38:58 UTC 2021

Modified Files:
src/usr.bin/xlint/common: tyname.c

Log Message:
lint: remove __noinline attribute from string interning function

I had committed this accidentally while ensuring that the generated code
is still efficient even though the source code looks heavy with the
double pointer indirection.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/usr.bin/xlint/common/tyname.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/xlint/common/tyname.c
diff -u src/usr.bin/xlint/common/tyname.c:1.25 src/usr.bin/xlint/common/tyname.c:1.26
--- src/usr.bin/xlint/common/tyname.c:1.25	Sun Jan 24 11:55:57 2021
+++ src/usr.bin/xlint/common/tyname.c	Tue Jan 26 18:38:57 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tyname.c,v 1.25 2021/01/24 11:55:57 rillig Exp $	*/
+/*	$NetBSD: tyname.c,v 1.26 2021/01/26 18:38:57 rillig Exp $	*/
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tyname.c,v 1.25 2021/01/24 11:55:57 rillig Exp $");
+__RCSID("$NetBSD: tyname.c,v 1.26 2021/01/26 18:38:57 rillig Exp $");
 #endif
 
 #include 
@@ -82,7 +82,7 @@ new_name_tree_node(const char *name)
 }
 
 /* Return the canonical instance of the string, with unlimited life time. */
-static const char * __noinline
+static const char *
 intern(const char *name)
 {
 	name_tree_node *n = type_names, **next;



CVS commit: src/usr.bin/xlint/common

2021-01-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 24 11:55:57 UTC 2021

Modified Files:
src/usr.bin/xlint/common: tyname.c

Log Message:
lint: merge duplicate code for interning type names


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/usr.bin/xlint/common/tyname.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/xlint/common/tyname.c
diff -u src/usr.bin/xlint/common/tyname.c:1.24 src/usr.bin/xlint/common/tyname.c:1.25
--- src/usr.bin/xlint/common/tyname.c:1.24	Sat Jan 16 16:53:23 2021
+++ src/usr.bin/xlint/common/tyname.c	Sun Jan 24 11:55:57 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tyname.c,v 1.24 2021/01/16 16:53:23 rillig Exp $	*/
+/*	$NetBSD: tyname.c,v 1.25 2021/01/24 11:55:57 rillig Exp $	*/
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tyname.c,v 1.24 2021/01/16 16:53:23 rillig Exp $");
+__RCSID("$NetBSD: tyname.c,v 1.25 2021/01/24 11:55:57 rillig Exp $");
 #endif
 
 #include 
@@ -82,10 +82,10 @@ new_name_tree_node(const char *name)
 }
 
 /* Return the canonical instance of the string, with unlimited life time. */
-static const char *
+static const char * __noinline
 intern(const char *name)
 {
-	name_tree_node *n = type_names;
+	name_tree_node *n = type_names, **next;
 	int cmp;
 
 	if (n == NULL) {
@@ -95,19 +95,12 @@ intern(const char *name)
 	}
 
 	while ((cmp = strcmp(name, n->ntn_name)) != 0) {
-		if (cmp < 0) {
-			if (n->ntn_less == NULL) {
-n->ntn_less = new_name_tree_node(name);
-return n->ntn_less->ntn_name;
-			}
-			n = n->ntn_less;
-		} else {
-			if (n->ntn_greater == NULL) {
-n->ntn_greater = new_name_tree_node(name);
-return n->ntn_greater->ntn_name;
-			}
-			n = n->ntn_greater;
+		next = cmp < 0 ? >ntn_less : >ntn_greater;
+		if (*next == NULL) {
+			*next = new_name_tree_node(name);
+			return (*next)->ntn_name;
 		}
+		n = *next;
 	}
 	return n->ntn_name;
 }



CVS commit: src/usr.bin/xlint/common

2021-01-03 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jan  4 01:12:20 UTC 2021

Modified Files:
src/usr.bin/xlint/common: externs.h inittyp.c lint.h lp64.h

Log Message:
lint: revert previous commit, except for the typo


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/xlint/common/externs.h
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/xlint/common/inittyp.c
cvs rdiff -u -r1.22 -r1.23 src/usr.bin/xlint/common/lint.h
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/xlint/common/lp64.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/xlint/common/externs.h
diff -u src/usr.bin/xlint/common/externs.h:1.11 src/usr.bin/xlint/common/externs.h:1.12
--- src/usr.bin/xlint/common/externs.h:1.11	Mon Jan  4 01:11:01 2021
+++ src/usr.bin/xlint/common/externs.h	Mon Jan  4 01:12:20 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: externs.h,v 1.11 2021/01/04 01:11:01 rillig Exp $	*/
+/*	$NetBSD: externs.h,v 1.12 2021/01/04 01:12:20 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -74,8 +74,3 @@ extern	void	outint(int);
 #define outname(a)	outname1(__FILE__, __LINE__, a);
 extern	void	outname1(const char *, size_t, const char *);
 extern	void	outsrc(const char *);
-
-/*
- * platforms.c
- */
-extern	const target_platform *platform(void);

Index: src/usr.bin/xlint/common/inittyp.c
diff -u src/usr.bin/xlint/common/inittyp.c:1.14 src/usr.bin/xlint/common/inittyp.c:1.15
--- src/usr.bin/xlint/common/inittyp.c:1.14	Mon Jan  4 01:11:01 2021
+++ src/usr.bin/xlint/common/inittyp.c	Mon Jan  4 01:12:20 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: inittyp.c,v 1.14 2021/01/04 01:11:01 rillig Exp $	*/
+/*	$NetBSD: inittyp.c,v 1.15 2021/01/04 01:12:20 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: inittyp.c,v 1.14 2021/01/04 01:11:01 rillig Exp $");
+__RCSID("$NetBSD: inittyp.c,v 1.15 2021/01/04 01:12:20 rillig Exp $");
 #endif
 
 #include 
@@ -113,10 +113,10 @@ inittyp(void)
   1, 1, 0, 1, 1, 0, "__uint128_t" } },
 #endif
 
-		{ FLOAT,{ 32, 4 * CHAR_BIT,
+		{ FLOAT,{ FLOAT_SIZE, 4 * CHAR_BIT,
   FLOAT, FLOAT,
   0, 0, 1, 1, 1, 0, "float" } },
-		{ DOUBLE,   { 64, 8 * CHAR_BIT,
+		{ DOUBLE,   { DOUBLE_SIZE, 8 * CHAR_BIT,
   DOUBLE, DOUBLE,
   0, 0, 1, 1, 1, 0, "double" } },
 		{ LDOUBLE,  { LDOUBLE_SIZE, 10 * CHAR_BIT,

Index: src/usr.bin/xlint/common/lint.h
diff -u src/usr.bin/xlint/common/lint.h:1.22 src/usr.bin/xlint/common/lint.h:1.23
--- src/usr.bin/xlint/common/lint.h:1.22	Mon Jan  4 01:11:01 2021
+++ src/usr.bin/xlint/common/lint.h	Mon Jan  4 01:12:20 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: lint.h,v 1.22 2021/01/04 01:11:01 rillig Exp $	*/
+/*	$NetBSD: lint.h,v 1.23 2021/01/04 01:12:20 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -136,12 +136,4 @@ typedef	struct	ob {
 
 typedef struct type type_t;
 
-typedef struct target_platform {
-	const char *pl_name;
-	tspec_t pl_char_type;
-	size_t pl_long_pointer_size;
-	tspec_t pl_intptr_type;		/* either INT or LONG */
-	size_t pl_sizeof_long_double;	/* either 8, 12 or 16 */
-} target_platform;
-
 #include "externs.h"

Index: src/usr.bin/xlint/common/lp64.h
diff -u src/usr.bin/xlint/common/lp64.h:1.8 src/usr.bin/xlint/common/lp64.h:1.9
--- src/usr.bin/xlint/common/lp64.h:1.8	Mon Jan  4 01:11:01 2021
+++ src/usr.bin/xlint/common/lp64.h	Mon Jan  4 01:12:20 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: lp64.h,v 1.8 2021/01/04 01:11:01 rillig Exp $	*/
+/*	$NetBSD: lp64.h,v 1.9 2021/01/04 01:12:20 rillig Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -53,11 +53,11 @@
 #define	TARG_SCHAR_MIN	((-TARG_CHAR_MAX) - 1)
 #define	TARG_UCHAR_MAX	((unsigned char) -1)
 
-#define	TARG_SHRT_MAX	32767
-#define	TARG_SHRT_MIN	(-32768)
-#define	TARG_USHRT_MAX	65535
+#define	TARG_SHRT_MAX	((int16_t) (((uint16_t) -1) >> 1))
+#define	TARG_SHRT_MIN	((-TARG_SHRT_MAX) - 1)
+#define	TARG_USHRT_MAX	((uint16_t) -1)
 
-#define	TARG_INT_MAX	(2147483647)
+#define	TARG_INT_MAX	((int32_t) (((uint32_t) -1) >> 1))
 #define	TARG_INT_MIN	((-TARG_INT_MAX) - 1)
 #define	TARG_UINT_MAX	((uint32_t) -1)
 



CVS commit: src/usr.bin/xlint/common

2021-01-03 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jan  4 01:11:01 UTC 2021

Modified Files:
src/usr.bin/xlint/common: externs.h ilp32.h inittyp.c lint.h lp64.h

Log Message:
lint: fix typo in comment


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/xlint/common/externs.h
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/xlint/common/ilp32.h
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/xlint/common/inittyp.c
cvs rdiff -u -r1.21 -r1.22 src/usr.bin/xlint/common/lint.h
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/xlint/common/lp64.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/xlint/common/externs.h
diff -u src/usr.bin/xlint/common/externs.h:1.10 src/usr.bin/xlint/common/externs.h:1.11
--- src/usr.bin/xlint/common/externs.h:1.10	Sat Jan  2 03:49:25 2021
+++ src/usr.bin/xlint/common/externs.h	Mon Jan  4 01:11:01 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: externs.h,v 1.10 2021/01/02 03:49:25 rillig Exp $	*/
+/*	$NetBSD: externs.h,v 1.11 2021/01/04 01:11:01 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -74,3 +74,8 @@ extern	void	outint(int);
 #define outname(a)	outname1(__FILE__, __LINE__, a);
 extern	void	outname1(const char *, size_t, const char *);
 extern	void	outsrc(const char *);
+
+/*
+ * platforms.c
+ */
+extern	const target_platform *platform(void);

Index: src/usr.bin/xlint/common/ilp32.h
diff -u src/usr.bin/xlint/common/ilp32.h:1.3 src/usr.bin/xlint/common/ilp32.h:1.4
--- src/usr.bin/xlint/common/ilp32.h:1.3	Tue Mar 27 19:24:03 2012
+++ src/usr.bin/xlint/common/ilp32.h	Mon Jan  4 01:11:01 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ilp32.h,v 1.3 2012/03/27 19:24:03 christos Exp $	*/
+/*	$NetBSD: ilp32.h,v 1.4 2021/01/04 01:11:01 rillig Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 /*
- * Type sizes for IPL32 platforms (int, long, pointer: 32-bit)
+ * Type sizes for ILP32 platforms (int, long, pointer: 32-bit)
  */
 
 #define	CHAR_SIZE	(CHAR_BIT)

Index: src/usr.bin/xlint/common/inittyp.c
diff -u src/usr.bin/xlint/common/inittyp.c:1.13 src/usr.bin/xlint/common/inittyp.c:1.14
--- src/usr.bin/xlint/common/inittyp.c:1.13	Wed Dec 30 11:39:55 2020
+++ src/usr.bin/xlint/common/inittyp.c	Mon Jan  4 01:11:01 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: inittyp.c,v 1.13 2020/12/30 11:39:55 rillig Exp $	*/
+/*	$NetBSD: inittyp.c,v 1.14 2021/01/04 01:11:01 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: inittyp.c,v 1.13 2020/12/30 11:39:55 rillig Exp $");
+__RCSID("$NetBSD: inittyp.c,v 1.14 2021/01/04 01:11:01 rillig Exp $");
 #endif
 
 #include 
@@ -113,10 +113,10 @@ inittyp(void)
   1, 1, 0, 1, 1, 0, "__uint128_t" } },
 #endif
 
-		{ FLOAT,{ FLOAT_SIZE, 4 * CHAR_BIT,
+		{ FLOAT,{ 32, 4 * CHAR_BIT,
   FLOAT, FLOAT,
   0, 0, 1, 1, 1, 0, "float" } },
-		{ DOUBLE,   { DOUBLE_SIZE, 8 * CHAR_BIT,
+		{ DOUBLE,   { 64, 8 * CHAR_BIT,
   DOUBLE, DOUBLE,
   0, 0, 1, 1, 1, 0, "double" } },
 		{ LDOUBLE,  { LDOUBLE_SIZE, 10 * CHAR_BIT,

Index: src/usr.bin/xlint/common/lint.h
diff -u src/usr.bin/xlint/common/lint.h:1.21 src/usr.bin/xlint/common/lint.h:1.22
--- src/usr.bin/xlint/common/lint.h:1.21	Sat Jan  2 01:06:15 2021
+++ src/usr.bin/xlint/common/lint.h	Mon Jan  4 01:11:01 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: lint.h,v 1.21 2021/01/02 01:06:15 rillig Exp $	*/
+/*	$NetBSD: lint.h,v 1.22 2021/01/04 01:11:01 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -136,4 +136,12 @@ typedef	struct	ob {
 
 typedef struct type type_t;
 
+typedef struct target_platform {
+	const char *pl_name;
+	tspec_t pl_char_type;
+	size_t pl_long_pointer_size;
+	tspec_t pl_intptr_type;		/* either INT or LONG */
+	size_t pl_sizeof_long_double;	/* either 8, 12 or 16 */
+} target_platform;
+
 #include "externs.h"

Index: src/usr.bin/xlint/common/lp64.h
diff -u src/usr.bin/xlint/common/lp64.h:1.7 src/usr.bin/xlint/common/lp64.h:1.8
--- src/usr.bin/xlint/common/lp64.h:1.7	Fri Nov 16 20:49:08 2018
+++ src/usr.bin/xlint/common/lp64.h	Mon Jan  4 01:11:01 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: lp64.h,v 1.7 2018/11/16 20:49:08 scole Exp $	*/
+/*	$NetBSD: lp64.h,v 1.8 2021/01/04 01:11:01 rillig Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -53,11 +53,11 @@
 #define	TARG_SCHAR_MIN	((-TARG_CHAR_MAX) - 1)
 #define	TARG_UCHAR_MAX	((unsigned char) -1)
 
-#define	TARG_SHRT_MAX	((int16_t) (((uint16_t) -1) >> 1))
-#define	TARG_SHRT_MIN	((-TARG_SHRT_MAX) - 1)
-#define	TARG_USHRT_MAX	((uint16_t) -1)
+#define	TARG_SHRT_MAX	32767
+#define	TARG_SHRT_MIN	(-32768)
+#define	TARG_USHRT_MAX	65535
 
-#define	TARG_INT_MAX	((int32_t) (((uint32_t) -1) >> 1))
+#define	TARG_INT_MAX	(2147483647)
 #define	TARG_INT_MIN	((-TARG_INT_MAX) - 1)
 #define	TARG_UINT_MAX	((uint32_t) -1)
 



CVS commit: src/usr.bin/xlint/common

2021-01-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jan  2 01:36:28 UTC 2021

Modified Files:
src/usr.bin/xlint/common: tyname.c

Log Message:
lint: order tspec_name in the same way as the enum


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/usr.bin/xlint/common/tyname.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/xlint/common/tyname.c
diff -u src/usr.bin/xlint/common/tyname.c:1.18 src/usr.bin/xlint/common/tyname.c:1.19
--- src/usr.bin/xlint/common/tyname.c:1.18	Fri Jan  1 01:42:55 2021
+++ src/usr.bin/xlint/common/tyname.c	Sat Jan  2 01:36:28 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tyname.c,v 1.18 2021/01/01 01:42:55 rillig Exp $	*/
+/*	$NetBSD: tyname.c,v 1.19 2021/01/02 01:36:28 rillig Exp $	*/
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tyname.c,v 1.18 2021/01/01 01:42:55 rillig Exp $");
+__RCSID("$NetBSD: tyname.c,v 1.19 2021/01/02 01:36:28 rillig Exp $");
 #endif
 
 #include 
@@ -57,10 +57,12 @@ const char *
 tspec_name(tspec_t t)
 {
 	switch (t) {
+	case SIGNED:	return "signed";
+	case UNSIGN:	return "unsigned";
 	case BOOL:	return "_Bool";
 	case CHAR:	return "char";
-	case UCHAR:	return "unsigned char";
 	case SCHAR:	return "signed char";
+	case UCHAR:	return "unsigned char";
 	case SHORT:	return "short";
 	case USHORT:	return "unsigned short";
 	case INT:	return "int";
@@ -77,18 +79,16 @@ tspec_name(tspec_t t)
 	case DOUBLE:	return "double";
 	case LDOUBLE:	return "long double";
 	case VOID:	return "void";
-	case PTR:	return "pointer";
-	case ENUM:	return "enum";
 	case STRUCT:	return "struct";
 	case UNION:	return "union";
-	case FUNC:	return "function";
+	case ENUM:	return "enum";
+	case PTR:	return "pointer";
 	case ARRAY:	return "array";
+	case FUNC:	return "function";
+	case COMPLEX:	return "_Complex";
 	case FCOMPLEX:	return "float _Complex";
 	case DCOMPLEX:	return "double _Complex";
 	case LCOMPLEX:	return "long double _Complex";
-	case COMPLEX:	return "_Complex";
-	case SIGNED:	return "signed";
-	case UNSIGN:	return "unsigned";
 	default:
 		LERROR("tspec_name(%d)", t);
 		return NULL;



CVS commit: src/usr.bin/xlint/common

2020-12-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Dec 30 11:47:16 UTC 2020

Modified Files:
src/usr.bin/xlint/common: emit.c

Log Message:
lint: fix Clang-tidy warning about narrowing conversion


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/xlint/common/emit.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/xlint/common/emit.c
diff -u src/usr.bin/xlint/common/emit.c:1.8 src/usr.bin/xlint/common/emit.c:1.9
--- src/usr.bin/xlint/common/emit.c:1.8	Wed Dec 30 10:46:11 2020
+++ src/usr.bin/xlint/common/emit.c	Wed Dec 30 11:47:15 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: emit.c,v 1.8 2020/12/30 10:46:11 rillig Exp $	*/
+/*	$NetBSD: emit.c,v 1.9 2020/12/30 11:47:15 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: emit.c,v 1.8 2020/12/30 10:46:11 rillig Exp $");
+__RCSID("$NetBSD: emit.c,v 1.9 2020/12/30 11:47:15 rillig Exp $");
 #endif
 
 #include 
@@ -133,7 +133,7 @@ outchar(int c)
 }
 
 /*
- * write a character to the output buffer, qouted if necessary
+ * write a character to the output buffer, quoted if necessary
  */
 void
 outqchar(int c)
@@ -175,8 +175,8 @@ outqchar(int c)
 			outchar('a');
 			break;
 		default:
-			outcharu_int)c >> 6) & 07) + '0');
-			outcharu_int)c >> 3) & 07) + '0');
+			outcharunsigned char)c >> 6) & 07) + '0');
+			outcharunsigned char)c >> 3) & 07) + '0');
 			outchar((c & 07) + '0');
 			break;
 		}



CVS commit: src/usr.bin/xlint/common

2020-12-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Dec 30 11:43:13 UTC 2020

Modified Files:
src/usr.bin/xlint/common: param.h

Log Message:
lint: remove unused macro STRBLEN


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/xlint/common/param.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/xlint/common/param.h
diff -u src/usr.bin/xlint/common/param.h:1.7 src/usr.bin/xlint/common/param.h:1.8
--- src/usr.bin/xlint/common/param.h:1.7	Wed Dec 30 11:39:55 2020
+++ src/usr.bin/xlint/common/param.h	Wed Dec 30 11:43:13 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.7 2020/12/30 11:39:55 rillig Exp $	*/
+/*	$NetBSD: param.h,v 1.8 2020/12/30 11:43:13 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -32,12 +32,6 @@
  */
 
 /*
- * Minimun size of string buffer. If this is not enough, the buffer
- * is enlarged in steps of STRBLEN bytes.
- */
-#define	STRBLEN		256
-
-/*
  * The size of memory blocks which are used to allocate memory in larger
  * chunks.
  */



CVS commit: src/usr.bin/xlint/common

2020-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Dec 28 22:16:42 UTC 2020

Modified Files:
src/usr.bin/xlint/common: mem.c

Log Message:
lint: remove trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/xlint/common/mem.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/xlint/common/mem.c
diff -u src/usr.bin/xlint/common/mem.c:1.9 src/usr.bin/xlint/common/mem.c:1.10
--- src/usr.bin/xlint/common/mem.c:1.9	Mon Dec 28 21:24:55 2020
+++ src/usr.bin/xlint/common/mem.c	Mon Dec 28 22:16:42 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: mem.c,v 1.9 2020/12/28 21:24:55 rillig Exp $	*/
+/*	$NetBSD: mem.c,v 1.10 2020/12/28 22:16:42 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: mem.c,v 1.9 2020/12/28 21:24:55 rillig Exp $");
+__RCSID("$NetBSD: mem.c,v 1.10 2020/12/28 22:16:42 rillig Exp $");
 #endif
 
 #include 
@@ -137,4 +137,3 @@ xmapalloc(size_t len)
 		err(1, "Cannot map memory for %lu bytes", (unsigned long)len);
 	return p;
 }
- 
\ No newline at end of file



CVS commit: src/usr.bin/xlint/common

2020-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Dec 28 18:06:23 UTC 2020

Modified Files:
src/usr.bin/xlint/common: lint.h

Log Message:
lint: fix typo in comment


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/xlint/common/lint.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/xlint/common/lint.h
diff -u src/usr.bin/xlint/common/lint.h:1.14 src/usr.bin/xlint/common/lint.h:1.15
--- src/usr.bin/xlint/common/lint.h:1.14	Fri Sep  7 15:16:15 2018
+++ src/usr.bin/xlint/common/lint.h	Mon Dec 28 18:06:23 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lint.h,v 1.14 2018/09/07 15:16:15 christos Exp $	*/
+/*	$NetBSD: lint.h,v 1.15 2020/12/28 18:06:23 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -100,7 +100,7 @@ typedef	struct {
 	u_int	tt_isatyp : 1;		/* 1 if arithmetic type */
 	u_int	tt_issclt : 1;		/* 1 if scalar type */
 	u_int	tt_isctyp : 1;		/* 1 if complex type */
-	const char *tt_name;		/* Bezeichnung des Typs */
+	const char *tt_name;		/* name of the type */
 } ttab_t;
 
 #define size(t)		(ttab[t].tt_sz)



CVS commit: src/usr.bin/xlint/common

2018-11-16 Thread Sean Cole
Module Name:src
Committed By:   scole
Date:   Fri Nov 16 20:49:08 UTC 2018

Modified Files:
src/usr.bin/xlint/common: lp64.h

Log Message:
PR toolchain/53710

allow 64bit target to compile on 32bit host

Ok'ed by 


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/xlint/common/lp64.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/xlint/common/lp64.h
diff -u src/usr.bin/xlint/common/lp64.h:1.6 src/usr.bin/xlint/common/lp64.h:1.7
--- src/usr.bin/xlint/common/lp64.h:1.6	Sun Oct  7 14:20:01 2018
+++ src/usr.bin/xlint/common/lp64.h	Fri Nov 16 20:49:08 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: lp64.h,v 1.6 2018/10/07 14:20:01 christos Exp $	*/
+/*	$NetBSD: lp64.h,v 1.7 2018/11/16 20:49:08 scole Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -45,7 +45,9 @@
 #define	LONG_SIZE	(8 * CHAR_BIT)
 #define	QUAD_SIZE	(8 * CHAR_BIT)
 #define	PTR_SIZE	(8 * CHAR_BIT)
+#ifdef _LP64
 #define	INT128_SIZE	(16 * CHAR_BIT)
+#endif
 
 #define	TARG_SCHAR_MAX	((signed char) (((unsigned char) -1) >> 1))
 #define	TARG_SCHAR_MIN	((-TARG_CHAR_MAX) - 1)
@@ -67,7 +69,7 @@
 #define	TARG_QUAD_MIN	((-TARG_QUAD_MAX) - 1)
 #define	TARG_UQUAD_MAX	((uint64_t) -1)
 
-#ifndef _LP64
+#ifdef _LP64
 /* XXX on a 32 build for a 64 build host we skip these */
 #define	TARG_INT128_MAX		((__int128_t) (((__uint128_t) -1) >> 1))
 #define	TARG_INT128_MIN		((-TARG_INT128_MAX) - 1)



CVS commit: src/usr.bin/xlint/common

2016-08-19 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Aug 19 10:18:11 UTC 2016

Modified Files:
src/usr.bin/xlint/common: externs.h tyname.c

Log Message:
add a type comparison function.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/xlint/common/externs.h
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/xlint/common/tyname.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/xlint/common/externs.h
diff -u src/usr.bin/xlint/common/externs.h:1.5 src/usr.bin/xlint/common/externs.h:1.6
--- src/usr.bin/xlint/common/externs.h:1.5	Thu Apr 17 14:52:03 2014
+++ src/usr.bin/xlint/common/externs.h	Fri Aug 19 06:18:11 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: externs.h,v 1.5 2014/04/17 18:52:03 christos Exp $	*/
+/*	$NetBSD: externs.h,v 1.6 2016/08/19 10:18:11 christos Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -44,7 +44,8 @@ extern	void	inittyp(void);
 /*
  * tyname.c
  */
-extern	const	char *tyname(char *, size_t, type_t *);
+extern	const	char *tyname(char *, size_t, const type_t *);
+extern	int	sametype(const type_t *, const type_t *);
 extern	const	char *basictyname(tspec_t);
 
 /*

Index: src/usr.bin/xlint/common/tyname.c
diff -u src/usr.bin/xlint/common/tyname.c:1.11 src/usr.bin/xlint/common/tyname.c:1.12
--- src/usr.bin/xlint/common/tyname.c:1.11	Wed Jun 20 14:50:11 2012
+++ src/usr.bin/xlint/common/tyname.c	Fri Aug 19 06:18:11 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: tyname.c,v 1.11 2012/06/20 18:50:11 christos Exp $	*/
+/*	$NetBSD: tyname.c,v 1.12 2016/08/19 10:18:11 christos Exp $	*/
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tyname.c,v 1.11 2012/06/20 18:50:11 christos Exp $");
+__RCSID("$NetBSD: tyname.c,v 1.12 2016/08/19 10:18:11 christos Exp $");
 #endif
 
 #include 
@@ -88,8 +88,68 @@ basictyname(tspec_t t)
 	}
 }
 
+int
+sametype(const type_t *t1, const type_t *t2)
+{
+	tspec_t	t;
+
+	if (t1->t_tspec != t2->t_tspec)
+		return 0;
+
+	/* Ignore const/void */
+
+	switch (t = t1->t_tspec) {
+	case BOOL:
+	case CHAR:
+	case UCHAR:
+	case SCHAR:
+	case SHORT:
+	case USHORT:
+	case INT:
+	case UINT:
+	case LONG:
+	case ULONG:
+	case QUAD:
+	case UQUAD:
+	case FLOAT:
+	case DOUBLE:
+	case LDOUBLE:
+	case VOID:
+	case FUNC:
+	case COMPLEX:
+	case FCOMPLEX:
+	case DCOMPLEX:
+	case LCOMPLEX:
+		return 1;
+	case ARRAY:
+		if (t1->t_dim != t2->t_dim)
+			return 0;
+		/*FALLTHROUGH*/
+	case PTR:
+		return sametype(t1->t_subt, t2->t_subt);
+	case ENUM:
+#ifdef t_enum
+		return strcmp(t1->t_enum->etag->s_name,
+		t2->t_enum->etag->s_name) == 0;
+#else
+		return 1;
+#endif
+	case STRUCT:
+	case UNION:
+#ifdef t_str
+		return strcmp(t1->t_str->stag->s_name,
+		t2->t_str->stag->s_name) == 0;
+#else
+		return 1;
+#endif
+	default:
+		LERROR("tyname(%d)", t);
+		return 0;
+	}
+}
+
 const char *
-tyname(char *buf, size_t bufsiz, type_t *tp)
+tyname(char *buf, size_t bufsiz, const type_t *tp)
 {
 	tspec_t	t;
 	const	char *s;



CVS commit: src/usr.bin/xlint/common

2014-04-17 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Apr 17 18:52:03 UTC 2014

Modified Files:
src/usr.bin/xlint/common: emit.c externs.h

Log Message:
make outname print where it came from in case of error


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/xlint/common/emit.c
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/xlint/common/externs.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/xlint/common/emit.c
diff -u src/usr.bin/xlint/common/emit.c:1.5 src/usr.bin/xlint/common/emit.c:1.6
--- src/usr.bin/xlint/common/emit.c:1.5	Tue Apr 14 21:20:57 2009
+++ src/usr.bin/xlint/common/emit.c	Thu Apr 17 14:52:03 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: emit.c,v 1.5 2009/04/15 01:20:57 christos Exp $	*/
+/*	$NetBSD: emit.c,v 1.6 2014/04/17 18:52:03 christos Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(lint)
-__RCSID($NetBSD: emit.c,v 1.5 2009/04/15 01:20:57 christos Exp $);
+__RCSID($NetBSD: emit.c,v 1.6 2014/04/17 18:52:03 christos Exp $);
 #endif
 
 #include ctype.h
@@ -216,11 +216,11 @@ outint(int i)
  * the name is preceded by its length
  */
 void
-outname(const char *name)
+outname1(const char *file, size_t line, const char *name)
 {
 
 	if (name == NULL)
-		errx(1, internal error: outname() 1);
+		errx(1, %s, %zu: internal error: outname(NULL), file, line);
 	outint((int)strlen(name));
 	outstrg(name);
 }

Index: src/usr.bin/xlint/common/externs.h
diff -u src/usr.bin/xlint/common/externs.h:1.4 src/usr.bin/xlint/common/externs.h:1.5
--- src/usr.bin/xlint/common/externs.h:1.4	Thu Apr  7 12:28:40 2005
+++ src/usr.bin/xlint/common/externs.h	Thu Apr 17 14:52:03 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: externs.h,v 1.4 2005/04/07 16:28:40 christos Exp $	*/
+/*	$NetBSD: externs.h,v 1.5 2014/04/17 18:52:03 christos Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -69,5 +69,6 @@ extern	void	outchar(int);
 extern	void	outqchar(int);
 extern	void	outstrg(const char *);
 extern	void	outint(int);
-extern	void	outname(const char *);
+#define outname(a)	outname1(__FILE__, __LINE__, a);
+extern	void	outname1(const char *, size_t, const char *);
 extern	void	outsrc(const char *);



CVS commit: src/usr.bin/xlint/common

2012-06-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Jun 20 18:50:11 UTC 2012

Modified Files:
src/usr.bin/xlint/common: tyname.c

Log Message:
better to print (null) than core-dump


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/xlint/common/tyname.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/xlint/common/tyname.c
diff -u src/usr.bin/xlint/common/tyname.c:1.10 src/usr.bin/xlint/common/tyname.c:1.11
--- src/usr.bin/xlint/common/tyname.c:1.10	Fri Sep 26 19:51:04 2008
+++ src/usr.bin/xlint/common/tyname.c	Wed Jun 20 14:50:11 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: tyname.c,v 1.10 2008/09/26 23:51:04 matt Exp $	*/
+/*	$NetBSD: tyname.c,v 1.11 2012/06/20 18:50:11 christos Exp $	*/
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(lint)
-__RCSID($NetBSD: tyname.c,v 1.10 2008/09/26 23:51:04 matt Exp $);
+__RCSID($NetBSD: tyname.c,v 1.11 2012/06/20 18:50:11 christos Exp $);
 #endif
 
 #include limits.h
@@ -96,6 +96,8 @@ tyname(char *buf, size_t bufsiz, type_t 
 	char lbuf[64];
 	char cv[20];
 
+	if (tp == NULL)
+		return (null);
 	if ((t = tp-t_tspec) == INT  tp-t_isenum)
 		t = ENUM;