Cast the log10 argument to double to disambiguate it
[deliverable/binutils-gdb.git] / gdb / dwarf-index-common.c
1 /* Things needed for both reading and writing DWARF indices.
2
3 Copyright (C) 1994-2019 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 "dwarf-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 }
This page took 0.03407 seconds and 4 git commands to generate.