Tue Sep 1 21:00:15 2020 UTC ()
make(1): replace Hash_Table macros with inline functions


(rillig)
diff -r1.19 -r1.20 src/usr.bin/make/hash.h

cvs diff -r1.19 -r1.20 src/usr.bin/make/hash.h (expand / switch to unified diff)

--- src/usr.bin/make/hash.h 2020/08/29 11:13:43 1.19
+++ src/usr.bin/make/hash.h 2020/09/01 21:00:15 1.20
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: hash.h,v 1.19 2020/08/29 11:13:43 rillig Exp $ */ 1/* $NetBSD: hash.h,v 1.20 2020/09/01 21:00:15 rillig Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. 4 * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
5 * 5 *
6 * This code is derived from software contributed to Berkeley by 6 * This code is derived from software contributed to Berkeley by
7 * Adam de Boor. 7 * Adam de Boor.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -104,43 +104,36 @@ typedef struct Hash_Table { @@ -104,43 +104,36 @@ typedef struct Hash_Table {
104} Hash_Table; 104} Hash_Table;
105 105
106/* 106/*
107 * The following structure is used by the searching routines 107 * The following structure is used by the searching routines
108 * to record where we are in the search. 108 * to record where we are in the search.
109 */ 109 */
110 110
111typedef struct Hash_Search { 111typedef struct Hash_Search {
112 Hash_Table *tablePtr; /* Table being searched. */ 112 Hash_Table *tablePtr; /* Table being searched. */
113 int nextIndex; /* Next bucket to check (after current). */ 113 int nextIndex; /* Next bucket to check (after current). */
114 Hash_Entry *hashEntryPtr; /* Next entry to check in current bucket. */ 114 Hash_Entry *hashEntryPtr; /* Next entry to check in current bucket. */
115} Hash_Search; 115} Hash_Search;
116 116
117/* 117static inline void * MAKE_ATTR_UNUSED
118 * Macros. 118Hash_GetValue(Hash_Entry *h)
119 */ 119{
120 120 return h->clientPtr;
121/* 121}
122 * void * Hash_GetValue(h) 122
123 * Hash_Entry *h; 123static inline void MAKE_ATTR_UNUSED
124 */ 124Hash_SetValue(Hash_Entry *h, void *datum)
125 125{
126#define Hash_GetValue(h) ((h)->clientPtr) 126 h->clientPtr = datum;
127 127}
128/* 
129 * Hash_SetValue(h, val); 
130 * Hash_Entry *h; 
131 * char *val; 
132 */ 
133 
134#define Hash_SetValue(h, val) ((h)->clientPtr = (val)) 
135 128
136void Hash_InitTable(Hash_Table *, int); 129void Hash_InitTable(Hash_Table *, int);
137void Hash_DeleteTable(Hash_Table *); 130void Hash_DeleteTable(Hash_Table *);
138Hash_Entry *Hash_FindEntry(Hash_Table *, const char *); 131Hash_Entry *Hash_FindEntry(Hash_Table *, const char *);
139Hash_Entry *Hash_CreateEntry(Hash_Table *, const char *, Boolean *); 132Hash_Entry *Hash_CreateEntry(Hash_Table *, const char *, Boolean *);
140void Hash_DeleteEntry(Hash_Table *, Hash_Entry *); 133void Hash_DeleteEntry(Hash_Table *, Hash_Entry *);
141Hash_Entry *Hash_EnumFirst(Hash_Table *, Hash_Search *); 134Hash_Entry *Hash_EnumFirst(Hash_Table *, Hash_Search *);
142Hash_Entry *Hash_EnumNext(Hash_Search *); 135Hash_Entry *Hash_EnumNext(Hash_Search *);
143void Hash_ForEach(Hash_Table *, void (*)(void *, void *), void *); 136void Hash_ForEach(Hash_Table *, void (*)(void *, void *), void *);
144void Hash_DebugStats(Hash_Table *, const char *); 137void Hash_DebugStats(Hash_Table *, const char *);
145 138
146#endif /* MAKE_HASH_H */ 139#endif /* MAKE_HASH_H */