21
21
#include <stdbool.h>
22
22
#include <errno.h>
23
23
24
+ #include <hashtable.h>
24
25
#include <list.h>
25
26
#include "modpost.h"
26
27
#include "../../include/linux/license.h"
@@ -201,13 +202,8 @@ static struct module *new_module(const char *name, size_t namelen)
201
202
return mod ;
202
203
}
203
204
204
- /* A hash of all exported symbols,
205
- * struct symbol is also used for lists of unresolved symbols */
206
-
207
- #define SYMBOL_HASH_SIZE 1024
208
-
209
205
struct symbol {
210
- struct symbol * next ;
206
+ struct hlist_node hnode ; /* link to hash table */
211
207
struct list_head list ; /* link to module::exported_symbols or module::unresolved_symbols */
212
208
struct module * module ;
213
209
char * namespace ;
@@ -220,7 +216,7 @@ struct symbol {
220
216
char name [];
221
217
};
222
218
223
- static struct symbol * symbolhash [ SYMBOL_HASH_SIZE ] ;
219
+ static HASHTABLE_DEFINE ( symbol_hashtable , 1U << 10 ) ;
224
220
225
221
/* This is based on the hash algorithm from gdbm, via tdb */
226
222
static inline unsigned int tdb_hash (const char * name )
@@ -252,11 +248,7 @@ static struct symbol *alloc_symbol(const char *name)
252
248
/* For the hash of exported symbols */
253
249
static void hash_add_symbol (struct symbol * sym )
254
250
{
255
- unsigned int hash ;
256
-
257
- hash = tdb_hash (sym -> name ) % SYMBOL_HASH_SIZE ;
258
- sym -> next = symbolhash [hash ];
259
- symbolhash [hash ] = sym ;
251
+ hash_add (symbol_hashtable , & sym -> hnode , tdb_hash (sym -> name ));
260
252
}
261
253
262
254
static void sym_add_unresolved (const char * name , struct module * mod , bool weak )
@@ -277,7 +269,7 @@ static struct symbol *sym_find_with_module(const char *name, struct module *mod)
277
269
if (name [0 ] == '.' )
278
270
name ++ ;
279
271
280
- for ( s = symbolhash [ tdb_hash (name ) % SYMBOL_HASH_SIZE ]; s ; s = s -> next ) {
272
+ hash_for_each_possible ( symbol_hashtable , s , hnode , tdb_hash (name )) {
281
273
if (strcmp (s -> name , name ) == 0 && (!mod || s -> module == mod ))
282
274
return s ;
283
275
}
0 commit comments