160484Sobrien/* hash.h -- header file for gas hash table routines 2218822Sdim Copyright 1987, 1992, 1993, 1995, 1999, 2003 3218822Sdim Free Software Foundation, Inc. 433965Sjdp 533965Sjdp This file is part of GAS, the GNU Assembler. 633965Sjdp 733965Sjdp GAS is free software; you can redistribute it and/or modify 833965Sjdp it under the terms of the GNU General Public License as published by 933965Sjdp the Free Software Foundation; either version 2, or (at your option) 1033965Sjdp any later version. 1133965Sjdp 1233965Sjdp GAS is distributed in the hope that it will be useful, 1333965Sjdp but WITHOUT ANY WARRANTY; without even the implied warranty of 1433965Sjdp MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1533965Sjdp GNU General Public License for more details. 1633965Sjdp 1733965Sjdp You should have received a copy of the GNU General Public License 1860484Sobrien along with GAS; see the file COPYING. If not, write to the Free 19218822Sdim Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 20218822Sdim 02110-1301, USA. */ 2133965Sjdp 2260484Sobrien#ifndef HASH_H 2360484Sobrien#define HASH_H 2433965Sjdp 2533965Sjdpstruct hash_control; 2633965Sjdp 27218822Sdim/* Set the size of the hash table used. */ 28218822Sdim 29218822Sdimvoid set_gas_hash_table_size (unsigned long); 30218822Sdim 3160484Sobrien/* Create a hash table. This return a control block. */ 3233965Sjdp 33130561Sobrienextern struct hash_control *hash_new (void); 3433965Sjdp 3560484Sobrien/* Delete a hash table, freeing all allocated memory. */ 3660484Sobrien 37130561Sobrienextern void hash_die (struct hash_control *); 3860484Sobrien 3960484Sobrien/* Insert an entry into a hash table. This returns NULL on success. 4060484Sobrien On error, it returns a printable string indicating the error. It 4160484Sobrien is considered to be an error if the entry already exists in the 4260484Sobrien hash table. */ 4360484Sobrien 44130561Sobrienextern const char *hash_insert (struct hash_control *, 45130561Sobrien const char *key, PTR value); 4660484Sobrien 4760484Sobrien/* Insert or replace an entry in a hash table. This returns NULL on 4860484Sobrien success. On error, it returns a printable string indicating the 4960484Sobrien error. If an entry already exists, its value is replaced. */ 5060484Sobrien 51130561Sobrienextern const char *hash_jam (struct hash_control *, 52130561Sobrien const char *key, PTR value); 5360484Sobrien 5460484Sobrien/* Replace an existing entry in a hash table. This returns the old 5560484Sobrien value stored for the entry. If the entry is not found in the hash 5660484Sobrien table, this does nothing and returns NULL. */ 5760484Sobrien 58130561Sobrienextern PTR hash_replace (struct hash_control *, const char *key, 59130561Sobrien PTR value); 6060484Sobrien 6160484Sobrien/* Find an entry in a hash table, returning its value. Returns NULL 6260484Sobrien if the entry is not found. */ 6360484Sobrien 64130561Sobrienextern PTR hash_find (struct hash_control *, const char *key); 6560484Sobrien 66218822Sdim/* As hash_find, but KEY is of length LEN and is not guaranteed to be 67218822Sdim NUL-terminated. */ 68218822Sdim 69218822Sdimextern PTR hash_find_n (struct hash_control *, const char *key, size_t len); 70218822Sdim 7160484Sobrien/* Delete an entry from a hash table. This returns the value stored 7260484Sobrien for that entry, or NULL if there is no such entry. */ 7360484Sobrien 74130561Sobrienextern PTR hash_delete (struct hash_control *, const char *key); 7560484Sobrien 7660484Sobrien/* Traverse a hash table. Call the function on every entry in the 7760484Sobrien hash table. */ 7860484Sobrien 79130561Sobrienextern void hash_traverse (struct hash_control *, 80130561Sobrien void (*pfn) (const char *key, PTR value)); 8160484Sobrien 8260484Sobrien/* Print hash table statistics on the specified file. NAME is the 8360484Sobrien name of the hash table, used for printing a header. */ 8460484Sobrien 85130561Sobrienextern void hash_print_statistics (FILE *, const char *name, 86130561Sobrien struct hash_control *); 8760484Sobrien 8860484Sobrien#endif /* HASH_H */ 89