binutils-gdb/libctf
Nick Alcock 54a0219150 libctf: remove static/dynamic name lookup distinction
libctf internally maintains a set of hash tables for type name lookups,
one for each valid C type namespace (struct, union, enum, and everything
else).

Or, rather, it maintains *two* sets of hash tables: one, a ctf_hash *,
is meant for lookups in ctf_(buf)open()ed dicts with fixed content; the
other, a ctf_dynhash *, is meant for lookups in ctf_create()d dicts.

This distinction was somewhat valuable in the far pre-binutils past when
two different hashtable implementations were used (one expanding, the
other fixed-size), but those days are long gone: the hash table
implementations are almost identical, both wrappers around the libiberty
hashtab. The ctf_dynhash has many more capabilities than the ctf_hash
(iteration, deletion, etc etc) and has no downsides other than starting
at a fixed, arbitrary small size.

That limitation is easy to lift (via a new ctf_dynhash_create_sized()),
following which we can throw away nearly all the ctf_hash
implementation, and all the code to choose between readable and writable
hashtabs; the few convenience functions that are still useful (for
insertion of name -> type mappings) can also be generalized a bit so
that the extra string verification they do is potentially available to
other string lookups as well.

(libctf still has two hashtable implementations, ctf_dynhash, above,
and ctf_dynset, which is a key-only hashtab that can avoid a great many
malloc()s, used for high-volume applications in the deduplicator.)

libctf/

	* ctf-create.c (ctf_create): Eliminate ctn_writable.
	(ctf_dtd_insert): Likewise.
	(ctf_dtd_delete): Likewise.
	(ctf_rollback): Likewise.
	(ctf_name_table): Eliminate ctf_names_t.
	* ctf-hash.c (ctf_dynhash_create): Comment update.
        Reimplement in terms of...
	(ctf_dynhash_create_sized): ... this new function.
	(ctf_hash_create): Remove.
	(ctf_hash_size): Remove.
	(ctf_hash_define_type): Remove.
	(ctf_hash_destroy): Remove.
	(ctf_hash_lookup_type): Rename to...
	(ctf_dynhash_lookup_type): ... this.
	(ctf_hash_insert_type): Rename to...
	(ctf_dynhash_insert_type): ... this, moving validation to...
	* ctf-string.c (ctf_strptr_validate): ... this new function.
	* ctf-impl.h (struct ctf_names): Extirpate.
	(struct ctf_lookup.ctl_hash): Now a ctf_dynhash_t.
	(struct ctf_dict): All ctf_names_t fields are now ctf_dynhash_t.
	(ctf_name_table): Now returns a ctf_dynhash_t.
	(ctf_lookup_by_rawhash): Remove.
	(ctf_hash_create): Likewise.
	(ctf_hash_insert_type): Likewise.
	(ctf_hash_define_type): Likewise.
	(ctf_hash_lookup_type): Likewise.
	(ctf_hash_size): Likewise.
	(ctf_hash_destroy): Likewise.
	(ctf_dynhash_create_sized): New.
	(ctf_dynhash_insert_type): New.
	(ctf_dynhash_lookup_type): New.
	(ctf_strptr_validate): New.
	* ctf-lookup.c (ctf_lookup_by_name_internal): Adapt.
	* ctf-open.c (init_types): Adapt.
	(ctf_set_ctl_hashes): Adapt.
	(ctf_dict_close): Adapt.
	* ctf-serialize.c (ctf_serialize): Adapt.
	* ctf-types.c (ctf_lookup_by_rawhash): Remove.
2024-04-19 16:14:46 +01:00
..
doc Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
testsuite libctf: fix uninitialized variables in testsuite 2024-03-11 17:16:12 +00:00
.gitignore libctf: restructure error handling to reduce relocations 2020-07-22 17:57:20 +01:00
aclocal.m4 mmap: Avoid the sanitizer configure check failure 2024-04-10 03:57:46 -07:00
ChangeLog Add markers for 2.42 branch 2024-01-15 14:42:15 +00:00
ChangeLog-2020 libctf: fix old ChangeLog typo 2021-01-05 14:53:40 +00:00
config.h.in Finalized intl-update patches 2023-11-15 12:53:04 +00:00
configure mmap: Avoid the sanitizer configure check failure 2024-04-10 03:57:46 -07:00
configure.ac mmap: Avoid the sanitizer configure check failure 2024-04-10 03:57:46 -07:00
ctf-archive.c libctf: don't leak the symbol name in the name->type cache 2024-04-19 16:14:45 +01:00
ctf-create.c libctf: remove static/dynamic name lookup distinction 2024-04-19 16:14:46 +01:00
ctf-decl.c Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
ctf-decls.h Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
ctf-dedup.c Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
ctf-dump.c Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
ctf-endian.h Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
ctf-error.c Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
ctf-hash.c libctf: remove static/dynamic name lookup distinction 2024-04-19 16:14:46 +01:00
ctf-impl.h libctf: remove static/dynamic name lookup distinction 2024-04-19 16:14:46 +01:00
ctf-inlines.h Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
ctf-intl.h Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
ctf-labels.c Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
ctf-link.c libctf warnings 2024-04-17 09:24:36 +09:30
ctf-lookup.c libctf: remove static/dynamic name lookup distinction 2024-04-19 16:14:46 +01:00
ctf-open-bfd.c Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
ctf-open.c libctf: remove static/dynamic name lookup distinction 2024-04-19 16:14:46 +01:00
ctf-qsort_r.c Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
ctf-serialize.c libctf: remove static/dynamic name lookup distinction 2024-04-19 16:14:46 +01:00
ctf-sha1.c Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
ctf-sha1.h Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
ctf-string.c libctf: remove static/dynamic name lookup distinction 2024-04-19 16:14:46 +01:00
ctf-subr.c Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
ctf-types.c libctf: remove static/dynamic name lookup distinction 2024-04-19 16:14:46 +01:00
ctf-util.c Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
elf.h Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
libctf.ver Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
Makefile.am Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
Makefile.in mmap: Avoid the sanitizer configure check failure 2024-04-10 03:57:46 -07:00
NEWS include, libctf, ld: extend variable section to contain functions too 2022-03-23 13:48:32 +00:00
swap.h libctf warnings 2024-04-17 09:24:36 +09:30