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 lint: use appropriate alignment on both ...
details: https://anonhg.NetBSD.org/src/rev/027de4a5978d
branches: trunk
changeset: 364651:027de4a5978d
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Apr 02 22:15:57 2022 +0000
description:
lint: use appropriate alignment on both the host and target platform
diffstat:
usr.bin/xlint/lint1/decl.c | 13 ++++++++-----
usr.bin/xlint/lint1/lint1.h | 17 +----------------
usr.bin/xlint/lint1/mem1.c | 7 ++++---
3 files changed, 13 insertions(+), 24 deletions(-)
diffs (103 lines):
diff -r d186724bbd64 -r 027de4a5978d usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c Sat Apr 02 21:47:04 2022 +0000
+++ b/usr.bin/xlint/lint1/decl.c Sat Apr 02 22:15:57 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.265 2022/04/02 21:47:04 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.266 2022/04/02 22:15:57 rillig 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.265 2022/04/02 21:47:04 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.266 2022/04/02 22:15:57 rillig Exp $");
#endif
#include <sys/param.h>
@@ -885,6 +885,9 @@
unsigned int a;
tspec_t t;
+ /* Super conservative so that it works for most systems. */
+ unsigned int worst_align_in_bits = 2 * LONG_SIZE;
+
while (tp->t_tspec == ARRAY)
tp = tp->t_subt;
@@ -894,12 +897,12 @@
lint_assert(t != FUNC);
if ((a = size_in_bits(t)) == 0) {
a = CHAR_SIZE;
- } else if (a > WORST_ALIGN(1) * CHAR_SIZE) {
- a = WORST_ALIGN(1) * CHAR_SIZE;
+ } else if (a > worst_align_in_bits) {
+ a = worst_align_in_bits;
}
}
lint_assert(a >= CHAR_SIZE);
- lint_assert(a <= WORST_ALIGN(1) * CHAR_SIZE);
+ lint_assert(a <= worst_align_in_bits);
return a;
}
diff -r d186724bbd64 -r 027de4a5978d usr.bin/xlint/lint1/lint1.h
--- a/usr.bin/xlint/lint1/lint1.h Sat Apr 02 21:47:04 2022 +0000
+++ b/usr.bin/xlint/lint1/lint1.h Sat Apr 02 22:15:57 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lint1.h,v 1.143 2022/04/02 14:28:30 rillig Exp $ */
+/* $NetBSD: lint1.h,v 1.144 2022/04/02 22:15:57 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -36,21 +36,6 @@
#include "err-msgs.h"
#include "op.h"
-/*
- * 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
-
#define LWARN_BAD (-3)
#define LWARN_ALL (-2)
#define LWARN_NONE (-1)
diff -r d186724bbd64 -r 027de4a5978d usr.bin/xlint/lint1/mem1.c
--- a/usr.bin/xlint/lint1/mem1.c Sat Apr 02 21:47:04 2022 +0000
+++ b/usr.bin/xlint/lint1/mem1.c Sat Apr 02 22:15:57 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mem1.c,v 1.61 2022/02/27 17:12:06 rillig Exp $ */
+/* $NetBSD: mem1.c,v 1.62 2022/04/02 22:15:57 rillig 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.61 2022/02/27 17:12:06 rillig Exp $");
+__RCSID("$NetBSD: mem1.c,v 1.62 2022/04/02 22:15:57 rillig Exp $");
#endif
#include <sys/param.h>
@@ -190,7 +190,8 @@
memory_block *mb;
void *p;
- s = WORST_ALIGN(s);
+ size_t worst_align = 2 * sizeof(long) - 1;
+ s = (s + worst_align) & ~worst_align;
if ((mb = *mbp) == NULL || mb->nfree < s) {
size_t block_size = s > mblk_size ? s : mblk_size;
Home |
Main Index |
Thread Index |
Old Index