xref: /dflybsd-src/contrib/binutils-2.27/gas/hash.h (revision e656dc90e3d65d744d534af2f5ea88cf8101ebcf)
1*a9fa9459Szrj /* hash.h -- header file for gas hash table routines
2*a9fa9459Szrj    Copyright (C) 1987-2016 Free Software Foundation, Inc.
3*a9fa9459Szrj 
4*a9fa9459Szrj    This file is part of GAS, the GNU Assembler.
5*a9fa9459Szrj 
6*a9fa9459Szrj    GAS is free software; you can redistribute it and/or modify
7*a9fa9459Szrj    it under the terms of the GNU General Public License as published by
8*a9fa9459Szrj    the Free Software Foundation; either version 3, or (at your option)
9*a9fa9459Szrj    any later version.
10*a9fa9459Szrj 
11*a9fa9459Szrj    GAS is distributed in the hope that it will be useful,
12*a9fa9459Szrj    but WITHOUT ANY WARRANTY; without even the implied warranty of
13*a9fa9459Szrj    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14*a9fa9459Szrj    GNU General Public License for more details.
15*a9fa9459Szrj 
16*a9fa9459Szrj    You should have received a copy of the GNU General Public License
17*a9fa9459Szrj    along with GAS; see the file COPYING.  If not, write to the Free
18*a9fa9459Szrj    Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
19*a9fa9459Szrj    02110-1301, USA.  */
20*a9fa9459Szrj 
21*a9fa9459Szrj #ifndef HASH_H
22*a9fa9459Szrj #define HASH_H
23*a9fa9459Szrj 
24*a9fa9459Szrj struct hash_control;
25*a9fa9459Szrj 
26*a9fa9459Szrj /* Set the size of the hash table used.  */
27*a9fa9459Szrj 
28*a9fa9459Szrj void set_gas_hash_table_size (unsigned long);
29*a9fa9459Szrj 
30*a9fa9459Szrj /* Create a hash table.  This return a control block.  */
31*a9fa9459Szrj 
32*a9fa9459Szrj extern struct hash_control *hash_new (void);
33*a9fa9459Szrj extern struct hash_control *hash_new_sized (unsigned long);
34*a9fa9459Szrj 
35*a9fa9459Szrj /* Delete a hash table, freeing all allocated memory.  */
36*a9fa9459Szrj 
37*a9fa9459Szrj extern void hash_die (struct hash_control *);
38*a9fa9459Szrj 
39*a9fa9459Szrj /* Insert an entry into a hash table.  This returns NULL on success.
40*a9fa9459Szrj    On error, it returns a printable string indicating the error.  It
41*a9fa9459Szrj    is considered to be an error if the entry already exists in the
42*a9fa9459Szrj    hash table.  */
43*a9fa9459Szrj 
44*a9fa9459Szrj extern const char *hash_insert (struct hash_control *,
45*a9fa9459Szrj 				const char *key, void *value);
46*a9fa9459Szrj 
47*a9fa9459Szrj /* Insert or replace an entry in a hash table.  This returns NULL on
48*a9fa9459Szrj    success.  On error, it returns a printable string indicating the
49*a9fa9459Szrj    error.  If an entry already exists, its value is replaced.  */
50*a9fa9459Szrj 
51*a9fa9459Szrj extern const char *hash_jam (struct hash_control *,
52*a9fa9459Szrj 			     const char *key, void *value);
53*a9fa9459Szrj 
54*a9fa9459Szrj /* Replace an existing entry in a hash table.  This returns the old
55*a9fa9459Szrj    value stored for the entry.  If the entry is not found in the hash
56*a9fa9459Szrj    table, this does nothing and returns NULL.  */
57*a9fa9459Szrj 
58*a9fa9459Szrj extern void *hash_replace (struct hash_control *, const char *key,
59*a9fa9459Szrj 			 void *value);
60*a9fa9459Szrj 
61*a9fa9459Szrj /* Find an entry in a hash table, returning its value.  Returns NULL
62*a9fa9459Szrj    if the entry is not found.  */
63*a9fa9459Szrj 
64*a9fa9459Szrj extern void *hash_find (struct hash_control *, const char *key);
65*a9fa9459Szrj 
66*a9fa9459Szrj /* As hash_find, but KEY is of length LEN and is not guaranteed to be
67*a9fa9459Szrj    NUL-terminated.  */
68*a9fa9459Szrj 
69*a9fa9459Szrj extern void *hash_find_n (struct hash_control *, const char *key, size_t len);
70*a9fa9459Szrj 
71*a9fa9459Szrj /* Delete an entry from a hash table.  This returns the value stored
72*a9fa9459Szrj    for that entry, or NULL if there is no such entry.  */
73*a9fa9459Szrj 
74*a9fa9459Szrj extern void *hash_delete (struct hash_control *, const char *key, int);
75*a9fa9459Szrj 
76*a9fa9459Szrj /* Traverse a hash table.  Call the function on every entry in the
77*a9fa9459Szrj    hash table.  */
78*a9fa9459Szrj 
79*a9fa9459Szrj extern void hash_traverse (struct hash_control *,
80*a9fa9459Szrj 			   void (*pfn) (const char *key, void *value));
81*a9fa9459Szrj 
82*a9fa9459Szrj /* Print hash table statistics on the specified file.  NAME is the
83*a9fa9459Szrj    name of the hash table, used for printing a header.  */
84*a9fa9459Szrj 
85*a9fa9459Szrj extern void hash_print_statistics (FILE *, const char *name,
86*a9fa9459Szrj 				   struct hash_control *);
87*a9fa9459Szrj 
88*a9fa9459Szrj #endif /* HASH_H */
89