History

modpost: replace tdb_hash() with hash_str()

Use a helper available in scripts/include/hash.h.

Masahiro Yamada committed 1 year ago

Commit 5eaea851 parent 6b1fabc1 file · +3 −15Browse files

Showing the changes to scripts (1 of 1 file). Show all

Unified · Split

scripts/mod/modpost.c+3−15
@@ -21,6 +21,7 @@ · 20 unmodified lines
21#include <stdbool.h>21#include <stdbool.h>
22#include <errno.h>22#include <errno.h>
23 23
24#include <hash.h>
24#include <hashtable.h>25#include <hashtable.h>
25#include <list.h>26#include <list.h>
26#include <xalloc.h>27#include <xalloc.h>
@@ -210,19 +211,6 @@ struct symbol { · 183 unmodified lines
210 211
211static HASHTABLE_DEFINE(symbol_hashtable, 1U << 10);212static HASHTABLE_DEFINE(symbol_hashtable, 1U << 10);
212 213
213/* This is based on the hash algorithm from gdbm, via tdb */
214static inline unsigned int tdb_hash(const char *name)
215{
216 unsigned value; /* Used to compute the hash value. */
217 unsigned i; /* Used to cycle through random values. */
218
219 /* Set the initial value from the key size. */
220 for (value = 0x238F13AF * strlen(name), i = 0; name[i]; i++)
221 value = (value + (((unsigned char *)name)[i] << (i*5 % 24)));
222
223 return (1103515243 * value + 12345);
224}
225
226/**214/**
227 * Allocate a new symbols for use in the hash of exported symbols or215 * Allocate a new symbols for use in the hash of exported symbols or
228 * the list of unresolved symbols per module216 * the list of unresolved symbols per module
@@ -240,7 +228,7 @@ static struct symbol *alloc_symbol(const char *name) · 11 unmodified lines
240/* For the hash of exported symbols */228/* For the hash of exported symbols */
241static void hash_add_symbol(struct symbol *sym)229static void hash_add_symbol(struct symbol *sym)
242{230{
243 hash_add(symbol_hashtable, &sym->hnode, tdb_hash(sym->name));231 hash_add(symbol_hashtable, &sym->hnode, hash_str(sym->name));
244}232}
245 233
246static void sym_add_unresolved(const char *name, struct module *mod, bool weak)234static void sym_add_unresolved(const char *name, struct module *mod, bool weak)
@@ -261,7 +249,7 @@ static struct symbol *sym_find_with_module(const char *name, struct module *mod) · 14 unmodified lines
261 if (name[0] == '.')249 if (name[0] == '.')
262 name++;250 name++;
263 251
264 hash_for_each_possible(symbol_hashtable, s, hnode, tdb_hash(name)) {252 hash_for_each_possible(symbol_hashtable, s, hnode, hash_str(name)) {
265 if (strcmp(s->name, name) == 0 && (!mod || s->module == mod))253 if (strcmp(s->name, name) == 0 && (!mod || s->module == mod))
266 return s;254 return s;
267 }255 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t