/src/binutils-gdb/gas/hash.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* hash.h -- header file for gas hash table routines |
2 | | Copyright (C) 1987-2024 Free Software Foundation, Inc. |
3 | | |
4 | | This file is part of GAS, the GNU Assembler. |
5 | | |
6 | | GAS is free software; you can redistribute it and/or modify |
7 | | it under the terms of the GNU General Public License as published by |
8 | | the Free Software Foundation; either version 3, or (at your option) |
9 | | any later version. |
10 | | |
11 | | GAS is distributed in the hope that it will be useful, |
12 | | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | | GNU General Public License for more details. |
15 | | |
16 | | You should have received a copy of the GNU General Public License |
17 | | along with GAS; see the file COPYING. If not, write to the Free |
18 | | Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA |
19 | | 02110-1301, USA. */ |
20 | | |
21 | | #ifndef HASH_H |
22 | | #define HASH_H |
23 | | |
24 | | struct string_tuple |
25 | | { |
26 | | const char *key; |
27 | | const void *value; |
28 | | }; |
29 | | |
30 | | typedef struct string_tuple string_tuple_t; |
31 | | |
32 | | /* Hash function for a string_tuple. */ |
33 | | |
34 | | extern hashval_t hash_string_tuple (const void *); |
35 | | |
36 | | /* Equality function for a string_tuple. */ |
37 | | |
38 | | extern int eq_string_tuple (const void *, const void *); |
39 | | |
40 | | /* Insert ELEMENT into HTAB. If REPLACE is non-zero existing elements |
41 | | are overwritten. If ELEMENT already exists, a pointer to the slot |
42 | | is returned. Otherwise NULL is returned. */ |
43 | | |
44 | | extern void **htab_insert (htab_t, void * /* element */, int /* replace */); |
45 | | |
46 | | /* Print statistics about a hash table. */ |
47 | | |
48 | | extern void htab_print_statistics (FILE *f, const char *name, htab_t table); |
49 | | |
50 | | /* Inline string hash table functions. */ |
51 | | |
52 | | static inline string_tuple_t * |
53 | | string_tuple_alloc (htab_t table, const char *key, const void *value) |
54 | 2.16M | { |
55 | 2.16M | string_tuple_t *tuple = table->alloc_f (1, sizeof (*tuple)); |
56 | 2.16M | tuple->key = key; |
57 | 2.16M | tuple->value = value; |
58 | 2.16M | return tuple; |
59 | 2.16M | } Unexecuted instantiation: fuzz_as.c:string_tuple_alloc Unexecuted instantiation: codeview.c:string_tuple_alloc Unexecuted instantiation: cond.c:string_tuple_alloc Unexecuted instantiation: depend.c:string_tuple_alloc Unexecuted instantiation: dw2gencfi.c:string_tuple_alloc Unexecuted instantiation: dwarf2dbg.c:string_tuple_alloc Unexecuted instantiation: ehopt.c:string_tuple_alloc Unexecuted instantiation: expr.c:string_tuple_alloc Unexecuted instantiation: frags.c:string_tuple_alloc Unexecuted instantiation: gen-sframe.c:string_tuple_alloc Unexecuted instantiation: input-scrub.c:string_tuple_alloc Unexecuted instantiation: listing.c:string_tuple_alloc macro.c:string_tuple_alloc Line | Count | Source | 54 | 2.77k | { | 55 | 2.77k | string_tuple_t *tuple = table->alloc_f (1, sizeof (*tuple)); | 56 | 2.77k | tuple->key = key; | 57 | 2.77k | tuple->value = value; | 58 | 2.77k | return tuple; | 59 | 2.77k | } |
Unexecuted instantiation: messages.c:string_tuple_alloc Unexecuted instantiation: output-file.c:string_tuple_alloc read.c:string_tuple_alloc Line | Count | Source | 54 | 181k | { | 55 | 181k | string_tuple_t *tuple = table->alloc_f (1, sizeof (*tuple)); | 56 | 181k | tuple->key = key; | 57 | 181k | tuple->value = value; | 58 | 181k | return tuple; | 59 | 181k | } |
Unexecuted instantiation: remap.c:string_tuple_alloc Unexecuted instantiation: sb.c:string_tuple_alloc Unexecuted instantiation: scfidw2gen.c:string_tuple_alloc Unexecuted instantiation: stabs.c:string_tuple_alloc Unexecuted instantiation: subsegs.c:string_tuple_alloc Unexecuted instantiation: symbols.c:string_tuple_alloc Unexecuted instantiation: write.c:string_tuple_alloc Unexecuted instantiation: app.c:string_tuple_alloc Unexecuted instantiation: atof-generic.c:string_tuple_alloc Unexecuted instantiation: ecoff.c:string_tuple_alloc Unexecuted instantiation: flonum-copy.c:string_tuple_alloc Unexecuted instantiation: ginsn.c:string_tuple_alloc Unexecuted instantiation: hash.c:string_tuple_alloc Unexecuted instantiation: input-file.c:string_tuple_alloc Unexecuted instantiation: scfi.c:string_tuple_alloc Unexecuted instantiation: sframe-opt.c:string_tuple_alloc tc-i386.c:string_tuple_alloc Line | Count | Source | 54 | 1.98M | { | 55 | 1.98M | string_tuple_t *tuple = table->alloc_f (1, sizeof (*tuple)); | 56 | 1.98M | tuple->key = key; | 57 | 1.98M | tuple->value = value; | 58 | 1.98M | return tuple; | 59 | 1.98M | } |
obj-elf.c:string_tuple_alloc Line | Count | Source | 54 | 9 | { | 55 | 9 | string_tuple_t *tuple = table->alloc_f (1, sizeof (*tuple)); | 56 | 9 | tuple->key = key; | 57 | 9 | tuple->value = value; | 58 | 9 | return tuple; | 59 | 9 | } |
Unexecuted instantiation: atof-ieee.c:string_tuple_alloc |
60 | | |
61 | | static inline void * |
62 | | str_hash_find (htab_t table, const char *key) |
63 | 3.09M | { |
64 | 3.09M | string_tuple_t needle = { key, NULL }; |
65 | 3.09M | string_tuple_t *tuple = htab_find (table, &needle); |
66 | 3.09M | return tuple != NULL ? (void *) tuple->value : NULL; |
67 | 3.09M | } Unexecuted instantiation: fuzz_as.c:str_hash_find Unexecuted instantiation: codeview.c:str_hash_find Unexecuted instantiation: cond.c:str_hash_find Unexecuted instantiation: depend.c:str_hash_find Unexecuted instantiation: dw2gencfi.c:str_hash_find Unexecuted instantiation: dwarf2dbg.c:str_hash_find Unexecuted instantiation: ehopt.c:str_hash_find Unexecuted instantiation: expr.c:str_hash_find Unexecuted instantiation: frags.c:str_hash_find Unexecuted instantiation: gen-sframe.c:str_hash_find Unexecuted instantiation: input-scrub.c:str_hash_find Unexecuted instantiation: listing.c:str_hash_find Line | Count | Source | 63 | 977k | { | 64 | 977k | string_tuple_t needle = { key, NULL }; | 65 | 977k | string_tuple_t *tuple = htab_find (table, &needle); | 66 | 977k | return tuple != NULL ? (void *) tuple->value : NULL; | 67 | 977k | } |
Unexecuted instantiation: messages.c:str_hash_find Unexecuted instantiation: output-file.c:str_hash_find Line | Count | Source | 63 | 715k | { | 64 | 715k | string_tuple_t needle = { key, NULL }; | 65 | 715k | string_tuple_t *tuple = htab_find (table, &needle); | 66 | 715k | return tuple != NULL ? (void *) tuple->value : NULL; | 67 | 715k | } |
Unexecuted instantiation: remap.c:str_hash_find Unexecuted instantiation: sb.c:str_hash_find Unexecuted instantiation: scfidw2gen.c:str_hash_find Unexecuted instantiation: stabs.c:str_hash_find Unexecuted instantiation: subsegs.c:str_hash_find Unexecuted instantiation: symbols.c:str_hash_find Unexecuted instantiation: write.c:str_hash_find Unexecuted instantiation: app.c:str_hash_find Unexecuted instantiation: atof-generic.c:str_hash_find Unexecuted instantiation: ecoff.c:str_hash_find Unexecuted instantiation: flonum-copy.c:str_hash_find Unexecuted instantiation: ginsn.c:str_hash_find Unexecuted instantiation: hash.c:str_hash_find Unexecuted instantiation: input-file.c:str_hash_find Unexecuted instantiation: scfi.c:str_hash_find Unexecuted instantiation: sframe-opt.c:str_hash_find Line | Count | Source | 63 | 1.40M | { | 64 | 1.40M | string_tuple_t needle = { key, NULL }; | 65 | 1.40M | string_tuple_t *tuple = htab_find (table, &needle); | 66 | 1.40M | return tuple != NULL ? (void *) tuple->value : NULL; | 67 | 1.40M | } |
Line | Count | Source | 63 | 2 | { | 64 | 2 | string_tuple_t needle = { key, NULL }; | 65 | 2 | string_tuple_t *tuple = htab_find (table, &needle); | 66 | 2 | return tuple != NULL ? (void *) tuple->value : NULL; | 67 | 2 | } |
Unexecuted instantiation: atof-ieee.c:str_hash_find |
68 | | |
69 | | static inline void * |
70 | | str_hash_find_n (htab_t table, const char *key, size_t n) |
71 | 0 | { |
72 | 0 | char *tmp = XNEWVEC (char, n + 1); |
73 | 0 | memcpy (tmp, key, n); |
74 | 0 | tmp[n] = '\0'; |
75 | 0 | string_tuple_t needle = { tmp, NULL }; |
76 | 0 | string_tuple_t *tuple = htab_find (table, &needle); |
77 | 0 | free (tmp); |
78 | 0 | return tuple != NULL ? (void *) tuple->value : NULL; |
79 | 0 | } Unexecuted instantiation: fuzz_as.c:str_hash_find_n Unexecuted instantiation: codeview.c:str_hash_find_n Unexecuted instantiation: cond.c:str_hash_find_n Unexecuted instantiation: depend.c:str_hash_find_n Unexecuted instantiation: dw2gencfi.c:str_hash_find_n Unexecuted instantiation: dwarf2dbg.c:str_hash_find_n Unexecuted instantiation: ehopt.c:str_hash_find_n Unexecuted instantiation: expr.c:str_hash_find_n Unexecuted instantiation: frags.c:str_hash_find_n Unexecuted instantiation: gen-sframe.c:str_hash_find_n Unexecuted instantiation: input-scrub.c:str_hash_find_n Unexecuted instantiation: listing.c:str_hash_find_n Unexecuted instantiation: macro.c:str_hash_find_n Unexecuted instantiation: messages.c:str_hash_find_n Unexecuted instantiation: output-file.c:str_hash_find_n Unexecuted instantiation: read.c:str_hash_find_n Unexecuted instantiation: remap.c:str_hash_find_n Unexecuted instantiation: sb.c:str_hash_find_n Unexecuted instantiation: scfidw2gen.c:str_hash_find_n Unexecuted instantiation: stabs.c:str_hash_find_n Unexecuted instantiation: subsegs.c:str_hash_find_n Unexecuted instantiation: symbols.c:str_hash_find_n Unexecuted instantiation: write.c:str_hash_find_n Unexecuted instantiation: app.c:str_hash_find_n Unexecuted instantiation: atof-generic.c:str_hash_find_n Unexecuted instantiation: ecoff.c:str_hash_find_n Unexecuted instantiation: flonum-copy.c:str_hash_find_n Unexecuted instantiation: ginsn.c:str_hash_find_n Unexecuted instantiation: hash.c:str_hash_find_n Unexecuted instantiation: input-file.c:str_hash_find_n Unexecuted instantiation: scfi.c:str_hash_find_n Unexecuted instantiation: sframe-opt.c:str_hash_find_n Unexecuted instantiation: tc-i386.c:str_hash_find_n Unexecuted instantiation: obj-elf.c:str_hash_find_n Unexecuted instantiation: atof-ieee.c:str_hash_find_n |
80 | | |
81 | | static inline void |
82 | | str_hash_delete (htab_t table, const char *key) |
83 | 251 | { |
84 | 251 | string_tuple_t needle = { key, NULL }; |
85 | 251 | htab_remove_elt (table, &needle); |
86 | 251 | } Unexecuted instantiation: fuzz_as.c:str_hash_delete Unexecuted instantiation: codeview.c:str_hash_delete Unexecuted instantiation: cond.c:str_hash_delete Unexecuted instantiation: depend.c:str_hash_delete Unexecuted instantiation: dw2gencfi.c:str_hash_delete Unexecuted instantiation: dwarf2dbg.c:str_hash_delete Unexecuted instantiation: ehopt.c:str_hash_delete Unexecuted instantiation: expr.c:str_hash_delete Unexecuted instantiation: frags.c:str_hash_delete Unexecuted instantiation: gen-sframe.c:str_hash_delete Unexecuted instantiation: input-scrub.c:str_hash_delete Unexecuted instantiation: listing.c:str_hash_delete Unexecuted instantiation: macro.c:str_hash_delete Unexecuted instantiation: messages.c:str_hash_delete Unexecuted instantiation: output-file.c:str_hash_delete Line | Count | Source | 83 | 251 | { | 84 | 251 | string_tuple_t needle = { key, NULL }; | 85 | 251 | htab_remove_elt (table, &needle); | 86 | 251 | } |
Unexecuted instantiation: remap.c:str_hash_delete Unexecuted instantiation: sb.c:str_hash_delete Unexecuted instantiation: scfidw2gen.c:str_hash_delete Unexecuted instantiation: stabs.c:str_hash_delete Unexecuted instantiation: subsegs.c:str_hash_delete Unexecuted instantiation: symbols.c:str_hash_delete Unexecuted instantiation: write.c:str_hash_delete Unexecuted instantiation: app.c:str_hash_delete Unexecuted instantiation: atof-generic.c:str_hash_delete Unexecuted instantiation: ecoff.c:str_hash_delete Unexecuted instantiation: flonum-copy.c:str_hash_delete Unexecuted instantiation: ginsn.c:str_hash_delete Unexecuted instantiation: hash.c:str_hash_delete Unexecuted instantiation: input-file.c:str_hash_delete Unexecuted instantiation: scfi.c:str_hash_delete Unexecuted instantiation: sframe-opt.c:str_hash_delete Unexecuted instantiation: tc-i386.c:str_hash_delete Unexecuted instantiation: obj-elf.c:str_hash_delete Unexecuted instantiation: atof-ieee.c:str_hash_delete |
87 | | |
88 | | static inline void ** |
89 | | str_hash_insert (htab_t table, const char *key, const void *value, int replace) |
90 | 2.16M | { |
91 | 2.16M | string_tuple_t *elt = string_tuple_alloc (table, key, value); |
92 | 2.16M | void **slot = htab_insert (table, elt, replace); |
93 | 2.16M | if (slot && !replace && table->free_f) |
94 | 0 | table->free_f (elt); |
95 | 2.16M | return slot; |
96 | 2.16M | } Unexecuted instantiation: fuzz_as.c:str_hash_insert Unexecuted instantiation: codeview.c:str_hash_insert Unexecuted instantiation: cond.c:str_hash_insert Unexecuted instantiation: depend.c:str_hash_insert Unexecuted instantiation: dw2gencfi.c:str_hash_insert Unexecuted instantiation: dwarf2dbg.c:str_hash_insert Unexecuted instantiation: ehopt.c:str_hash_insert Unexecuted instantiation: expr.c:str_hash_insert Unexecuted instantiation: frags.c:str_hash_insert Unexecuted instantiation: gen-sframe.c:str_hash_insert Unexecuted instantiation: input-scrub.c:str_hash_insert Unexecuted instantiation: listing.c:str_hash_insert Line | Count | Source | 90 | 2.77k | { | 91 | 2.77k | string_tuple_t *elt = string_tuple_alloc (table, key, value); | 92 | 2.77k | void **slot = htab_insert (table, elt, replace); | 93 | 2.77k | if (slot && !replace && table->free_f) | 94 | 0 | table->free_f (elt); | 95 | 2.77k | return slot; | 96 | 2.77k | } |
Unexecuted instantiation: messages.c:str_hash_insert Unexecuted instantiation: output-file.c:str_hash_insert Line | Count | Source | 90 | 181k | { | 91 | 181k | string_tuple_t *elt = string_tuple_alloc (table, key, value); | 92 | 181k | void **slot = htab_insert (table, elt, replace); | 93 | 181k | if (slot && !replace && table->free_f) | 94 | 0 | table->free_f (elt); | 95 | 181k | return slot; | 96 | 181k | } |
Unexecuted instantiation: remap.c:str_hash_insert Unexecuted instantiation: sb.c:str_hash_insert Unexecuted instantiation: scfidw2gen.c:str_hash_insert Unexecuted instantiation: stabs.c:str_hash_insert Unexecuted instantiation: subsegs.c:str_hash_insert Unexecuted instantiation: symbols.c:str_hash_insert Unexecuted instantiation: write.c:str_hash_insert Unexecuted instantiation: app.c:str_hash_insert Unexecuted instantiation: atof-generic.c:str_hash_insert Unexecuted instantiation: ecoff.c:str_hash_insert Unexecuted instantiation: flonum-copy.c:str_hash_insert Unexecuted instantiation: ginsn.c:str_hash_insert Unexecuted instantiation: hash.c:str_hash_insert Unexecuted instantiation: input-file.c:str_hash_insert Unexecuted instantiation: scfi.c:str_hash_insert Unexecuted instantiation: sframe-opt.c:str_hash_insert tc-i386.c:str_hash_insert Line | Count | Source | 90 | 1.98M | { | 91 | 1.98M | string_tuple_t *elt = string_tuple_alloc (table, key, value); | 92 | 1.98M | void **slot = htab_insert (table, elt, replace); | 93 | 1.98M | if (slot && !replace && table->free_f) | 94 | 0 | table->free_f (elt); | 95 | 1.98M | return slot; | 96 | 1.98M | } |
obj-elf.c:str_hash_insert Line | Count | Source | 90 | 9 | { | 91 | 9 | string_tuple_t *elt = string_tuple_alloc (table, key, value); | 92 | 9 | void **slot = htab_insert (table, elt, replace); | 93 | 9 | if (slot && !replace && table->free_f) | 94 | 0 | table->free_f (elt); | 95 | 9 | return slot; | 96 | 9 | } |
Unexecuted instantiation: atof-ieee.c:str_hash_insert |
97 | | |
98 | | static inline htab_t |
99 | | str_htab_create (void) |
100 | 5.87k | { |
101 | 5.87k | return htab_create_alloc (16, hash_string_tuple, eq_string_tuple, |
102 | 5.87k | NULL, notes_calloc, NULL); |
103 | 5.87k | } Unexecuted instantiation: fuzz_as.c:str_htab_create Unexecuted instantiation: codeview.c:str_htab_create Unexecuted instantiation: cond.c:str_htab_create Unexecuted instantiation: depend.c:str_htab_create Unexecuted instantiation: dw2gencfi.c:str_htab_create Unexecuted instantiation: dwarf2dbg.c:str_htab_create Unexecuted instantiation: ehopt.c:str_htab_create Unexecuted instantiation: expr.c:str_htab_create Unexecuted instantiation: frags.c:str_htab_create Unexecuted instantiation: gen-sframe.c:str_htab_create Unexecuted instantiation: input-scrub.c:str_htab_create Unexecuted instantiation: listing.c:str_htab_create Line | Count | Source | 100 | 3.66k | { | 101 | 3.66k | return htab_create_alloc (16, hash_string_tuple, eq_string_tuple, | 102 | 3.66k | NULL, notes_calloc, NULL); | 103 | 3.66k | } |
Unexecuted instantiation: messages.c:str_htab_create Unexecuted instantiation: output-file.c:str_htab_create Line | Count | Source | 100 | 736 | { | 101 | 736 | return htab_create_alloc (16, hash_string_tuple, eq_string_tuple, | 102 | 736 | NULL, notes_calloc, NULL); | 103 | 736 | } |
Unexecuted instantiation: remap.c:str_htab_create Unexecuted instantiation: sb.c:str_htab_create Unexecuted instantiation: scfidw2gen.c:str_htab_create Unexecuted instantiation: stabs.c:str_htab_create Unexecuted instantiation: subsegs.c:str_htab_create Unexecuted instantiation: symbols.c:str_htab_create Unexecuted instantiation: write.c:str_htab_create Unexecuted instantiation: app.c:str_htab_create Unexecuted instantiation: atof-generic.c:str_htab_create Unexecuted instantiation: ecoff.c:str_htab_create Unexecuted instantiation: flonum-copy.c:str_htab_create Unexecuted instantiation: ginsn.c:str_htab_create Unexecuted instantiation: hash.c:str_htab_create Unexecuted instantiation: input-file.c:str_htab_create Unexecuted instantiation: scfi.c:str_htab_create Unexecuted instantiation: sframe-opt.c:str_htab_create tc-i386.c:str_htab_create Line | Count | Source | 100 | 1.47k | { | 101 | 1.47k | return htab_create_alloc (16, hash_string_tuple, eq_string_tuple, | 102 | 1.47k | NULL, notes_calloc, NULL); | 103 | 1.47k | } |
Unexecuted instantiation: obj-elf.c:str_htab_create Unexecuted instantiation: atof-ieee.c:str_htab_create |
104 | | |
105 | | #endif /* HASH_H */ |