diff options
author | Nick Alcock <nick.alcock@oracle.com> | 2019-04-23 22:12:16 +0100 |
---|---|---|
committer | Nick Alcock <nick.alcock@oracle.com> | 2019-05-28 17:07:29 +0100 |
commit | c0754cdd9af6d8259eac5c9daad9f9b0611358dd (patch) | |
tree | 625374afe71c3246193da4a6c8be8df14d0859be /libctf/ctf-impl.h | |
parent | 479604f44fc1eaa02a97ebcc1b60f55a606c4046 (diff) | |
download | fsf-binutils-gdb-c0754cdd9af6d8259eac5c9daad9f9b0611358dd.zip fsf-binutils-gdb-c0754cdd9af6d8259eac5c9daad9f9b0611358dd.tar.gz fsf-binutils-gdb-c0754cdd9af6d8259eac5c9daad9f9b0611358dd.tar.bz2 |
libctf: hashing
libctf maintains two distinct hash ADTs, one (ctf_dynhash) for wrapping
dynamically-generated unknown-sized hashes during CTF file construction,
one (ctf_hash) for wrapping unchanging hashes whose size is known at
creation time for reading CTF files that were previously created.
In the binutils implementation, these are both fairly thin wrappers
around libiberty hashtab.
Unusually, this code is not kept synchronized with libdtrace-ctf,
due to its dependence on libiberty hashtab.
libctf/
* ctf-hash.c: New file.
* ctf-impl.h: New declarations.
Diffstat (limited to 'libctf/ctf-impl.h')
-rw-r--r-- | libctf/ctf-impl.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/libctf/ctf-impl.h b/libctf/ctf-impl.h index 268b2f3..31207cd 100644 --- a/libctf/ctf-impl.h +++ b/libctf/ctf-impl.h @@ -58,12 +58,41 @@ extern "C" #endif +/* libctf in-memory state. */ + +typedef struct ctf_fixed_hash ctf_hash_t; /* Private to ctf-hash.c. */ +typedef struct ctf_dynhash ctf_dynhash_t; /* Private to ctf-hash.c. */ + typedef struct ctf_list { struct ctf_list *l_prev; /* Previous pointer or tail pointer. */ struct ctf_list *l_next; /* Next pointer or head pointer. */ } ctf_list_t; +typedef unsigned int (*ctf_hash_fun) (const void *ptr); +extern unsigned int ctf_hash_integer (const void *ptr); +extern unsigned int ctf_hash_string (const void *ptr); + +typedef int (*ctf_hash_eq_fun) (const void *, const void *); +extern int ctf_hash_eq_integer (const void *, const void *); +extern int ctf_hash_eq_string (const void *, const void *); + +typedef void (*ctf_hash_free_fun) (void *); + +extern ctf_hash_t *ctf_hash_create (unsigned long, ctf_hash_fun, ctf_hash_eq_fun); +extern int ctf_hash_insert_type (ctf_hash_t *, ctf_file_t *, uint32_t, uint32_t); +extern int ctf_hash_define_type (ctf_hash_t *, ctf_file_t *, uint32_t, uint32_t); +extern ctf_id_t ctf_hash_lookup_type (ctf_hash_t *, ctf_file_t *, const char *); +extern uint32_t ctf_hash_size (const ctf_hash_t *); +extern void ctf_hash_destroy (ctf_hash_t *); + +extern ctf_dynhash_t *ctf_dynhash_create (ctf_hash_fun, ctf_hash_eq_fun, + ctf_hash_free_fun, ctf_hash_free_fun); +extern int ctf_dynhash_insert (ctf_dynhash_t *, void *, void *); +extern void ctf_dynhash_remove (ctf_dynhash_t *, const void *); +extern void *ctf_dynhash_lookup (ctf_dynhash_t *, const void *); +extern void ctf_dynhash_destroy (ctf_dynhash_t *); + #define ctf_list_prev(elem) ((void *)(((ctf_list_t *)(elem))->l_prev)) #define ctf_list_next(elem) ((void *)(((ctf_list_t *)(elem))->l_next)) |