Coverage Report

Created: 2023-08-28 06:31

/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-2023 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
3.41M
{
55
3.41M
  string_tuple_t *tuple = table->alloc_f (1, sizeof (*tuple));
56
3.41M
  tuple->key = key;
57
3.41M
  tuple->value = value;
58
3.41M
  return tuple;
59
3.41M
}
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
104k
{
55
104k
  string_tuple_t *tuple = table->alloc_f (1, sizeof (*tuple));
56
104k
  tuple->key = key;
57
104k
  tuple->value = value;
58
104k
  return tuple;
59
104k
}
Unexecuted instantiation: messages.c:string_tuple_alloc
Unexecuted instantiation: output-file.c:string_tuple_alloc
read.c:string_tuple_alloc
Line
Count
Source
54
285k
{
55
285k
  string_tuple_t *tuple = table->alloc_f (1, sizeof (*tuple));
56
285k
  tuple->key = key;
57
285k
  tuple->value = value;
58
285k
  return tuple;
59
285k
}
Unexecuted instantiation: remap.c:string_tuple_alloc
Unexecuted instantiation: sb.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: hash.c:string_tuple_alloc
Unexecuted instantiation: input-file.c:string_tuple_alloc
Unexecuted instantiation: sframe-opt.c:string_tuple_alloc
tc-i386.c:string_tuple_alloc
Line
Count
Source
54
3.02M
{
55
3.02M
  string_tuple_t *tuple = table->alloc_f (1, sizeof (*tuple));
56
3.02M
  tuple->key = key;
57
3.02M
  tuple->value = value;
58
3.02M
  return tuple;
59
3.02M
}
Unexecuted instantiation: obj-elf.c:string_tuple_alloc
Unexecuted instantiation: atof-ieee.c:string_tuple_alloc
60
61
static inline void *
62
str_hash_find (htab_t table, const char *key)
63
4.67M
{
64
4.67M
  string_tuple_t needle = { key, NULL };
65
4.67M
  string_tuple_t *tuple = htab_find (table, &needle);
66
4.67M
  return tuple != NULL ? (void *) tuple->value : NULL;
67
4.67M
}
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
macro.c:str_hash_find
Line
Count
Source
63
1.09M
{
64
1.09M
  string_tuple_t needle = { key, NULL };
65
1.09M
  string_tuple_t *tuple = htab_find (table, &needle);
66
1.09M
  return tuple != NULL ? (void *) tuple->value : NULL;
67
1.09M
}
Unexecuted instantiation: messages.c:str_hash_find
Unexecuted instantiation: output-file.c:str_hash_find
read.c:str_hash_find
Line
Count
Source
63
1.77M
{
64
1.77M
  string_tuple_t needle = { key, NULL };
65
1.77M
  string_tuple_t *tuple = htab_find (table, &needle);
66
1.77M
  return tuple != NULL ? (void *) tuple->value : NULL;
67
1.77M
}
Unexecuted instantiation: remap.c:str_hash_find
Unexecuted instantiation: sb.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: hash.c:str_hash_find
Unexecuted instantiation: input-file.c:str_hash_find
Unexecuted instantiation: sframe-opt.c:str_hash_find
tc-i386.c:str_hash_find
Line
Count
Source
63
1.79M
{
64
1.79M
  string_tuple_t needle = { key, NULL };
65
1.79M
  string_tuple_t *tuple = htab_find (table, &needle);
66
1.79M
  return tuple != NULL ? (void *) tuple->value : NULL;
67
1.79M
}
Unexecuted instantiation: obj-elf.c:str_hash_find
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: 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: hash.c:str_hash_find_n
Unexecuted instantiation: input-file.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
76
{
84
76
  string_tuple_t needle = { key, NULL };
85
76
  htab_remove_elt (table, &needle);
86
76
}
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
macro.c:str_hash_delete
Line
Count
Source
83
1
{
84
1
  string_tuple_t needle = { key, NULL };
85
1
  htab_remove_elt (table, &needle);
86
1
}
Unexecuted instantiation: messages.c:str_hash_delete
Unexecuted instantiation: output-file.c:str_hash_delete
read.c:str_hash_delete
Line
Count
Source
83
75
{
84
75
  string_tuple_t needle = { key, NULL };
85
75
  htab_remove_elt (table, &needle);
86
75
}
Unexecuted instantiation: remap.c:str_hash_delete
Unexecuted instantiation: sb.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: hash.c:str_hash_delete
Unexecuted instantiation: input-file.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
3.41M
{
91
3.41M
  string_tuple_t *elt = string_tuple_alloc (table, key, value);
92
3.41M
  void **slot = htab_insert (table, elt, replace);
93
3.41M
  if (slot && !replace && table->free_f)
94
0
    table->free_f (elt);
95
3.41M
  return slot;
96
3.41M
}
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
macro.c:str_hash_insert
Line
Count
Source
90
104k
{
91
104k
  string_tuple_t *elt = string_tuple_alloc (table, key, value);
92
104k
  void **slot = htab_insert (table, elt, replace);
93
104k
  if (slot && !replace && table->free_f)
94
0
    table->free_f (elt);
95
104k
  return slot;
96
104k
}
Unexecuted instantiation: messages.c:str_hash_insert
Unexecuted instantiation: output-file.c:str_hash_insert
read.c:str_hash_insert
Line
Count
Source
90
285k
{
91
285k
  string_tuple_t *elt = string_tuple_alloc (table, key, value);
92
285k
  void **slot = htab_insert (table, elt, replace);
93
285k
  if (slot && !replace && table->free_f)
94
0
    table->free_f (elt);
95
285k
  return slot;
96
285k
}
Unexecuted instantiation: remap.c:str_hash_insert
Unexecuted instantiation: sb.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: hash.c:str_hash_insert
Unexecuted instantiation: input-file.c:str_hash_insert
Unexecuted instantiation: sframe-opt.c:str_hash_insert
tc-i386.c:str_hash_insert
Line
Count
Source
90
3.02M
{
91
3.02M
  string_tuple_t *elt = string_tuple_alloc (table, key, value);
92
3.02M
  void **slot = htab_insert (table, elt, replace);
93
3.02M
  if (slot && !replace && table->free_f)
94
0
    table->free_f (elt);
95
3.02M
  return slot;
96
3.02M
}
Unexecuted instantiation: obj-elf.c:str_hash_insert
Unexecuted instantiation: atof-ieee.c:str_hash_insert
97
98
static inline htab_t
99
str_htab_create (void)
100
88.2k
{
101
88.2k
  return htab_create_alloc (16, hash_string_tuple, eq_string_tuple,
102
88.2k
          NULL, notes_calloc, NULL);
103
88.2k
}
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
macro.c:str_htab_create
Line
Count
Source
100
84.7k
{
101
84.7k
  return htab_create_alloc (16, hash_string_tuple, eq_string_tuple,
102
84.7k
          NULL, notes_calloc, NULL);
103
84.7k
}
Unexecuted instantiation: messages.c:str_htab_create
Unexecuted instantiation: output-file.c:str_htab_create
read.c:str_htab_create
Line
Count
Source
100
1.15k
{
101
1.15k
  return htab_create_alloc (16, hash_string_tuple, eq_string_tuple,
102
1.15k
          NULL, notes_calloc, NULL);
103
1.15k
}
Unexecuted instantiation: remap.c:str_htab_create
Unexecuted instantiation: sb.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: hash.c:str_htab_create
Unexecuted instantiation: input-file.c:str_htab_create
Unexecuted instantiation: sframe-opt.c:str_htab_create
tc-i386.c:str_htab_create
Line
Count
Source
100
2.30k
{
101
2.30k
  return htab_create_alloc (16, hash_string_tuple, eq_string_tuple,
102
2.30k
          NULL, notes_calloc, NULL);
103
2.30k
}
Unexecuted instantiation: obj-elf.c:str_htab_create
Unexecuted instantiation: atof-ieee.c:str_htab_create
104
105
#endif /* HASH_H */