Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make make(1): don't use bitfields in list processing
details: https://anonhg.NetBSD.org/src/rev/3a2c5ee707b3
branches: trunk
changeset: 942863:3a2c5ee707b3
user: rillig <rillig%NetBSD.org@localhost>
date: Fri Aug 21 03:03:45 2020 +0000
description:
make(1): don't use bitfields in list processing
There is no need to squeeze unrelated fields of the struct into a single
object. A bitset with a single flag is the same as a simple boolean
variable.
diffstat:
usr.bin/make/lst.c | 27 +++++++++++++--------------
1 files changed, 13 insertions(+), 14 deletions(-)
diffs (89 lines):
diff -r c823efae7617 -r 3a2c5ee707b3 usr.bin/make/lst.c
--- a/usr.bin/make/lst.c Fri Aug 21 02:56:25 2020 +0000
+++ b/usr.bin/make/lst.c Fri Aug 21 03:03:45 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lst.c,v 1.6 2020/08/21 02:56:25 rillig Exp $ */
+/* $NetBSD: lst.c,v 1.7 2020/08/21 03:03:45 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -36,27 +36,23 @@
#include "make_malloc.h"
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: lst.c,v 1.6 2020/08/21 02:56:25 rillig Exp $";
+static char rcsid[] = "$NetBSD: lst.c,v 1.7 2020/08/21 03:03:45 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: lst.c,v 1.6 2020/08/21 02:56:25 rillig Exp $");
+__RCSID("$NetBSD: lst.c,v 1.7 2020/08/21 03:03:45 rillig Exp $");
#endif /* not lint */
#endif
typedef struct ListNode {
struct ListNode *prevPtr; /* previous element in list */
struct ListNode *nextPtr; /* next in list */
- unsigned int useCount: 8, /* Count of functions using the node.
+ uint8_t useCount; /* Count of functions using the node.
* node may not be deleted until count
* goes to 0 */
- flags: 8; /* Node status flags */
+ Boolean deleted; /* List node should be removed when done */
void *datum; /* datum associated with this element */
} *ListNode;
-/*
- * Flags required for synchronization
- */
-#define LN_DELETED 0x0001 /* List node should be removed when done */
typedef enum {
Head, Middle, Tail, Unknown
@@ -272,7 +268,8 @@
PAlloc (nLNode, ListNode);
nLNode->datum = d;
- nLNode->useCount = nLNode->flags = 0;
+ nLNode->useCount = 0;
+ nLNode->deleted = FALSE;
if (ln == NULL) {
nLNode->prevPtr = nLNode->nextPtr = NULL;
@@ -336,7 +333,8 @@
PAlloc (nLNode, ListNode);
nLNode->datum = d;
- nLNode->useCount = nLNode->flags = 0;
+ nLNode->useCount = 0;
+ nLNode->deleted = FALSE;
if (lNode == NULL) {
nLNode->nextPtr = nLNode->prevPtr = NULL;
@@ -473,7 +471,7 @@
if (lNode->useCount == 0) {
free(ln);
} else {
- lNode->flags |= LN_DELETED;
+ lNode->deleted = TRUE;
}
return SUCCESS;
@@ -793,7 +791,7 @@
done = 0;
}
- if (tln->flags & LN_DELETED) {
+ if (tln->deleted) {
free((char *)tln);
}
tln = next;
@@ -884,7 +882,8 @@
list1->firstPtr = nln;
}
nln->prevPtr = last;
- nln->flags = nln->useCount = 0;
+ nln->useCount = 0;
+ nln->deleted = FALSE;
last = nln;
}
Home |
Main Index |
Thread Index |
Old Index