| 1 | /* hash.h - for hash.c |
| 2 | Copyright (C) 1987, 1992 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 2, 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 |
| 18 | the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ |
| 19 | |
| 20 | #ifndef hashH |
| 21 | #define hashH |
| 22 | |
| 23 | #include "ansidecl.h" |
| 24 | |
| 25 | struct hash_entry |
| 26 | { |
| 27 | const char *hash_string; /* points to where the symbol string is */ |
| 28 | /* NULL means slot is not used */ |
| 29 | /* DELETED means slot was deleted */ |
| 30 | PTR hash_value; /* user's datum, associated with symbol */ |
| 31 | }; |
| 32 | |
| 33 | |
| 34 | #define HASH_STATLENGTH (6) |
| 35 | struct hash_control |
| 36 | { |
| 37 | struct hash_entry *hash_where;/* address of hash table */ |
| 38 | int hash_sizelog; /* Log of ( hash_mask + 1 ) */ |
| 39 | int hash_mask; /* masks a hash into index into table */ |
| 40 | int hash_full; /* when hash_stat[STAT_USED] exceeds this, */ |
| 41 | /* grow table */ |
| 42 | struct hash_entry *hash_wall; /* point just after last (usable) entry */ |
| 43 | /* here we have some statistics */ |
| 44 | int hash_stat[HASH_STATLENGTH]; /* lies & statistics */ |
| 45 | /* we need STAT_USED & STAT_SIZE */ |
| 46 | }; |
| 47 | |
| 48 | |
| 49 | /* returns control block */ |
| 50 | struct hash_control *hash_new PARAMS ((void)); |
| 51 | void hash_die PARAMS ((struct hash_control *)); |
| 52 | void hash_say PARAMS ((struct hash_control *, int *buffer, int bufsiz)); |
| 53 | /* returns previous value */ |
| 54 | PTR hash_delete PARAMS ((struct hash_control *, const char *str)); |
| 55 | /* returns previous value */ |
| 56 | PTR hash_replace PARAMS ((struct hash_control *, const char *str, PTR val)); |
| 57 | /* returns error string or null */ |
| 58 | const char *hash_insert PARAMS ((struct hash_control *, const char *str, |
| 59 | PTR val)); |
| 60 | /* return of 0 means OK */ |
| 61 | char *hash_apply PARAMS ((struct hash_control *, |
| 62 | char *(*fn) (const char *str, PTR val))); |
| 63 | /* returns value */ |
| 64 | PTR hash_find PARAMS ((struct hash_control *, const char *str)); |
| 65 | /* returns error text or null (internal) */ |
| 66 | const char *hash_jam PARAMS ((struct hash_control *, const char *str, |
| 67 | PTR val)); |
| 68 | #endif /* #ifdef hashH */ |
| 69 | |
| 70 | /* $Id: hash.h,v 1.2 1998/08/13 06:13:30 boyns Exp $ */ |