Hash table in FreeBSD kernel?
Yue Chen
ycyc321 at gmail.com
Mon Mar 16 19:19:24 UTC 2015
Dear all,
Is there a good hash table implementation for FreeBSD kernel, x86_64? I
tried "uthash", but encountered some memory problems (during HASH_FIND())
when the entry number becomes large. The cause may be my replacements for
the user-space header functions and types are incorrect.
=====================================================================
The userland functions/types need to be replaced:
#include <string.h> /* memcmp,strlen */
#include <stddef.h> /* ptrdiff_t */
#include <stdlib.h> /* exit() */ /* malloc() */
=====================================================================
I use:
#include <sys/systm.h> /* memcmp */
#include <sys/_types.h>
typedef __ptrdiff_t ptrdiff_t;
#include <sys/types.h>
#include <sys/malloc.h> /* the malloc() */
------------------------------------------------------------------------------------------------------------------------
size_t strlen(const char *str)
{
const char *s;
for (s = str; *s; ++s);
return(s - str);
}
=====================================================================
Any suggestions for using "uthash" in kernel, or any other alternatives
that I can use? (the FreeBSD kernel's "hash32" function set seems only
support 32-bit key hash)
Best regards and thanks,
Yue
More information about the freebsd-hackers
mailing list