GDB (xrefs)
Loading...
Searching...
No Matches
gdb
dwarf2
index-common.c
Go to the documentation of this file.
1
/* Things needed for both reading and writing DWARF indices.
2
3
Copyright (C) 1994-2023 Free Software Foundation, Inc.
4
5
This file is part of GDB.
6
7
This program is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 3 of the License, or
10
(at your option) any later version.
11
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
16
17
You should have received a copy of the GNU General Public License
18
along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20
#include "
defs.h
"
21
#include "
dwarf2/index-common.h
"
22
23
/* See dwarf-index-common.h. */
24
25
hashval_t
26
mapped_index_string_hash
(
int
index_version,
const
void
*p)
27
{
28
const
unsigned
char
*str = (
const
unsigned
char
*) p;
29
hashval_t r = 0;
30
unsigned
char
c;
31
32
while
((c = *str++) != 0)
33
{
34
if
(index_version >= 5)
35
c = tolower (c);
36
r = r * 67 + c - 113;
37
}
38
39
return
r;
40
}
41
42
/* See dwarf-index-common.h. */
43
44
uint32_t
45
dwarf5_djb_hash
(
const
char
*str_)
46
{
47
const
unsigned
char
*str = (
const
unsigned
char
*) str_;
48
49
/* Note: tolower here ignores UTF-8, which isn't fully compliant.
50
See http://dwarfstd.org/ShowIssue.php?issue=161027.1. */
51
52
uint32_t hash = 5381;
53
while
(
int
c = *str++)
54
hash = hash * 33 + tolower (c);
55
return
hash;
56
}
57
58
/* See dwarf-index-common.h. */
59
60
uint32_t
61
dwarf5_djb_hash
(gdb::string_view str)
62
{
63
/* Note: tolower here ignores UTF-8, which isn't fully compliant.
64
See http://dwarfstd.org/ShowIssue.php?issue=161027.1. */
65
66
uint32_t hash = 5381;
67
for
(
char
c : str)
68
hash = hash * 33 + tolower (c & 0xff);
69
return
hash;
70
}
defs.h
dwarf5_djb_hash
uint32_t dwarf5_djb_hash(const char *str_)
Definition
index-common.c:45
mapped_index_string_hash
hashval_t mapped_index_string_hash(int index_version, const void *p)
Definition
index-common.c:26
index-common.h
Generated by
1.10.0