1 /* Copyright (C) 2000-2010 Red Hat, Inc.
2 This file is part of elfutils.
3 Written by Ulrich Drepper <drepper@redhat.com>, 2000.
5 This file is free software; you can redistribute it and/or modify
6 it under the terms of either
8 * the GNU Lesser General Public License as published by the Free
9 Software Foundation; either version 3 of the License, or (at
10 your option) any later version
14 * the GNU General Public License as published by the Free
15 Software Foundation; either version 2 of the License, or (at
16 your option) any later version
18 or both in parallel, as here.
20 elfutils is distributed in the hope that it will be useful, but
21 WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 General Public License for more details.
25 You should have received copies of the GNU General Public License and
26 the GNU Lesser General Public License along with this program. If
27 not, see <http://www.gnu.org/licenses/>. */
31 /* Before including this file the following macros must be defined:
33 NAME name of the hash table structure.
34 TYPE data type of the hash table entries
36 The following macros if present select features:
38 ITERATE iterating over the table entries is possible
39 HASHTYPE integer type for hash values, default unsigned long int
43 /* Optionally include an entry pointing to the first used entry. */
45 # define FIRST(name) name##_ent *first;
46 # define NEXT(name) struct name##_ent *next;
53 # define HASHTYPE unsigned long int
57 /* Defined separately. */
58 extern size_t next_prime (size_t seed);
61 /* Table entry type. */
62 #define _DYNHASHENTTYPE(name) \
63 typedef struct name##_ent \
69 #define DYNHASHENTTYPE(name) _DYNHASHENTTYPE (name)
70 DYNHASHENTTYPE (NAME);
73 /* Type of the dynamic hash table data structure. */
74 #define _DYNHASHTYPE(name) \
82 #define DYNHASHTYPE(name) _DYNHASHTYPE (name)
87 #define _FUNCTIONS(name) \
88 /* Initialize the hash table. */ \
89 extern int name##_init (name *htab, size_t init_size); \
91 /* Free resources allocated for hash table. */ \
92 extern int name##_free (name *htab); \
94 /* Insert new entry. */ \
95 extern int name##_insert (name *htab, HASHTYPE hval, TYPE data); \
97 /* Insert new entry, possibly overwrite old entry. */ \
98 extern int name##_overwrite (name *htab, HASHTYPE hval, TYPE data); \
100 /* Find entry in hash table. */ \
101 extern TYPE name##_find (name *htab, HASHTYPE hval, TYPE val);
102 #define FUNCTIONS(name) _FUNCTIONS (name)
107 # define _XFUNCTIONS(name) \
108 /* Get next element in table. */ \
109 extern TYPE name##_iterate (name *htab, void **ptr);
110 # define XFUNCTIONS(name) _XFUNCTIONS (name)
115 # undef DYNHASHENTTYPE