2 * Copyright (c) 1984 through 2008, William LeFebvre
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the
16 * * Neither the name of William LeFebvre nor the names of other
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 /* Interface definition for hash.c */
37 /* The file hash.h is generated from hash.m4h via the preprocessor M4 */
42 #include <sys/types.h>
44 typedef struct pidthr_t
{
49 typedef struct llistitem
{
51 struct llistitem
*next
;
54 typedef struct llist
{
59 typedef struct bucket
{
63 typedef struct hash_table
{
68 typedef struct hash_pos
{
71 bucket_t
*hash_bucket
;
76 hash_table
*hash_create(int num
);
77 void hash_sizeinfo(unsigned int *sizes
, int max
, hash_table
*ht
);
82 typedef struct hash_item_uint
{
87 void *hash_add_uint(hash_table
*ht
, unsigned int key
, void *value
);
88 void *hash_replace_uint(hash_table
*ht
, unsigned int key
, void *value
);
89 void *hash_lookup_uint(hash_table
*ht
, unsigned int key
);
90 void *hash_remove_uint(hash_table
*ht
, unsigned int key
);
91 hash_item_uint
*hash_first_uint(hash_table
*ht
, hash_pos
*pos
);
92 hash_item_uint
*hash_next_uint(hash_pos
*pos
);
93 void *hash_remove_pos_uint(hash_pos
*pos
);
96 typedef struct hash_item_pid
{
101 void *hash_add_pid(hash_table
*ht
, pid_t key
, void *value
);
102 void *hash_replace_pid(hash_table
*ht
, pid_t key
, void *value
);
103 void *hash_lookup_pid(hash_table
*ht
, pid_t key
);
104 void *hash_remove_pid(hash_table
*ht
, pid_t key
);
105 hash_item_pid
*hash_first_pid(hash_table
*ht
, hash_pos
*pos
);
106 hash_item_pid
*hash_next_pid(hash_pos
*pos
);
107 void *hash_remove_pos_pid(hash_pos
*pos
);
110 typedef struct hash_item_string
{
115 void *hash_add_string(hash_table
*ht
, char * key
, void *value
);
116 void *hash_replace_string(hash_table
*ht
, char * key
, void *value
);
117 void *hash_lookup_string(hash_table
*ht
, char * key
);
118 void *hash_remove_string(hash_table
*ht
, char * key
);
119 hash_item_string
*hash_first_string(hash_table
*ht
, hash_pos
*pos
);
120 hash_item_string
*hash_next_string(hash_pos
*pos
);
121 void *hash_remove_pos_string(hash_pos
*pos
);
124 typedef struct hash_item_pidthr
{
129 void *hash_add_pidthr(hash_table
*ht
, pidthr_t key
, void *value
);
130 void *hash_replace_pidthr(hash_table
*ht
, pidthr_t key
, void *value
);
131 void *hash_lookup_pidthr(hash_table
*ht
, pidthr_t key
);
132 void *hash_remove_pidthr(hash_table
*ht
, pidthr_t key
);
133 hash_item_pidthr
*hash_first_pidthr(hash_table
*ht
, hash_pos
*pos
);
134 hash_item_pidthr
*hash_next_pidthr(hash_pos
*pos
);
135 void *hash_remove_pos_pidthr(hash_pos
*pos
);
139 typedef struct hash_item_lwpid
{
144 void *hash_add_lwpid(hash_table
*ht
, lwpid_t key
, void *value
);
145 void *hash_replace_lwpid(hash_table
*ht
, lwpid_t key
, void *value
);
146 void *hash_lookup_lwpid(hash_table
*ht
, lwpid_t key
);
147 void *hash_remove_lwpid(hash_table
*ht
, lwpid_t key
);
148 hash_item_lwpid
*hash_first_lwpid(hash_table
*ht
, hash_pos
*pos
);
149 hash_item_lwpid
*hash_next_lwpid(hash_pos
*pos
);
150 void *hash_remove_pos_lwpid(hash_pos
*pos
);