dhcpcd: Note update to 9.4.1
[dragonfly.git] / usr.bin / top / hash.h
blob44a121bc0f20827771c7f30bb3cc1fbe10f25eaf
1 /*
2 * Copyright (c) 1984 through 2008, William LeFebvre
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
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
14 * distribution.
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.
33 /* hash.m4h */
35 /* Interface definition for hash.c */
37 /* The file hash.h is generated from hash.m4h via the preprocessor M4 */
39 #ifndef _HASH_H
40 #define _HASH_H
42 #include <sys/types.h>
44 typedef struct pidthr_t {
45 pid_t k_pid;
46 id_t k_thr;
47 } pidthr_t;
49 typedef struct llistitem {
50 void *datum;
51 struct llistitem *next;
52 } llistitem;
54 typedef struct llist {
55 llistitem *head;
56 unsigned int count;
57 } llist;
59 typedef struct bucket {
60 llist list;
61 } bucket_t;
63 typedef struct hash_table {
64 int num_buckets;
65 bucket_t *buckets;
66 } hash_table;
68 typedef struct hash_pos {
69 int num_buckets;
70 int curr;
71 bucket_t *hash_bucket;
72 llistitem *ll_item;
73 llistitem *ll_last;
74 } hash_pos;
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 {
83 unsigned int key;
84 void *value;
85 } 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 {
97 pid_t key;
98 void *value;
99 } 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 {
111 char * key;
112 void *value;
113 } 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 {
125 pidthr_t key;
126 void *value;
127 } 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);
137 #if HAVE_LWPID_T
139 typedef struct hash_item_lwpid {
140 lwpid_t key;
141 void *value;
142 } 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);
152 #endif
155 #endif