VirtualBox

source: vbox/trunk/src/libs/openssl-3.1.7/gen-includes/openssl/lhash.h@ 107278

最後變更 在這個檔案從107278是 99371,由 vboxsync 提交於 22 月 前

openssl-3.1.0: After generating headers and asm (kmk recreate-headers recreate-headers)

檔案大小: 14.3 KB
 
1/*
2 * Copyright 1995-2022 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
8 */
9
10
11
12/*
13 * Header for dynamic hash table routines Author - Eric Young
14 */
15
16#ifndef OPENSSL_LHASH_H
17# define OPENSSL_LHASH_H
18# pragma once
19
20# include <openssl/macros.h>
21# ifndef OPENSSL_NO_DEPRECATED_3_0
22# define HEADER_LHASH_H
23# endif
24
25# include <openssl/e_os2.h>
26# include <openssl/bio.h>
27# ifndef OPENSSL_NO_STDIO
28# include <stdio.h>
29# endif
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
35typedef struct lhash_node_st OPENSSL_LH_NODE;
36typedef int (*OPENSSL_LH_COMPFUNC) (const void *, const void *);
37typedef unsigned long (*OPENSSL_LH_HASHFUNC) (const void *);
38typedef void (*OPENSSL_LH_DOALL_FUNC) (void *);
39typedef void (*OPENSSL_LH_DOALL_FUNCARG) (void *, void *);
40typedef struct lhash_st OPENSSL_LHASH;
41
42/*
43 * Macros for declaring and implementing type-safe wrappers for LHASH
44 * callbacks. This way, callbacks can be provided to LHASH structures without
45 * function pointer casting and the macro-defined callbacks provide
46 * per-variable casting before deferring to the underlying type-specific
47 * callbacks. NB: It is possible to place a "static" in front of both the
48 * DECLARE and IMPLEMENT macros if the functions are strictly internal.
49 */
50
51/* First: "hash" functions */
52# define DECLARE_LHASH_HASH_FN(name, o_type) \
53 unsigned long name##_LHASH_HASH(const void *);
54# define IMPLEMENT_LHASH_HASH_FN(name, o_type) \
55 unsigned long name##_LHASH_HASH(const void *arg) { \
56 const o_type *a = arg; \
57 return name##_hash(a); }
58# define LHASH_HASH_FN(name) name##_LHASH_HASH
59
60/* Second: "compare" functions */
61# define DECLARE_LHASH_COMP_FN(name, o_type) \
62 int name##_LHASH_COMP(const void *, const void *);
63# define IMPLEMENT_LHASH_COMP_FN(name, o_type) \
64 int name##_LHASH_COMP(const void *arg1, const void *arg2) { \
65 const o_type *a = arg1; \
66 const o_type *b = arg2; \
67 return name##_cmp(a,b); }
68# define LHASH_COMP_FN(name) name##_LHASH_COMP
69
70/* Fourth: "doall_arg" functions */
71# define DECLARE_LHASH_DOALL_ARG_FN(name, o_type, a_type) \
72 void name##_LHASH_DOALL_ARG(void *, void *);
73# define IMPLEMENT_LHASH_DOALL_ARG_FN(name, o_type, a_type) \
74 void name##_LHASH_DOALL_ARG(void *arg1, void *arg2) { \
75 o_type *a = arg1; \
76 a_type *b = arg2; \
77 name##_doall_arg(a, b); }
78# define LHASH_DOALL_ARG_FN(name) name##_LHASH_DOALL_ARG
79
80
81# define LH_LOAD_MULT 256
82
83int OPENSSL_LH_error(OPENSSL_LHASH *lh);
84OPENSSL_LHASH *OPENSSL_LH_new(OPENSSL_LH_HASHFUNC h, OPENSSL_LH_COMPFUNC c);
85void OPENSSL_LH_free(OPENSSL_LHASH *lh);
86void OPENSSL_LH_flush(OPENSSL_LHASH *lh);
87void *OPENSSL_LH_insert(OPENSSL_LHASH *lh, void *data);
88void *OPENSSL_LH_delete(OPENSSL_LHASH *lh, const void *data);
89void *OPENSSL_LH_retrieve(OPENSSL_LHASH *lh, const void *data);
90void OPENSSL_LH_doall(OPENSSL_LHASH *lh, OPENSSL_LH_DOALL_FUNC func);
91void OPENSSL_LH_doall_arg(OPENSSL_LHASH *lh, OPENSSL_LH_DOALL_FUNCARG func, void *arg);
92unsigned long OPENSSL_LH_strhash(const char *c);
93unsigned long OPENSSL_LH_num_items(const OPENSSL_LHASH *lh);
94unsigned long OPENSSL_LH_get_down_load(const OPENSSL_LHASH *lh);
95void OPENSSL_LH_set_down_load(OPENSSL_LHASH *lh, unsigned long down_load);
96
97# ifndef OPENSSL_NO_STDIO
98# ifndef OPENSSL_NO_DEPRECATED_3_1
99OSSL_DEPRECATEDIN_3_1 void OPENSSL_LH_stats(const OPENSSL_LHASH *lh, FILE *fp);
100OSSL_DEPRECATEDIN_3_1 void OPENSSL_LH_node_stats(const OPENSSL_LHASH *lh, FILE *fp);
101OSSL_DEPRECATEDIN_3_1 void OPENSSL_LH_node_usage_stats(const OPENSSL_LHASH *lh, FILE *fp);
102# endif
103# endif
104# ifndef OPENSSL_NO_DEPRECATED_3_1
105OSSL_DEPRECATEDIN_3_1 void OPENSSL_LH_stats_bio(const OPENSSL_LHASH *lh, BIO *out);
106OSSL_DEPRECATEDIN_3_1 void OPENSSL_LH_node_stats_bio(const OPENSSL_LHASH *lh, BIO *out);
107OSSL_DEPRECATEDIN_3_1 void OPENSSL_LH_node_usage_stats_bio(const OPENSSL_LHASH *lh, BIO *out);
108# endif
109
110# ifndef OPENSSL_NO_DEPRECATED_1_1_0
111# define _LHASH OPENSSL_LHASH
112# define LHASH_NODE OPENSSL_LH_NODE
113# define lh_error OPENSSL_LH_error
114# define lh_new OPENSSL_LH_new
115# define lh_free OPENSSL_LH_free
116# define lh_insert OPENSSL_LH_insert
117# define lh_delete OPENSSL_LH_delete
118# define lh_retrieve OPENSSL_LH_retrieve
119# define lh_doall OPENSSL_LH_doall
120# define lh_doall_arg OPENSSL_LH_doall_arg
121# define lh_strhash OPENSSL_LH_strhash
122# define lh_num_items OPENSSL_LH_num_items
123# ifndef OPENSSL_NO_STDIO
124# define lh_stats OPENSSL_LH_stats
125# define lh_node_stats OPENSSL_LH_node_stats
126# define lh_node_usage_stats OPENSSL_LH_node_usage_stats
127# endif
128# define lh_stats_bio OPENSSL_LH_stats_bio
129# define lh_node_stats_bio OPENSSL_LH_node_stats_bio
130# define lh_node_usage_stats_bio OPENSSL_LH_node_usage_stats_bio
131# endif
132
133/* Type checking... */
134
135# define LHASH_OF(type) struct lhash_st_##type
136
137/* Helper macro for internal use */
138# define DEFINE_LHASH_OF_INTERNAL(type) \
139 LHASH_OF(type) { \
140 union lh_##type##_dummy { void* d1; unsigned long d2; int d3; } dummy; \
141 }; \
142 typedef int (*lh_##type##_compfunc)(const type *a, const type *b); \
143 typedef unsigned long (*lh_##type##_hashfunc)(const type *a); \
144 typedef void (*lh_##type##_doallfunc)(type *a); \
145 static ossl_unused ossl_inline type *\
146 ossl_check_##type##_lh_plain_type(type *ptr) \
147 { \
148 return ptr; \
149 } \
150 static ossl_unused ossl_inline const type * \
151 ossl_check_const_##type##_lh_plain_type(const type *ptr) \
152 { \
153 return ptr; \
154 } \
155 static ossl_unused ossl_inline const OPENSSL_LHASH * \
156 ossl_check_const_##type##_lh_type(const LHASH_OF(type) *lh) \
157 { \
158 return (const OPENSSL_LHASH *)lh; \
159 } \
160 static ossl_unused ossl_inline OPENSSL_LHASH * \
161 ossl_check_##type##_lh_type(LHASH_OF(type) *lh) \
162 { \
163 return (OPENSSL_LHASH *)lh; \
164 } \
165 static ossl_unused ossl_inline OPENSSL_LH_COMPFUNC \
166 ossl_check_##type##_lh_compfunc_type(lh_##type##_compfunc cmp) \
167 { \
168 return (OPENSSL_LH_COMPFUNC)cmp; \
169 } \
170 static ossl_unused ossl_inline OPENSSL_LH_HASHFUNC \
171 ossl_check_##type##_lh_hashfunc_type(lh_##type##_hashfunc hfn) \
172 { \
173 return (OPENSSL_LH_HASHFUNC)hfn; \
174 } \
175 static ossl_unused ossl_inline OPENSSL_LH_DOALL_FUNC \
176 ossl_check_##type##_lh_doallfunc_type(lh_##type##_doallfunc dfn) \
177 { \
178 return (OPENSSL_LH_DOALL_FUNC)dfn; \
179 } \
180 LHASH_OF(type)
181
182# ifndef OPENSSL_NO_DEPRECATED_3_1
183# define DEFINE_LHASH_OF_DEPRECATED(type) \
184 static ossl_unused ossl_inline void \
185 lh_##type##_node_stats_bio(const LHASH_OF(type) *lh, BIO *out) \
186 { \
187 OPENSSL_LH_node_stats_bio((const OPENSSL_LHASH *)lh, out); \
188 } \
189 static ossl_unused ossl_inline void \
190 lh_##type##_node_usage_stats_bio(const LHASH_OF(type) *lh, BIO *out) \
191 { \
192 OPENSSL_LH_node_usage_stats_bio((const OPENSSL_LHASH *)lh, out); \
193 } \
194 static ossl_unused ossl_inline void \
195 lh_##type##_stats_bio(const LHASH_OF(type) *lh, BIO *out) \
196 { \
197 OPENSSL_LH_stats_bio((const OPENSSL_LHASH *)lh, out); \
198 }
199# else
200# define DEFINE_LHASH_OF_DEPRECATED(type)
201# endif
202
203# define DEFINE_LHASH_OF_EX(type) \
204 LHASH_OF(type) { \
205 union lh_##type##_dummy { void* d1; unsigned long d2; int d3; } dummy; \
206 }; \
207 static ossl_unused ossl_inline LHASH_OF(type) * \
208 lh_##type##_new(unsigned long (*hfn)(const type *), \
209 int (*cfn)(const type *, const type *)) \
210 { \
211 return (LHASH_OF(type) *) \
212 OPENSSL_LH_new((OPENSSL_LH_HASHFUNC)hfn, (OPENSSL_LH_COMPFUNC)cfn); \
213 } \
214 static ossl_unused ossl_inline void \
215 lh_##type##_free(LHASH_OF(type) *lh) \
216 { \
217 OPENSSL_LH_free((OPENSSL_LHASH *)lh); \
218 } \
219 static ossl_unused ossl_inline void \
220 lh_##type##_flush(LHASH_OF(type) *lh) \
221 { \
222 OPENSSL_LH_flush((OPENSSL_LHASH *)lh); \
223 } \
224 static ossl_unused ossl_inline type * \
225 lh_##type##_insert(LHASH_OF(type) *lh, type *d) \
226 { \
227 return (type *)OPENSSL_LH_insert((OPENSSL_LHASH *)lh, d); \
228 } \
229 static ossl_unused ossl_inline type * \
230 lh_##type##_delete(LHASH_OF(type) *lh, const type *d) \
231 { \
232 return (type *)OPENSSL_LH_delete((OPENSSL_LHASH *)lh, d); \
233 } \
234 static ossl_unused ossl_inline type * \
235 lh_##type##_retrieve(LHASH_OF(type) *lh, const type *d) \
236 { \
237 return (type *)OPENSSL_LH_retrieve((OPENSSL_LHASH *)lh, d); \
238 } \
239 static ossl_unused ossl_inline int \
240 lh_##type##_error(LHASH_OF(type) *lh) \
241 { \
242 return OPENSSL_LH_error((OPENSSL_LHASH *)lh); \
243 } \
244 static ossl_unused ossl_inline unsigned long \
245 lh_##type##_num_items(LHASH_OF(type) *lh) \
246 { \
247 return OPENSSL_LH_num_items((OPENSSL_LHASH *)lh); \
248 } \
249 static ossl_unused ossl_inline unsigned long \
250 lh_##type##_get_down_load(LHASH_OF(type) *lh) \
251 { \
252 return OPENSSL_LH_get_down_load((OPENSSL_LHASH *)lh); \
253 } \
254 static ossl_unused ossl_inline void \
255 lh_##type##_set_down_load(LHASH_OF(type) *lh, unsigned long dl) \
256 { \
257 OPENSSL_LH_set_down_load((OPENSSL_LHASH *)lh, dl); \
258 } \
259 static ossl_unused ossl_inline void \
260 lh_##type##_doall(LHASH_OF(type) *lh, void (*doall)(type *)) \
261 { \
262 OPENSSL_LH_doall((OPENSSL_LHASH *)lh, (OPENSSL_LH_DOALL_FUNC)doall); \
263 } \
264 static ossl_unused ossl_inline void \
265 lh_##type##_doall_arg(LHASH_OF(type) *lh, \
266 void (*doallarg)(type *, void *), void *arg) \
267 { \
268 OPENSSL_LH_doall_arg((OPENSSL_LHASH *)lh, \
269 (OPENSSL_LH_DOALL_FUNCARG)doallarg, arg); \
270 } \
271 LHASH_OF(type)
272
273# define DEFINE_LHASH_OF(type) \
274 DEFINE_LHASH_OF_EX(type); \
275 DEFINE_LHASH_OF_DEPRECATED(type) \
276 LHASH_OF(type)
277
278#define IMPLEMENT_LHASH_DOALL_ARG_CONST(type, argtype) \
279 int_implement_lhash_doall(type, argtype, const type)
280
281#define IMPLEMENT_LHASH_DOALL_ARG(type, argtype) \
282 int_implement_lhash_doall(type, argtype, type)
283
284#define int_implement_lhash_doall(type, argtype, cbargtype) \
285 static ossl_unused ossl_inline void \
286 lh_##type##_doall_##argtype(LHASH_OF(type) *lh, \
287 void (*fn)(cbargtype *, argtype *), \
288 argtype *arg) \
289 { \
290 OPENSSL_LH_doall_arg((OPENSSL_LHASH *)lh, \
291 (OPENSSL_LH_DOALL_FUNCARG)fn, (void *)arg); \
292 } \
293 LHASH_OF(type)
294
295DEFINE_LHASH_OF_INTERNAL(OPENSSL_STRING);
296#define lh_OPENSSL_STRING_new(hfn, cmp) ((LHASH_OF(OPENSSL_STRING) *)OPENSSL_LH_new(ossl_check_OPENSSL_STRING_lh_hashfunc_type(hfn), ossl_check_OPENSSL_STRING_lh_compfunc_type(cmp)))
297#define lh_OPENSSL_STRING_free(lh) OPENSSL_LH_free(ossl_check_OPENSSL_STRING_lh_type(lh))
298#define lh_OPENSSL_STRING_flush(lh) OPENSSL_LH_flush(ossl_check_OPENSSL_STRING_lh_type(lh))
299#define lh_OPENSSL_STRING_insert(lh, ptr) ((OPENSSL_STRING *)OPENSSL_LH_insert(ossl_check_OPENSSL_STRING_lh_type(lh), ossl_check_OPENSSL_STRING_lh_plain_type(ptr)))
300#define lh_OPENSSL_STRING_delete(lh, ptr) ((OPENSSL_STRING *)OPENSSL_LH_delete(ossl_check_OPENSSL_STRING_lh_type(lh), ossl_check_const_OPENSSL_STRING_lh_plain_type(ptr)))
301#define lh_OPENSSL_STRING_retrieve(lh, ptr) ((OPENSSL_STRING *)OPENSSL_LH_retrieve(ossl_check_OPENSSL_STRING_lh_type(lh), ossl_check_const_OPENSSL_STRING_lh_plain_type(ptr)))
302#define lh_OPENSSL_STRING_error(lh) OPENSSL_LH_error(ossl_check_OPENSSL_STRING_lh_type(lh))
303#define lh_OPENSSL_STRING_num_items(lh) OPENSSL_LH_num_items(ossl_check_OPENSSL_STRING_lh_type(lh))
304#define lh_OPENSSL_STRING_node_stats_bio(lh, out) OPENSSL_LH_node_stats_bio(ossl_check_const_OPENSSL_STRING_lh_type(lh), out)
305#define lh_OPENSSL_STRING_node_usage_stats_bio(lh, out) OPENSSL_LH_node_usage_stats_bio(ossl_check_const_OPENSSL_STRING_lh_type(lh), out)
306#define lh_OPENSSL_STRING_stats_bio(lh, out) OPENSSL_LH_stats_bio(ossl_check_const_OPENSSL_STRING_lh_type(lh), out)
307#define lh_OPENSSL_STRING_get_down_load(lh) OPENSSL_LH_get_down_load(ossl_check_OPENSSL_STRING_lh_type(lh))
308#define lh_OPENSSL_STRING_set_down_load(lh, dl) OPENSSL_LH_set_down_load(ossl_check_OPENSSL_STRING_lh_type(lh), dl)
309#define lh_OPENSSL_STRING_doall(lh, dfn) OPENSSL_LH_doall(ossl_check_OPENSSL_STRING_lh_type(lh), ossl_check_OPENSSL_STRING_lh_doallfunc_type(dfn))
310DEFINE_LHASH_OF_INTERNAL(OPENSSL_CSTRING);
311#define lh_OPENSSL_CSTRING_new(hfn, cmp) ((LHASH_OF(OPENSSL_CSTRING) *)OPENSSL_LH_new(ossl_check_OPENSSL_CSTRING_lh_hashfunc_type(hfn), ossl_check_OPENSSL_CSTRING_lh_compfunc_type(cmp)))
312#define lh_OPENSSL_CSTRING_free(lh) OPENSSL_LH_free(ossl_check_OPENSSL_CSTRING_lh_type(lh))
313#define lh_OPENSSL_CSTRING_flush(lh) OPENSSL_LH_flush(ossl_check_OPENSSL_CSTRING_lh_type(lh))
314#define lh_OPENSSL_CSTRING_insert(lh, ptr) ((OPENSSL_CSTRING *)OPENSSL_LH_insert(ossl_check_OPENSSL_CSTRING_lh_type(lh), ossl_check_OPENSSL_CSTRING_lh_plain_type(ptr)))
315#define lh_OPENSSL_CSTRING_delete(lh, ptr) ((OPENSSL_CSTRING *)OPENSSL_LH_delete(ossl_check_OPENSSL_CSTRING_lh_type(lh), ossl_check_const_OPENSSL_CSTRING_lh_plain_type(ptr)))
316#define lh_OPENSSL_CSTRING_retrieve(lh, ptr) ((OPENSSL_CSTRING *)OPENSSL_LH_retrieve(ossl_check_OPENSSL_CSTRING_lh_type(lh), ossl_check_const_OPENSSL_CSTRING_lh_plain_type(ptr)))
317#define lh_OPENSSL_CSTRING_error(lh) OPENSSL_LH_error(ossl_check_OPENSSL_CSTRING_lh_type(lh))
318#define lh_OPENSSL_CSTRING_num_items(lh) OPENSSL_LH_num_items(ossl_check_OPENSSL_CSTRING_lh_type(lh))
319#define lh_OPENSSL_CSTRING_node_stats_bio(lh, out) OPENSSL_LH_node_stats_bio(ossl_check_const_OPENSSL_CSTRING_lh_type(lh), out)
320#define lh_OPENSSL_CSTRING_node_usage_stats_bio(lh, out) OPENSSL_LH_node_usage_stats_bio(ossl_check_const_OPENSSL_CSTRING_lh_type(lh), out)
321#define lh_OPENSSL_CSTRING_stats_bio(lh, out) OPENSSL_LH_stats_bio(ossl_check_const_OPENSSL_CSTRING_lh_type(lh), out)
322#define lh_OPENSSL_CSTRING_get_down_load(lh) OPENSSL_LH_get_down_load(ossl_check_OPENSSL_CSTRING_lh_type(lh))
323#define lh_OPENSSL_CSTRING_set_down_load(lh, dl) OPENSSL_LH_set_down_load(ossl_check_OPENSSL_CSTRING_lh_type(lh), dl)
324#define lh_OPENSSL_CSTRING_doall(lh, dfn) OPENSSL_LH_doall(ossl_check_OPENSSL_CSTRING_lh_type(lh), ossl_check_OPENSSL_CSTRING_lh_doallfunc_type(dfn))
325
326
327#ifdef __cplusplus
328}
329#endif
330
331#endif
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette