1 /* Copyright (c) 2014, Google Inc.
2  *
3  * Permission to use, copy, modify, and/or distribute this software for any
4  * purpose with or without fee is hereby granted, provided that the above
5  * copyright notice and this permission notice appear in all copies.
6  *
7  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
10  * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
12  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
13  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
14 
15 #if !defined(IN_STACK_H)
16 #error "Don't include this file directly. Include stack.h."
17 #endif
18 
19 /* ACCESS_DESCRIPTION */
20 #define sk_ACCESS_DESCRIPTION_new(comp)                                    \
21   ((STACK_OF(ACCESS_DESCRIPTION) *)sk_new(CHECKED_CAST(                    \
22       stack_cmp_func,                                                      \
23       int (*)(const ACCESS_DESCRIPTION **a, const ACCESS_DESCRIPTION **b), \
24       comp)))
25 
26 #define sk_ACCESS_DESCRIPTION_new_null() \
27   ((STACK_OF(ACCESS_DESCRIPTION) *)sk_new_null())
28 
29 #define sk_ACCESS_DESCRIPTION_num(sk) \
30   sk_num(CHECKED_CAST(const _STACK *, const STACK_OF(ACCESS_DESCRIPTION) *, sk))
31 
32 #define sk_ACCESS_DESCRIPTION_zero(sk) \
33   sk_zero(CHECKED_CAST(_STACK *, STACK_OF(ACCESS_DESCRIPTION) *, sk));
34 
35 #define sk_ACCESS_DESCRIPTION_value(sk, i)                                    \
36   ((ACCESS_DESCRIPTION *)sk_value(                                            \
37       CHECKED_CAST(const _STACK *, const STACK_OF(ACCESS_DESCRIPTION) *, sk), \
38       (i)))
39 
40 #define sk_ACCESS_DESCRIPTION_set(sk, i, p)                            \
41   ((ACCESS_DESCRIPTION *)sk_set(                                       \
42       CHECKED_CAST(_STACK *, STACK_OF(ACCESS_DESCRIPTION) *, sk), (i), \
43       CHECKED_CAST(void *, ACCESS_DESCRIPTION *, p)))
44 
45 #define sk_ACCESS_DESCRIPTION_free(sk) \
46   sk_free(CHECKED_CAST(_STACK *, STACK_OF(ACCESS_DESCRIPTION) *, sk))
47 
48 #define sk_ACCESS_DESCRIPTION_pop_free(sk, free_func)                        \
49   sk_pop_free(CHECKED_CAST(_STACK *, STACK_OF(ACCESS_DESCRIPTION) *, sk),    \
50               CHECKED_CAST(void (*)(void *), void (*)(ACCESS_DESCRIPTION *), \
51                            free_func))
52 
53 #define sk_ACCESS_DESCRIPTION_insert(sk, p, where)                      \
54   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(ACCESS_DESCRIPTION) *, sk), \
55             CHECKED_CAST(void *, ACCESS_DESCRIPTION *, p), (where))
56 
57 #define sk_ACCESS_DESCRIPTION_delete(sk, where) \
58   ((ACCESS_DESCRIPTION *)sk_delete(             \
59       CHECKED_CAST(_STACK *, STACK_OF(ACCESS_DESCRIPTION) *, sk), (where)))
60 
61 #define sk_ACCESS_DESCRIPTION_delete_ptr(sk, p)                   \
62   ((ACCESS_DESCRIPTION *)sk_delete_ptr(                           \
63       CHECKED_CAST(_STACK *, STACK_OF(ACCESS_DESCRIPTION) *, sk), \
64       CHECKED_CAST(void *, ACCESS_DESCRIPTION *, p)))
65 
66 #define sk_ACCESS_DESCRIPTION_find(sk, out_index, p)                  \
67   sk_find(CHECKED_CAST(_STACK *, STACK_OF(ACCESS_DESCRIPTION) *, sk), \
68           (out_index), CHECKED_CAST(void *, ACCESS_DESCRIPTION *, p))
69 
70 #define sk_ACCESS_DESCRIPTION_shift(sk) \
71   ((ACCESS_DESCRIPTION *)sk_shift(      \
72       CHECKED_CAST(_STACK *, STACK_OF(ACCESS_DESCRIPTION) *, sk)))
73 
74 #define sk_ACCESS_DESCRIPTION_push(sk, p)                             \
75   sk_push(CHECKED_CAST(_STACK *, STACK_OF(ACCESS_DESCRIPTION) *, sk), \
76           CHECKED_CAST(void *, ACCESS_DESCRIPTION *, p))
77 
78 #define sk_ACCESS_DESCRIPTION_pop(sk) \
79   ((ACCESS_DESCRIPTION *)sk_pop(      \
80       CHECKED_CAST(_STACK *, STACK_OF(ACCESS_DESCRIPTION) *, sk)))
81 
82 #define sk_ACCESS_DESCRIPTION_dup(sk)      \
83   ((STACK_OF(ACCESS_DESCRIPTION) *)sk_dup( \
84       CHECKED_CAST(const _STACK *, const STACK_OF(ACCESS_DESCRIPTION) *, sk)))
85 
86 #define sk_ACCESS_DESCRIPTION_sort(sk) \
87   sk_sort(CHECKED_CAST(_STACK *, STACK_OF(ACCESS_DESCRIPTION) *, sk))
88 
89 #define sk_ACCESS_DESCRIPTION_is_sorted(sk) \
90   sk_is_sorted(                             \
91       CHECKED_CAST(const _STACK *, const STACK_OF(ACCESS_DESCRIPTION) *, sk))
92 
93 #define sk_ACCESS_DESCRIPTION_set_cmp_func(sk, comp)                           \
94   ((int (*)(const ACCESS_DESCRIPTION **a, const ACCESS_DESCRIPTION **b))       \
95        sk_set_cmp_func(                                                        \
96            CHECKED_CAST(_STACK *, STACK_OF(ACCESS_DESCRIPTION) *, sk),         \
97            CHECKED_CAST(stack_cmp_func, int (*)(const ACCESS_DESCRIPTION **a,  \
98                                                 const ACCESS_DESCRIPTION **b), \
99                         comp)))
100 
101 #define sk_ACCESS_DESCRIPTION_deep_copy(sk, copy_func, free_func)             \
102   ((STACK_OF(ACCESS_DESCRIPTION) *)sk_deep_copy(                              \
103       CHECKED_CAST(const _STACK *, const STACK_OF(ACCESS_DESCRIPTION) *, sk), \
104       CHECKED_CAST(void *(*)(void *),                                         \
105                    ACCESS_DESCRIPTION *(*)(ACCESS_DESCRIPTION *), copy_func), \
106       CHECKED_CAST(void (*)(void *), void (*)(ACCESS_DESCRIPTION *),          \
107                    free_func)))
108 
109 /* ASN1_ADB_TABLE */
110 #define sk_ASN1_ADB_TABLE_new(comp)                 \
111   ((STACK_OF(ASN1_ADB_TABLE) *)sk_new(CHECKED_CAST( \
112       stack_cmp_func,                               \
113       int (*)(const ASN1_ADB_TABLE **a, const ASN1_ADB_TABLE **b), comp)))
114 
115 #define sk_ASN1_ADB_TABLE_new_null() ((STACK_OF(ASN1_ADB_TABLE) *)sk_new_null())
116 
117 #define sk_ASN1_ADB_TABLE_num(sk) \
118   sk_num(CHECKED_CAST(const _STACK *, const STACK_OF(ASN1_ADB_TABLE) *, sk))
119 
120 #define sk_ASN1_ADB_TABLE_zero(sk) \
121   sk_zero(CHECKED_CAST(_STACK *, STACK_OF(ASN1_ADB_TABLE) *, sk));
122 
123 #define sk_ASN1_ADB_TABLE_value(sk, i)                                    \
124   ((ASN1_ADB_TABLE *)sk_value(                                            \
125       CHECKED_CAST(const _STACK *, const STACK_OF(ASN1_ADB_TABLE) *, sk), \
126       (i)))
127 
128 #define sk_ASN1_ADB_TABLE_set(sk, i, p)                            \
129   ((ASN1_ADB_TABLE *)sk_set(                                       \
130       CHECKED_CAST(_STACK *, STACK_OF(ASN1_ADB_TABLE) *, sk), (i), \
131       CHECKED_CAST(void *, ASN1_ADB_TABLE *, p)))
132 
133 #define sk_ASN1_ADB_TABLE_free(sk) \
134   sk_free(CHECKED_CAST(_STACK *, STACK_OF(ASN1_ADB_TABLE) *, sk))
135 
136 #define sk_ASN1_ADB_TABLE_pop_free(sk, free_func)             \
137   sk_pop_free(                                                \
138       CHECKED_CAST(_STACK *, STACK_OF(ASN1_ADB_TABLE) *, sk), \
139       CHECKED_CAST(void (*)(void *), void (*)(ASN1_ADB_TABLE *), free_func))
140 
141 #define sk_ASN1_ADB_TABLE_insert(sk, p, where)                      \
142   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(ASN1_ADB_TABLE) *, sk), \
143             CHECKED_CAST(void *, ASN1_ADB_TABLE *, p), (where))
144 
145 #define sk_ASN1_ADB_TABLE_delete(sk, where) \
146   ((ASN1_ADB_TABLE *)sk_delete(             \
147       CHECKED_CAST(_STACK *, STACK_OF(ASN1_ADB_TABLE) *, sk), (where)))
148 
149 #define sk_ASN1_ADB_TABLE_delete_ptr(sk, p)                   \
150   ((ASN1_ADB_TABLE *)sk_delete_ptr(                           \
151       CHECKED_CAST(_STACK *, STACK_OF(ASN1_ADB_TABLE) *, sk), \
152       CHECKED_CAST(void *, ASN1_ADB_TABLE *, p)))
153 
154 #define sk_ASN1_ADB_TABLE_find(sk, out_index, p)                               \
155   sk_find(CHECKED_CAST(_STACK *, STACK_OF(ASN1_ADB_TABLE) *, sk), (out_index), \
156           CHECKED_CAST(void *, ASN1_ADB_TABLE *, p))
157 
158 #define sk_ASN1_ADB_TABLE_shift(sk) \
159   ((ASN1_ADB_TABLE *)sk_shift(      \
160       CHECKED_CAST(_STACK *, STACK_OF(ASN1_ADB_TABLE) *, sk)))
161 
162 #define sk_ASN1_ADB_TABLE_push(sk, p)                             \
163   sk_push(CHECKED_CAST(_STACK *, STACK_OF(ASN1_ADB_TABLE) *, sk), \
164           CHECKED_CAST(void *, ASN1_ADB_TABLE *, p))
165 
166 #define sk_ASN1_ADB_TABLE_pop(sk) \
167   ((ASN1_ADB_TABLE *)sk_pop(      \
168       CHECKED_CAST(_STACK *, STACK_OF(ASN1_ADB_TABLE) *, sk)))
169 
170 #define sk_ASN1_ADB_TABLE_dup(sk)      \
171   ((STACK_OF(ASN1_ADB_TABLE) *)sk_dup( \
172       CHECKED_CAST(const _STACK *, const STACK_OF(ASN1_ADB_TABLE) *, sk)))
173 
174 #define sk_ASN1_ADB_TABLE_sort(sk) \
175   sk_sort(CHECKED_CAST(_STACK *, STACK_OF(ASN1_ADB_TABLE) *, sk))
176 
177 #define sk_ASN1_ADB_TABLE_is_sorted(sk) \
178   sk_is_sorted(                         \
179       CHECKED_CAST(const _STACK *, const STACK_OF(ASN1_ADB_TABLE) *, sk))
180 
181 #define sk_ASN1_ADB_TABLE_set_cmp_func(sk, comp)                           \
182   ((int (*)(const ASN1_ADB_TABLE **a, const ASN1_ADB_TABLE **b))           \
183        sk_set_cmp_func(                                                    \
184            CHECKED_CAST(_STACK *, STACK_OF(ASN1_ADB_TABLE) *, sk),         \
185            CHECKED_CAST(stack_cmp_func, int (*)(const ASN1_ADB_TABLE **a,  \
186                                                 const ASN1_ADB_TABLE **b), \
187                         comp)))
188 
189 #define sk_ASN1_ADB_TABLE_deep_copy(sk, copy_func, free_func)                \
190   ((STACK_OF(ASN1_ADB_TABLE) *)sk_deep_copy(                                 \
191       CHECKED_CAST(const _STACK *, const STACK_OF(ASN1_ADB_TABLE) *, sk),    \
192       CHECKED_CAST(void *(*)(void *), ASN1_ADB_TABLE *(*)(ASN1_ADB_TABLE *), \
193                    copy_func),                                               \
194       CHECKED_CAST(void (*)(void *), void (*)(ASN1_ADB_TABLE *), free_func)))
195 
196 /* ASN1_GENERALSTRING */
197 #define sk_ASN1_GENERALSTRING_new(comp)                                    \
198   ((STACK_OF(ASN1_GENERALSTRING) *)sk_new(CHECKED_CAST(                    \
199       stack_cmp_func,                                                      \
200       int (*)(const ASN1_GENERALSTRING **a, const ASN1_GENERALSTRING **b), \
201       comp)))
202 
203 #define sk_ASN1_GENERALSTRING_new_null() \
204   ((STACK_OF(ASN1_GENERALSTRING) *)sk_new_null())
205 
206 #define sk_ASN1_GENERALSTRING_num(sk) \
207   sk_num(CHECKED_CAST(const _STACK *, const STACK_OF(ASN1_GENERALSTRING) *, sk))
208 
209 #define sk_ASN1_GENERALSTRING_zero(sk) \
210   sk_zero(CHECKED_CAST(_STACK *, STACK_OF(ASN1_GENERALSTRING) *, sk));
211 
212 #define sk_ASN1_GENERALSTRING_value(sk, i)                                    \
213   ((ASN1_GENERALSTRING *)sk_value(                                            \
214       CHECKED_CAST(const _STACK *, const STACK_OF(ASN1_GENERALSTRING) *, sk), \
215       (i)))
216 
217 #define sk_ASN1_GENERALSTRING_set(sk, i, p)                            \
218   ((ASN1_GENERALSTRING *)sk_set(                                       \
219       CHECKED_CAST(_STACK *, STACK_OF(ASN1_GENERALSTRING) *, sk), (i), \
220       CHECKED_CAST(void *, ASN1_GENERALSTRING *, p)))
221 
222 #define sk_ASN1_GENERALSTRING_free(sk) \
223   sk_free(CHECKED_CAST(_STACK *, STACK_OF(ASN1_GENERALSTRING) *, sk))
224 
225 #define sk_ASN1_GENERALSTRING_pop_free(sk, free_func)                        \
226   sk_pop_free(CHECKED_CAST(_STACK *, STACK_OF(ASN1_GENERALSTRING) *, sk),    \
227               CHECKED_CAST(void (*)(void *), void (*)(ASN1_GENERALSTRING *), \
228                            free_func))
229 
230 #define sk_ASN1_GENERALSTRING_insert(sk, p, where)                      \
231   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(ASN1_GENERALSTRING) *, sk), \
232             CHECKED_CAST(void *, ASN1_GENERALSTRING *, p), (where))
233 
234 #define sk_ASN1_GENERALSTRING_delete(sk, where) \
235   ((ASN1_GENERALSTRING *)sk_delete(             \
236       CHECKED_CAST(_STACK *, STACK_OF(ASN1_GENERALSTRING) *, sk), (where)))
237 
238 #define sk_ASN1_GENERALSTRING_delete_ptr(sk, p)                   \
239   ((ASN1_GENERALSTRING *)sk_delete_ptr(                           \
240       CHECKED_CAST(_STACK *, STACK_OF(ASN1_GENERALSTRING) *, sk), \
241       CHECKED_CAST(void *, ASN1_GENERALSTRING *, p)))
242 
243 #define sk_ASN1_GENERALSTRING_find(sk, out_index, p)                  \
244   sk_find(CHECKED_CAST(_STACK *, STACK_OF(ASN1_GENERALSTRING) *, sk), \
245           (out_index), CHECKED_CAST(void *, ASN1_GENERALSTRING *, p))
246 
247 #define sk_ASN1_GENERALSTRING_shift(sk) \
248   ((ASN1_GENERALSTRING *)sk_shift(      \
249       CHECKED_CAST(_STACK *, STACK_OF(ASN1_GENERALSTRING) *, sk)))
250 
251 #define sk_ASN1_GENERALSTRING_push(sk, p)                             \
252   sk_push(CHECKED_CAST(_STACK *, STACK_OF(ASN1_GENERALSTRING) *, sk), \
253           CHECKED_CAST(void *, ASN1_GENERALSTRING *, p))
254 
255 #define sk_ASN1_GENERALSTRING_pop(sk) \
256   ((ASN1_GENERALSTRING *)sk_pop(      \
257       CHECKED_CAST(_STACK *, STACK_OF(ASN1_GENERALSTRING) *, sk)))
258 
259 #define sk_ASN1_GENERALSTRING_dup(sk)      \
260   ((STACK_OF(ASN1_GENERALSTRING) *)sk_dup( \
261       CHECKED_CAST(const _STACK *, const STACK_OF(ASN1_GENERALSTRING) *, sk)))
262 
263 #define sk_ASN1_GENERALSTRING_sort(sk) \
264   sk_sort(CHECKED_CAST(_STACK *, STACK_OF(ASN1_GENERALSTRING) *, sk))
265 
266 #define sk_ASN1_GENERALSTRING_is_sorted(sk) \
267   sk_is_sorted(                             \
268       CHECKED_CAST(const _STACK *, const STACK_OF(ASN1_GENERALSTRING) *, sk))
269 
270 #define sk_ASN1_GENERALSTRING_set_cmp_func(sk, comp)                           \
271   ((int (*)(const ASN1_GENERALSTRING **a, const ASN1_GENERALSTRING **b))       \
272        sk_set_cmp_func(                                                        \
273            CHECKED_CAST(_STACK *, STACK_OF(ASN1_GENERALSTRING) *, sk),         \
274            CHECKED_CAST(stack_cmp_func, int (*)(const ASN1_GENERALSTRING **a,  \
275                                                 const ASN1_GENERALSTRING **b), \
276                         comp)))
277 
278 #define sk_ASN1_GENERALSTRING_deep_copy(sk, copy_func, free_func)             \
279   ((STACK_OF(ASN1_GENERALSTRING) *)sk_deep_copy(                              \
280       CHECKED_CAST(const _STACK *, const STACK_OF(ASN1_GENERALSTRING) *, sk), \
281       CHECKED_CAST(void *(*)(void *),                                         \
282                    ASN1_GENERALSTRING *(*)(ASN1_GENERALSTRING *), copy_func), \
283       CHECKED_CAST(void (*)(void *), void (*)(ASN1_GENERALSTRING *),          \
284                    free_func)))
285 
286 /* ASN1_INTEGER */
287 #define sk_ASN1_INTEGER_new(comp)                                              \
288   ((STACK_OF(ASN1_INTEGER) *)sk_new(CHECKED_CAST(                              \
289       stack_cmp_func, int (*)(const ASN1_INTEGER **a, const ASN1_INTEGER **b), \
290       comp)))
291 
292 #define sk_ASN1_INTEGER_new_null() ((STACK_OF(ASN1_INTEGER) *)sk_new_null())
293 
294 #define sk_ASN1_INTEGER_num(sk) \
295   sk_num(CHECKED_CAST(const _STACK *, const STACK_OF(ASN1_INTEGER) *, sk))
296 
297 #define sk_ASN1_INTEGER_zero(sk) \
298   sk_zero(CHECKED_CAST(_STACK *, STACK_OF(ASN1_INTEGER) *, sk));
299 
300 #define sk_ASN1_INTEGER_value(sk, i) \
301   ((ASN1_INTEGER *)sk_value(         \
302       CHECKED_CAST(const _STACK *, const STACK_OF(ASN1_INTEGER) *, sk), (i)))
303 
304 #define sk_ASN1_INTEGER_set(sk, i, p)                            \
305   ((ASN1_INTEGER *)sk_set(                                       \
306       CHECKED_CAST(_STACK *, STACK_OF(ASN1_INTEGER) *, sk), (i), \
307       CHECKED_CAST(void *, ASN1_INTEGER *, p)))
308 
309 #define sk_ASN1_INTEGER_free(sk) \
310   sk_free(CHECKED_CAST(_STACK *, STACK_OF(ASN1_INTEGER) *, sk))
311 
312 #define sk_ASN1_INTEGER_pop_free(sk, free_func)             \
313   sk_pop_free(                                              \
314       CHECKED_CAST(_STACK *, STACK_OF(ASN1_INTEGER) *, sk), \
315       CHECKED_CAST(void (*)(void *), void (*)(ASN1_INTEGER *), free_func))
316 
317 #define sk_ASN1_INTEGER_insert(sk, p, where)                      \
318   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(ASN1_INTEGER) *, sk), \
319             CHECKED_CAST(void *, ASN1_INTEGER *, p), (where))
320 
321 #define sk_ASN1_INTEGER_delete(sk, where) \
322   ((ASN1_INTEGER *)sk_delete(             \
323       CHECKED_CAST(_STACK *, STACK_OF(ASN1_INTEGER) *, sk), (where)))
324 
325 #define sk_ASN1_INTEGER_delete_ptr(sk, p)                   \
326   ((ASN1_INTEGER *)sk_delete_ptr(                           \
327       CHECKED_CAST(_STACK *, STACK_OF(ASN1_INTEGER) *, sk), \
328       CHECKED_CAST(void *, ASN1_INTEGER *, p)))
329 
330 #define sk_ASN1_INTEGER_find(sk, out_index, p)                               \
331   sk_find(CHECKED_CAST(_STACK *, STACK_OF(ASN1_INTEGER) *, sk), (out_index), \
332           CHECKED_CAST(void *, ASN1_INTEGER *, p))
333 
334 #define sk_ASN1_INTEGER_shift(sk) \
335   ((ASN1_INTEGER *)sk_shift(      \
336       CHECKED_CAST(_STACK *, STACK_OF(ASN1_INTEGER) *, sk)))
337 
338 #define sk_ASN1_INTEGER_push(sk, p)                             \
339   sk_push(CHECKED_CAST(_STACK *, STACK_OF(ASN1_INTEGER) *, sk), \
340           CHECKED_CAST(void *, ASN1_INTEGER *, p))
341 
342 #define sk_ASN1_INTEGER_pop(sk) \
343   ((ASN1_INTEGER *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(ASN1_INTEGER) *, sk)))
344 
345 #define sk_ASN1_INTEGER_dup(sk)      \
346   ((STACK_OF(ASN1_INTEGER) *)sk_dup( \
347       CHECKED_CAST(const _STACK *, const STACK_OF(ASN1_INTEGER) *, sk)))
348 
349 #define sk_ASN1_INTEGER_sort(sk) \
350   sk_sort(CHECKED_CAST(_STACK *, STACK_OF(ASN1_INTEGER) *, sk))
351 
352 #define sk_ASN1_INTEGER_is_sorted(sk) \
353   sk_is_sorted(CHECKED_CAST(const _STACK *, const STACK_OF(ASN1_INTEGER) *, sk))
354 
355 #define sk_ASN1_INTEGER_set_cmp_func(sk, comp)                               \
356   ((int (*)(const ASN1_INTEGER **a, const ASN1_INTEGER **b))sk_set_cmp_func( \
357       CHECKED_CAST(_STACK *, STACK_OF(ASN1_INTEGER) *, sk),                  \
358       CHECKED_CAST(stack_cmp_func,                                           \
359                    int (*)(const ASN1_INTEGER **a, const ASN1_INTEGER **b),  \
360                    comp)))
361 
362 #define sk_ASN1_INTEGER_deep_copy(sk, copy_func, free_func)              \
363   ((STACK_OF(ASN1_INTEGER) *)sk_deep_copy(                               \
364       CHECKED_CAST(const _STACK *, const STACK_OF(ASN1_INTEGER) *, sk),  \
365       CHECKED_CAST(void *(*)(void *), ASN1_INTEGER *(*)(ASN1_INTEGER *), \
366                    copy_func),                                           \
367       CHECKED_CAST(void (*)(void *), void (*)(ASN1_INTEGER *), free_func)))
368 
369 /* ASN1_OBJECT */
370 #define sk_ASN1_OBJECT_new(comp)                                             \
371   ((STACK_OF(ASN1_OBJECT) *)sk_new(CHECKED_CAST(                             \
372       stack_cmp_func, int (*)(const ASN1_OBJECT **a, const ASN1_OBJECT **b), \
373       comp)))
374 
375 #define sk_ASN1_OBJECT_new_null() ((STACK_OF(ASN1_OBJECT) *)sk_new_null())
376 
377 #define sk_ASN1_OBJECT_num(sk) \
378   sk_num(CHECKED_CAST(const _STACK *, const STACK_OF(ASN1_OBJECT) *, sk))
379 
380 #define sk_ASN1_OBJECT_zero(sk) \
381   sk_zero(CHECKED_CAST(_STACK *, STACK_OF(ASN1_OBJECT) *, sk));
382 
383 #define sk_ASN1_OBJECT_value(sk, i) \
384   ((ASN1_OBJECT *)sk_value(         \
385       CHECKED_CAST(const _STACK *, const STACK_OF(ASN1_OBJECT) *, sk), (i)))
386 
387 #define sk_ASN1_OBJECT_set(sk, i, p)                                          \
388   ((ASN1_OBJECT *)sk_set(CHECKED_CAST(_STACK *, STACK_OF(ASN1_OBJECT) *, sk), \
389                          (i), CHECKED_CAST(void *, ASN1_OBJECT *, p)))
390 
391 #define sk_ASN1_OBJECT_free(sk) \
392   sk_free(CHECKED_CAST(_STACK *, STACK_OF(ASN1_OBJECT) *, sk))
393 
394 #define sk_ASN1_OBJECT_pop_free(sk, free_func)             \
395   sk_pop_free(                                             \
396       CHECKED_CAST(_STACK *, STACK_OF(ASN1_OBJECT) *, sk), \
397       CHECKED_CAST(void (*)(void *), void (*)(ASN1_OBJECT *), free_func))
398 
399 #define sk_ASN1_OBJECT_insert(sk, p, where)                      \
400   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(ASN1_OBJECT) *, sk), \
401             CHECKED_CAST(void *, ASN1_OBJECT *, p), (where))
402 
403 #define sk_ASN1_OBJECT_delete(sk, where) \
404   ((ASN1_OBJECT *)sk_delete(             \
405       CHECKED_CAST(_STACK *, STACK_OF(ASN1_OBJECT) *, sk), (where)))
406 
407 #define sk_ASN1_OBJECT_delete_ptr(sk, p)                   \
408   ((ASN1_OBJECT *)sk_delete_ptr(                           \
409       CHECKED_CAST(_STACK *, STACK_OF(ASN1_OBJECT) *, sk), \
410       CHECKED_CAST(void *, ASN1_OBJECT *, p)))
411 
412 #define sk_ASN1_OBJECT_find(sk, out_index, p)                               \
413   sk_find(CHECKED_CAST(_STACK *, STACK_OF(ASN1_OBJECT) *, sk), (out_index), \
414           CHECKED_CAST(void *, ASN1_OBJECT *, p))
415 
416 #define sk_ASN1_OBJECT_shift(sk) \
417   ((ASN1_OBJECT *)sk_shift(CHECKED_CAST(_STACK *, STACK_OF(ASN1_OBJECT) *, sk)))
418 
419 #define sk_ASN1_OBJECT_push(sk, p)                             \
420   sk_push(CHECKED_CAST(_STACK *, STACK_OF(ASN1_OBJECT) *, sk), \
421           CHECKED_CAST(void *, ASN1_OBJECT *, p))
422 
423 #define sk_ASN1_OBJECT_pop(sk) \
424   ((ASN1_OBJECT *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(ASN1_OBJECT) *, sk)))
425 
426 #define sk_ASN1_OBJECT_dup(sk)      \
427   ((STACK_OF(ASN1_OBJECT) *)sk_dup( \
428       CHECKED_CAST(const _STACK *, const STACK_OF(ASN1_OBJECT) *, sk)))
429 
430 #define sk_ASN1_OBJECT_sort(sk) \
431   sk_sort(CHECKED_CAST(_STACK *, STACK_OF(ASN1_OBJECT) *, sk))
432 
433 #define sk_ASN1_OBJECT_is_sorted(sk) \
434   sk_is_sorted(CHECKED_CAST(const _STACK *, const STACK_OF(ASN1_OBJECT) *, sk))
435 
436 #define sk_ASN1_OBJECT_set_cmp_func(sk, comp)                              \
437   ((int (*)(const ASN1_OBJECT **a, const ASN1_OBJECT **b))sk_set_cmp_func( \
438       CHECKED_CAST(_STACK *, STACK_OF(ASN1_OBJECT) *, sk),                 \
439       CHECKED_CAST(stack_cmp_func,                                         \
440                    int (*)(const ASN1_OBJECT **a, const ASN1_OBJECT **b),  \
441                    comp)))
442 
443 #define sk_ASN1_OBJECT_deep_copy(sk, copy_func, free_func)             \
444   ((STACK_OF(ASN1_OBJECT) *)sk_deep_copy(                              \
445       CHECKED_CAST(const _STACK *, const STACK_OF(ASN1_OBJECT) *, sk), \
446       CHECKED_CAST(void *(*)(void *), ASN1_OBJECT *(*)(ASN1_OBJECT *), \
447                    copy_func),                                         \
448       CHECKED_CAST(void (*)(void *), void (*)(ASN1_OBJECT *), free_func)))
449 
450 /* ASN1_STRING_TABLE */
451 #define sk_ASN1_STRING_TABLE_new(comp)                                   \
452   ((STACK_OF(ASN1_STRING_TABLE) *)sk_new(CHECKED_CAST(                   \
453       stack_cmp_func,                                                    \
454       int (*)(const ASN1_STRING_TABLE **a, const ASN1_STRING_TABLE **b), \
455       comp)))
456 
457 #define sk_ASN1_STRING_TABLE_new_null() \
458   ((STACK_OF(ASN1_STRING_TABLE) *)sk_new_null())
459 
460 #define sk_ASN1_STRING_TABLE_num(sk) \
461   sk_num(CHECKED_CAST(const _STACK *, const STACK_OF(ASN1_STRING_TABLE) *, sk))
462 
463 #define sk_ASN1_STRING_TABLE_zero(sk) \
464   sk_zero(CHECKED_CAST(_STACK *, STACK_OF(ASN1_STRING_TABLE) *, sk));
465 
466 #define sk_ASN1_STRING_TABLE_value(sk, i)                                    \
467   ((ASN1_STRING_TABLE *)sk_value(                                            \
468       CHECKED_CAST(const _STACK *, const STACK_OF(ASN1_STRING_TABLE) *, sk), \
469       (i)))
470 
471 #define sk_ASN1_STRING_TABLE_set(sk, i, p)                            \
472   ((ASN1_STRING_TABLE *)sk_set(                                       \
473       CHECKED_CAST(_STACK *, STACK_OF(ASN1_STRING_TABLE) *, sk), (i), \
474       CHECKED_CAST(void *, ASN1_STRING_TABLE *, p)))
475 
476 #define sk_ASN1_STRING_TABLE_free(sk) \
477   sk_free(CHECKED_CAST(_STACK *, STACK_OF(ASN1_STRING_TABLE) *, sk))
478 
479 #define sk_ASN1_STRING_TABLE_pop_free(sk, free_func)                        \
480   sk_pop_free(CHECKED_CAST(_STACK *, STACK_OF(ASN1_STRING_TABLE) *, sk),    \
481               CHECKED_CAST(void (*)(void *), void (*)(ASN1_STRING_TABLE *), \
482                            free_func))
483 
484 #define sk_ASN1_STRING_TABLE_insert(sk, p, where)                      \
485   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(ASN1_STRING_TABLE) *, sk), \
486             CHECKED_CAST(void *, ASN1_STRING_TABLE *, p), (where))
487 
488 #define sk_ASN1_STRING_TABLE_delete(sk, where) \
489   ((ASN1_STRING_TABLE *)sk_delete(             \
490       CHECKED_CAST(_STACK *, STACK_OF(ASN1_STRING_TABLE) *, sk), (where)))
491 
492 #define sk_ASN1_STRING_TABLE_delete_ptr(sk, p)                   \
493   ((ASN1_STRING_TABLE *)sk_delete_ptr(                           \
494       CHECKED_CAST(_STACK *, STACK_OF(ASN1_STRING_TABLE) *, sk), \
495       CHECKED_CAST(void *, ASN1_STRING_TABLE *, p)))
496 
497 #define sk_ASN1_STRING_TABLE_find(sk, out_index, p)                  \
498   sk_find(CHECKED_CAST(_STACK *, STACK_OF(ASN1_STRING_TABLE) *, sk), \
499           (out_index), CHECKED_CAST(void *, ASN1_STRING_TABLE *, p))
500 
501 #define sk_ASN1_STRING_TABLE_shift(sk) \
502   ((ASN1_STRING_TABLE *)sk_shift(      \
503       CHECKED_CAST(_STACK *, STACK_OF(ASN1_STRING_TABLE) *, sk)))
504 
505 #define sk_ASN1_STRING_TABLE_push(sk, p)                             \
506   sk_push(CHECKED_CAST(_STACK *, STACK_OF(ASN1_STRING_TABLE) *, sk), \
507           CHECKED_CAST(void *, ASN1_STRING_TABLE *, p))
508 
509 #define sk_ASN1_STRING_TABLE_pop(sk) \
510   ((ASN1_STRING_TABLE *)sk_pop(      \
511       CHECKED_CAST(_STACK *, STACK_OF(ASN1_STRING_TABLE) *, sk)))
512 
513 #define sk_ASN1_STRING_TABLE_dup(sk)      \
514   ((STACK_OF(ASN1_STRING_TABLE) *)sk_dup( \
515       CHECKED_CAST(const _STACK *, const STACK_OF(ASN1_STRING_TABLE) *, sk)))
516 
517 #define sk_ASN1_STRING_TABLE_sort(sk) \
518   sk_sort(CHECKED_CAST(_STACK *, STACK_OF(ASN1_STRING_TABLE) *, sk))
519 
520 #define sk_ASN1_STRING_TABLE_is_sorted(sk) \
521   sk_is_sorted(                            \
522       CHECKED_CAST(const _STACK *, const STACK_OF(ASN1_STRING_TABLE) *, sk))
523 
524 #define sk_ASN1_STRING_TABLE_set_cmp_func(sk, comp)                           \
525   ((int (*)(const ASN1_STRING_TABLE **a, const ASN1_STRING_TABLE **b))        \
526        sk_set_cmp_func(                                                       \
527            CHECKED_CAST(_STACK *, STACK_OF(ASN1_STRING_TABLE) *, sk),         \
528            CHECKED_CAST(stack_cmp_func, int (*)(const ASN1_STRING_TABLE **a,  \
529                                                 const ASN1_STRING_TABLE **b), \
530                         comp)))
531 
532 #define sk_ASN1_STRING_TABLE_deep_copy(sk, copy_func, free_func)             \
533   ((STACK_OF(ASN1_STRING_TABLE) *)sk_deep_copy(                              \
534       CHECKED_CAST(const _STACK *, const STACK_OF(ASN1_STRING_TABLE) *, sk), \
535       CHECKED_CAST(void *(*)(void *),                                        \
536                    ASN1_STRING_TABLE *(*)(ASN1_STRING_TABLE *), copy_func),  \
537       CHECKED_CAST(void (*)(void *), void (*)(ASN1_STRING_TABLE *),          \
538                    free_func)))
539 
540 /* ASN1_TYPE */
541 #define sk_ASN1_TYPE_new(comp)     \
542   ((STACK_OF(ASN1_TYPE) *)sk_new(  \
543       CHECKED_CAST(stack_cmp_func, \
544                    int (*)(const ASN1_TYPE **a, const ASN1_TYPE **b), comp)))
545 
546 #define sk_ASN1_TYPE_new_null() ((STACK_OF(ASN1_TYPE) *)sk_new_null())
547 
548 #define sk_ASN1_TYPE_num(sk) \
549   sk_num(CHECKED_CAST(const _STACK *, const STACK_OF(ASN1_TYPE) *, sk))
550 
551 #define sk_ASN1_TYPE_zero(sk) \
552   sk_zero(CHECKED_CAST(_STACK *, STACK_OF(ASN1_TYPE) *, sk));
553 
554 #define sk_ASN1_TYPE_value(sk, i) \
555   ((ASN1_TYPE *)sk_value(         \
556       CHECKED_CAST(const _STACK *, const STACK_OF(ASN1_TYPE) *, sk), (i)))
557 
558 #define sk_ASN1_TYPE_set(sk, i, p)                                             \
559   ((ASN1_TYPE *)sk_set(CHECKED_CAST(_STACK *, STACK_OF(ASN1_TYPE) *, sk), (i), \
560                        CHECKED_CAST(void *, ASN1_TYPE *, p)))
561 
562 #define sk_ASN1_TYPE_free(sk) \
563   sk_free(CHECKED_CAST(_STACK *, STACK_OF(ASN1_TYPE) *, sk))
564 
565 #define sk_ASN1_TYPE_pop_free(sk, free_func)             \
566   sk_pop_free(                                           \
567       CHECKED_CAST(_STACK *, STACK_OF(ASN1_TYPE) *, sk), \
568       CHECKED_CAST(void (*)(void *), void (*)(ASN1_TYPE *), free_func))
569 
570 #define sk_ASN1_TYPE_insert(sk, p, where)                      \
571   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(ASN1_TYPE) *, sk), \
572             CHECKED_CAST(void *, ASN1_TYPE *, p), (where))
573 
574 #define sk_ASN1_TYPE_delete(sk, where)                                       \
575   ((ASN1_TYPE *)sk_delete(CHECKED_CAST(_STACK *, STACK_OF(ASN1_TYPE) *, sk), \
576                           (where)))
577 
578 #define sk_ASN1_TYPE_delete_ptr(sk, p)                   \
579   ((ASN1_TYPE *)sk_delete_ptr(                           \
580       CHECKED_CAST(_STACK *, STACK_OF(ASN1_TYPE) *, sk), \
581       CHECKED_CAST(void *, ASN1_TYPE *, p)))
582 
583 #define sk_ASN1_TYPE_find(sk, out_index, p)                               \
584   sk_find(CHECKED_CAST(_STACK *, STACK_OF(ASN1_TYPE) *, sk), (out_index), \
585           CHECKED_CAST(void *, ASN1_TYPE *, p))
586 
587 #define sk_ASN1_TYPE_shift(sk) \
588   ((ASN1_TYPE *)sk_shift(CHECKED_CAST(_STACK *, STACK_OF(ASN1_TYPE) *, sk)))
589 
590 #define sk_ASN1_TYPE_push(sk, p)                             \
591   sk_push(CHECKED_CAST(_STACK *, STACK_OF(ASN1_TYPE) *, sk), \
592           CHECKED_CAST(void *, ASN1_TYPE *, p))
593 
594 #define sk_ASN1_TYPE_pop(sk) \
595   ((ASN1_TYPE *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(ASN1_TYPE) *, sk)))
596 
597 #define sk_ASN1_TYPE_dup(sk)      \
598   ((STACK_OF(ASN1_TYPE) *)sk_dup( \
599       CHECKED_CAST(const _STACK *, const STACK_OF(ASN1_TYPE) *, sk)))
600 
601 #define sk_ASN1_TYPE_sort(sk) \
602   sk_sort(CHECKED_CAST(_STACK *, STACK_OF(ASN1_TYPE) *, sk))
603 
604 #define sk_ASN1_TYPE_is_sorted(sk) \
605   sk_is_sorted(CHECKED_CAST(const _STACK *, const STACK_OF(ASN1_TYPE) *, sk))
606 
607 #define sk_ASN1_TYPE_set_cmp_func(sk, comp)                            \
608   ((int (*)(const ASN1_TYPE **a, const ASN1_TYPE **b))sk_set_cmp_func( \
609       CHECKED_CAST(_STACK *, STACK_OF(ASN1_TYPE) *, sk),               \
610       CHECKED_CAST(stack_cmp_func,                                     \
611                    int (*)(const ASN1_TYPE **a, const ASN1_TYPE **b), comp)))
612 
613 #define sk_ASN1_TYPE_deep_copy(sk, copy_func, free_func)                       \
614   ((STACK_OF(ASN1_TYPE) *)sk_deep_copy(                                        \
615       CHECKED_CAST(const _STACK *, const STACK_OF(ASN1_TYPE) *, sk),           \
616       CHECKED_CAST(void *(*)(void *), ASN1_TYPE *(*)(ASN1_TYPE *), copy_func), \
617       CHECKED_CAST(void (*)(void *), void (*)(ASN1_TYPE *), free_func)))
618 
619 /* ASN1_VALUE */
620 #define sk_ASN1_VALUE_new(comp)                                            \
621   ((STACK_OF(ASN1_VALUE) *)sk_new(CHECKED_CAST(                            \
622       stack_cmp_func, int (*)(const ASN1_VALUE **a, const ASN1_VALUE **b), \
623       comp)))
624 
625 #define sk_ASN1_VALUE_new_null() ((STACK_OF(ASN1_VALUE) *)sk_new_null())
626 
627 #define sk_ASN1_VALUE_num(sk) \
628   sk_num(CHECKED_CAST(const _STACK *, const STACK_OF(ASN1_VALUE) *, sk))
629 
630 #define sk_ASN1_VALUE_zero(sk) \
631   sk_zero(CHECKED_CAST(_STACK *, STACK_OF(ASN1_VALUE) *, sk));
632 
633 #define sk_ASN1_VALUE_value(sk, i) \
634   ((ASN1_VALUE *)sk_value(         \
635       CHECKED_CAST(const _STACK *, const STACK_OF(ASN1_VALUE) *, sk), (i)))
636 
637 #define sk_ASN1_VALUE_set(sk, i, p)                                         \
638   ((ASN1_VALUE *)sk_set(CHECKED_CAST(_STACK *, STACK_OF(ASN1_VALUE) *, sk), \
639                         (i), CHECKED_CAST(void *, ASN1_VALUE *, p)))
640 
641 #define sk_ASN1_VALUE_free(sk) \
642   sk_free(CHECKED_CAST(_STACK *, STACK_OF(ASN1_VALUE) *, sk))
643 
644 #define sk_ASN1_VALUE_pop_free(sk, free_func)             \
645   sk_pop_free(                                            \
646       CHECKED_CAST(_STACK *, STACK_OF(ASN1_VALUE) *, sk), \
647       CHECKED_CAST(void (*)(void *), void (*)(ASN1_VALUE *), free_func))
648 
649 #define sk_ASN1_VALUE_insert(sk, p, where)                      \
650   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(ASN1_VALUE) *, sk), \
651             CHECKED_CAST(void *, ASN1_VALUE *, p), (where))
652 
653 #define sk_ASN1_VALUE_delete(sk, where)                                        \
654   ((ASN1_VALUE *)sk_delete(CHECKED_CAST(_STACK *, STACK_OF(ASN1_VALUE) *, sk), \
655                            (where)))
656 
657 #define sk_ASN1_VALUE_delete_ptr(sk, p)                   \
658   ((ASN1_VALUE *)sk_delete_ptr(                           \
659       CHECKED_CAST(_STACK *, STACK_OF(ASN1_VALUE) *, sk), \
660       CHECKED_CAST(void *, ASN1_VALUE *, p)))
661 
662 #define sk_ASN1_VALUE_find(sk, out_index, p)                               \
663   sk_find(CHECKED_CAST(_STACK *, STACK_OF(ASN1_VALUE) *, sk), (out_index), \
664           CHECKED_CAST(void *, ASN1_VALUE *, p))
665 
666 #define sk_ASN1_VALUE_shift(sk) \
667   ((ASN1_VALUE *)sk_shift(CHECKED_CAST(_STACK *, STACK_OF(ASN1_VALUE) *, sk)))
668 
669 #define sk_ASN1_VALUE_push(sk, p)                             \
670   sk_push(CHECKED_CAST(_STACK *, STACK_OF(ASN1_VALUE) *, sk), \
671           CHECKED_CAST(void *, ASN1_VALUE *, p))
672 
673 #define sk_ASN1_VALUE_pop(sk) \
674   ((ASN1_VALUE *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(ASN1_VALUE) *, sk)))
675 
676 #define sk_ASN1_VALUE_dup(sk)      \
677   ((STACK_OF(ASN1_VALUE) *)sk_dup( \
678       CHECKED_CAST(const _STACK *, const STACK_OF(ASN1_VALUE) *, sk)))
679 
680 #define sk_ASN1_VALUE_sort(sk) \
681   sk_sort(CHECKED_CAST(_STACK *, STACK_OF(ASN1_VALUE) *, sk))
682 
683 #define sk_ASN1_VALUE_is_sorted(sk) \
684   sk_is_sorted(CHECKED_CAST(const _STACK *, const STACK_OF(ASN1_VALUE) *, sk))
685 
686 #define sk_ASN1_VALUE_set_cmp_func(sk, comp)                             \
687   ((int (*)(const ASN1_VALUE **a, const ASN1_VALUE **b))sk_set_cmp_func( \
688       CHECKED_CAST(_STACK *, STACK_OF(ASN1_VALUE) *, sk),                \
689       CHECKED_CAST(stack_cmp_func,                                       \
690                    int (*)(const ASN1_VALUE **a, const ASN1_VALUE **b),  \
691                    comp)))
692 
693 #define sk_ASN1_VALUE_deep_copy(sk, copy_func, free_func)             \
694   ((STACK_OF(ASN1_VALUE) *)sk_deep_copy(                              \
695       CHECKED_CAST(const _STACK *, const STACK_OF(ASN1_VALUE) *, sk), \
696       CHECKED_CAST(void *(*)(void *), ASN1_VALUE *(*)(ASN1_VALUE *),  \
697                    copy_func),                                        \
698       CHECKED_CAST(void (*)(void *), void (*)(ASN1_VALUE *), free_func)))
699 
700 /* BIO */
701 #define sk_BIO_new(comp)                 \
702   ((STACK_OF(BIO) *)sk_new(CHECKED_CAST( \
703       stack_cmp_func, int (*)(const BIO **a, const BIO **b), comp)))
704 
705 #define sk_BIO_new_null() ((STACK_OF(BIO) *)sk_new_null())
706 
707 #define sk_BIO_num(sk) \
708   sk_num(CHECKED_CAST(const _STACK *, const STACK_OF(BIO) *, sk))
709 
710 #define sk_BIO_zero(sk) sk_zero(CHECKED_CAST(_STACK *, STACK_OF(BIO) *, sk));
711 
712 #define sk_BIO_value(sk, i)                                                 \
713   ((BIO *)sk_value(CHECKED_CAST(const _STACK *, const STACK_OF(BIO) *, sk), \
714                    (i)))
715 
716 #define sk_BIO_set(sk, i, p)                                       \
717   ((BIO *)sk_set(CHECKED_CAST(_STACK *, STACK_OF(BIO) *, sk), (i), \
718                  CHECKED_CAST(void *, BIO *, p)))
719 
720 #define sk_BIO_free(sk) sk_free(CHECKED_CAST(_STACK *, STACK_OF(BIO) *, sk))
721 
722 #define sk_BIO_pop_free(sk, free_func)                     \
723   sk_pop_free(CHECKED_CAST(_STACK *, STACK_OF(BIO) *, sk), \
724               CHECKED_CAST(void (*)(void *), void (*)(BIO *), free_func))
725 
726 #define sk_BIO_insert(sk, p, where)                      \
727   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(BIO) *, sk), \
728             CHECKED_CAST(void *, BIO *, p), (where))
729 
730 #define sk_BIO_delete(sk, where) \
731   ((BIO *)sk_delete(CHECKED_CAST(_STACK *, STACK_OF(BIO) *, sk), (where)))
732 
733 #define sk_BIO_delete_ptr(sk, p)                                     \
734   ((BIO *)sk_delete_ptr(CHECKED_CAST(_STACK *, STACK_OF(BIO) *, sk), \
735                         CHECKED_CAST(void *, BIO *, p)))
736 
737 #define sk_BIO_find(sk, out_index, p)                               \
738   sk_find(CHECKED_CAST(_STACK *, STACK_OF(BIO) *, sk), (out_index), \
739           CHECKED_CAST(void *, BIO *, p))
740 
741 #define sk_BIO_shift(sk) \
742   ((BIO *)sk_shift(CHECKED_CAST(_STACK *, STACK_OF(BIO) *, sk)))
743 
744 #define sk_BIO_push(sk, p)                             \
745   sk_push(CHECKED_CAST(_STACK *, STACK_OF(BIO) *, sk), \
746           CHECKED_CAST(void *, BIO *, p))
747 
748 #define sk_BIO_pop(sk) \
749   ((BIO *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(BIO) *, sk)))
750 
751 #define sk_BIO_dup(sk)      \
752   ((STACK_OF(BIO) *)sk_dup( \
753       CHECKED_CAST(const _STACK *, const STACK_OF(BIO) *, sk)))
754 
755 #define sk_BIO_sort(sk) sk_sort(CHECKED_CAST(_STACK *, STACK_OF(BIO) *, sk))
756 
757 #define sk_BIO_is_sorted(sk) \
758   sk_is_sorted(CHECKED_CAST(const _STACK *, const STACK_OF(BIO) *, sk))
759 
760 #define sk_BIO_set_cmp_func(sk, comp)                                     \
761   ((int (*)(const BIO **a, const BIO **b))sk_set_cmp_func(                \
762       CHECKED_CAST(_STACK *, STACK_OF(BIO) *, sk),                        \
763       CHECKED_CAST(stack_cmp_func, int (*)(const BIO **a, const BIO **b), \
764                    comp)))
765 
766 #define sk_BIO_deep_copy(sk, copy_func, free_func)                 \
767   ((STACK_OF(BIO) *)sk_deep_copy(                                  \
768       CHECKED_CAST(const _STACK *, const STACK_OF(BIO) *, sk),     \
769       CHECKED_CAST(void *(*)(void *), BIO *(*)(BIO *), copy_func), \
770       CHECKED_CAST(void (*)(void *), void (*)(BIO *), free_func)))
771 
772 /* BY_DIR_ENTRY */
773 #define sk_BY_DIR_ENTRY_new(comp)                                              \
774   ((STACK_OF(BY_DIR_ENTRY) *)sk_new(CHECKED_CAST(                              \
775       stack_cmp_func, int (*)(const BY_DIR_ENTRY **a, const BY_DIR_ENTRY **b), \
776       comp)))
777 
778 #define sk_BY_DIR_ENTRY_new_null() ((STACK_OF(BY_DIR_ENTRY) *)sk_new_null())
779 
780 #define sk_BY_DIR_ENTRY_num(sk) \
781   sk_num(CHECKED_CAST(const _STACK *, const STACK_OF(BY_DIR_ENTRY) *, sk))
782 
783 #define sk_BY_DIR_ENTRY_zero(sk) \
784   sk_zero(CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_ENTRY) *, sk));
785 
786 #define sk_BY_DIR_ENTRY_value(sk, i) \
787   ((BY_DIR_ENTRY *)sk_value(         \
788       CHECKED_CAST(const _STACK *, const STACK_OF(BY_DIR_ENTRY) *, sk), (i)))
789 
790 #define sk_BY_DIR_ENTRY_set(sk, i, p)                            \
791   ((BY_DIR_ENTRY *)sk_set(                                       \
792       CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_ENTRY) *, sk), (i), \
793       CHECKED_CAST(void *, BY_DIR_ENTRY *, p)))
794 
795 #define sk_BY_DIR_ENTRY_free(sk) \
796   sk_free(CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_ENTRY) *, sk))
797 
798 #define sk_BY_DIR_ENTRY_pop_free(sk, free_func)             \
799   sk_pop_free(                                              \
800       CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_ENTRY) *, sk), \
801       CHECKED_CAST(void (*)(void *), void (*)(BY_DIR_ENTRY *), free_func))
802 
803 #define sk_BY_DIR_ENTRY_insert(sk, p, where)                      \
804   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_ENTRY) *, sk), \
805             CHECKED_CAST(void *, BY_DIR_ENTRY *, p), (where))
806 
807 #define sk_BY_DIR_ENTRY_delete(sk, where) \
808   ((BY_DIR_ENTRY *)sk_delete(             \
809       CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_ENTRY) *, sk), (where)))
810 
811 #define sk_BY_DIR_ENTRY_delete_ptr(sk, p)                   \
812   ((BY_DIR_ENTRY *)sk_delete_ptr(                           \
813       CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_ENTRY) *, sk), \
814       CHECKED_CAST(void *, BY_DIR_ENTRY *, p)))
815 
816 #define sk_BY_DIR_ENTRY_find(sk, out_index, p)                               \
817   sk_find(CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_ENTRY) *, sk), (out_index), \
818           CHECKED_CAST(void *, BY_DIR_ENTRY *, p))
819 
820 #define sk_BY_DIR_ENTRY_shift(sk) \
821   ((BY_DIR_ENTRY *)sk_shift(      \
822       CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_ENTRY) *, sk)))
823 
824 #define sk_BY_DIR_ENTRY_push(sk, p)                             \
825   sk_push(CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_ENTRY) *, sk), \
826           CHECKED_CAST(void *, BY_DIR_ENTRY *, p))
827 
828 #define sk_BY_DIR_ENTRY_pop(sk) \
829   ((BY_DIR_ENTRY *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_ENTRY) *, sk)))
830 
831 #define sk_BY_DIR_ENTRY_dup(sk)      \
832   ((STACK_OF(BY_DIR_ENTRY) *)sk_dup( \
833       CHECKED_CAST(const _STACK *, const STACK_OF(BY_DIR_ENTRY) *, sk)))
834 
835 #define sk_BY_DIR_ENTRY_sort(sk) \
836   sk_sort(CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_ENTRY) *, sk))
837 
838 #define sk_BY_DIR_ENTRY_is_sorted(sk) \
839   sk_is_sorted(CHECKED_CAST(const _STACK *, const STACK_OF(BY_DIR_ENTRY) *, sk))
840 
841 #define sk_BY_DIR_ENTRY_set_cmp_func(sk, comp)                               \
842   ((int (*)(const BY_DIR_ENTRY **a, const BY_DIR_ENTRY **b))sk_set_cmp_func( \
843       CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_ENTRY) *, sk),                  \
844       CHECKED_CAST(stack_cmp_func,                                           \
845                    int (*)(const BY_DIR_ENTRY **a, const BY_DIR_ENTRY **b),  \
846                    comp)))
847 
848 #define sk_BY_DIR_ENTRY_deep_copy(sk, copy_func, free_func)              \
849   ((STACK_OF(BY_DIR_ENTRY) *)sk_deep_copy(                               \
850       CHECKED_CAST(const _STACK *, const STACK_OF(BY_DIR_ENTRY) *, sk),  \
851       CHECKED_CAST(void *(*)(void *), BY_DIR_ENTRY *(*)(BY_DIR_ENTRY *), \
852                    copy_func),                                           \
853       CHECKED_CAST(void (*)(void *), void (*)(BY_DIR_ENTRY *), free_func)))
854 
855 /* BY_DIR_HASH */
856 #define sk_BY_DIR_HASH_new(comp)                                             \
857   ((STACK_OF(BY_DIR_HASH) *)sk_new(CHECKED_CAST(                             \
858       stack_cmp_func, int (*)(const BY_DIR_HASH **a, const BY_DIR_HASH **b), \
859       comp)))
860 
861 #define sk_BY_DIR_HASH_new_null() ((STACK_OF(BY_DIR_HASH) *)sk_new_null())
862 
863 #define sk_BY_DIR_HASH_num(sk) \
864   sk_num(CHECKED_CAST(const _STACK *, const STACK_OF(BY_DIR_HASH) *, sk))
865 
866 #define sk_BY_DIR_HASH_zero(sk) \
867   sk_zero(CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_HASH) *, sk));
868 
869 #define sk_BY_DIR_HASH_value(sk, i) \
870   ((BY_DIR_HASH *)sk_value(         \
871       CHECKED_CAST(const _STACK *, const STACK_OF(BY_DIR_HASH) *, sk), (i)))
872 
873 #define sk_BY_DIR_HASH_set(sk, i, p)                                          \
874   ((BY_DIR_HASH *)sk_set(CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_HASH) *, sk), \
875                          (i), CHECKED_CAST(void *, BY_DIR_HASH *, p)))
876 
877 #define sk_BY_DIR_HASH_free(sk) \
878   sk_free(CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_HASH) *, sk))
879 
880 #define sk_BY_DIR_HASH_pop_free(sk, free_func)             \
881   sk_pop_free(                                             \
882       CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_HASH) *, sk), \
883       CHECKED_CAST(void (*)(void *), void (*)(BY_DIR_HASH *), free_func))
884 
885 #define sk_BY_DIR_HASH_insert(sk, p, where)                      \
886   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_HASH) *, sk), \
887             CHECKED_CAST(void *, BY_DIR_HASH *, p), (where))
888 
889 #define sk_BY_DIR_HASH_delete(sk, where) \
890   ((BY_DIR_HASH *)sk_delete(             \
891       CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_HASH) *, sk), (where)))
892 
893 #define sk_BY_DIR_HASH_delete_ptr(sk, p)                   \
894   ((BY_DIR_HASH *)sk_delete_ptr(                           \
895       CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_HASH) *, sk), \
896       CHECKED_CAST(void *, BY_DIR_HASH *, p)))
897 
898 #define sk_BY_DIR_HASH_find(sk, out_index, p)                               \
899   sk_find(CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_HASH) *, sk), (out_index), \
900           CHECKED_CAST(void *, BY_DIR_HASH *, p))
901 
902 #define sk_BY_DIR_HASH_shift(sk) \
903   ((BY_DIR_HASH *)sk_shift(CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_HASH) *, sk)))
904 
905 #define sk_BY_DIR_HASH_push(sk, p)                             \
906   sk_push(CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_HASH) *, sk), \
907           CHECKED_CAST(void *, BY_DIR_HASH *, p))
908 
909 #define sk_BY_DIR_HASH_pop(sk) \
910   ((BY_DIR_HASH *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_HASH) *, sk)))
911 
912 #define sk_BY_DIR_HASH_dup(sk)      \
913   ((STACK_OF(BY_DIR_HASH) *)sk_dup( \
914       CHECKED_CAST(const _STACK *, const STACK_OF(BY_DIR_HASH) *, sk)))
915 
916 #define sk_BY_DIR_HASH_sort(sk) \
917   sk_sort(CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_HASH) *, sk))
918 
919 #define sk_BY_DIR_HASH_is_sorted(sk) \
920   sk_is_sorted(CHECKED_CAST(const _STACK *, const STACK_OF(BY_DIR_HASH) *, sk))
921 
922 #define sk_BY_DIR_HASH_set_cmp_func(sk, comp)                              \
923   ((int (*)(const BY_DIR_HASH **a, const BY_DIR_HASH **b))sk_set_cmp_func( \
924       CHECKED_CAST(_STACK *, STACK_OF(BY_DIR_HASH) *, sk),                 \
925       CHECKED_CAST(stack_cmp_func,                                         \
926                    int (*)(const BY_DIR_HASH **a, const BY_DIR_HASH **b),  \
927                    comp)))
928 
929 #define sk_BY_DIR_HASH_deep_copy(sk, copy_func, free_func)             \
930   ((STACK_OF(BY_DIR_HASH) *)sk_deep_copy(                              \
931       CHECKED_CAST(const _STACK *, const STACK_OF(BY_DIR_HASH) *, sk), \
932       CHECKED_CAST(void *(*)(void *), BY_DIR_HASH *(*)(BY_DIR_HASH *), \
933                    copy_func),                                         \
934       CHECKED_CAST(void (*)(void *), void (*)(BY_DIR_HASH *), free_func)))
935 
936 /* CONF_VALUE */
937 #define sk_CONF_VALUE_new(comp)                                            \
938   ((STACK_OF(CONF_VALUE) *)sk_new(CHECKED_CAST(                            \
939       stack_cmp_func, int (*)(const CONF_VALUE **a, const CONF_VALUE **b), \
940       comp)))
941 
942 #define sk_CONF_VALUE_new_null() ((STACK_OF(CONF_VALUE) *)sk_new_null())
943 
944 #define sk_CONF_VALUE_num(sk) \
945   sk_num(CHECKED_CAST(const _STACK *, const STACK_OF(CONF_VALUE) *, sk))
946 
947 #define sk_CONF_VALUE_zero(sk) \
948   sk_zero(CHECKED_CAST(_STACK *, STACK_OF(CONF_VALUE) *, sk));
949 
950 #define sk_CONF_VALUE_value(sk, i) \
951   ((CONF_VALUE *)sk_value(         \
952       CHECKED_CAST(const _STACK *, const STACK_OF(CONF_VALUE) *, sk), (i)))
953 
954 #define sk_CONF_VALUE_set(sk, i, p)                                         \
955   ((CONF_VALUE *)sk_set(CHECKED_CAST(_STACK *, STACK_OF(CONF_VALUE) *, sk), \
956                         (i), CHECKED_CAST(void *, CONF_VALUE *, p)))
957 
958 #define sk_CONF_VALUE_free(sk) \
959   sk_free(CHECKED_CAST(_STACK *, STACK_OF(CONF_VALUE) *, sk))
960 
961 #define sk_CONF_VALUE_pop_free(sk, free_func)             \
962   sk_pop_free(                                            \
963       CHECKED_CAST(_STACK *, STACK_OF(CONF_VALUE) *, sk), \
964       CHECKED_CAST(void (*)(void *), void (*)(CONF_VALUE *), free_func))
965 
966 #define sk_CONF_VALUE_insert(sk, p, where)                      \
967   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(CONF_VALUE) *, sk), \
968             CHECKED_CAST(void *, CONF_VALUE *, p), (where))
969 
970 #define sk_CONF_VALUE_delete(sk, where)                                        \
971   ((CONF_VALUE *)sk_delete(CHECKED_CAST(_STACK *, STACK_OF(CONF_VALUE) *, sk), \
972                            (where)))
973 
974 #define sk_CONF_VALUE_delete_ptr(sk, p)                   \
975   ((CONF_VALUE *)sk_delete_ptr(                           \
976       CHECKED_CAST(_STACK *, STACK_OF(CONF_VALUE) *, sk), \
977       CHECKED_CAST(void *, CONF_VALUE *, p)))
978 
979 #define sk_CONF_VALUE_find(sk, out_index, p)                               \
980   sk_find(CHECKED_CAST(_STACK *, STACK_OF(CONF_VALUE) *, sk), (out_index), \
981           CHECKED_CAST(void *, CONF_VALUE *, p))
982 
983 #define sk_CONF_VALUE_shift(sk) \
984   ((CONF_VALUE *)sk_shift(CHECKED_CAST(_STACK *, STACK_OF(CONF_VALUE) *, sk)))
985 
986 #define sk_CONF_VALUE_push(sk, p)                             \
987   sk_push(CHECKED_CAST(_STACK *, STACK_OF(CONF_VALUE) *, sk), \
988           CHECKED_CAST(void *, CONF_VALUE *, p))
989 
990 #define sk_CONF_VALUE_pop(sk) \
991   ((CONF_VALUE *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(CONF_VALUE) *, sk)))
992 
993 #define sk_CONF_VALUE_dup(sk)      \
994   ((STACK_OF(CONF_VALUE) *)sk_dup( \
995       CHECKED_CAST(const _STACK *, const STACK_OF(CONF_VALUE) *, sk)))
996 
997 #define sk_CONF_VALUE_sort(sk) \
998   sk_sort(CHECKED_CAST(_STACK *, STACK_OF(CONF_VALUE) *, sk))
999 
1000 #define sk_CONF_VALUE_is_sorted(sk) \
1001   sk_is_sorted(CHECKED_CAST(const _STACK *, const STACK_OF(CONF_VALUE) *, sk))
1002 
1003 #define sk_CONF_VALUE_set_cmp_func(sk, comp)                             \
1004   ((int (*)(const CONF_VALUE **a, const CONF_VALUE **b))sk_set_cmp_func( \
1005       CHECKED_CAST(_STACK *, STACK_OF(CONF_VALUE) *, sk),                \
1006       CHECKED_CAST(stack_cmp_func,                                       \
1007                    int (*)(const CONF_VALUE **a, const CONF_VALUE **b),  \
1008                    comp)))
1009 
1010 #define sk_CONF_VALUE_deep_copy(sk, copy_func, free_func)             \
1011   ((STACK_OF(CONF_VALUE) *)sk_deep_copy(                              \
1012       CHECKED_CAST(const _STACK *, const STACK_OF(CONF_VALUE) *, sk), \
1013       CHECKED_CAST(void *(*)(void *), CONF_VALUE *(*)(CONF_VALUE *),  \
1014                    copy_func),                                        \
1015       CHECKED_CAST(void (*)(void *), void (*)(CONF_VALUE *), free_func)))
1016 
1017 /* CRYPTO_BUFFER */
1018 #define sk_CRYPTO_BUFFER_new(comp)                 \
1019   ((STACK_OF(CRYPTO_BUFFER) *)sk_new(CHECKED_CAST( \
1020       stack_cmp_func,                              \
1021       int (*)(const CRYPTO_BUFFER **a, const CRYPTO_BUFFER **b), comp)))
1022 
1023 #define sk_CRYPTO_BUFFER_new_null() ((STACK_OF(CRYPTO_BUFFER) *)sk_new_null())
1024 
1025 #define sk_CRYPTO_BUFFER_num(sk) \
1026   sk_num(CHECKED_CAST(const _STACK *, const STACK_OF(CRYPTO_BUFFER) *, sk))
1027 
1028 #define sk_CRYPTO_BUFFER_zero(sk) \
1029   sk_zero(CHECKED_CAST(_STACK *, STACK_OF(CRYPTO_BUFFER) *, sk));
1030 
1031 #define sk_CRYPTO_BUFFER_value(sk, i) \
1032   ((CRYPTO_BUFFER *)sk_value(         \
1033       CHECKED_CAST(const _STACK *, const STACK_OF(CRYPTO_BUFFER) *, sk), (i)))
1034 
1035 #define sk_CRYPTO_BUFFER_set(sk, i, p)                            \
1036   ((CRYPTO_BUFFER *)sk_set(                                       \
1037       CHECKED_CAST(_STACK *, STACK_OF(CRYPTO_BUFFER) *, sk), (i), \
1038       CHECKED_CAST(void *, CRYPTO_BUFFER *, p)))
1039 
1040 #define sk_CRYPTO_BUFFER_free(sk) \
1041   sk_free(CHECKED_CAST(_STACK *, STACK_OF(CRYPTO_BUFFER) *, sk))
1042 
1043 #define sk_CRYPTO_BUFFER_pop_free(sk, free_func)             \
1044   sk_pop_free(                                               \
1045       CHECKED_CAST(_STACK *, STACK_OF(CRYPTO_BUFFER) *, sk), \
1046       CHECKED_CAST(void (*)(void *), void (*)(CRYPTO_BUFFER *), free_func))
1047 
1048 #define sk_CRYPTO_BUFFER_insert(sk, p, where)                      \
1049   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(CRYPTO_BUFFER) *, sk), \
1050             CHECKED_CAST(void *, CRYPTO_BUFFER *, p), (where))
1051 
1052 #define sk_CRYPTO_BUFFER_delete(sk, where) \
1053   ((CRYPTO_BUFFER *)sk_delete(             \
1054       CHECKED_CAST(_STACK *, STACK_OF(CRYPTO_BUFFER) *, sk), (where)))
1055 
1056 #define sk_CRYPTO_BUFFER_delete_ptr(sk, p)                   \
1057   ((CRYPTO_BUFFER *)sk_delete_ptr(                           \
1058       CHECKED_CAST(_STACK *, STACK_OF(CRYPTO_BUFFER) *, sk), \
1059       CHECKED_CAST(void *, CRYPTO_BUFFER *, p)))
1060 
1061 #define sk_CRYPTO_BUFFER_find(sk, out_index, p)                               \
1062   sk_find(CHECKED_CAST(_STACK *, STACK_OF(CRYPTO_BUFFER) *, sk), (out_index), \
1063           CHECKED_CAST(void *, CRYPTO_BUFFER *, p))
1064 
1065 #define sk_CRYPTO_BUFFER_shift(sk) \
1066   ((CRYPTO_BUFFER *)sk_shift(      \
1067       CHECKED_CAST(_STACK *, STACK_OF(CRYPTO_BUFFER) *, sk)))
1068 
1069 #define sk_CRYPTO_BUFFER_push(sk, p)                             \
1070   sk_push(CHECKED_CAST(_STACK *, STACK_OF(CRYPTO_BUFFER) *, sk), \
1071           CHECKED_CAST(void *, CRYPTO_BUFFER *, p))
1072 
1073 #define sk_CRYPTO_BUFFER_pop(sk) \
1074   ((CRYPTO_BUFFER *)sk_pop(      \
1075       CHECKED_CAST(_STACK *, STACK_OF(CRYPTO_BUFFER) *, sk)))
1076 
1077 #define sk_CRYPTO_BUFFER_dup(sk)      \
1078   ((STACK_OF(CRYPTO_BUFFER) *)sk_dup( \
1079       CHECKED_CAST(const _STACK *, const STACK_OF(CRYPTO_BUFFER) *, sk)))
1080 
1081 #define sk_CRYPTO_BUFFER_sort(sk) \
1082   sk_sort(CHECKED_CAST(_STACK *, STACK_OF(CRYPTO_BUFFER) *, sk))
1083 
1084 #define sk_CRYPTO_BUFFER_is_sorted(sk) \
1085   sk_is_sorted(                        \
1086       CHECKED_CAST(const _STACK *, const STACK_OF(CRYPTO_BUFFER) *, sk))
1087 
1088 #define sk_CRYPTO_BUFFER_set_cmp_func(sk, comp)                                \
1089   ((int (*)(const CRYPTO_BUFFER **a, const CRYPTO_BUFFER **b))sk_set_cmp_func( \
1090       CHECKED_CAST(_STACK *, STACK_OF(CRYPTO_BUFFER) *, sk),                   \
1091       CHECKED_CAST(stack_cmp_func,                                             \
1092                    int (*)(const CRYPTO_BUFFER **a, const CRYPTO_BUFFER **b),  \
1093                    comp)))
1094 
1095 #define sk_CRYPTO_BUFFER_deep_copy(sk, copy_func, free_func)               \
1096   ((STACK_OF(CRYPTO_BUFFER) *)sk_deep_copy(                                \
1097       CHECKED_CAST(const _STACK *, const STACK_OF(CRYPTO_BUFFER) *, sk),   \
1098       CHECKED_CAST(void *(*)(void *), CRYPTO_BUFFER *(*)(CRYPTO_BUFFER *), \
1099                    copy_func),                                             \
1100       CHECKED_CAST(void (*)(void *), void (*)(CRYPTO_BUFFER *), free_func)))
1101 
1102 /* CRYPTO_EX_DATA_FUNCS */
1103 #define sk_CRYPTO_EX_DATA_FUNCS_new(comp)                                      \
1104   ((STACK_OF(CRYPTO_EX_DATA_FUNCS) *)sk_new(CHECKED_CAST(                      \
1105       stack_cmp_func,                                                          \
1106       int (*)(const CRYPTO_EX_DATA_FUNCS **a, const CRYPTO_EX_DATA_FUNCS **b), \
1107       comp)))
1108 
1109 #define sk_CRYPTO_EX_DATA_FUNCS_new_null() \
1110   ((STACK_OF(CRYPTO_EX_DATA_FUNCS) *)sk_new_null())
1111 
1112 #define sk_CRYPTO_EX_DATA_FUNCS_num(sk)                                       \
1113   sk_num(CHECKED_CAST(const _STACK *, const STACK_OF(CRYPTO_EX_DATA_FUNCS) *, \
1114                       sk))
1115 
1116 #define sk_CRYPTO_EX_DATA_FUNCS_zero(sk) \
1117   sk_zero(CHECKED_CAST(_STACK *, STACK_OF(CRYPTO_EX_DATA_FUNCS) *, sk));
1118 
1119 #define sk_CRYPTO_EX_DATA_FUNCS_value(sk, i)                               \
1120   ((CRYPTO_EX_DATA_FUNCS *)sk_value(                                       \
1121       CHECKED_CAST(const _STACK *, const STACK_OF(CRYPTO_EX_DATA_FUNCS) *, \
1122                    sk),                                                    \
1123       (i)))
1124 
1125 #define sk_CRYPTO_EX_DATA_FUNCS_set(sk, i, p)                            \
1126   ((CRYPTO_EX_DATA_FUNCS *)sk_set(                                       \
1127       CHECKED_CAST(_STACK *, STACK_OF(CRYPTO_EX_DATA_FUNCS) *, sk), (i), \
1128       CHECKED_CAST(void *, CRYPTO_EX_DATA_FUNCS *, p)))
1129 
1130 #define sk_CRYPTO_EX_DATA_FUNCS_free(sk) \
1131   sk_free(CHECKED_CAST(_STACK *, STACK_OF(CRYPTO_EX_DATA_FUNCS) *, sk))
1132 
1133 #define sk_CRYPTO_EX_DATA_FUNCS_pop_free(sk, free_func)                        \
1134   sk_pop_free(CHECKED_CAST(_STACK *, STACK_OF(CRYPTO_EX_DATA_FUNCS) *, sk),    \
1135               CHECKED_CAST(void (*)(void *), void (*)(CRYPTO_EX_DATA_FUNCS *), \
1136                            free_func))
1137 
1138 #define sk_CRYPTO_EX_DATA_FUNCS_insert(sk, p, where)                      \
1139   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(CRYPTO_EX_DATA_FUNCS) *, sk), \
1140             CHECKED_CAST(void *, CRYPTO_EX_DATA_FUNCS *, p), (where))
1141 
1142 #define sk_CRYPTO_EX_DATA_FUNCS_delete(sk, where) \
1143   ((CRYPTO_EX_DATA_FUNCS *)sk_delete(             \
1144       CHECKED_CAST(_STACK *, STACK_OF(CRYPTO_EX_DATA_FUNCS) *, sk), (where)))
1145 
1146 #define sk_CRYPTO_EX_DATA_FUNCS_delete_ptr(sk, p)                   \
1147   ((CRYPTO_EX_DATA_FUNCS *)sk_delete_ptr(                           \
1148       CHECKED_CAST(_STACK *, STACK_OF(CRYPTO_EX_DATA_FUNCS) *, sk), \
1149       CHECKED_CAST(void *, CRYPTO_EX_DATA_FUNCS *, p)))
1150 
1151 #define sk_CRYPTO_EX_DATA_FUNCS_find(sk, out_index, p)                  \
1152   sk_find(CHECKED_CAST(_STACK *, STACK_OF(CRYPTO_EX_DATA_FUNCS) *, sk), \
1153           (out_index), CHECKED_CAST(void *, CRYPTO_EX_DATA_FUNCS *, p))
1154 
1155 #define sk_CRYPTO_EX_DATA_FUNCS_shift(sk) \
1156   ((CRYPTO_EX_DATA_FUNCS *)sk_shift(      \
1157       CHECKED_CAST(_STACK *, STACK_OF(CRYPTO_EX_DATA_FUNCS) *, sk)))
1158 
1159 #define sk_CRYPTO_EX_DATA_FUNCS_push(sk, p)                             \
1160   sk_push(CHECKED_CAST(_STACK *, STACK_OF(CRYPTO_EX_DATA_FUNCS) *, sk), \
1161           CHECKED_CAST(void *, CRYPTO_EX_DATA_FUNCS *, p))
1162 
1163 #define sk_CRYPTO_EX_DATA_FUNCS_pop(sk) \
1164   ((CRYPTO_EX_DATA_FUNCS *)sk_pop(      \
1165       CHECKED_CAST(_STACK *, STACK_OF(CRYPTO_EX_DATA_FUNCS) *, sk)))
1166 
1167 #define sk_CRYPTO_EX_DATA_FUNCS_dup(sk)                   \
1168   ((STACK_OF(CRYPTO_EX_DATA_FUNCS) *)sk_dup(CHECKED_CAST( \
1169       const _STACK *, const STACK_OF(CRYPTO_EX_DATA_FUNCS) *, sk)))
1170 
1171 #define sk_CRYPTO_EX_DATA_FUNCS_sort(sk) \
1172   sk_sort(CHECKED_CAST(_STACK *, STACK_OF(CRYPTO_EX_DATA_FUNCS) *, sk))
1173 
1174 #define sk_CRYPTO_EX_DATA_FUNCS_is_sorted(sk) \
1175   sk_is_sorted(CHECKED_CAST(const _STACK *,   \
1176                             const STACK_OF(CRYPTO_EX_DATA_FUNCS) *, sk))
1177 
1178 #define sk_CRYPTO_EX_DATA_FUNCS_set_cmp_func(sk, comp)                       \
1179   ((int (*)(const CRYPTO_EX_DATA_FUNCS **a, const CRYPTO_EX_DATA_FUNCS **b)) \
1180        sk_set_cmp_func(                                                      \
1181            CHECKED_CAST(_STACK *, STACK_OF(CRYPTO_EX_DATA_FUNCS) *, sk),     \
1182            CHECKED_CAST(stack_cmp_func,                                      \
1183                         int (*)(const CRYPTO_EX_DATA_FUNCS **a,              \
1184                                 const CRYPTO_EX_DATA_FUNCS **b),             \
1185                         comp)))
1186 
1187 #define sk_CRYPTO_EX_DATA_FUNCS_deep_copy(sk, copy_func, free_func)        \
1188   ((STACK_OF(CRYPTO_EX_DATA_FUNCS) *)sk_deep_copy(                         \
1189       CHECKED_CAST(const _STACK *, const STACK_OF(CRYPTO_EX_DATA_FUNCS) *, \
1190                    sk),                                                    \
1191       CHECKED_CAST(void *(*)(void *),                                      \
1192                    CRYPTO_EX_DATA_FUNCS *(*)(CRYPTO_EX_DATA_FUNCS *),      \
1193                    copy_func),                                             \
1194       CHECKED_CAST(void (*)(void *), void (*)(CRYPTO_EX_DATA_FUNCS *),     \
1195                    free_func)))
1196 
1197 /* DIST_POINT */
1198 #define sk_DIST_POINT_new(comp)                                            \
1199   ((STACK_OF(DIST_POINT) *)sk_new(CHECKED_CAST(                            \
1200       stack_cmp_func, int (*)(const DIST_POINT **a, const DIST_POINT **b), \
1201       comp)))
1202 
1203 #define sk_DIST_POINT_new_null() ((STACK_OF(DIST_POINT) *)sk_new_null())
1204 
1205 #define sk_DIST_POINT_num(sk) \
1206   sk_num(CHECKED_CAST(const _STACK *, const STACK_OF(DIST_POINT) *, sk))
1207 
1208 #define sk_DIST_POINT_zero(sk) \
1209   sk_zero(CHECKED_CAST(_STACK *, STACK_OF(DIST_POINT) *, sk));
1210 
1211 #define sk_DIST_POINT_value(sk, i) \
1212   ((DIST_POINT *)sk_value(         \
1213       CHECKED_CAST(const _STACK *, const STACK_OF(DIST_POINT) *, sk), (i)))
1214 
1215 #define sk_DIST_POINT_set(sk, i, p)                                         \
1216   ((DIST_POINT *)sk_set(CHECKED_CAST(_STACK *, STACK_OF(DIST_POINT) *, sk), \
1217                         (i), CHECKED_CAST(void *, DIST_POINT *, p)))
1218 
1219 #define sk_DIST_POINT_free(sk) \
1220   sk_free(CHECKED_CAST(_STACK *, STACK_OF(DIST_POINT) *, sk))
1221 
1222 #define sk_DIST_POINT_pop_free(sk, free_func)             \
1223   sk_pop_free(                                            \
1224       CHECKED_CAST(_STACK *, STACK_OF(DIST_POINT) *, sk), \
1225       CHECKED_CAST(void (*)(void *), void (*)(DIST_POINT *), free_func))
1226 
1227 #define sk_DIST_POINT_insert(sk, p, where)                      \
1228   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(DIST_POINT) *, sk), \
1229             CHECKED_CAST(void *, DIST_POINT *, p), (where))
1230 
1231 #define sk_DIST_POINT_delete(sk, where)                                        \
1232   ((DIST_POINT *)sk_delete(CHECKED_CAST(_STACK *, STACK_OF(DIST_POINT) *, sk), \
1233                            (where)))
1234 
1235 #define sk_DIST_POINT_delete_ptr(sk, p)                   \
1236   ((DIST_POINT *)sk_delete_ptr(                           \
1237       CHECKED_CAST(_STACK *, STACK_OF(DIST_POINT) *, sk), \
1238       CHECKED_CAST(void *, DIST_POINT *, p)))
1239 
1240 #define sk_DIST_POINT_find(sk, out_index, p)                               \
1241   sk_find(CHECKED_CAST(_STACK *, STACK_OF(DIST_POINT) *, sk), (out_index), \
1242           CHECKED_CAST(void *, DIST_POINT *, p))
1243 
1244 #define sk_DIST_POINT_shift(sk) \
1245   ((DIST_POINT *)sk_shift(CHECKED_CAST(_STACK *, STACK_OF(DIST_POINT) *, sk)))
1246 
1247 #define sk_DIST_POINT_push(sk, p)                             \
1248   sk_push(CHECKED_CAST(_STACK *, STACK_OF(DIST_POINT) *, sk), \
1249           CHECKED_CAST(void *, DIST_POINT *, p))
1250 
1251 #define sk_DIST_POINT_pop(sk) \
1252   ((DIST_POINT *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(DIST_POINT) *, sk)))
1253 
1254 #define sk_DIST_POINT_dup(sk)      \
1255   ((STACK_OF(DIST_POINT) *)sk_dup( \
1256       CHECKED_CAST(const _STACK *, const STACK_OF(DIST_POINT) *, sk)))
1257 
1258 #define sk_DIST_POINT_sort(sk) \
1259   sk_sort(CHECKED_CAST(_STACK *, STACK_OF(DIST_POINT) *, sk))
1260 
1261 #define sk_DIST_POINT_is_sorted(sk) \
1262   sk_is_sorted(CHECKED_CAST(const _STACK *, const STACK_OF(DIST_POINT) *, sk))
1263 
1264 #define sk_DIST_POINT_set_cmp_func(sk, comp)                             \
1265   ((int (*)(const DIST_POINT **a, const DIST_POINT **b))sk_set_cmp_func( \
1266       CHECKED_CAST(_STACK *, STACK_OF(DIST_POINT) *, sk),                \
1267       CHECKED_CAST(stack_cmp_func,                                       \
1268                    int (*)(const DIST_POINT **a, const DIST_POINT **b),  \
1269                    comp)))
1270 
1271 #define sk_DIST_POINT_deep_copy(sk, copy_func, free_func)             \
1272   ((STACK_OF(DIST_POINT) *)sk_deep_copy(                              \
1273       CHECKED_CAST(const _STACK *, const STACK_OF(DIST_POINT) *, sk), \
1274       CHECKED_CAST(void *(*)(void *), DIST_POINT *(*)(DIST_POINT *),  \
1275                    copy_func),                                        \
1276       CHECKED_CAST(void (*)(void *), void (*)(DIST_POINT *), free_func)))
1277 
1278 /* GENERAL_NAME */
1279 #define sk_GENERAL_NAME_new(comp)                                              \
1280   ((STACK_OF(GENERAL_NAME) *)sk_new(CHECKED_CAST(                              \
1281       stack_cmp_func, int (*)(const GENERAL_NAME **a, const GENERAL_NAME **b), \
1282       comp)))
1283 
1284 #define sk_GENERAL_NAME_new_null() ((STACK_OF(GENERAL_NAME) *)sk_new_null())
1285 
1286 #define sk_GENERAL_NAME_num(sk) \
1287   sk_num(CHECKED_CAST(const _STACK *, const STACK_OF(GENERAL_NAME) *, sk))
1288 
1289 #define sk_GENERAL_NAME_zero(sk) \
1290   sk_zero(CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAME) *, sk));
1291 
1292 #define sk_GENERAL_NAME_value(sk, i) \
1293   ((GENERAL_NAME *)sk_value(         \
1294       CHECKED_CAST(const _STACK *, const STACK_OF(GENERAL_NAME) *, sk), (i)))
1295 
1296 #define sk_GENERAL_NAME_set(sk, i, p)                            \
1297   ((GENERAL_NAME *)sk_set(                                       \
1298       CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAME) *, sk), (i), \
1299       CHECKED_CAST(void *, GENERAL_NAME *, p)))
1300 
1301 #define sk_GENERAL_NAME_free(sk) \
1302   sk_free(CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAME) *, sk))
1303 
1304 #define sk_GENERAL_NAME_pop_free(sk, free_func)             \
1305   sk_pop_free(                                              \
1306       CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAME) *, sk), \
1307       CHECKED_CAST(void (*)(void *), void (*)(GENERAL_NAME *), free_func))
1308 
1309 #define sk_GENERAL_NAME_insert(sk, p, where)                      \
1310   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAME) *, sk), \
1311             CHECKED_CAST(void *, GENERAL_NAME *, p), (where))
1312 
1313 #define sk_GENERAL_NAME_delete(sk, where) \
1314   ((GENERAL_NAME *)sk_delete(             \
1315       CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAME) *, sk), (where)))
1316 
1317 #define sk_GENERAL_NAME_delete_ptr(sk, p)                   \
1318   ((GENERAL_NAME *)sk_delete_ptr(                           \
1319       CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAME) *, sk), \
1320       CHECKED_CAST(void *, GENERAL_NAME *, p)))
1321 
1322 #define sk_GENERAL_NAME_find(sk, out_index, p)                               \
1323   sk_find(CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAME) *, sk), (out_index), \
1324           CHECKED_CAST(void *, GENERAL_NAME *, p))
1325 
1326 #define sk_GENERAL_NAME_shift(sk) \
1327   ((GENERAL_NAME *)sk_shift(      \
1328       CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAME) *, sk)))
1329 
1330 #define sk_GENERAL_NAME_push(sk, p)                             \
1331   sk_push(CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAME) *, sk), \
1332           CHECKED_CAST(void *, GENERAL_NAME *, p))
1333 
1334 #define sk_GENERAL_NAME_pop(sk) \
1335   ((GENERAL_NAME *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAME) *, sk)))
1336 
1337 #define sk_GENERAL_NAME_dup(sk)      \
1338   ((STACK_OF(GENERAL_NAME) *)sk_dup( \
1339       CHECKED_CAST(const _STACK *, const STACK_OF(GENERAL_NAME) *, sk)))
1340 
1341 #define sk_GENERAL_NAME_sort(sk) \
1342   sk_sort(CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAME) *, sk))
1343 
1344 #define sk_GENERAL_NAME_is_sorted(sk) \
1345   sk_is_sorted(CHECKED_CAST(const _STACK *, const STACK_OF(GENERAL_NAME) *, sk))
1346 
1347 #define sk_GENERAL_NAME_set_cmp_func(sk, comp)                               \
1348   ((int (*)(const GENERAL_NAME **a, const GENERAL_NAME **b))sk_set_cmp_func( \
1349       CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAME) *, sk),                  \
1350       CHECKED_CAST(stack_cmp_func,                                           \
1351                    int (*)(const GENERAL_NAME **a, const GENERAL_NAME **b),  \
1352                    comp)))
1353 
1354 #define sk_GENERAL_NAME_deep_copy(sk, copy_func, free_func)              \
1355   ((STACK_OF(GENERAL_NAME) *)sk_deep_copy(                               \
1356       CHECKED_CAST(const _STACK *, const STACK_OF(GENERAL_NAME) *, sk),  \
1357       CHECKED_CAST(void *(*)(void *), GENERAL_NAME *(*)(GENERAL_NAME *), \
1358                    copy_func),                                           \
1359       CHECKED_CAST(void (*)(void *), void (*)(GENERAL_NAME *), free_func)))
1360 
1361 /* GENERAL_NAMES */
1362 #define sk_GENERAL_NAMES_new(comp)                 \
1363   ((STACK_OF(GENERAL_NAMES) *)sk_new(CHECKED_CAST( \
1364       stack_cmp_func,                              \
1365       int (*)(const GENERAL_NAMES **a, const GENERAL_NAMES **b), comp)))
1366 
1367 #define sk_GENERAL_NAMES_new_null() ((STACK_OF(GENERAL_NAMES) *)sk_new_null())
1368 
1369 #define sk_GENERAL_NAMES_num(sk) \
1370   sk_num(CHECKED_CAST(const _STACK *, const STACK_OF(GENERAL_NAMES) *, sk))
1371 
1372 #define sk_GENERAL_NAMES_zero(sk) \
1373   sk_zero(CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAMES) *, sk));
1374 
1375 #define sk_GENERAL_NAMES_value(sk, i) \
1376   ((GENERAL_NAMES *)sk_value(         \
1377       CHECKED_CAST(const _STACK *, const STACK_OF(GENERAL_NAMES) *, sk), (i)))
1378 
1379 #define sk_GENERAL_NAMES_set(sk, i, p)                            \
1380   ((GENERAL_NAMES *)sk_set(                                       \
1381       CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAMES) *, sk), (i), \
1382       CHECKED_CAST(void *, GENERAL_NAMES *, p)))
1383 
1384 #define sk_GENERAL_NAMES_free(sk) \
1385   sk_free(CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAMES) *, sk))
1386 
1387 #define sk_GENERAL_NAMES_pop_free(sk, free_func)             \
1388   sk_pop_free(                                               \
1389       CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAMES) *, sk), \
1390       CHECKED_CAST(void (*)(void *), void (*)(GENERAL_NAMES *), free_func))
1391 
1392 #define sk_GENERAL_NAMES_insert(sk, p, where)                      \
1393   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAMES) *, sk), \
1394             CHECKED_CAST(void *, GENERAL_NAMES *, p), (where))
1395 
1396 #define sk_GENERAL_NAMES_delete(sk, where) \
1397   ((GENERAL_NAMES *)sk_delete(             \
1398       CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAMES) *, sk), (where)))
1399 
1400 #define sk_GENERAL_NAMES_delete_ptr(sk, p)                   \
1401   ((GENERAL_NAMES *)sk_delete_ptr(                           \
1402       CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAMES) *, sk), \
1403       CHECKED_CAST(void *, GENERAL_NAMES *, p)))
1404 
1405 #define sk_GENERAL_NAMES_find(sk, out_index, p)                               \
1406   sk_find(CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAMES) *, sk), (out_index), \
1407           CHECKED_CAST(void *, GENERAL_NAMES *, p))
1408 
1409 #define sk_GENERAL_NAMES_shift(sk) \
1410   ((GENERAL_NAMES *)sk_shift(      \
1411       CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAMES) *, sk)))
1412 
1413 #define sk_GENERAL_NAMES_push(sk, p)                             \
1414   sk_push(CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAMES) *, sk), \
1415           CHECKED_CAST(void *, GENERAL_NAMES *, p))
1416 
1417 #define sk_GENERAL_NAMES_pop(sk) \
1418   ((GENERAL_NAMES *)sk_pop(      \
1419       CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAMES) *, sk)))
1420 
1421 #define sk_GENERAL_NAMES_dup(sk)      \
1422   ((STACK_OF(GENERAL_NAMES) *)sk_dup( \
1423       CHECKED_CAST(const _STACK *, const STACK_OF(GENERAL_NAMES) *, sk)))
1424 
1425 #define sk_GENERAL_NAMES_sort(sk) \
1426   sk_sort(CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAMES) *, sk))
1427 
1428 #define sk_GENERAL_NAMES_is_sorted(sk) \
1429   sk_is_sorted(                        \
1430       CHECKED_CAST(const _STACK *, const STACK_OF(GENERAL_NAMES) *, sk))
1431 
1432 #define sk_GENERAL_NAMES_set_cmp_func(sk, comp)                                \
1433   ((int (*)(const GENERAL_NAMES **a, const GENERAL_NAMES **b))sk_set_cmp_func( \
1434       CHECKED_CAST(_STACK *, STACK_OF(GENERAL_NAMES) *, sk),                   \
1435       CHECKED_CAST(stack_cmp_func,                                             \
1436                    int (*)(const GENERAL_NAMES **a, const GENERAL_NAMES **b),  \
1437                    comp)))
1438 
1439 #define sk_GENERAL_NAMES_deep_copy(sk, copy_func, free_func)               \
1440   ((STACK_OF(GENERAL_NAMES) *)sk_deep_copy(                                \
1441       CHECKED_CAST(const _STACK *, const STACK_OF(GENERAL_NAMES) *, sk),   \
1442       CHECKED_CAST(void *(*)(void *), GENERAL_NAMES *(*)(GENERAL_NAMES *), \
1443                    copy_func),                                             \
1444       CHECKED_CAST(void (*)(void *), void (*)(GENERAL_NAMES *), free_func)))
1445 
1446 /* GENERAL_SUBTREE */
1447 #define sk_GENERAL_SUBTREE_new(comp)                 \
1448   ((STACK_OF(GENERAL_SUBTREE) *)sk_new(CHECKED_CAST( \
1449       stack_cmp_func,                                \
1450       int (*)(const GENERAL_SUBTREE **a, const GENERAL_SUBTREE **b), comp)))
1451 
1452 #define sk_GENERAL_SUBTREE_new_null() \
1453   ((STACK_OF(GENERAL_SUBTREE) *)sk_new_null())
1454 
1455 #define sk_GENERAL_SUBTREE_num(sk) \
1456   sk_num(CHECKED_CAST(const _STACK *, const STACK_OF(GENERAL_SUBTREE) *, sk))
1457 
1458 #define sk_GENERAL_SUBTREE_zero(sk) \
1459   sk_zero(CHECKED_CAST(_STACK *, STACK_OF(GENERAL_SUBTREE) *, sk));
1460 
1461 #define sk_GENERAL_SUBTREE_value(sk, i)                                    \
1462   ((GENERAL_SUBTREE *)sk_value(                                            \
1463       CHECKED_CAST(const _STACK *, const STACK_OF(GENERAL_SUBTREE) *, sk), \
1464       (i)))
1465 
1466 #define sk_GENERAL_SUBTREE_set(sk, i, p)                            \
1467   ((GENERAL_SUBTREE *)sk_set(                                       \
1468       CHECKED_CAST(_STACK *, STACK_OF(GENERAL_SUBTREE) *, sk), (i), \
1469       CHECKED_CAST(void *, GENERAL_SUBTREE *, p)))
1470 
1471 #define sk_GENERAL_SUBTREE_free(sk) \
1472   sk_free(CHECKED_CAST(_STACK *, STACK_OF(GENERAL_SUBTREE) *, sk))
1473 
1474 #define sk_GENERAL_SUBTREE_pop_free(sk, free_func)             \
1475   sk_pop_free(                                                 \
1476       CHECKED_CAST(_STACK *, STACK_OF(GENERAL_SUBTREE) *, sk), \
1477       CHECKED_CAST(void (*)(void *), void (*)(GENERAL_SUBTREE *), free_func))
1478 
1479 #define sk_GENERAL_SUBTREE_insert(sk, p, where)                      \
1480   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(GENERAL_SUBTREE) *, sk), \
1481             CHECKED_CAST(void *, GENERAL_SUBTREE *, p), (where))
1482 
1483 #define sk_GENERAL_SUBTREE_delete(sk, where) \
1484   ((GENERAL_SUBTREE *)sk_delete(             \
1485       CHECKED_CAST(_STACK *, STACK_OF(GENERAL_SUBTREE) *, sk), (where)))
1486 
1487 #define sk_GENERAL_SUBTREE_delete_ptr(sk, p)                   \
1488   ((GENERAL_SUBTREE *)sk_delete_ptr(                           \
1489       CHECKED_CAST(_STACK *, STACK_OF(GENERAL_SUBTREE) *, sk), \
1490       CHECKED_CAST(void *, GENERAL_SUBTREE *, p)))
1491 
1492 #define sk_GENERAL_SUBTREE_find(sk, out_index, p)                  \
1493   sk_find(CHECKED_CAST(_STACK *, STACK_OF(GENERAL_SUBTREE) *, sk), \
1494           (out_index), CHECKED_CAST(void *, GENERAL_SUBTREE *, p))
1495 
1496 #define sk_GENERAL_SUBTREE_shift(sk) \
1497   ((GENERAL_SUBTREE *)sk_shift(      \
1498       CHECKED_CAST(_STACK *, STACK_OF(GENERAL_SUBTREE) *, sk)))
1499 
1500 #define sk_GENERAL_SUBTREE_push(sk, p)                             \
1501   sk_push(CHECKED_CAST(_STACK *, STACK_OF(GENERAL_SUBTREE) *, sk), \
1502           CHECKED_CAST(void *, GENERAL_SUBTREE *, p))
1503 
1504 #define sk_GENERAL_SUBTREE_pop(sk) \
1505   ((GENERAL_SUBTREE *)sk_pop(      \
1506       CHECKED_CAST(_STACK *, STACK_OF(GENERAL_SUBTREE) *, sk)))
1507 
1508 #define sk_GENERAL_SUBTREE_dup(sk)      \
1509   ((STACK_OF(GENERAL_SUBTREE) *)sk_dup( \
1510       CHECKED_CAST(const _STACK *, const STACK_OF(GENERAL_SUBTREE) *, sk)))
1511 
1512 #define sk_GENERAL_SUBTREE_sort(sk) \
1513   sk_sort(CHECKED_CAST(_STACK *, STACK_OF(GENERAL_SUBTREE) *, sk))
1514 
1515 #define sk_GENERAL_SUBTREE_is_sorted(sk) \
1516   sk_is_sorted(                          \
1517       CHECKED_CAST(const _STACK *, const STACK_OF(GENERAL_SUBTREE) *, sk))
1518 
1519 #define sk_GENERAL_SUBTREE_set_cmp_func(sk, comp)                           \
1520   ((int (*)(const GENERAL_SUBTREE **a, const GENERAL_SUBTREE **b))          \
1521        sk_set_cmp_func(                                                     \
1522            CHECKED_CAST(_STACK *, STACK_OF(GENERAL_SUBTREE) *, sk),         \
1523            CHECKED_CAST(stack_cmp_func, int (*)(const GENERAL_SUBTREE **a,  \
1524                                                 const GENERAL_SUBTREE **b), \
1525                         comp)))
1526 
1527 #define sk_GENERAL_SUBTREE_deep_copy(sk, copy_func, free_func)                 \
1528   ((STACK_OF(GENERAL_SUBTREE) *)sk_deep_copy(                                  \
1529       CHECKED_CAST(const _STACK *, const STACK_OF(GENERAL_SUBTREE) *, sk),     \
1530       CHECKED_CAST(void *(*)(void *), GENERAL_SUBTREE *(*)(GENERAL_SUBTREE *), \
1531                    copy_func),                                                 \
1532       CHECKED_CAST(void (*)(void *), void (*)(GENERAL_SUBTREE *), free_func)))
1533 
1534 /* POLICYINFO */
1535 #define sk_POLICYINFO_new(comp)                                            \
1536   ((STACK_OF(POLICYINFO) *)sk_new(CHECKED_CAST(                            \
1537       stack_cmp_func, int (*)(const POLICYINFO **a, const POLICYINFO **b), \
1538       comp)))
1539 
1540 #define sk_POLICYINFO_new_null() ((STACK_OF(POLICYINFO) *)sk_new_null())
1541 
1542 #define sk_POLICYINFO_num(sk) \
1543   sk_num(CHECKED_CAST(const _STACK *, const STACK_OF(POLICYINFO) *, sk))
1544 
1545 #define sk_POLICYINFO_zero(sk) \
1546   sk_zero(CHECKED_CAST(_STACK *, STACK_OF(POLICYINFO) *, sk));
1547 
1548 #define sk_POLICYINFO_value(sk, i) \
1549   ((POLICYINFO *)sk_value(         \
1550       CHECKED_CAST(const _STACK *, const STACK_OF(POLICYINFO) *, sk), (i)))
1551 
1552 #define sk_POLICYINFO_set(sk, i, p)                                         \
1553   ((POLICYINFO *)sk_set(CHECKED_CAST(_STACK *, STACK_OF(POLICYINFO) *, sk), \
1554                         (i), CHECKED_CAST(void *, POLICYINFO *, p)))
1555 
1556 #define sk_POLICYINFO_free(sk) \
1557   sk_free(CHECKED_CAST(_STACK *, STACK_OF(POLICYINFO) *, sk))
1558 
1559 #define sk_POLICYINFO_pop_free(sk, free_func)             \
1560   sk_pop_free(                                            \
1561       CHECKED_CAST(_STACK *, STACK_OF(POLICYINFO) *, sk), \
1562       CHECKED_CAST(void (*)(void *), void (*)(POLICYINFO *), free_func))
1563 
1564 #define sk_POLICYINFO_insert(sk, p, where)                      \
1565   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(POLICYINFO) *, sk), \
1566             CHECKED_CAST(void *, POLICYINFO *, p), (where))
1567 
1568 #define sk_POLICYINFO_delete(sk, where)                                        \
1569   ((POLICYINFO *)sk_delete(CHECKED_CAST(_STACK *, STACK_OF(POLICYINFO) *, sk), \
1570                            (where)))
1571 
1572 #define sk_POLICYINFO_delete_ptr(sk, p)                   \
1573   ((POLICYINFO *)sk_delete_ptr(                           \
1574       CHECKED_CAST(_STACK *, STACK_OF(POLICYINFO) *, sk), \
1575       CHECKED_CAST(void *, POLICYINFO *, p)))
1576 
1577 #define sk_POLICYINFO_find(sk, out_index, p)                               \
1578   sk_find(CHECKED_CAST(_STACK *, STACK_OF(POLICYINFO) *, sk), (out_index), \
1579           CHECKED_CAST(void *, POLICYINFO *, p))
1580 
1581 #define sk_POLICYINFO_shift(sk) \
1582   ((POLICYINFO *)sk_shift(CHECKED_CAST(_STACK *, STACK_OF(POLICYINFO) *, sk)))
1583 
1584 #define sk_POLICYINFO_push(sk, p)                             \
1585   sk_push(CHECKED_CAST(_STACK *, STACK_OF(POLICYINFO) *, sk), \
1586           CHECKED_CAST(void *, POLICYINFO *, p))
1587 
1588 #define sk_POLICYINFO_pop(sk) \
1589   ((POLICYINFO *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(POLICYINFO) *, sk)))
1590 
1591 #define sk_POLICYINFO_dup(sk)      \
1592   ((STACK_OF(POLICYINFO) *)sk_dup( \
1593       CHECKED_CAST(const _STACK *, const STACK_OF(POLICYINFO) *, sk)))
1594 
1595 #define sk_POLICYINFO_sort(sk) \
1596   sk_sort(CHECKED_CAST(_STACK *, STACK_OF(POLICYINFO) *, sk))
1597 
1598 #define sk_POLICYINFO_is_sorted(sk) \
1599   sk_is_sorted(CHECKED_CAST(const _STACK *, const STACK_OF(POLICYINFO) *, sk))
1600 
1601 #define sk_POLICYINFO_set_cmp_func(sk, comp)                             \
1602   ((int (*)(const POLICYINFO **a, const POLICYINFO **b))sk_set_cmp_func( \
1603       CHECKED_CAST(_STACK *, STACK_OF(POLICYINFO) *, sk),                \
1604       CHECKED_CAST(stack_cmp_func,                                       \
1605                    int (*)(const POLICYINFO **a, const POLICYINFO **b),  \
1606                    comp)))
1607 
1608 #define sk_POLICYINFO_deep_copy(sk, copy_func, free_func)             \
1609   ((STACK_OF(POLICYINFO) *)sk_deep_copy(                              \
1610       CHECKED_CAST(const _STACK *, const STACK_OF(POLICYINFO) *, sk), \
1611       CHECKED_CAST(void *(*)(void *), POLICYINFO *(*)(POLICYINFO *),  \
1612                    copy_func),                                        \
1613       CHECKED_CAST(void (*)(void *), void (*)(POLICYINFO *), free_func)))
1614 
1615 /* POLICYQUALINFO */
1616 #define sk_POLICYQUALINFO_new(comp)                 \
1617   ((STACK_OF(POLICYQUALINFO) *)sk_new(CHECKED_CAST( \
1618       stack_cmp_func,                               \
1619       int (*)(const POLICYQUALINFO **a, const POLICYQUALINFO **b), comp)))
1620 
1621 #define sk_POLICYQUALINFO_new_null() ((STACK_OF(POLICYQUALINFO) *)sk_new_null())
1622 
1623 #define sk_POLICYQUALINFO_num(sk) \
1624   sk_num(CHECKED_CAST(const _STACK *, const STACK_OF(POLICYQUALINFO) *, sk))
1625 
1626 #define sk_POLICYQUALINFO_zero(sk) \
1627   sk_zero(CHECKED_CAST(_STACK *, STACK_OF(POLICYQUALINFO) *, sk));
1628 
1629 #define sk_POLICYQUALINFO_value(sk, i)                                    \
1630   ((POLICYQUALINFO *)sk_value(                                            \
1631       CHECKED_CAST(const _STACK *, const STACK_OF(POLICYQUALINFO) *, sk), \
1632       (i)))
1633 
1634 #define sk_POLICYQUALINFO_set(sk, i, p)                            \
1635   ((POLICYQUALINFO *)sk_set(                                       \
1636       CHECKED_CAST(_STACK *, STACK_OF(POLICYQUALINFO) *, sk), (i), \
1637       CHECKED_CAST(void *, POLICYQUALINFO *, p)))
1638 
1639 #define sk_POLICYQUALINFO_free(sk) \
1640   sk_free(CHECKED_CAST(_STACK *, STACK_OF(POLICYQUALINFO) *, sk))
1641 
1642 #define sk_POLICYQUALINFO_pop_free(sk, free_func)             \
1643   sk_pop_free(                                                \
1644       CHECKED_CAST(_STACK *, STACK_OF(POLICYQUALINFO) *, sk), \
1645       CHECKED_CAST(void (*)(void *), void (*)(POLICYQUALINFO *), free_func))
1646 
1647 #define sk_POLICYQUALINFO_insert(sk, p, where)                      \
1648   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(POLICYQUALINFO) *, sk), \
1649             CHECKED_CAST(void *, POLICYQUALINFO *, p), (where))
1650 
1651 #define sk_POLICYQUALINFO_delete(sk, where) \
1652   ((POLICYQUALINFO *)sk_delete(             \
1653       CHECKED_CAST(_STACK *, STACK_OF(POLICYQUALINFO) *, sk), (where)))
1654 
1655 #define sk_POLICYQUALINFO_delete_ptr(sk, p)                   \
1656   ((POLICYQUALINFO *)sk_delete_ptr(                           \
1657       CHECKED_CAST(_STACK *, STACK_OF(POLICYQUALINFO) *, sk), \
1658       CHECKED_CAST(void *, POLICYQUALINFO *, p)))
1659 
1660 #define sk_POLICYQUALINFO_find(sk, out_index, p)                               \
1661   sk_find(CHECKED_CAST(_STACK *, STACK_OF(POLICYQUALINFO) *, sk), (out_index), \
1662           CHECKED_CAST(void *, POLICYQUALINFO *, p))
1663 
1664 #define sk_POLICYQUALINFO_shift(sk) \
1665   ((POLICYQUALINFO *)sk_shift(      \
1666       CHECKED_CAST(_STACK *, STACK_OF(POLICYQUALINFO) *, sk)))
1667 
1668 #define sk_POLICYQUALINFO_push(sk, p)                             \
1669   sk_push(CHECKED_CAST(_STACK *, STACK_OF(POLICYQUALINFO) *, sk), \
1670           CHECKED_CAST(void *, POLICYQUALINFO *, p))
1671 
1672 #define sk_POLICYQUALINFO_pop(sk) \
1673   ((POLICYQUALINFO *)sk_pop(      \
1674       CHECKED_CAST(_STACK *, STACK_OF(POLICYQUALINFO) *, sk)))
1675 
1676 #define sk_POLICYQUALINFO_dup(sk)      \
1677   ((STACK_OF(POLICYQUALINFO) *)sk_dup( \
1678       CHECKED_CAST(const _STACK *, const STACK_OF(POLICYQUALINFO) *, sk)))
1679 
1680 #define sk_POLICYQUALINFO_sort(sk) \
1681   sk_sort(CHECKED_CAST(_STACK *, STACK_OF(POLICYQUALINFO) *, sk))
1682 
1683 #define sk_POLICYQUALINFO_is_sorted(sk) \
1684   sk_is_sorted(                         \
1685       CHECKED_CAST(const _STACK *, const STACK_OF(POLICYQUALINFO) *, sk))
1686 
1687 #define sk_POLICYQUALINFO_set_cmp_func(sk, comp)                           \
1688   ((int (*)(const POLICYQUALINFO **a, const POLICYQUALINFO **b))           \
1689        sk_set_cmp_func(                                                    \
1690            CHECKED_CAST(_STACK *, STACK_OF(POLICYQUALINFO) *, sk),         \
1691            CHECKED_CAST(stack_cmp_func, int (*)(const POLICYQUALINFO **a,  \
1692                                                 const POLICYQUALINFO **b), \
1693                         comp)))
1694 
1695 #define sk_POLICYQUALINFO_deep_copy(sk, copy_func, free_func)                \
1696   ((STACK_OF(POLICYQUALINFO) *)sk_deep_copy(                                 \
1697       CHECKED_CAST(const _STACK *, const STACK_OF(POLICYQUALINFO) *, sk),    \
1698       CHECKED_CAST(void *(*)(void *), POLICYQUALINFO *(*)(POLICYQUALINFO *), \
1699                    copy_func),                                               \
1700       CHECKED_CAST(void (*)(void *), void (*)(POLICYQUALINFO *), free_func)))
1701 
1702 /* POLICY_MAPPING */
1703 #define sk_POLICY_MAPPING_new(comp)                 \
1704   ((STACK_OF(POLICY_MAPPING) *)sk_new(CHECKED_CAST( \
1705       stack_cmp_func,                               \
1706       int (*)(const POLICY_MAPPING **a, const POLICY_MAPPING **b), comp)))
1707 
1708 #define sk_POLICY_MAPPING_new_null() ((STACK_OF(POLICY_MAPPING) *)sk_new_null())
1709 
1710 #define sk_POLICY_MAPPING_num(sk) \
1711   sk_num(CHECKED_CAST(const _STACK *, const STACK_OF(POLICY_MAPPING) *, sk))
1712 
1713 #define sk_POLICY_MAPPING_zero(sk) \
1714   sk_zero(CHECKED_CAST(_STACK *, STACK_OF(POLICY_MAPPING) *, sk));
1715 
1716 #define sk_POLICY_MAPPING_value(sk, i)                                    \
1717   ((POLICY_MAPPING *)sk_value(                                            \
1718       CHECKED_CAST(const _STACK *, const STACK_OF(POLICY_MAPPING) *, sk), \
1719       (i)))
1720 
1721 #define sk_POLICY_MAPPING_set(sk, i, p)                            \
1722   ((POLICY_MAPPING *)sk_set(                                       \
1723       CHECKED_CAST(_STACK *, STACK_OF(POLICY_MAPPING) *, sk), (i), \
1724       CHECKED_CAST(void *, POLICY_MAPPING *, p)))
1725 
1726 #define sk_POLICY_MAPPING_free(sk) \
1727   sk_free(CHECKED_CAST(_STACK *, STACK_OF(POLICY_MAPPING) *, sk))
1728 
1729 #define sk_POLICY_MAPPING_pop_free(sk, free_func)             \
1730   sk_pop_free(                                                \
1731       CHECKED_CAST(_STACK *, STACK_OF(POLICY_MAPPING) *, sk), \
1732       CHECKED_CAST(void (*)(void *), void (*)(POLICY_MAPPING *), free_func))
1733 
1734 #define sk_POLICY_MAPPING_insert(sk, p, where)                      \
1735   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(POLICY_MAPPING) *, sk), \
1736             CHECKED_CAST(void *, POLICY_MAPPING *, p), (where))
1737 
1738 #define sk_POLICY_MAPPING_delete(sk, where) \
1739   ((POLICY_MAPPING *)sk_delete(             \
1740       CHECKED_CAST(_STACK *, STACK_OF(POLICY_MAPPING) *, sk), (where)))
1741 
1742 #define sk_POLICY_MAPPING_delete_ptr(sk, p)                   \
1743   ((POLICY_MAPPING *)sk_delete_ptr(                           \
1744       CHECKED_CAST(_STACK *, STACK_OF(POLICY_MAPPING) *, sk), \
1745       CHECKED_CAST(void *, POLICY_MAPPING *, p)))
1746 
1747 #define sk_POLICY_MAPPING_find(sk, out_index, p)                               \
1748   sk_find(CHECKED_CAST(_STACK *, STACK_OF(POLICY_MAPPING) *, sk), (out_index), \
1749           CHECKED_CAST(void *, POLICY_MAPPING *, p))
1750 
1751 #define sk_POLICY_MAPPING_shift(sk) \
1752   ((POLICY_MAPPING *)sk_shift(      \
1753       CHECKED_CAST(_STACK *, STACK_OF(POLICY_MAPPING) *, sk)))
1754 
1755 #define sk_POLICY_MAPPING_push(sk, p)                             \
1756   sk_push(CHECKED_CAST(_STACK *, STACK_OF(POLICY_MAPPING) *, sk), \
1757           CHECKED_CAST(void *, POLICY_MAPPING *, p))
1758 
1759 #define sk_POLICY_MAPPING_pop(sk) \
1760   ((POLICY_MAPPING *)sk_pop(      \
1761       CHECKED_CAST(_STACK *, STACK_OF(POLICY_MAPPING) *, sk)))
1762 
1763 #define sk_POLICY_MAPPING_dup(sk)      \
1764   ((STACK_OF(POLICY_MAPPING) *)sk_dup( \
1765       CHECKED_CAST(const _STACK *, const STACK_OF(POLICY_MAPPING) *, sk)))
1766 
1767 #define sk_POLICY_MAPPING_sort(sk) \
1768   sk_sort(CHECKED_CAST(_STACK *, STACK_OF(POLICY_MAPPING) *, sk))
1769 
1770 #define sk_POLICY_MAPPING_is_sorted(sk) \
1771   sk_is_sorted(                         \
1772       CHECKED_CAST(const _STACK *, const STACK_OF(POLICY_MAPPING) *, sk))
1773 
1774 #define sk_POLICY_MAPPING_set_cmp_func(sk, comp)                           \
1775   ((int (*)(const POLICY_MAPPING **a, const POLICY_MAPPING **b))           \
1776        sk_set_cmp_func(                                                    \
1777            CHECKED_CAST(_STACK *, STACK_OF(POLICY_MAPPING) *, sk),         \
1778            CHECKED_CAST(stack_cmp_func, int (*)(const POLICY_MAPPING **a,  \
1779                                                 const POLICY_MAPPING **b), \
1780                         comp)))
1781 
1782 #define sk_POLICY_MAPPING_deep_copy(sk, copy_func, free_func)                \
1783   ((STACK_OF(POLICY_MAPPING) *)sk_deep_copy(                                 \
1784       CHECKED_CAST(const _STACK *, const STACK_OF(POLICY_MAPPING) *, sk),    \
1785       CHECKED_CAST(void *(*)(void *), POLICY_MAPPING *(*)(POLICY_MAPPING *), \
1786                    copy_func),                                               \
1787       CHECKED_CAST(void (*)(void *), void (*)(POLICY_MAPPING *), free_func)))
1788 
1789 /* RSA_additional_prime */
1790 #define sk_RSA_additional_prime_new(comp)                                      \
1791   ((STACK_OF(RSA_additional_prime) *)sk_new(CHECKED_CAST(                      \
1792       stack_cmp_func,                                                          \
1793       int (*)(const RSA_additional_prime **a, const RSA_additional_prime **b), \
1794       comp)))
1795 
1796 #define sk_RSA_additional_prime_new_null() \
1797   ((STACK_OF(RSA_additional_prime) *)sk_new_null())
1798 
1799 #define sk_RSA_additional_prime_num(sk)                                       \
1800   sk_num(CHECKED_CAST(const _STACK *, const STACK_OF(RSA_additional_prime) *, \
1801                       sk))
1802 
1803 #define sk_RSA_additional_prime_zero(sk) \
1804   sk_zero(CHECKED_CAST(_STACK *, STACK_OF(RSA_additional_prime) *, sk));
1805 
1806 #define sk_RSA_additional_prime_value(sk, i)                               \
1807   ((RSA_additional_prime *)sk_value(                                       \
1808       CHECKED_CAST(const _STACK *, const STACK_OF(RSA_additional_prime) *, \
1809                    sk),                                                    \
1810       (i)))
1811 
1812 #define sk_RSA_additional_prime_set(sk, i, p)                            \
1813   ((RSA_additional_prime *)sk_set(                                       \
1814       CHECKED_CAST(_STACK *, STACK_OF(RSA_additional_prime) *, sk), (i), \
1815       CHECKED_CAST(void *, RSA_additional_prime *, p)))
1816 
1817 #define sk_RSA_additional_prime_free(sk) \
1818   sk_free(CHECKED_CAST(_STACK *, STACK_OF(RSA_additional_prime) *, sk))
1819 
1820 #define sk_RSA_additional_prime_pop_free(sk, free_func)                        \
1821   sk_pop_free(CHECKED_CAST(_STACK *, STACK_OF(RSA_additional_prime) *, sk),    \
1822               CHECKED_CAST(void (*)(void *), void (*)(RSA_additional_prime *), \
1823                            free_func))
1824 
1825 #define sk_RSA_additional_prime_insert(sk, p, where)                      \
1826   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(RSA_additional_prime) *, sk), \
1827             CHECKED_CAST(void *, RSA_additional_prime *, p), (where))
1828 
1829 #define sk_RSA_additional_prime_delete(sk, where) \
1830   ((RSA_additional_prime *)sk_delete(             \
1831       CHECKED_CAST(_STACK *, STACK_OF(RSA_additional_prime) *, sk), (where)))
1832 
1833 #define sk_RSA_additional_prime_delete_ptr(sk, p)                   \
1834   ((RSA_additional_prime *)sk_delete_ptr(                           \
1835       CHECKED_CAST(_STACK *, STACK_OF(RSA_additional_prime) *, sk), \
1836       CHECKED_CAST(void *, RSA_additional_prime *, p)))
1837 
1838 #define sk_RSA_additional_prime_find(sk, out_index, p)                  \
1839   sk_find(CHECKED_CAST(_STACK *, STACK_OF(RSA_additional_prime) *, sk), \
1840           (out_index), CHECKED_CAST(void *, RSA_additional_prime *, p))
1841 
1842 #define sk_RSA_additional_prime_shift(sk) \
1843   ((RSA_additional_prime *)sk_shift(      \
1844       CHECKED_CAST(_STACK *, STACK_OF(RSA_additional_prime) *, sk)))
1845 
1846 #define sk_RSA_additional_prime_push(sk, p)                             \
1847   sk_push(CHECKED_CAST(_STACK *, STACK_OF(RSA_additional_prime) *, sk), \
1848           CHECKED_CAST(void *, RSA_additional_prime *, p))
1849 
1850 #define sk_RSA_additional_prime_pop(sk) \
1851   ((RSA_additional_prime *)sk_pop(      \
1852       CHECKED_CAST(_STACK *, STACK_OF(RSA_additional_prime) *, sk)))
1853 
1854 #define sk_RSA_additional_prime_dup(sk)                   \
1855   ((STACK_OF(RSA_additional_prime) *)sk_dup(CHECKED_CAST( \
1856       const _STACK *, const STACK_OF(RSA_additional_prime) *, sk)))
1857 
1858 #define sk_RSA_additional_prime_sort(sk) \
1859   sk_sort(CHECKED_CAST(_STACK *, STACK_OF(RSA_additional_prime) *, sk))
1860 
1861 #define sk_RSA_additional_prime_is_sorted(sk) \
1862   sk_is_sorted(CHECKED_CAST(const _STACK *,   \
1863                             const STACK_OF(RSA_additional_prime) *, sk))
1864 
1865 #define sk_RSA_additional_prime_set_cmp_func(sk, comp)                       \
1866   ((int (*)(const RSA_additional_prime **a, const RSA_additional_prime **b)) \
1867        sk_set_cmp_func(                                                      \
1868            CHECKED_CAST(_STACK *, STACK_OF(RSA_additional_prime) *, sk),     \
1869            CHECKED_CAST(stack_cmp_func,                                      \
1870                         int (*)(const RSA_additional_prime **a,              \
1871                                 const RSA_additional_prime **b),             \
1872                         comp)))
1873 
1874 #define sk_RSA_additional_prime_deep_copy(sk, copy_func, free_func)        \
1875   ((STACK_OF(RSA_additional_prime) *)sk_deep_copy(                         \
1876       CHECKED_CAST(const _STACK *, const STACK_OF(RSA_additional_prime) *, \
1877                    sk),                                                    \
1878       CHECKED_CAST(void *(*)(void *),                                      \
1879                    RSA_additional_prime *(*)(RSA_additional_prime *),      \
1880                    copy_func),                                             \
1881       CHECKED_CAST(void (*)(void *), void (*)(RSA_additional_prime *),     \
1882                    free_func)))
1883 
1884 /* SSL_COMP */
1885 #define sk_SSL_COMP_new(comp)                 \
1886   ((STACK_OF(SSL_COMP) *)sk_new(CHECKED_CAST( \
1887       stack_cmp_func, int (*)(const SSL_COMP **a, const SSL_COMP **b), comp)))
1888 
1889 #define sk_SSL_COMP_new_null() ((STACK_OF(SSL_COMP) *)sk_new_null())
1890 
1891 #define sk_SSL_COMP_num(sk) \
1892   sk_num(CHECKED_CAST(const _STACK *, const STACK_OF(SSL_COMP) *, sk))
1893 
1894 #define sk_SSL_COMP_zero(sk) \
1895   sk_zero(CHECKED_CAST(_STACK *, STACK_OF(SSL_COMP) *, sk));
1896 
1897 #define sk_SSL_COMP_value(sk, i) \
1898   ((SSL_COMP *)sk_value(         \
1899       CHECKED_CAST(const _STACK *, const STACK_OF(SSL_COMP) *, sk), (i)))
1900 
1901 #define sk_SSL_COMP_set(sk, i, p)                                            \
1902   ((SSL_COMP *)sk_set(CHECKED_CAST(_STACK *, STACK_OF(SSL_COMP) *, sk), (i), \
1903                       CHECKED_CAST(void *, SSL_COMP *, p)))
1904 
1905 #define sk_SSL_COMP_free(sk) \
1906   sk_free(CHECKED_CAST(_STACK *, STACK_OF(SSL_COMP) *, sk))
1907 
1908 #define sk_SSL_COMP_pop_free(sk, free_func)                     \
1909   sk_pop_free(CHECKED_CAST(_STACK *, STACK_OF(SSL_COMP) *, sk), \
1910               CHECKED_CAST(void (*)(void *), void (*)(SSL_COMP *), free_func))
1911 
1912 #define sk_SSL_COMP_insert(sk, p, where)                      \
1913   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(SSL_COMP) *, sk), \
1914             CHECKED_CAST(void *, SSL_COMP *, p), (where))
1915 
1916 #define sk_SSL_COMP_delete(sk, where)                                      \
1917   ((SSL_COMP *)sk_delete(CHECKED_CAST(_STACK *, STACK_OF(SSL_COMP) *, sk), \
1918                          (where)))
1919 
1920 #define sk_SSL_COMP_delete_ptr(sk, p)                                          \
1921   ((SSL_COMP *)sk_delete_ptr(CHECKED_CAST(_STACK *, STACK_OF(SSL_COMP) *, sk), \
1922                              CHECKED_CAST(void *, SSL_COMP *, p)))
1923 
1924 #define sk_SSL_COMP_find(sk, out_index, p)                               \
1925   sk_find(CHECKED_CAST(_STACK *, STACK_OF(SSL_COMP) *, sk), (out_index), \
1926           CHECKED_CAST(void *, SSL_COMP *, p))
1927 
1928 #define sk_SSL_COMP_shift(sk) \
1929   ((SSL_COMP *)sk_shift(CHECKED_CAST(_STACK *, STACK_OF(SSL_COMP) *, sk)))
1930 
1931 #define sk_SSL_COMP_push(sk, p)                             \
1932   sk_push(CHECKED_CAST(_STACK *, STACK_OF(SSL_COMP) *, sk), \
1933           CHECKED_CAST(void *, SSL_COMP *, p))
1934 
1935 #define sk_SSL_COMP_pop(sk) \
1936   ((SSL_COMP *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(SSL_COMP) *, sk)))
1937 
1938 #define sk_SSL_COMP_dup(sk)      \
1939   ((STACK_OF(SSL_COMP) *)sk_dup( \
1940       CHECKED_CAST(const _STACK *, const STACK_OF(SSL_COMP) *, sk)))
1941 
1942 #define sk_SSL_COMP_sort(sk) \
1943   sk_sort(CHECKED_CAST(_STACK *, STACK_OF(SSL_COMP) *, sk))
1944 
1945 #define sk_SSL_COMP_is_sorted(sk) \
1946   sk_is_sorted(CHECKED_CAST(const _STACK *, const STACK_OF(SSL_COMP) *, sk))
1947 
1948 #define sk_SSL_COMP_set_cmp_func(sk, comp)                           \
1949   ((int (*)(const SSL_COMP **a, const SSL_COMP **b))sk_set_cmp_func( \
1950       CHECKED_CAST(_STACK *, STACK_OF(SSL_COMP) *, sk),              \
1951       CHECKED_CAST(stack_cmp_func,                                   \
1952                    int (*)(const SSL_COMP **a, const SSL_COMP **b), comp)))
1953 
1954 #define sk_SSL_COMP_deep_copy(sk, copy_func, free_func)                      \
1955   ((STACK_OF(SSL_COMP) *)sk_deep_copy(                                       \
1956       CHECKED_CAST(const _STACK *, const STACK_OF(SSL_COMP) *, sk),          \
1957       CHECKED_CAST(void *(*)(void *), SSL_COMP *(*)(SSL_COMP *), copy_func), \
1958       CHECKED_CAST(void (*)(void *), void (*)(SSL_COMP *), free_func)))
1959 
1960 /* SSL_CUSTOM_EXTENSION */
1961 #define sk_SSL_CUSTOM_EXTENSION_new(comp)                                      \
1962   ((STACK_OF(SSL_CUSTOM_EXTENSION) *)sk_new(CHECKED_CAST(                      \
1963       stack_cmp_func,                                                          \
1964       int (*)(const SSL_CUSTOM_EXTENSION **a, const SSL_CUSTOM_EXTENSION **b), \
1965       comp)))
1966 
1967 #define sk_SSL_CUSTOM_EXTENSION_new_null() \
1968   ((STACK_OF(SSL_CUSTOM_EXTENSION) *)sk_new_null())
1969 
1970 #define sk_SSL_CUSTOM_EXTENSION_num(sk)                                       \
1971   sk_num(CHECKED_CAST(const _STACK *, const STACK_OF(SSL_CUSTOM_EXTENSION) *, \
1972                       sk))
1973 
1974 #define sk_SSL_CUSTOM_EXTENSION_zero(sk) \
1975   sk_zero(CHECKED_CAST(_STACK *, STACK_OF(SSL_CUSTOM_EXTENSION) *, sk));
1976 
1977 #define sk_SSL_CUSTOM_EXTENSION_value(sk, i)                               \
1978   ((SSL_CUSTOM_EXTENSION *)sk_value(                                       \
1979       CHECKED_CAST(const _STACK *, const STACK_OF(SSL_CUSTOM_EXTENSION) *, \
1980                    sk),                                                    \
1981       (i)))
1982 
1983 #define sk_SSL_CUSTOM_EXTENSION_set(sk, i, p)                            \
1984   ((SSL_CUSTOM_EXTENSION *)sk_set(                                       \
1985       CHECKED_CAST(_STACK *, STACK_OF(SSL_CUSTOM_EXTENSION) *, sk), (i), \
1986       CHECKED_CAST(void *, SSL_CUSTOM_EXTENSION *, p)))
1987 
1988 #define sk_SSL_CUSTOM_EXTENSION_free(sk) \
1989   sk_free(CHECKED_CAST(_STACK *, STACK_OF(SSL_CUSTOM_EXTENSION) *, sk))
1990 
1991 #define sk_SSL_CUSTOM_EXTENSION_pop_free(sk, free_func)                        \
1992   sk_pop_free(CHECKED_CAST(_STACK *, STACK_OF(SSL_CUSTOM_EXTENSION) *, sk),    \
1993               CHECKED_CAST(void (*)(void *), void (*)(SSL_CUSTOM_EXTENSION *), \
1994                            free_func))
1995 
1996 #define sk_SSL_CUSTOM_EXTENSION_insert(sk, p, where)                      \
1997   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(SSL_CUSTOM_EXTENSION) *, sk), \
1998             CHECKED_CAST(void *, SSL_CUSTOM_EXTENSION *, p), (where))
1999 
2000 #define sk_SSL_CUSTOM_EXTENSION_delete(sk, where) \
2001   ((SSL_CUSTOM_EXTENSION *)sk_delete(             \
2002       CHECKED_CAST(_STACK *, STACK_OF(SSL_CUSTOM_EXTENSION) *, sk), (where)))
2003 
2004 #define sk_SSL_CUSTOM_EXTENSION_delete_ptr(sk, p)                   \
2005   ((SSL_CUSTOM_EXTENSION *)sk_delete_ptr(                           \
2006       CHECKED_CAST(_STACK *, STACK_OF(SSL_CUSTOM_EXTENSION) *, sk), \
2007       CHECKED_CAST(void *, SSL_CUSTOM_EXTENSION *, p)))
2008 
2009 #define sk_SSL_CUSTOM_EXTENSION_find(sk, out_index, p)                  \
2010   sk_find(CHECKED_CAST(_STACK *, STACK_OF(SSL_CUSTOM_EXTENSION) *, sk), \
2011           (out_index), CHECKED_CAST(void *, SSL_CUSTOM_EXTENSION *, p))
2012 
2013 #define sk_SSL_CUSTOM_EXTENSION_shift(sk) \
2014   ((SSL_CUSTOM_EXTENSION *)sk_shift(      \
2015       CHECKED_CAST(_STACK *, STACK_OF(SSL_CUSTOM_EXTENSION) *, sk)))
2016 
2017 #define sk_SSL_CUSTOM_EXTENSION_push(sk, p)                             \
2018   sk_push(CHECKED_CAST(_STACK *, STACK_OF(SSL_CUSTOM_EXTENSION) *, sk), \
2019           CHECKED_CAST(void *, SSL_CUSTOM_EXTENSION *, p))
2020 
2021 #define sk_SSL_CUSTOM_EXTENSION_pop(sk) \
2022   ((SSL_CUSTOM_EXTENSION *)sk_pop(      \
2023       CHECKED_CAST(_STACK *, STACK_OF(SSL_CUSTOM_EXTENSION) *, sk)))
2024 
2025 #define sk_SSL_CUSTOM_EXTENSION_dup(sk)                   \
2026   ((STACK_OF(SSL_CUSTOM_EXTENSION) *)sk_dup(CHECKED_CAST( \
2027       const _STACK *, const STACK_OF(SSL_CUSTOM_EXTENSION) *, sk)))
2028 
2029 #define sk_SSL_CUSTOM_EXTENSION_sort(sk) \
2030   sk_sort(CHECKED_CAST(_STACK *, STACK_OF(SSL_CUSTOM_EXTENSION) *, sk))
2031 
2032 #define sk_SSL_CUSTOM_EXTENSION_is_sorted(sk) \
2033   sk_is_sorted(CHECKED_CAST(const _STACK *,   \
2034                             const STACK_OF(SSL_CUSTOM_EXTENSION) *, sk))
2035 
2036 #define sk_SSL_CUSTOM_EXTENSION_set_cmp_func(sk, comp)                       \
2037   ((int (*)(const SSL_CUSTOM_EXTENSION **a, const SSL_CUSTOM_EXTENSION **b)) \
2038        sk_set_cmp_func(                                                      \
2039            CHECKED_CAST(_STACK *, STACK_OF(SSL_CUSTOM_EXTENSION) *, sk),     \
2040            CHECKED_CAST(stack_cmp_func,                                      \
2041                         int (*)(const SSL_CUSTOM_EXTENSION **a,              \
2042                                 const SSL_CUSTOM_EXTENSION **b),             \
2043                         comp)))
2044 
2045 #define sk_SSL_CUSTOM_EXTENSION_deep_copy(sk, copy_func, free_func)        \
2046   ((STACK_OF(SSL_CUSTOM_EXTENSION) *)sk_deep_copy(                         \
2047       CHECKED_CAST(const _STACK *, const STACK_OF(SSL_CUSTOM_EXTENSION) *, \
2048                    sk),                                                    \
2049       CHECKED_CAST(void *(*)(void *),                                      \
2050                    SSL_CUSTOM_EXTENSION *(*)(SSL_CUSTOM_EXTENSION *),      \
2051                    copy_func),                                             \
2052       CHECKED_CAST(void (*)(void *), void (*)(SSL_CUSTOM_EXTENSION *),     \
2053                    free_func)))
2054 
2055 /* STACK_OF_X509_NAME_ENTRY */
2056 #define sk_STACK_OF_X509_NAME_ENTRY_new(comp)                      \
2057   ((STACK_OF(STACK_OF_X509_NAME_ENTRY) *)sk_new(CHECKED_CAST(      \
2058       stack_cmp_func, int (*)(const STACK_OF_X509_NAME_ENTRY **a,  \
2059                               const STACK_OF_X509_NAME_ENTRY **b), \
2060       comp)))
2061 
2062 #define sk_STACK_OF_X509_NAME_ENTRY_new_null() \
2063   ((STACK_OF(STACK_OF_X509_NAME_ENTRY) *)sk_new_null())
2064 
2065 #define sk_STACK_OF_X509_NAME_ENTRY_num(sk) \
2066   sk_num(CHECKED_CAST(const _STACK *,       \
2067                       const STACK_OF(STACK_OF_X509_NAME_ENTRY) *, sk))
2068 
2069 #define sk_STACK_OF_X509_NAME_ENTRY_zero(sk) \
2070   sk_zero(CHECKED_CAST(_STACK *, STACK_OF(STACK_OF_X509_NAME_ENTRY) *, sk));
2071 
2072 #define sk_STACK_OF_X509_NAME_ENTRY_value(sk, i)                               \
2073   ((STACK_OF_X509_NAME_ENTRY *)sk_value(                                       \
2074       CHECKED_CAST(const _STACK *, const STACK_OF(STACK_OF_X509_NAME_ENTRY) *, \
2075                    sk),                                                        \
2076       (i)))
2077 
2078 #define sk_STACK_OF_X509_NAME_ENTRY_set(sk, i, p)                            \
2079   ((STACK_OF_X509_NAME_ENTRY *)sk_set(                                       \
2080       CHECKED_CAST(_STACK *, STACK_OF(STACK_OF_X509_NAME_ENTRY) *, sk), (i), \
2081       CHECKED_CAST(void *, STACK_OF_X509_NAME_ENTRY *, p)))
2082 
2083 #define sk_STACK_OF_X509_NAME_ENTRY_free(sk) \
2084   sk_free(CHECKED_CAST(_STACK *, STACK_OF(STACK_OF_X509_NAME_ENTRY) *, sk))
2085 
2086 #define sk_STACK_OF_X509_NAME_ENTRY_pop_free(sk, free_func)                \
2087   sk_pop_free(                                                             \
2088       CHECKED_CAST(_STACK *, STACK_OF(STACK_OF_X509_NAME_ENTRY) *, sk),    \
2089       CHECKED_CAST(void (*)(void *), void (*)(STACK_OF_X509_NAME_ENTRY *), \
2090                    free_func))
2091 
2092 #define sk_STACK_OF_X509_NAME_ENTRY_insert(sk, p, where)                      \
2093   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(STACK_OF_X509_NAME_ENTRY) *, sk), \
2094             CHECKED_CAST(void *, STACK_OF_X509_NAME_ENTRY *, p), (where))
2095 
2096 #define sk_STACK_OF_X509_NAME_ENTRY_delete(sk, where)                   \
2097   ((STACK_OF_X509_NAME_ENTRY *)sk_delete(                               \
2098       CHECKED_CAST(_STACK *, STACK_OF(STACK_OF_X509_NAME_ENTRY) *, sk), \
2099       (where)))
2100 
2101 #define sk_STACK_OF_X509_NAME_ENTRY_delete_ptr(sk, p)                   \
2102   ((STACK_OF_X509_NAME_ENTRY *)sk_delete_ptr(                           \
2103       CHECKED_CAST(_STACK *, STACK_OF(STACK_OF_X509_NAME_ENTRY) *, sk), \
2104       CHECKED_CAST(void *, STACK_OF_X509_NAME_ENTRY *, p)))
2105 
2106 #define sk_STACK_OF_X509_NAME_ENTRY_find(sk, out_index, p)                  \
2107   sk_find(CHECKED_CAST(_STACK *, STACK_OF(STACK_OF_X509_NAME_ENTRY) *, sk), \
2108           (out_index), CHECKED_CAST(void *, STACK_OF_X509_NAME_ENTRY *, p))
2109 
2110 #define sk_STACK_OF_X509_NAME_ENTRY_shift(sk) \
2111   ((STACK_OF_X509_NAME_ENTRY *)sk_shift(      \
2112       CHECKED_CAST(_STACK *, STACK_OF(STACK_OF_X509_NAME_ENTRY) *, sk)))
2113 
2114 #define sk_STACK_OF_X509_NAME_ENTRY_push(sk, p)                             \
2115   sk_push(CHECKED_CAST(_STACK *, STACK_OF(STACK_OF_X509_NAME_ENTRY) *, sk), \
2116           CHECKED_CAST(void *, STACK_OF_X509_NAME_ENTRY *, p))
2117 
2118 #define sk_STACK_OF_X509_NAME_ENTRY_pop(sk) \
2119   ((STACK_OF_X509_NAME_ENTRY *)sk_pop(      \
2120       CHECKED_CAST(_STACK *, STACK_OF(STACK_OF_X509_NAME_ENTRY) *, sk)))
2121 
2122 #define sk_STACK_OF_X509_NAME_ENTRY_dup(sk)                   \
2123   ((STACK_OF(STACK_OF_X509_NAME_ENTRY) *)sk_dup(CHECKED_CAST( \
2124       const _STACK *, const STACK_OF(STACK_OF_X509_NAME_ENTRY) *, sk)))
2125 
2126 #define sk_STACK_OF_X509_NAME_ENTRY_sort(sk) \
2127   sk_sort(CHECKED_CAST(_STACK *, STACK_OF(STACK_OF_X509_NAME_ENTRY) *, sk))
2128 
2129 #define sk_STACK_OF_X509_NAME_ENTRY_is_sorted(sk) \
2130   sk_is_sorted(CHECKED_CAST(const _STACK *,       \
2131                             const STACK_OF(STACK_OF_X509_NAME_ENTRY) *, sk))
2132 
2133 #define sk_STACK_OF_X509_NAME_ENTRY_set_cmp_func(sk, comp)                   \
2134   ((int (*)(const STACK_OF_X509_NAME_ENTRY **a,                              \
2135             const STACK_OF_X509_NAME_ENTRY **b))                             \
2136        sk_set_cmp_func(                                                      \
2137            CHECKED_CAST(_STACK *, STACK_OF(STACK_OF_X509_NAME_ENTRY) *, sk), \
2138            CHECKED_CAST(stack_cmp_func,                                      \
2139                         int (*)(const STACK_OF_X509_NAME_ENTRY **a,          \
2140                                 const STACK_OF_X509_NAME_ENTRY **b),         \
2141                         comp)))
2142 
2143 #define sk_STACK_OF_X509_NAME_ENTRY_deep_copy(sk, copy_func, free_func)        \
2144   ((STACK_OF(STACK_OF_X509_NAME_ENTRY) *)sk_deep_copy(                         \
2145       CHECKED_CAST(const _STACK *, const STACK_OF(STACK_OF_X509_NAME_ENTRY) *, \
2146                    sk),                                                        \
2147       CHECKED_CAST(void *(*)(void *),                                          \
2148                    STACK_OF_X509_NAME_ENTRY *(*)(STACK_OF_X509_NAME_ENTRY *),  \
2149                    copy_func),                                                 \
2150       CHECKED_CAST(void (*)(void *), void (*)(STACK_OF_X509_NAME_ENTRY *),     \
2151                    free_func)))
2152 
2153 /* SXNETID */
2154 #define sk_SXNETID_new(comp)                 \
2155   ((STACK_OF(SXNETID) *)sk_new(CHECKED_CAST( \
2156       stack_cmp_func, int (*)(const SXNETID **a, const SXNETID **b), comp)))
2157 
2158 #define sk_SXNETID_new_null() ((STACK_OF(SXNETID) *)sk_new_null())
2159 
2160 #define sk_SXNETID_num(sk) \
2161   sk_num(CHECKED_CAST(const _STACK *, const STACK_OF(SXNETID) *, sk))
2162 
2163 #define sk_SXNETID_zero(sk) \
2164   sk_zero(CHECKED_CAST(_STACK *, STACK_OF(SXNETID) *, sk));
2165 
2166 #define sk_SXNETID_value(sk, i) \
2167   ((SXNETID *)sk_value(         \
2168       CHECKED_CAST(const _STACK *, const STACK_OF(SXNETID) *, sk), (i)))
2169 
2170 #define sk_SXNETID_set(sk, i, p)                                           \
2171   ((SXNETID *)sk_set(CHECKED_CAST(_STACK *, STACK_OF(SXNETID) *, sk), (i), \
2172                      CHECKED_CAST(void *, SXNETID *, p)))
2173 
2174 #define sk_SXNETID_free(sk) \
2175   sk_free(CHECKED_CAST(_STACK *, STACK_OF(SXNETID) *, sk))
2176 
2177 #define sk_SXNETID_pop_free(sk, free_func)                     \
2178   sk_pop_free(CHECKED_CAST(_STACK *, STACK_OF(SXNETID) *, sk), \
2179               CHECKED_CAST(void (*)(void *), void (*)(SXNETID *), free_func))
2180 
2181 #define sk_SXNETID_insert(sk, p, where)                      \
2182   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(SXNETID) *, sk), \
2183             CHECKED_CAST(void *, SXNETID *, p), (where))
2184 
2185 #define sk_SXNETID_delete(sk, where)                                     \
2186   ((SXNETID *)sk_delete(CHECKED_CAST(_STACK *, STACK_OF(SXNETID) *, sk), \
2187                         (where)))
2188 
2189 #define sk_SXNETID_delete_ptr(sk, p)                                         \
2190   ((SXNETID *)sk_delete_ptr(CHECKED_CAST(_STACK *, STACK_OF(SXNETID) *, sk), \
2191                             CHECKED_CAST(void *, SXNETID *, p)))
2192 
2193 #define sk_SXNETID_find(sk, out_index, p)                               \
2194   sk_find(CHECKED_CAST(_STACK *, STACK_OF(SXNETID) *, sk), (out_index), \
2195           CHECKED_CAST(void *, SXNETID *, p))
2196 
2197 #define sk_SXNETID_shift(sk) \
2198   ((SXNETID *)sk_shift(CHECKED_CAST(_STACK *, STACK_OF(SXNETID) *, sk)))
2199 
2200 #define sk_SXNETID_push(sk, p)                             \
2201   sk_push(CHECKED_CAST(_STACK *, STACK_OF(SXNETID) *, sk), \
2202           CHECKED_CAST(void *, SXNETID *, p))
2203 
2204 #define sk_SXNETID_pop(sk) \
2205   ((SXNETID *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(SXNETID) *, sk)))
2206 
2207 #define sk_SXNETID_dup(sk)      \
2208   ((STACK_OF(SXNETID) *)sk_dup( \
2209       CHECKED_CAST(const _STACK *, const STACK_OF(SXNETID) *, sk)))
2210 
2211 #define sk_SXNETID_sort(sk) \
2212   sk_sort(CHECKED_CAST(_STACK *, STACK_OF(SXNETID) *, sk))
2213 
2214 #define sk_SXNETID_is_sorted(sk) \
2215   sk_is_sorted(CHECKED_CAST(const _STACK *, const STACK_OF(SXNETID) *, sk))
2216 
2217 #define sk_SXNETID_set_cmp_func(sk, comp)                          \
2218   ((int (*)(const SXNETID **a, const SXNETID **b))sk_set_cmp_func( \
2219       CHECKED_CAST(_STACK *, STACK_OF(SXNETID) *, sk),             \
2220       CHECKED_CAST(stack_cmp_func,                                 \
2221                    int (*)(const SXNETID **a, const SXNETID **b), comp)))
2222 
2223 #define sk_SXNETID_deep_copy(sk, copy_func, free_func)                     \
2224   ((STACK_OF(SXNETID) *)sk_deep_copy(                                      \
2225       CHECKED_CAST(const _STACK *, const STACK_OF(SXNETID) *, sk),         \
2226       CHECKED_CAST(void *(*)(void *), SXNETID *(*)(SXNETID *), copy_func), \
2227       CHECKED_CAST(void (*)(void *), void (*)(SXNETID *), free_func)))
2228 
2229 /* X509 */
2230 #define sk_X509_new(comp)                 \
2231   ((STACK_OF(X509) *)sk_new(CHECKED_CAST( \
2232       stack_cmp_func, int (*)(const X509 **a, const X509 **b), comp)))
2233 
2234 #define sk_X509_new_null() ((STACK_OF(X509) *)sk_new_null())
2235 
2236 #define sk_X509_num(sk) \
2237   sk_num(CHECKED_CAST(const _STACK *, const STACK_OF(X509) *, sk))
2238 
2239 #define sk_X509_zero(sk) sk_zero(CHECKED_CAST(_STACK *, STACK_OF(X509) *, sk));
2240 
2241 #define sk_X509_value(sk, i)                                                  \
2242   ((X509 *)sk_value(CHECKED_CAST(const _STACK *, const STACK_OF(X509) *, sk), \
2243                     (i)))
2244 
2245 #define sk_X509_set(sk, i, p)                                        \
2246   ((X509 *)sk_set(CHECKED_CAST(_STACK *, STACK_OF(X509) *, sk), (i), \
2247                   CHECKED_CAST(void *, X509 *, p)))
2248 
2249 #define sk_X509_free(sk) sk_free(CHECKED_CAST(_STACK *, STACK_OF(X509) *, sk))
2250 
2251 #define sk_X509_pop_free(sk, free_func)                     \
2252   sk_pop_free(CHECKED_CAST(_STACK *, STACK_OF(X509) *, sk), \
2253               CHECKED_CAST(void (*)(void *), void (*)(X509 *), free_func))
2254 
2255 #define sk_X509_insert(sk, p, where)                      \
2256   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(X509) *, sk), \
2257             CHECKED_CAST(void *, X509 *, p), (where))
2258 
2259 #define sk_X509_delete(sk, where) \
2260   ((X509 *)sk_delete(CHECKED_CAST(_STACK *, STACK_OF(X509) *, sk), (where)))
2261 
2262 #define sk_X509_delete_ptr(sk, p)                                      \
2263   ((X509 *)sk_delete_ptr(CHECKED_CAST(_STACK *, STACK_OF(X509) *, sk), \
2264                          CHECKED_CAST(void *, X509 *, p)))
2265 
2266 #define sk_X509_find(sk, out_index, p)                               \
2267   sk_find(CHECKED_CAST(_STACK *, STACK_OF(X509) *, sk), (out_index), \
2268           CHECKED_CAST(void *, X509 *, p))
2269 
2270 #define sk_X509_shift(sk) \
2271   ((X509 *)sk_shift(CHECKED_CAST(_STACK *, STACK_OF(X509) *, sk)))
2272 
2273 #define sk_X509_push(sk, p)                             \
2274   sk_push(CHECKED_CAST(_STACK *, STACK_OF(X509) *, sk), \
2275           CHECKED_CAST(void *, X509 *, p))
2276 
2277 #define sk_X509_pop(sk) \
2278   ((X509 *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(X509) *, sk)))
2279 
2280 #define sk_X509_dup(sk)      \
2281   ((STACK_OF(X509) *)sk_dup( \
2282       CHECKED_CAST(const _STACK *, const STACK_OF(X509) *, sk)))
2283 
2284 #define sk_X509_sort(sk) sk_sort(CHECKED_CAST(_STACK *, STACK_OF(X509) *, sk))
2285 
2286 #define sk_X509_is_sorted(sk) \
2287   sk_is_sorted(CHECKED_CAST(const _STACK *, const STACK_OF(X509) *, sk))
2288 
2289 #define sk_X509_set_cmp_func(sk, comp)                                      \
2290   ((int (*)(const X509 **a, const X509 **b))sk_set_cmp_func(                \
2291       CHECKED_CAST(_STACK *, STACK_OF(X509) *, sk),                         \
2292       CHECKED_CAST(stack_cmp_func, int (*)(const X509 **a, const X509 **b), \
2293                    comp)))
2294 
2295 #define sk_X509_deep_copy(sk, copy_func, free_func)                  \
2296   ((STACK_OF(X509) *)sk_deep_copy(                                   \
2297       CHECKED_CAST(const _STACK *, const STACK_OF(X509) *, sk),      \
2298       CHECKED_CAST(void *(*)(void *), X509 *(*)(X509 *), copy_func), \
2299       CHECKED_CAST(void (*)(void *), void (*)(X509 *), free_func)))
2300 
2301 /* X509V3_EXT_METHOD */
2302 #define sk_X509V3_EXT_METHOD_new(comp)                                   \
2303   ((STACK_OF(X509V3_EXT_METHOD) *)sk_new(CHECKED_CAST(                   \
2304       stack_cmp_func,                                                    \
2305       int (*)(const X509V3_EXT_METHOD **a, const X509V3_EXT_METHOD **b), \
2306       comp)))
2307 
2308 #define sk_X509V3_EXT_METHOD_new_null() \
2309   ((STACK_OF(X509V3_EXT_METHOD) *)sk_new_null())
2310 
2311 #define sk_X509V3_EXT_METHOD_num(sk) \
2312   sk_num(CHECKED_CAST(const _STACK *, const STACK_OF(X509V3_EXT_METHOD) *, sk))
2313 
2314 #define sk_X509V3_EXT_METHOD_zero(sk) \
2315   sk_zero(CHECKED_CAST(_STACK *, STACK_OF(X509V3_EXT_METHOD) *, sk));
2316 
2317 #define sk_X509V3_EXT_METHOD_value(sk, i)                                    \
2318   ((X509V3_EXT_METHOD *)sk_value(                                            \
2319       CHECKED_CAST(const _STACK *, const STACK_OF(X509V3_EXT_METHOD) *, sk), \
2320       (i)))
2321 
2322 #define sk_X509V3_EXT_METHOD_set(sk, i, p)                            \
2323   ((X509V3_EXT_METHOD *)sk_set(                                       \
2324       CHECKED_CAST(_STACK *, STACK_OF(X509V3_EXT_METHOD) *, sk), (i), \
2325       CHECKED_CAST(void *, X509V3_EXT_METHOD *, p)))
2326 
2327 #define sk_X509V3_EXT_METHOD_free(sk) \
2328   sk_free(CHECKED_CAST(_STACK *, STACK_OF(X509V3_EXT_METHOD) *, sk))
2329 
2330 #define sk_X509V3_EXT_METHOD_pop_free(sk, free_func)                        \
2331   sk_pop_free(CHECKED_CAST(_STACK *, STACK_OF(X509V3_EXT_METHOD) *, sk),    \
2332               CHECKED_CAST(void (*)(void *), void (*)(X509V3_EXT_METHOD *), \
2333                            free_func))
2334 
2335 #define sk_X509V3_EXT_METHOD_insert(sk, p, where)                      \
2336   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(X509V3_EXT_METHOD) *, sk), \
2337             CHECKED_CAST(void *, X509V3_EXT_METHOD *, p), (where))
2338 
2339 #define sk_X509V3_EXT_METHOD_delete(sk, where) \
2340   ((X509V3_EXT_METHOD *)sk_delete(             \
2341       CHECKED_CAST(_STACK *, STACK_OF(X509V3_EXT_METHOD) *, sk), (where)))
2342 
2343 #define sk_X509V3_EXT_METHOD_delete_ptr(sk, p)                   \
2344   ((X509V3_EXT_METHOD *)sk_delete_ptr(                           \
2345       CHECKED_CAST(_STACK *, STACK_OF(X509V3_EXT_METHOD) *, sk), \
2346       CHECKED_CAST(void *, X509V3_EXT_METHOD *, p)))
2347 
2348 #define sk_X509V3_EXT_METHOD_find(sk, out_index, p)                  \
2349   sk_find(CHECKED_CAST(_STACK *, STACK_OF(X509V3_EXT_METHOD) *, sk), \
2350           (out_index), CHECKED_CAST(void *, X509V3_EXT_METHOD *, p))
2351 
2352 #define sk_X509V3_EXT_METHOD_shift(sk) \
2353   ((X509V3_EXT_METHOD *)sk_shift(      \
2354       CHECKED_CAST(_STACK *, STACK_OF(X509V3_EXT_METHOD) *, sk)))
2355 
2356 #define sk_X509V3_EXT_METHOD_push(sk, p)                             \
2357   sk_push(CHECKED_CAST(_STACK *, STACK_OF(X509V3_EXT_METHOD) *, sk), \
2358           CHECKED_CAST(void *, X509V3_EXT_METHOD *, p))
2359 
2360 #define sk_X509V3_EXT_METHOD_pop(sk) \
2361   ((X509V3_EXT_METHOD *)sk_pop(      \
2362       CHECKED_CAST(_STACK *, STACK_OF(X509V3_EXT_METHOD) *, sk)))
2363 
2364 #define sk_X509V3_EXT_METHOD_dup(sk)      \
2365   ((STACK_OF(X509V3_EXT_METHOD) *)sk_dup( \
2366       CHECKED_CAST(const _STACK *, const STACK_OF(X509V3_EXT_METHOD) *, sk)))
2367 
2368 #define sk_X509V3_EXT_METHOD_sort(sk) \
2369   sk_sort(CHECKED_CAST(_STACK *, STACK_OF(X509V3_EXT_METHOD) *, sk))
2370 
2371 #define sk_X509V3_EXT_METHOD_is_sorted(sk) \
2372   sk_is_sorted(                            \
2373       CHECKED_CAST(const _STACK *, const STACK_OF(X509V3_EXT_METHOD) *, sk))
2374 
2375 #define sk_X509V3_EXT_METHOD_set_cmp_func(sk, comp)                           \
2376   ((int (*)(const X509V3_EXT_METHOD **a, const X509V3_EXT_METHOD **b))        \
2377        sk_set_cmp_func(                                                       \
2378            CHECKED_CAST(_STACK *, STACK_OF(X509V3_EXT_METHOD) *, sk),         \
2379            CHECKED_CAST(stack_cmp_func, int (*)(const X509V3_EXT_METHOD **a,  \
2380                                                 const X509V3_EXT_METHOD **b), \
2381                         comp)))
2382 
2383 #define sk_X509V3_EXT_METHOD_deep_copy(sk, copy_func, free_func)             \
2384   ((STACK_OF(X509V3_EXT_METHOD) *)sk_deep_copy(                              \
2385       CHECKED_CAST(const _STACK *, const STACK_OF(X509V3_EXT_METHOD) *, sk), \
2386       CHECKED_CAST(void *(*)(void *),                                        \
2387                    X509V3_EXT_METHOD *(*)(X509V3_EXT_METHOD *), copy_func),  \
2388       CHECKED_CAST(void (*)(void *), void (*)(X509V3_EXT_METHOD *),          \
2389                    free_func)))
2390 
2391 /* X509_ALGOR */
2392 #define sk_X509_ALGOR_new(comp)                                            \
2393   ((STACK_OF(X509_ALGOR) *)sk_new(CHECKED_CAST(                            \
2394       stack_cmp_func, int (*)(const X509_ALGOR **a, const X509_ALGOR **b), \
2395       comp)))
2396 
2397 #define sk_X509_ALGOR_new_null() ((STACK_OF(X509_ALGOR) *)sk_new_null())
2398 
2399 #define sk_X509_ALGOR_num(sk) \
2400   sk_num(CHECKED_CAST(const _STACK *, const STACK_OF(X509_ALGOR) *, sk))
2401 
2402 #define sk_X509_ALGOR_zero(sk) \
2403   sk_zero(CHECKED_CAST(_STACK *, STACK_OF(X509_ALGOR) *, sk));
2404 
2405 #define sk_X509_ALGOR_value(sk, i) \
2406   ((X509_ALGOR *)sk_value(         \
2407       CHECKED_CAST(const _STACK *, const STACK_OF(X509_ALGOR) *, sk), (i)))
2408 
2409 #define sk_X509_ALGOR_set(sk, i, p)                                         \
2410   ((X509_ALGOR *)sk_set(CHECKED_CAST(_STACK *, STACK_OF(X509_ALGOR) *, sk), \
2411                         (i), CHECKED_CAST(void *, X509_ALGOR *, p)))
2412 
2413 #define sk_X509_ALGOR_free(sk) \
2414   sk_free(CHECKED_CAST(_STACK *, STACK_OF(X509_ALGOR) *, sk))
2415 
2416 #define sk_X509_ALGOR_pop_free(sk, free_func)             \
2417   sk_pop_free(                                            \
2418       CHECKED_CAST(_STACK *, STACK_OF(X509_ALGOR) *, sk), \
2419       CHECKED_CAST(void (*)(void *), void (*)(X509_ALGOR *), free_func))
2420 
2421 #define sk_X509_ALGOR_insert(sk, p, where)                      \
2422   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(X509_ALGOR) *, sk), \
2423             CHECKED_CAST(void *, X509_ALGOR *, p), (where))
2424 
2425 #define sk_X509_ALGOR_delete(sk, where)                                        \
2426   ((X509_ALGOR *)sk_delete(CHECKED_CAST(_STACK *, STACK_OF(X509_ALGOR) *, sk), \
2427                            (where)))
2428 
2429 #define sk_X509_ALGOR_delete_ptr(sk, p)                   \
2430   ((X509_ALGOR *)sk_delete_ptr(                           \
2431       CHECKED_CAST(_STACK *, STACK_OF(X509_ALGOR) *, sk), \
2432       CHECKED_CAST(void *, X509_ALGOR *, p)))
2433 
2434 #define sk_X509_ALGOR_find(sk, out_index, p)                               \
2435   sk_find(CHECKED_CAST(_STACK *, STACK_OF(X509_ALGOR) *, sk), (out_index), \
2436           CHECKED_CAST(void *, X509_ALGOR *, p))
2437 
2438 #define sk_X509_ALGOR_shift(sk) \
2439   ((X509_ALGOR *)sk_shift(CHECKED_CAST(_STACK *, STACK_OF(X509_ALGOR) *, sk)))
2440 
2441 #define sk_X509_ALGOR_push(sk, p)                             \
2442   sk_push(CHECKED_CAST(_STACK *, STACK_OF(X509_ALGOR) *, sk), \
2443           CHECKED_CAST(void *, X509_ALGOR *, p))
2444 
2445 #define sk_X509_ALGOR_pop(sk) \
2446   ((X509_ALGOR *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(X509_ALGOR) *, sk)))
2447 
2448 #define sk_X509_ALGOR_dup(sk)      \
2449   ((STACK_OF(X509_ALGOR) *)sk_dup( \
2450       CHECKED_CAST(const _STACK *, const STACK_OF(X509_ALGOR) *, sk)))
2451 
2452 #define sk_X509_ALGOR_sort(sk) \
2453   sk_sort(CHECKED_CAST(_STACK *, STACK_OF(X509_ALGOR) *, sk))
2454 
2455 #define sk_X509_ALGOR_is_sorted(sk) \
2456   sk_is_sorted(CHECKED_CAST(const _STACK *, const STACK_OF(X509_ALGOR) *, sk))
2457 
2458 #define sk_X509_ALGOR_set_cmp_func(sk, comp)                             \
2459   ((int (*)(const X509_ALGOR **a, const X509_ALGOR **b))sk_set_cmp_func( \
2460       CHECKED_CAST(_STACK *, STACK_OF(X509_ALGOR) *, sk),                \
2461       CHECKED_CAST(stack_cmp_func,                                       \
2462                    int (*)(const X509_ALGOR **a, const X509_ALGOR **b),  \
2463                    comp)))
2464 
2465 #define sk_X509_ALGOR_deep_copy(sk, copy_func, free_func)             \
2466   ((STACK_OF(X509_ALGOR) *)sk_deep_copy(                              \
2467       CHECKED_CAST(const _STACK *, const STACK_OF(X509_ALGOR) *, sk), \
2468       CHECKED_CAST(void *(*)(void *), X509_ALGOR *(*)(X509_ALGOR *),  \
2469                    copy_func),                                        \
2470       CHECKED_CAST(void (*)(void *), void (*)(X509_ALGOR *), free_func)))
2471 
2472 /* X509_ATTRIBUTE */
2473 #define sk_X509_ATTRIBUTE_new(comp)                 \
2474   ((STACK_OF(X509_ATTRIBUTE) *)sk_new(CHECKED_CAST( \
2475       stack_cmp_func,                               \
2476       int (*)(const X509_ATTRIBUTE **a, const X509_ATTRIBUTE **b), comp)))
2477 
2478 #define sk_X509_ATTRIBUTE_new_null() ((STACK_OF(X509_ATTRIBUTE) *)sk_new_null())
2479 
2480 #define sk_X509_ATTRIBUTE_num(sk) \
2481   sk_num(CHECKED_CAST(const _STACK *, const STACK_OF(X509_ATTRIBUTE) *, sk))
2482 
2483 #define sk_X509_ATTRIBUTE_zero(sk) \
2484   sk_zero(CHECKED_CAST(_STACK *, STACK_OF(X509_ATTRIBUTE) *, sk));
2485 
2486 #define sk_X509_ATTRIBUTE_value(sk, i)                                    \
2487   ((X509_ATTRIBUTE *)sk_value(                                            \
2488       CHECKED_CAST(const _STACK *, const STACK_OF(X509_ATTRIBUTE) *, sk), \
2489       (i)))
2490 
2491 #define sk_X509_ATTRIBUTE_set(sk, i, p)                            \
2492   ((X509_ATTRIBUTE *)sk_set(                                       \
2493       CHECKED_CAST(_STACK *, STACK_OF(X509_ATTRIBUTE) *, sk), (i), \
2494       CHECKED_CAST(void *, X509_ATTRIBUTE *, p)))
2495 
2496 #define sk_X509_ATTRIBUTE_free(sk) \
2497   sk_free(CHECKED_CAST(_STACK *, STACK_OF(X509_ATTRIBUTE) *, sk))
2498 
2499 #define sk_X509_ATTRIBUTE_pop_free(sk, free_func)             \
2500   sk_pop_free(                                                \
2501       CHECKED_CAST(_STACK *, STACK_OF(X509_ATTRIBUTE) *, sk), \
2502       CHECKED_CAST(void (*)(void *), void (*)(X509_ATTRIBUTE *), free_func))
2503 
2504 #define sk_X509_ATTRIBUTE_insert(sk, p, where)                      \
2505   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(X509_ATTRIBUTE) *, sk), \
2506             CHECKED_CAST(void *, X509_ATTRIBUTE *, p), (where))
2507 
2508 #define sk_X509_ATTRIBUTE_delete(sk, where) \
2509   ((X509_ATTRIBUTE *)sk_delete(             \
2510       CHECKED_CAST(_STACK *, STACK_OF(X509_ATTRIBUTE) *, sk), (where)))
2511 
2512 #define sk_X509_ATTRIBUTE_delete_ptr(sk, p)                   \
2513   ((X509_ATTRIBUTE *)sk_delete_ptr(                           \
2514       CHECKED_CAST(_STACK *, STACK_OF(X509_ATTRIBUTE) *, sk), \
2515       CHECKED_CAST(void *, X509_ATTRIBUTE *, p)))
2516 
2517 #define sk_X509_ATTRIBUTE_find(sk, out_index, p)                               \
2518   sk_find(CHECKED_CAST(_STACK *, STACK_OF(X509_ATTRIBUTE) *, sk), (out_index), \
2519           CHECKED_CAST(void *, X509_ATTRIBUTE *, p))
2520 
2521 #define sk_X509_ATTRIBUTE_shift(sk) \
2522   ((X509_ATTRIBUTE *)sk_shift(      \
2523       CHECKED_CAST(_STACK *, STACK_OF(X509_ATTRIBUTE) *, sk)))
2524 
2525 #define sk_X509_ATTRIBUTE_push(sk, p)                             \
2526   sk_push(CHECKED_CAST(_STACK *, STACK_OF(X509_ATTRIBUTE) *, sk), \
2527           CHECKED_CAST(void *, X509_ATTRIBUTE *, p))
2528 
2529 #define sk_X509_ATTRIBUTE_pop(sk) \
2530   ((X509_ATTRIBUTE *)sk_pop(      \
2531       CHECKED_CAST(_STACK *, STACK_OF(X509_ATTRIBUTE) *, sk)))
2532 
2533 #define sk_X509_ATTRIBUTE_dup(sk)      \
2534   ((STACK_OF(X509_ATTRIBUTE) *)sk_dup( \
2535       CHECKED_CAST(const _STACK *, const STACK_OF(X509_ATTRIBUTE) *, sk)))
2536 
2537 #define sk_X509_ATTRIBUTE_sort(sk) \
2538   sk_sort(CHECKED_CAST(_STACK *, STACK_OF(X509_ATTRIBUTE) *, sk))
2539 
2540 #define sk_X509_ATTRIBUTE_is_sorted(sk) \
2541   sk_is_sorted(                         \
2542       CHECKED_CAST(const _STACK *, const STACK_OF(X509_ATTRIBUTE) *, sk))
2543 
2544 #define sk_X509_ATTRIBUTE_set_cmp_func(sk, comp)                           \
2545   ((int (*)(const X509_ATTRIBUTE **a, const X509_ATTRIBUTE **b))           \
2546        sk_set_cmp_func(                                                    \
2547            CHECKED_CAST(_STACK *, STACK_OF(X509_ATTRIBUTE) *, sk),         \
2548            CHECKED_CAST(stack_cmp_func, int (*)(const X509_ATTRIBUTE **a,  \
2549                                                 const X509_ATTRIBUTE **b), \
2550                         comp)))
2551 
2552 #define sk_X509_ATTRIBUTE_deep_copy(sk, copy_func, free_func)                \
2553   ((STACK_OF(X509_ATTRIBUTE) *)sk_deep_copy(                                 \
2554       CHECKED_CAST(const _STACK *, const STACK_OF(X509_ATTRIBUTE) *, sk),    \
2555       CHECKED_CAST(void *(*)(void *), X509_ATTRIBUTE *(*)(X509_ATTRIBUTE *), \
2556                    copy_func),                                               \
2557       CHECKED_CAST(void (*)(void *), void (*)(X509_ATTRIBUTE *), free_func)))
2558 
2559 /* X509_CRL */
2560 #define sk_X509_CRL_new(comp)                 \
2561   ((STACK_OF(X509_CRL) *)sk_new(CHECKED_CAST( \
2562       stack_cmp_func, int (*)(const X509_CRL **a, const X509_CRL **b), comp)))
2563 
2564 #define sk_X509_CRL_new_null() ((STACK_OF(X509_CRL) *)sk_new_null())
2565 
2566 #define sk_X509_CRL_num(sk) \
2567   sk_num(CHECKED_CAST(const _STACK *, const STACK_OF(X509_CRL) *, sk))
2568 
2569 #define sk_X509_CRL_zero(sk) \
2570   sk_zero(CHECKED_CAST(_STACK *, STACK_OF(X509_CRL) *, sk));
2571 
2572 #define sk_X509_CRL_value(sk, i) \
2573   ((X509_CRL *)sk_value(         \
2574       CHECKED_CAST(const _STACK *, const STACK_OF(X509_CRL) *, sk), (i)))
2575 
2576 #define sk_X509_CRL_set(sk, i, p)                                            \
2577   ((X509_CRL *)sk_set(CHECKED_CAST(_STACK *, STACK_OF(X509_CRL) *, sk), (i), \
2578                       CHECKED_CAST(void *, X509_CRL *, p)))
2579 
2580 #define sk_X509_CRL_free(sk) \
2581   sk_free(CHECKED_CAST(_STACK *, STACK_OF(X509_CRL) *, sk))
2582 
2583 #define sk_X509_CRL_pop_free(sk, free_func)                     \
2584   sk_pop_free(CHECKED_CAST(_STACK *, STACK_OF(X509_CRL) *, sk), \
2585               CHECKED_CAST(void (*)(void *), void (*)(X509_CRL *), free_func))
2586 
2587 #define sk_X509_CRL_insert(sk, p, where)                      \
2588   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(X509_CRL) *, sk), \
2589             CHECKED_CAST(void *, X509_CRL *, p), (where))
2590 
2591 #define sk_X509_CRL_delete(sk, where)                                      \
2592   ((X509_CRL *)sk_delete(CHECKED_CAST(_STACK *, STACK_OF(X509_CRL) *, sk), \
2593                          (where)))
2594 
2595 #define sk_X509_CRL_delete_ptr(sk, p)                                          \
2596   ((X509_CRL *)sk_delete_ptr(CHECKED_CAST(_STACK *, STACK_OF(X509_CRL) *, sk), \
2597                              CHECKED_CAST(void *, X509_CRL *, p)))
2598 
2599 #define sk_X509_CRL_find(sk, out_index, p)                               \
2600   sk_find(CHECKED_CAST(_STACK *, STACK_OF(X509_CRL) *, sk), (out_index), \
2601           CHECKED_CAST(void *, X509_CRL *, p))
2602 
2603 #define sk_X509_CRL_shift(sk) \
2604   ((X509_CRL *)sk_shift(CHECKED_CAST(_STACK *, STACK_OF(X509_CRL) *, sk)))
2605 
2606 #define sk_X509_CRL_push(sk, p)                             \
2607   sk_push(CHECKED_CAST(_STACK *, STACK_OF(X509_CRL) *, sk), \
2608           CHECKED_CAST(void *, X509_CRL *, p))
2609 
2610 #define sk_X509_CRL_pop(sk) \
2611   ((X509_CRL *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(X509_CRL) *, sk)))
2612 
2613 #define sk_X509_CRL_dup(sk)      \
2614   ((STACK_OF(X509_CRL) *)sk_dup( \
2615       CHECKED_CAST(const _STACK *, const STACK_OF(X509_CRL) *, sk)))
2616 
2617 #define sk_X509_CRL_sort(sk) \
2618   sk_sort(CHECKED_CAST(_STACK *, STACK_OF(X509_CRL) *, sk))
2619 
2620 #define sk_X509_CRL_is_sorted(sk) \
2621   sk_is_sorted(CHECKED_CAST(const _STACK *, const STACK_OF(X509_CRL) *, sk))
2622 
2623 #define sk_X509_CRL_set_cmp_func(sk, comp)                           \
2624   ((int (*)(const X509_CRL **a, const X509_CRL **b))sk_set_cmp_func( \
2625       CHECKED_CAST(_STACK *, STACK_OF(X509_CRL) *, sk),              \
2626       CHECKED_CAST(stack_cmp_func,                                   \
2627                    int (*)(const X509_CRL **a, const X509_CRL **b), comp)))
2628 
2629 #define sk_X509_CRL_deep_copy(sk, copy_func, free_func)                      \
2630   ((STACK_OF(X509_CRL) *)sk_deep_copy(                                       \
2631       CHECKED_CAST(const _STACK *, const STACK_OF(X509_CRL) *, sk),          \
2632       CHECKED_CAST(void *(*)(void *), X509_CRL *(*)(X509_CRL *), copy_func), \
2633       CHECKED_CAST(void (*)(void *), void (*)(X509_CRL *), free_func)))
2634 
2635 /* X509_EXTENSION */
2636 #define sk_X509_EXTENSION_new(comp)                 \
2637   ((STACK_OF(X509_EXTENSION) *)sk_new(CHECKED_CAST( \
2638       stack_cmp_func,                               \
2639       int (*)(const X509_EXTENSION **a, const X509_EXTENSION **b), comp)))
2640 
2641 #define sk_X509_EXTENSION_new_null() ((STACK_OF(X509_EXTENSION) *)sk_new_null())
2642 
2643 #define sk_X509_EXTENSION_num(sk) \
2644   sk_num(CHECKED_CAST(const _STACK *, const STACK_OF(X509_EXTENSION) *, sk))
2645 
2646 #define sk_X509_EXTENSION_zero(sk) \
2647   sk_zero(CHECKED_CAST(_STACK *, STACK_OF(X509_EXTENSION) *, sk));
2648 
2649 #define sk_X509_EXTENSION_value(sk, i)                                    \
2650   ((X509_EXTENSION *)sk_value(                                            \
2651       CHECKED_CAST(const _STACK *, const STACK_OF(X509_EXTENSION) *, sk), \
2652       (i)))
2653 
2654 #define sk_X509_EXTENSION_set(sk, i, p)                            \
2655   ((X509_EXTENSION *)sk_set(                                       \
2656       CHECKED_CAST(_STACK *, STACK_OF(X509_EXTENSION) *, sk), (i), \
2657       CHECKED_CAST(void *, X509_EXTENSION *, p)))
2658 
2659 #define sk_X509_EXTENSION_free(sk) \
2660   sk_free(CHECKED_CAST(_STACK *, STACK_OF(X509_EXTENSION) *, sk))
2661 
2662 #define sk_X509_EXTENSION_pop_free(sk, free_func)             \
2663   sk_pop_free(                                                \
2664       CHECKED_CAST(_STACK *, STACK_OF(X509_EXTENSION) *, sk), \
2665       CHECKED_CAST(void (*)(void *), void (*)(X509_EXTENSION *), free_func))
2666 
2667 #define sk_X509_EXTENSION_insert(sk, p, where)                      \
2668   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(X509_EXTENSION) *, sk), \
2669             CHECKED_CAST(void *, X509_EXTENSION *, p), (where))
2670 
2671 #define sk_X509_EXTENSION_delete(sk, where) \
2672   ((X509_EXTENSION *)sk_delete(             \
2673       CHECKED_CAST(_STACK *, STACK_OF(X509_EXTENSION) *, sk), (where)))
2674 
2675 #define sk_X509_EXTENSION_delete_ptr(sk, p)                   \
2676   ((X509_EXTENSION *)sk_delete_ptr(                           \
2677       CHECKED_CAST(_STACK *, STACK_OF(X509_EXTENSION) *, sk), \
2678       CHECKED_CAST(void *, X509_EXTENSION *, p)))
2679 
2680 #define sk_X509_EXTENSION_find(sk, out_index, p)                               \
2681   sk_find(CHECKED_CAST(_STACK *, STACK_OF(X509_EXTENSION) *, sk), (out_index), \
2682           CHECKED_CAST(void *, X509_EXTENSION *, p))
2683 
2684 #define sk_X509_EXTENSION_shift(sk) \
2685   ((X509_EXTENSION *)sk_shift(      \
2686       CHECKED_CAST(_STACK *, STACK_OF(X509_EXTENSION) *, sk)))
2687 
2688 #define sk_X509_EXTENSION_push(sk, p)                             \
2689   sk_push(CHECKED_CAST(_STACK *, STACK_OF(X509_EXTENSION) *, sk), \
2690           CHECKED_CAST(void *, X509_EXTENSION *, p))
2691 
2692 #define sk_X509_EXTENSION_pop(sk) \
2693   ((X509_EXTENSION *)sk_pop(      \
2694       CHECKED_CAST(_STACK *, STACK_OF(X509_EXTENSION) *, sk)))
2695 
2696 #define sk_X509_EXTENSION_dup(sk)      \
2697   ((STACK_OF(X509_EXTENSION) *)sk_dup( \
2698       CHECKED_CAST(const _STACK *, const STACK_OF(X509_EXTENSION) *, sk)))
2699 
2700 #define sk_X509_EXTENSION_sort(sk) \
2701   sk_sort(CHECKED_CAST(_STACK *, STACK_OF(X509_EXTENSION) *, sk))
2702 
2703 #define sk_X509_EXTENSION_is_sorted(sk) \
2704   sk_is_sorted(                         \
2705       CHECKED_CAST(const _STACK *, const STACK_OF(X509_EXTENSION) *, sk))
2706 
2707 #define sk_X509_EXTENSION_set_cmp_func(sk, comp)                           \
2708   ((int (*)(const X509_EXTENSION **a, const X509_EXTENSION **b))           \
2709        sk_set_cmp_func(                                                    \
2710            CHECKED_CAST(_STACK *, STACK_OF(X509_EXTENSION) *, sk),         \
2711            CHECKED_CAST(stack_cmp_func, int (*)(const X509_EXTENSION **a,  \
2712                                                 const X509_EXTENSION **b), \
2713                         comp)))
2714 
2715 #define sk_X509_EXTENSION_deep_copy(sk, copy_func, free_func)                \
2716   ((STACK_OF(X509_EXTENSION) *)sk_deep_copy(                                 \
2717       CHECKED_CAST(const _STACK *, const STACK_OF(X509_EXTENSION) *, sk),    \
2718       CHECKED_CAST(void *(*)(void *), X509_EXTENSION *(*)(X509_EXTENSION *), \
2719                    copy_func),                                               \
2720       CHECKED_CAST(void (*)(void *), void (*)(X509_EXTENSION *), free_func)))
2721 
2722 /* X509_INFO */
2723 #define sk_X509_INFO_new(comp)     \
2724   ((STACK_OF(X509_INFO) *)sk_new(  \
2725       CHECKED_CAST(stack_cmp_func, \
2726                    int (*)(const X509_INFO **a, const X509_INFO **b), comp)))
2727 
2728 #define sk_X509_INFO_new_null() ((STACK_OF(X509_INFO) *)sk_new_null())
2729 
2730 #define sk_X509_INFO_num(sk) \
2731   sk_num(CHECKED_CAST(const _STACK *, const STACK_OF(X509_INFO) *, sk))
2732 
2733 #define sk_X509_INFO_zero(sk) \
2734   sk_zero(CHECKED_CAST(_STACK *, STACK_OF(X509_INFO) *, sk));
2735 
2736 #define sk_X509_INFO_value(sk, i) \
2737   ((X509_INFO *)sk_value(         \
2738       CHECKED_CAST(const _STACK *, const STACK_OF(X509_INFO) *, sk), (i)))
2739 
2740 #define sk_X509_INFO_set(sk, i, p)                                             \
2741   ((X509_INFO *)sk_set(CHECKED_CAST(_STACK *, STACK_OF(X509_INFO) *, sk), (i), \
2742                        CHECKED_CAST(void *, X509_INFO *, p)))
2743 
2744 #define sk_X509_INFO_free(sk) \
2745   sk_free(CHECKED_CAST(_STACK *, STACK_OF(X509_INFO) *, sk))
2746 
2747 #define sk_X509_INFO_pop_free(sk, free_func)             \
2748   sk_pop_free(                                           \
2749       CHECKED_CAST(_STACK *, STACK_OF(X509_INFO) *, sk), \
2750       CHECKED_CAST(void (*)(void *), void (*)(X509_INFO *), free_func))
2751 
2752 #define sk_X509_INFO_insert(sk, p, where)                      \
2753   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(X509_INFO) *, sk), \
2754             CHECKED_CAST(void *, X509_INFO *, p), (where))
2755 
2756 #define sk_X509_INFO_delete(sk, where)                                       \
2757   ((X509_INFO *)sk_delete(CHECKED_CAST(_STACK *, STACK_OF(X509_INFO) *, sk), \
2758                           (where)))
2759 
2760 #define sk_X509_INFO_delete_ptr(sk, p)                   \
2761   ((X509_INFO *)sk_delete_ptr(                           \
2762       CHECKED_CAST(_STACK *, STACK_OF(X509_INFO) *, sk), \
2763       CHECKED_CAST(void *, X509_INFO *, p)))
2764 
2765 #define sk_X509_INFO_find(sk, out_index, p)                               \
2766   sk_find(CHECKED_CAST(_STACK *, STACK_OF(X509_INFO) *, sk), (out_index), \
2767           CHECKED_CAST(void *, X509_INFO *, p))
2768 
2769 #define sk_X509_INFO_shift(sk) \
2770   ((X509_INFO *)sk_shift(CHECKED_CAST(_STACK *, STACK_OF(X509_INFO) *, sk)))
2771 
2772 #define sk_X509_INFO_push(sk, p)                             \
2773   sk_push(CHECKED_CAST(_STACK *, STACK_OF(X509_INFO) *, sk), \
2774           CHECKED_CAST(void *, X509_INFO *, p))
2775 
2776 #define sk_X509_INFO_pop(sk) \
2777   ((X509_INFO *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(X509_INFO) *, sk)))
2778 
2779 #define sk_X509_INFO_dup(sk)      \
2780   ((STACK_OF(X509_INFO) *)sk_dup( \
2781       CHECKED_CAST(const _STACK *, const STACK_OF(X509_INFO) *, sk)))
2782 
2783 #define sk_X509_INFO_sort(sk) \
2784   sk_sort(CHECKED_CAST(_STACK *, STACK_OF(X509_INFO) *, sk))
2785 
2786 #define sk_X509_INFO_is_sorted(sk) \
2787   sk_is_sorted(CHECKED_CAST(const _STACK *, const STACK_OF(X509_INFO) *, sk))
2788 
2789 #define sk_X509_INFO_set_cmp_func(sk, comp)                            \
2790   ((int (*)(const X509_INFO **a, const X509_INFO **b))sk_set_cmp_func( \
2791       CHECKED_CAST(_STACK *, STACK_OF(X509_INFO) *, sk),               \
2792       CHECKED_CAST(stack_cmp_func,                                     \
2793                    int (*)(const X509_INFO **a, const X509_INFO **b), comp)))
2794 
2795 #define sk_X509_INFO_deep_copy(sk, copy_func, free_func)                       \
2796   ((STACK_OF(X509_INFO) *)sk_deep_copy(                                        \
2797       CHECKED_CAST(const _STACK *, const STACK_OF(X509_INFO) *, sk),           \
2798       CHECKED_CAST(void *(*)(void *), X509_INFO *(*)(X509_INFO *), copy_func), \
2799       CHECKED_CAST(void (*)(void *), void (*)(X509_INFO *), free_func)))
2800 
2801 /* X509_LOOKUP */
2802 #define sk_X509_LOOKUP_new(comp)                                             \
2803   ((STACK_OF(X509_LOOKUP) *)sk_new(CHECKED_CAST(                             \
2804       stack_cmp_func, int (*)(const X509_LOOKUP **a, const X509_LOOKUP **b), \
2805       comp)))
2806 
2807 #define sk_X509_LOOKUP_new_null() ((STACK_OF(X509_LOOKUP) *)sk_new_null())
2808 
2809 #define sk_X509_LOOKUP_num(sk) \
2810   sk_num(CHECKED_CAST(const _STACK *, const STACK_OF(X509_LOOKUP) *, sk))
2811 
2812 #define sk_X509_LOOKUP_zero(sk) \
2813   sk_zero(CHECKED_CAST(_STACK *, STACK_OF(X509_LOOKUP) *, sk));
2814 
2815 #define sk_X509_LOOKUP_value(sk, i) \
2816   ((X509_LOOKUP *)sk_value(         \
2817       CHECKED_CAST(const _STACK *, const STACK_OF(X509_LOOKUP) *, sk), (i)))
2818 
2819 #define sk_X509_LOOKUP_set(sk, i, p)                                          \
2820   ((X509_LOOKUP *)sk_set(CHECKED_CAST(_STACK *, STACK_OF(X509_LOOKUP) *, sk), \
2821                          (i), CHECKED_CAST(void *, X509_LOOKUP *, p)))
2822 
2823 #define sk_X509_LOOKUP_free(sk) \
2824   sk_free(CHECKED_CAST(_STACK *, STACK_OF(X509_LOOKUP) *, sk))
2825 
2826 #define sk_X509_LOOKUP_pop_free(sk, free_func)             \
2827   sk_pop_free(                                             \
2828       CHECKED_CAST(_STACK *, STACK_OF(X509_LOOKUP) *, sk), \
2829       CHECKED_CAST(void (*)(void *), void (*)(X509_LOOKUP *), free_func))
2830 
2831 #define sk_X509_LOOKUP_insert(sk, p, where)                      \
2832   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(X509_LOOKUP) *, sk), \
2833             CHECKED_CAST(void *, X509_LOOKUP *, p), (where))
2834 
2835 #define sk_X509_LOOKUP_delete(sk, where) \
2836   ((X509_LOOKUP *)sk_delete(             \
2837       CHECKED_CAST(_STACK *, STACK_OF(X509_LOOKUP) *, sk), (where)))
2838 
2839 #define sk_X509_LOOKUP_delete_ptr(sk, p)                   \
2840   ((X509_LOOKUP *)sk_delete_ptr(                           \
2841       CHECKED_CAST(_STACK *, STACK_OF(X509_LOOKUP) *, sk), \
2842       CHECKED_CAST(void *, X509_LOOKUP *, p)))
2843 
2844 #define sk_X509_LOOKUP_find(sk, out_index, p)                               \
2845   sk_find(CHECKED_CAST(_STACK *, STACK_OF(X509_LOOKUP) *, sk), (out_index), \
2846           CHECKED_CAST(void *, X509_LOOKUP *, p))
2847 
2848 #define sk_X509_LOOKUP_shift(sk) \
2849   ((X509_LOOKUP *)sk_shift(CHECKED_CAST(_STACK *, STACK_OF(X509_LOOKUP) *, sk)))
2850 
2851 #define sk_X509_LOOKUP_push(sk, p)                             \
2852   sk_push(CHECKED_CAST(_STACK *, STACK_OF(X509_LOOKUP) *, sk), \
2853           CHECKED_CAST(void *, X509_LOOKUP *, p))
2854 
2855 #define sk_X509_LOOKUP_pop(sk) \
2856   ((X509_LOOKUP *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(X509_LOOKUP) *, sk)))
2857 
2858 #define sk_X509_LOOKUP_dup(sk)      \
2859   ((STACK_OF(X509_LOOKUP) *)sk_dup( \
2860       CHECKED_CAST(const _STACK *, const STACK_OF(X509_LOOKUP) *, sk)))
2861 
2862 #define sk_X509_LOOKUP_sort(sk) \
2863   sk_sort(CHECKED_CAST(_STACK *, STACK_OF(X509_LOOKUP) *, sk))
2864 
2865 #define sk_X509_LOOKUP_is_sorted(sk) \
2866   sk_is_sorted(CHECKED_CAST(const _STACK *, const STACK_OF(X509_LOOKUP) *, sk))
2867 
2868 #define sk_X509_LOOKUP_set_cmp_func(sk, comp)                              \
2869   ((int (*)(const X509_LOOKUP **a, const X509_LOOKUP **b))sk_set_cmp_func( \
2870       CHECKED_CAST(_STACK *, STACK_OF(X509_LOOKUP) *, sk),                 \
2871       CHECKED_CAST(stack_cmp_func,                                         \
2872                    int (*)(const X509_LOOKUP **a, const X509_LOOKUP **b),  \
2873                    comp)))
2874 
2875 #define sk_X509_LOOKUP_deep_copy(sk, copy_func, free_func)             \
2876   ((STACK_OF(X509_LOOKUP) *)sk_deep_copy(                              \
2877       CHECKED_CAST(const _STACK *, const STACK_OF(X509_LOOKUP) *, sk), \
2878       CHECKED_CAST(void *(*)(void *), X509_LOOKUP *(*)(X509_LOOKUP *), \
2879                    copy_func),                                         \
2880       CHECKED_CAST(void (*)(void *), void (*)(X509_LOOKUP *), free_func)))
2881 
2882 /* X509_NAME */
2883 #define sk_X509_NAME_new(comp)     \
2884   ((STACK_OF(X509_NAME) *)sk_new(  \
2885       CHECKED_CAST(stack_cmp_func, \
2886                    int (*)(const X509_NAME **a, const X509_NAME **b), comp)))
2887 
2888 #define sk_X509_NAME_new_null() ((STACK_OF(X509_NAME) *)sk_new_null())
2889 
2890 #define sk_X509_NAME_num(sk) \
2891   sk_num(CHECKED_CAST(const _STACK *, const STACK_OF(X509_NAME) *, sk))
2892 
2893 #define sk_X509_NAME_zero(sk) \
2894   sk_zero(CHECKED_CAST(_STACK *, STACK_OF(X509_NAME) *, sk));
2895 
2896 #define sk_X509_NAME_value(sk, i) \
2897   ((X509_NAME *)sk_value(         \
2898       CHECKED_CAST(const _STACK *, const STACK_OF(X509_NAME) *, sk), (i)))
2899 
2900 #define sk_X509_NAME_set(sk, i, p)                                             \
2901   ((X509_NAME *)sk_set(CHECKED_CAST(_STACK *, STACK_OF(X509_NAME) *, sk), (i), \
2902                        CHECKED_CAST(void *, X509_NAME *, p)))
2903 
2904 #define sk_X509_NAME_free(sk) \
2905   sk_free(CHECKED_CAST(_STACK *, STACK_OF(X509_NAME) *, sk))
2906 
2907 #define sk_X509_NAME_pop_free(sk, free_func)             \
2908   sk_pop_free(                                           \
2909       CHECKED_CAST(_STACK *, STACK_OF(X509_NAME) *, sk), \
2910       CHECKED_CAST(void (*)(void *), void (*)(X509_NAME *), free_func))
2911 
2912 #define sk_X509_NAME_insert(sk, p, where)                      \
2913   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(X509_NAME) *, sk), \
2914             CHECKED_CAST(void *, X509_NAME *, p), (where))
2915 
2916 #define sk_X509_NAME_delete(sk, where)                                       \
2917   ((X509_NAME *)sk_delete(CHECKED_CAST(_STACK *, STACK_OF(X509_NAME) *, sk), \
2918                           (where)))
2919 
2920 #define sk_X509_NAME_delete_ptr(sk, p)                   \
2921   ((X509_NAME *)sk_delete_ptr(                           \
2922       CHECKED_CAST(_STACK *, STACK_OF(X509_NAME) *, sk), \
2923       CHECKED_CAST(void *, X509_NAME *, p)))
2924 
2925 #define sk_X509_NAME_find(sk, out_index, p)                               \
2926   sk_find(CHECKED_CAST(_STACK *, STACK_OF(X509_NAME) *, sk), (out_index), \
2927           CHECKED_CAST(void *, X509_NAME *, p))
2928 
2929 #define sk_X509_NAME_shift(sk) \
2930   ((X509_NAME *)sk_shift(CHECKED_CAST(_STACK *, STACK_OF(X509_NAME) *, sk)))
2931 
2932 #define sk_X509_NAME_push(sk, p)                             \
2933   sk_push(CHECKED_CAST(_STACK *, STACK_OF(X509_NAME) *, sk), \
2934           CHECKED_CAST(void *, X509_NAME *, p))
2935 
2936 #define sk_X509_NAME_pop(sk) \
2937   ((X509_NAME *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(X509_NAME) *, sk)))
2938 
2939 #define sk_X509_NAME_dup(sk)      \
2940   ((STACK_OF(X509_NAME) *)sk_dup( \
2941       CHECKED_CAST(const _STACK *, const STACK_OF(X509_NAME) *, sk)))
2942 
2943 #define sk_X509_NAME_sort(sk) \
2944   sk_sort(CHECKED_CAST(_STACK *, STACK_OF(X509_NAME) *, sk))
2945 
2946 #define sk_X509_NAME_is_sorted(sk) \
2947   sk_is_sorted(CHECKED_CAST(const _STACK *, const STACK_OF(X509_NAME) *, sk))
2948 
2949 #define sk_X509_NAME_set_cmp_func(sk, comp)                            \
2950   ((int (*)(const X509_NAME **a, const X509_NAME **b))sk_set_cmp_func( \
2951       CHECKED_CAST(_STACK *, STACK_OF(X509_NAME) *, sk),               \
2952       CHECKED_CAST(stack_cmp_func,                                     \
2953                    int (*)(const X509_NAME **a, const X509_NAME **b), comp)))
2954 
2955 #define sk_X509_NAME_deep_copy(sk, copy_func, free_func)                       \
2956   ((STACK_OF(X509_NAME) *)sk_deep_copy(                                        \
2957       CHECKED_CAST(const _STACK *, const STACK_OF(X509_NAME) *, sk),           \
2958       CHECKED_CAST(void *(*)(void *), X509_NAME *(*)(X509_NAME *), copy_func), \
2959       CHECKED_CAST(void (*)(void *), void (*)(X509_NAME *), free_func)))
2960 
2961 /* X509_NAME_ENTRY */
2962 #define sk_X509_NAME_ENTRY_new(comp)                 \
2963   ((STACK_OF(X509_NAME_ENTRY) *)sk_new(CHECKED_CAST( \
2964       stack_cmp_func,                                \
2965       int (*)(const X509_NAME_ENTRY **a, const X509_NAME_ENTRY **b), comp)))
2966 
2967 #define sk_X509_NAME_ENTRY_new_null() \
2968   ((STACK_OF(X509_NAME_ENTRY) *)sk_new_null())
2969 
2970 #define sk_X509_NAME_ENTRY_num(sk) \
2971   sk_num(CHECKED_CAST(const _STACK *, const STACK_OF(X509_NAME_ENTRY) *, sk))
2972 
2973 #define sk_X509_NAME_ENTRY_zero(sk) \
2974   sk_zero(CHECKED_CAST(_STACK *, STACK_OF(X509_NAME_ENTRY) *, sk));
2975 
2976 #define sk_X509_NAME_ENTRY_value(sk, i)                                    \
2977   ((X509_NAME_ENTRY *)sk_value(                                            \
2978       CHECKED_CAST(const _STACK *, const STACK_OF(X509_NAME_ENTRY) *, sk), \
2979       (i)))
2980 
2981 #define sk_X509_NAME_ENTRY_set(sk, i, p)                            \
2982   ((X509_NAME_ENTRY *)sk_set(                                       \
2983       CHECKED_CAST(_STACK *, STACK_OF(X509_NAME_ENTRY) *, sk), (i), \
2984       CHECKED_CAST(void *, X509_NAME_ENTRY *, p)))
2985 
2986 #define sk_X509_NAME_ENTRY_free(sk) \
2987   sk_free(CHECKED_CAST(_STACK *, STACK_OF(X509_NAME_ENTRY) *, sk))
2988 
2989 #define sk_X509_NAME_ENTRY_pop_free(sk, free_func)             \
2990   sk_pop_free(                                                 \
2991       CHECKED_CAST(_STACK *, STACK_OF(X509_NAME_ENTRY) *, sk), \
2992       CHECKED_CAST(void (*)(void *), void (*)(X509_NAME_ENTRY *), free_func))
2993 
2994 #define sk_X509_NAME_ENTRY_insert(sk, p, where)                      \
2995   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(X509_NAME_ENTRY) *, sk), \
2996             CHECKED_CAST(void *, X509_NAME_ENTRY *, p), (where))
2997 
2998 #define sk_X509_NAME_ENTRY_delete(sk, where) \
2999   ((X509_NAME_ENTRY *)sk_delete(             \
3000       CHECKED_CAST(_STACK *, STACK_OF(X509_NAME_ENTRY) *, sk), (where)))
3001 
3002 #define sk_X509_NAME_ENTRY_delete_ptr(sk, p)                   \
3003   ((X509_NAME_ENTRY *)sk_delete_ptr(                           \
3004       CHECKED_CAST(_STACK *, STACK_OF(X509_NAME_ENTRY) *, sk), \
3005       CHECKED_CAST(void *, X509_NAME_ENTRY *, p)))
3006 
3007 #define sk_X509_NAME_ENTRY_find(sk, out_index, p)                  \
3008   sk_find(CHECKED_CAST(_STACK *, STACK_OF(X509_NAME_ENTRY) *, sk), \
3009           (out_index), CHECKED_CAST(void *, X509_NAME_ENTRY *, p))
3010 
3011 #define sk_X509_NAME_ENTRY_shift(sk) \
3012   ((X509_NAME_ENTRY *)sk_shift(      \
3013       CHECKED_CAST(_STACK *, STACK_OF(X509_NAME_ENTRY) *, sk)))
3014 
3015 #define sk_X509_NAME_ENTRY_push(sk, p)                             \
3016   sk_push(CHECKED_CAST(_STACK *, STACK_OF(X509_NAME_ENTRY) *, sk), \
3017           CHECKED_CAST(void *, X509_NAME_ENTRY *, p))
3018 
3019 #define sk_X509_NAME_ENTRY_pop(sk) \
3020   ((X509_NAME_ENTRY *)sk_pop(      \
3021       CHECKED_CAST(_STACK *, STACK_OF(X509_NAME_ENTRY) *, sk)))
3022 
3023 #define sk_X509_NAME_ENTRY_dup(sk)      \
3024   ((STACK_OF(X509_NAME_ENTRY) *)sk_dup( \
3025       CHECKED_CAST(const _STACK *, const STACK_OF(X509_NAME_ENTRY) *, sk)))
3026 
3027 #define sk_X509_NAME_ENTRY_sort(sk) \
3028   sk_sort(CHECKED_CAST(_STACK *, STACK_OF(X509_NAME_ENTRY) *, sk))
3029 
3030 #define sk_X509_NAME_ENTRY_is_sorted(sk) \
3031   sk_is_sorted(                          \
3032       CHECKED_CAST(const _STACK *, const STACK_OF(X509_NAME_ENTRY) *, sk))
3033 
3034 #define sk_X509_NAME_ENTRY_set_cmp_func(sk, comp)                           \
3035   ((int (*)(const X509_NAME_ENTRY **a, const X509_NAME_ENTRY **b))          \
3036        sk_set_cmp_func(                                                     \
3037            CHECKED_CAST(_STACK *, STACK_OF(X509_NAME_ENTRY) *, sk),         \
3038            CHECKED_CAST(stack_cmp_func, int (*)(const X509_NAME_ENTRY **a,  \
3039                                                 const X509_NAME_ENTRY **b), \
3040                         comp)))
3041 
3042 #define sk_X509_NAME_ENTRY_deep_copy(sk, copy_func, free_func)                 \
3043   ((STACK_OF(X509_NAME_ENTRY) *)sk_deep_copy(                                  \
3044       CHECKED_CAST(const _STACK *, const STACK_OF(X509_NAME_ENTRY) *, sk),     \
3045       CHECKED_CAST(void *(*)(void *), X509_NAME_ENTRY *(*)(X509_NAME_ENTRY *), \
3046                    copy_func),                                                 \
3047       CHECKED_CAST(void (*)(void *), void (*)(X509_NAME_ENTRY *), free_func)))
3048 
3049 /* X509_OBJECT */
3050 #define sk_X509_OBJECT_new(comp)                                             \
3051   ((STACK_OF(X509_OBJECT) *)sk_new(CHECKED_CAST(                             \
3052       stack_cmp_func, int (*)(const X509_OBJECT **a, const X509_OBJECT **b), \
3053       comp)))
3054 
3055 #define sk_X509_OBJECT_new_null() ((STACK_OF(X509_OBJECT) *)sk_new_null())
3056 
3057 #define sk_X509_OBJECT_num(sk) \
3058   sk_num(CHECKED_CAST(const _STACK *, const STACK_OF(X509_OBJECT) *, sk))
3059 
3060 #define sk_X509_OBJECT_zero(sk) \
3061   sk_zero(CHECKED_CAST(_STACK *, STACK_OF(X509_OBJECT) *, sk));
3062 
3063 #define sk_X509_OBJECT_value(sk, i) \
3064   ((X509_OBJECT *)sk_value(         \
3065       CHECKED_CAST(const _STACK *, const STACK_OF(X509_OBJECT) *, sk), (i)))
3066 
3067 #define sk_X509_OBJECT_set(sk, i, p)                                          \
3068   ((X509_OBJECT *)sk_set(CHECKED_CAST(_STACK *, STACK_OF(X509_OBJECT) *, sk), \
3069                          (i), CHECKED_CAST(void *, X509_OBJECT *, p)))
3070 
3071 #define sk_X509_OBJECT_free(sk) \
3072   sk_free(CHECKED_CAST(_STACK *, STACK_OF(X509_OBJECT) *, sk))
3073 
3074 #define sk_X509_OBJECT_pop_free(sk, free_func)             \
3075   sk_pop_free(                                             \
3076       CHECKED_CAST(_STACK *, STACK_OF(X509_OBJECT) *, sk), \
3077       CHECKED_CAST(void (*)(void *), void (*)(X509_OBJECT *), free_func))
3078 
3079 #define sk_X509_OBJECT_insert(sk, p, where)                      \
3080   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(X509_OBJECT) *, sk), \
3081             CHECKED_CAST(void *, X509_OBJECT *, p), (where))
3082 
3083 #define sk_X509_OBJECT_delete(sk, where) \
3084   ((X509_OBJECT *)sk_delete(             \
3085       CHECKED_CAST(_STACK *, STACK_OF(X509_OBJECT) *, sk), (where)))
3086 
3087 #define sk_X509_OBJECT_delete_ptr(sk, p)                   \
3088   ((X509_OBJECT *)sk_delete_ptr(                           \
3089       CHECKED_CAST(_STACK *, STACK_OF(X509_OBJECT) *, sk), \
3090       CHECKED_CAST(void *, X509_OBJECT *, p)))
3091 
3092 #define sk_X509_OBJECT_find(sk, out_index, p)                               \
3093   sk_find(CHECKED_CAST(_STACK *, STACK_OF(X509_OBJECT) *, sk), (out_index), \
3094           CHECKED_CAST(void *, X509_OBJECT *, p))
3095 
3096 #define sk_X509_OBJECT_shift(sk) \
3097   ((X509_OBJECT *)sk_shift(CHECKED_CAST(_STACK *, STACK_OF(X509_OBJECT) *, sk)))
3098 
3099 #define sk_X509_OBJECT_push(sk, p)                             \
3100   sk_push(CHECKED_CAST(_STACK *, STACK_OF(X509_OBJECT) *, sk), \
3101           CHECKED_CAST(void *, X509_OBJECT *, p))
3102 
3103 #define sk_X509_OBJECT_pop(sk) \
3104   ((X509_OBJECT *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(X509_OBJECT) *, sk)))
3105 
3106 #define sk_X509_OBJECT_dup(sk)      \
3107   ((STACK_OF(X509_OBJECT) *)sk_dup( \
3108       CHECKED_CAST(const _STACK *, const STACK_OF(X509_OBJECT) *, sk)))
3109 
3110 #define sk_X509_OBJECT_sort(sk) \
3111   sk_sort(CHECKED_CAST(_STACK *, STACK_OF(X509_OBJECT) *, sk))
3112 
3113 #define sk_X509_OBJECT_is_sorted(sk) \
3114   sk_is_sorted(CHECKED_CAST(const _STACK *, const STACK_OF(X509_OBJECT) *, sk))
3115 
3116 #define sk_X509_OBJECT_set_cmp_func(sk, comp)                              \
3117   ((int (*)(const X509_OBJECT **a, const X509_OBJECT **b))sk_set_cmp_func( \
3118       CHECKED_CAST(_STACK *, STACK_OF(X509_OBJECT) *, sk),                 \
3119       CHECKED_CAST(stack_cmp_func,                                         \
3120                    int (*)(const X509_OBJECT **a, const X509_OBJECT **b),  \
3121                    comp)))
3122 
3123 #define sk_X509_OBJECT_deep_copy(sk, copy_func, free_func)             \
3124   ((STACK_OF(X509_OBJECT) *)sk_deep_copy(                              \
3125       CHECKED_CAST(const _STACK *, const STACK_OF(X509_OBJECT) *, sk), \
3126       CHECKED_CAST(void *(*)(void *), X509_OBJECT *(*)(X509_OBJECT *), \
3127                    copy_func),                                         \
3128       CHECKED_CAST(void (*)(void *), void (*)(X509_OBJECT *), free_func)))
3129 
3130 /* X509_POLICY_DATA */
3131 #define sk_X509_POLICY_DATA_new(comp)                 \
3132   ((STACK_OF(X509_POLICY_DATA) *)sk_new(CHECKED_CAST( \
3133       stack_cmp_func,                                 \
3134       int (*)(const X509_POLICY_DATA **a, const X509_POLICY_DATA **b), comp)))
3135 
3136 #define sk_X509_POLICY_DATA_new_null() \
3137   ((STACK_OF(X509_POLICY_DATA) *)sk_new_null())
3138 
3139 #define sk_X509_POLICY_DATA_num(sk) \
3140   sk_num(CHECKED_CAST(const _STACK *, const STACK_OF(X509_POLICY_DATA) *, sk))
3141 
3142 #define sk_X509_POLICY_DATA_zero(sk) \
3143   sk_zero(CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_DATA) *, sk));
3144 
3145 #define sk_X509_POLICY_DATA_value(sk, i)                                    \
3146   ((X509_POLICY_DATA *)sk_value(                                            \
3147       CHECKED_CAST(const _STACK *, const STACK_OF(X509_POLICY_DATA) *, sk), \
3148       (i)))
3149 
3150 #define sk_X509_POLICY_DATA_set(sk, i, p)                            \
3151   ((X509_POLICY_DATA *)sk_set(                                       \
3152       CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_DATA) *, sk), (i), \
3153       CHECKED_CAST(void *, X509_POLICY_DATA *, p)))
3154 
3155 #define sk_X509_POLICY_DATA_free(sk) \
3156   sk_free(CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_DATA) *, sk))
3157 
3158 #define sk_X509_POLICY_DATA_pop_free(sk, free_func)             \
3159   sk_pop_free(                                                  \
3160       CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_DATA) *, sk), \
3161       CHECKED_CAST(void (*)(void *), void (*)(X509_POLICY_DATA *), free_func))
3162 
3163 #define sk_X509_POLICY_DATA_insert(sk, p, where)                      \
3164   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_DATA) *, sk), \
3165             CHECKED_CAST(void *, X509_POLICY_DATA *, p), (where))
3166 
3167 #define sk_X509_POLICY_DATA_delete(sk, where) \
3168   ((X509_POLICY_DATA *)sk_delete(             \
3169       CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_DATA) *, sk), (where)))
3170 
3171 #define sk_X509_POLICY_DATA_delete_ptr(sk, p)                   \
3172   ((X509_POLICY_DATA *)sk_delete_ptr(                           \
3173       CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_DATA) *, sk), \
3174       CHECKED_CAST(void *, X509_POLICY_DATA *, p)))
3175 
3176 #define sk_X509_POLICY_DATA_find(sk, out_index, p)                  \
3177   sk_find(CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_DATA) *, sk), \
3178           (out_index), CHECKED_CAST(void *, X509_POLICY_DATA *, p))
3179 
3180 #define sk_X509_POLICY_DATA_shift(sk) \
3181   ((X509_POLICY_DATA *)sk_shift(      \
3182       CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_DATA) *, sk)))
3183 
3184 #define sk_X509_POLICY_DATA_push(sk, p)                             \
3185   sk_push(CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_DATA) *, sk), \
3186           CHECKED_CAST(void *, X509_POLICY_DATA *, p))
3187 
3188 #define sk_X509_POLICY_DATA_pop(sk) \
3189   ((X509_POLICY_DATA *)sk_pop(      \
3190       CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_DATA) *, sk)))
3191 
3192 #define sk_X509_POLICY_DATA_dup(sk)      \
3193   ((STACK_OF(X509_POLICY_DATA) *)sk_dup( \
3194       CHECKED_CAST(const _STACK *, const STACK_OF(X509_POLICY_DATA) *, sk)))
3195 
3196 #define sk_X509_POLICY_DATA_sort(sk) \
3197   sk_sort(CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_DATA) *, sk))
3198 
3199 #define sk_X509_POLICY_DATA_is_sorted(sk) \
3200   sk_is_sorted(                           \
3201       CHECKED_CAST(const _STACK *, const STACK_OF(X509_POLICY_DATA) *, sk))
3202 
3203 #define sk_X509_POLICY_DATA_set_cmp_func(sk, comp)                           \
3204   ((int (*)(const X509_POLICY_DATA **a, const X509_POLICY_DATA **b))         \
3205        sk_set_cmp_func(                                                      \
3206            CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_DATA) *, sk),         \
3207            CHECKED_CAST(stack_cmp_func, int (*)(const X509_POLICY_DATA **a,  \
3208                                                 const X509_POLICY_DATA **b), \
3209                         comp)))
3210 
3211 #define sk_X509_POLICY_DATA_deep_copy(sk, copy_func, free_func)             \
3212   ((STACK_OF(X509_POLICY_DATA) *)sk_deep_copy(                              \
3213       CHECKED_CAST(const _STACK *, const STACK_OF(X509_POLICY_DATA) *, sk), \
3214       CHECKED_CAST(void *(*)(void *),                                       \
3215                    X509_POLICY_DATA *(*)(X509_POLICY_DATA *), copy_func),   \
3216       CHECKED_CAST(void (*)(void *), void (*)(X509_POLICY_DATA *),          \
3217                    free_func)))
3218 
3219 /* X509_POLICY_NODE */
3220 #define sk_X509_POLICY_NODE_new(comp)                 \
3221   ((STACK_OF(X509_POLICY_NODE) *)sk_new(CHECKED_CAST( \
3222       stack_cmp_func,                                 \
3223       int (*)(const X509_POLICY_NODE **a, const X509_POLICY_NODE **b), comp)))
3224 
3225 #define sk_X509_POLICY_NODE_new_null() \
3226   ((STACK_OF(X509_POLICY_NODE) *)sk_new_null())
3227 
3228 #define sk_X509_POLICY_NODE_num(sk) \
3229   sk_num(CHECKED_CAST(const _STACK *, const STACK_OF(X509_POLICY_NODE) *, sk))
3230 
3231 #define sk_X509_POLICY_NODE_zero(sk) \
3232   sk_zero(CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_NODE) *, sk));
3233 
3234 #define sk_X509_POLICY_NODE_value(sk, i)                                    \
3235   ((X509_POLICY_NODE *)sk_value(                                            \
3236       CHECKED_CAST(const _STACK *, const STACK_OF(X509_POLICY_NODE) *, sk), \
3237       (i)))
3238 
3239 #define sk_X509_POLICY_NODE_set(sk, i, p)                            \
3240   ((X509_POLICY_NODE *)sk_set(                                       \
3241       CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_NODE) *, sk), (i), \
3242       CHECKED_CAST(void *, X509_POLICY_NODE *, p)))
3243 
3244 #define sk_X509_POLICY_NODE_free(sk) \
3245   sk_free(CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_NODE) *, sk))
3246 
3247 #define sk_X509_POLICY_NODE_pop_free(sk, free_func)             \
3248   sk_pop_free(                                                  \
3249       CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_NODE) *, sk), \
3250       CHECKED_CAST(void (*)(void *), void (*)(X509_POLICY_NODE *), free_func))
3251 
3252 #define sk_X509_POLICY_NODE_insert(sk, p, where)                      \
3253   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_NODE) *, sk), \
3254             CHECKED_CAST(void *, X509_POLICY_NODE *, p), (where))
3255 
3256 #define sk_X509_POLICY_NODE_delete(sk, where) \
3257   ((X509_POLICY_NODE *)sk_delete(             \
3258       CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_NODE) *, sk), (where)))
3259 
3260 #define sk_X509_POLICY_NODE_delete_ptr(sk, p)                   \
3261   ((X509_POLICY_NODE *)sk_delete_ptr(                           \
3262       CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_NODE) *, sk), \
3263       CHECKED_CAST(void *, X509_POLICY_NODE *, p)))
3264 
3265 #define sk_X509_POLICY_NODE_find(sk, out_index, p)                  \
3266   sk_find(CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_NODE) *, sk), \
3267           (out_index), CHECKED_CAST(void *, X509_POLICY_NODE *, p))
3268 
3269 #define sk_X509_POLICY_NODE_shift(sk) \
3270   ((X509_POLICY_NODE *)sk_shift(      \
3271       CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_NODE) *, sk)))
3272 
3273 #define sk_X509_POLICY_NODE_push(sk, p)                             \
3274   sk_push(CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_NODE) *, sk), \
3275           CHECKED_CAST(void *, X509_POLICY_NODE *, p))
3276 
3277 #define sk_X509_POLICY_NODE_pop(sk) \
3278   ((X509_POLICY_NODE *)sk_pop(      \
3279       CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_NODE) *, sk)))
3280 
3281 #define sk_X509_POLICY_NODE_dup(sk)      \
3282   ((STACK_OF(X509_POLICY_NODE) *)sk_dup( \
3283       CHECKED_CAST(const _STACK *, const STACK_OF(X509_POLICY_NODE) *, sk)))
3284 
3285 #define sk_X509_POLICY_NODE_sort(sk) \
3286   sk_sort(CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_NODE) *, sk))
3287 
3288 #define sk_X509_POLICY_NODE_is_sorted(sk) \
3289   sk_is_sorted(                           \
3290       CHECKED_CAST(const _STACK *, const STACK_OF(X509_POLICY_NODE) *, sk))
3291 
3292 #define sk_X509_POLICY_NODE_set_cmp_func(sk, comp)                           \
3293   ((int (*)(const X509_POLICY_NODE **a, const X509_POLICY_NODE **b))         \
3294        sk_set_cmp_func(                                                      \
3295            CHECKED_CAST(_STACK *, STACK_OF(X509_POLICY_NODE) *, sk),         \
3296            CHECKED_CAST(stack_cmp_func, int (*)(const X509_POLICY_NODE **a,  \
3297                                                 const X509_POLICY_NODE **b), \
3298                         comp)))
3299 
3300 #define sk_X509_POLICY_NODE_deep_copy(sk, copy_func, free_func)             \
3301   ((STACK_OF(X509_POLICY_NODE) *)sk_deep_copy(                              \
3302       CHECKED_CAST(const _STACK *, const STACK_OF(X509_POLICY_NODE) *, sk), \
3303       CHECKED_CAST(void *(*)(void *),                                       \
3304                    X509_POLICY_NODE *(*)(X509_POLICY_NODE *), copy_func),   \
3305       CHECKED_CAST(void (*)(void *), void (*)(X509_POLICY_NODE *),          \
3306                    free_func)))
3307 
3308 /* X509_PURPOSE */
3309 #define sk_X509_PURPOSE_new(comp)                                              \
3310   ((STACK_OF(X509_PURPOSE) *)sk_new(CHECKED_CAST(                              \
3311       stack_cmp_func, int (*)(const X509_PURPOSE **a, const X509_PURPOSE **b), \
3312       comp)))
3313 
3314 #define sk_X509_PURPOSE_new_null() ((STACK_OF(X509_PURPOSE) *)sk_new_null())
3315 
3316 #define sk_X509_PURPOSE_num(sk) \
3317   sk_num(CHECKED_CAST(const _STACK *, const STACK_OF(X509_PURPOSE) *, sk))
3318 
3319 #define sk_X509_PURPOSE_zero(sk) \
3320   sk_zero(CHECKED_CAST(_STACK *, STACK_OF(X509_PURPOSE) *, sk));
3321 
3322 #define sk_X509_PURPOSE_value(sk, i) \
3323   ((X509_PURPOSE *)sk_value(         \
3324       CHECKED_CAST(const _STACK *, const STACK_OF(X509_PURPOSE) *, sk), (i)))
3325 
3326 #define sk_X509_PURPOSE_set(sk, i, p)                            \
3327   ((X509_PURPOSE *)sk_set(                                       \
3328       CHECKED_CAST(_STACK *, STACK_OF(X509_PURPOSE) *, sk), (i), \
3329       CHECKED_CAST(void *, X509_PURPOSE *, p)))
3330 
3331 #define sk_X509_PURPOSE_free(sk) \
3332   sk_free(CHECKED_CAST(_STACK *, STACK_OF(X509_PURPOSE) *, sk))
3333 
3334 #define sk_X509_PURPOSE_pop_free(sk, free_func)             \
3335   sk_pop_free(                                              \
3336       CHECKED_CAST(_STACK *, STACK_OF(X509_PURPOSE) *, sk), \
3337       CHECKED_CAST(void (*)(void *), void (*)(X509_PURPOSE *), free_func))
3338 
3339 #define sk_X509_PURPOSE_insert(sk, p, where)                      \
3340   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(X509_PURPOSE) *, sk), \
3341             CHECKED_CAST(void *, X509_PURPOSE *, p), (where))
3342 
3343 #define sk_X509_PURPOSE_delete(sk, where) \
3344   ((X509_PURPOSE *)sk_delete(             \
3345       CHECKED_CAST(_STACK *, STACK_OF(X509_PURPOSE) *, sk), (where)))
3346 
3347 #define sk_X509_PURPOSE_delete_ptr(sk, p)                   \
3348   ((X509_PURPOSE *)sk_delete_ptr(                           \
3349       CHECKED_CAST(_STACK *, STACK_OF(X509_PURPOSE) *, sk), \
3350       CHECKED_CAST(void *, X509_PURPOSE *, p)))
3351 
3352 #define sk_X509_PURPOSE_find(sk, out_index, p)                               \
3353   sk_find(CHECKED_CAST(_STACK *, STACK_OF(X509_PURPOSE) *, sk), (out_index), \
3354           CHECKED_CAST(void *, X509_PURPOSE *, p))
3355 
3356 #define sk_X509_PURPOSE_shift(sk) \
3357   ((X509_PURPOSE *)sk_shift(      \
3358       CHECKED_CAST(_STACK *, STACK_OF(X509_PURPOSE) *, sk)))
3359 
3360 #define sk_X509_PURPOSE_push(sk, p)                             \
3361   sk_push(CHECKED_CAST(_STACK *, STACK_OF(X509_PURPOSE) *, sk), \
3362           CHECKED_CAST(void *, X509_PURPOSE *, p))
3363 
3364 #define sk_X509_PURPOSE_pop(sk) \
3365   ((X509_PURPOSE *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(X509_PURPOSE) *, sk)))
3366 
3367 #define sk_X509_PURPOSE_dup(sk)      \
3368   ((STACK_OF(X509_PURPOSE) *)sk_dup( \
3369       CHECKED_CAST(const _STACK *, const STACK_OF(X509_PURPOSE) *, sk)))
3370 
3371 #define sk_X509_PURPOSE_sort(sk) \
3372   sk_sort(CHECKED_CAST(_STACK *, STACK_OF(X509_PURPOSE) *, sk))
3373 
3374 #define sk_X509_PURPOSE_is_sorted(sk) \
3375   sk_is_sorted(CHECKED_CAST(const _STACK *, const STACK_OF(X509_PURPOSE) *, sk))
3376 
3377 #define sk_X509_PURPOSE_set_cmp_func(sk, comp)                               \
3378   ((int (*)(const X509_PURPOSE **a, const X509_PURPOSE **b))sk_set_cmp_func( \
3379       CHECKED_CAST(_STACK *, STACK_OF(X509_PURPOSE) *, sk),                  \
3380       CHECKED_CAST(stack_cmp_func,                                           \
3381                    int (*)(const X509_PURPOSE **a, const X509_PURPOSE **b),  \
3382                    comp)))
3383 
3384 #define sk_X509_PURPOSE_deep_copy(sk, copy_func, free_func)              \
3385   ((STACK_OF(X509_PURPOSE) *)sk_deep_copy(                               \
3386       CHECKED_CAST(const _STACK *, const STACK_OF(X509_PURPOSE) *, sk),  \
3387       CHECKED_CAST(void *(*)(void *), X509_PURPOSE *(*)(X509_PURPOSE *), \
3388                    copy_func),                                           \
3389       CHECKED_CAST(void (*)(void *), void (*)(X509_PURPOSE *), free_func)))
3390 
3391 /* X509_REVOKED */
3392 #define sk_X509_REVOKED_new(comp)                                              \
3393   ((STACK_OF(X509_REVOKED) *)sk_new(CHECKED_CAST(                              \
3394       stack_cmp_func, int (*)(const X509_REVOKED **a, const X509_REVOKED **b), \
3395       comp)))
3396 
3397 #define sk_X509_REVOKED_new_null() ((STACK_OF(X509_REVOKED) *)sk_new_null())
3398 
3399 #define sk_X509_REVOKED_num(sk) \
3400   sk_num(CHECKED_CAST(const _STACK *, const STACK_OF(X509_REVOKED) *, sk))
3401 
3402 #define sk_X509_REVOKED_zero(sk) \
3403   sk_zero(CHECKED_CAST(_STACK *, STACK_OF(X509_REVOKED) *, sk));
3404 
3405 #define sk_X509_REVOKED_value(sk, i) \
3406   ((X509_REVOKED *)sk_value(         \
3407       CHECKED_CAST(const _STACK *, const STACK_OF(X509_REVOKED) *, sk), (i)))
3408 
3409 #define sk_X509_REVOKED_set(sk, i, p)                            \
3410   ((X509_REVOKED *)sk_set(                                       \
3411       CHECKED_CAST(_STACK *, STACK_OF(X509_REVOKED) *, sk), (i), \
3412       CHECKED_CAST(void *, X509_REVOKED *, p)))
3413 
3414 #define sk_X509_REVOKED_free(sk) \
3415   sk_free(CHECKED_CAST(_STACK *, STACK_OF(X509_REVOKED) *, sk))
3416 
3417 #define sk_X509_REVOKED_pop_free(sk, free_func)             \
3418   sk_pop_free(                                              \
3419       CHECKED_CAST(_STACK *, STACK_OF(X509_REVOKED) *, sk), \
3420       CHECKED_CAST(void (*)(void *), void (*)(X509_REVOKED *), free_func))
3421 
3422 #define sk_X509_REVOKED_insert(sk, p, where)                      \
3423   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(X509_REVOKED) *, sk), \
3424             CHECKED_CAST(void *, X509_REVOKED *, p), (where))
3425 
3426 #define sk_X509_REVOKED_delete(sk, where) \
3427   ((X509_REVOKED *)sk_delete(             \
3428       CHECKED_CAST(_STACK *, STACK_OF(X509_REVOKED) *, sk), (where)))
3429 
3430 #define sk_X509_REVOKED_delete_ptr(sk, p)                   \
3431   ((X509_REVOKED *)sk_delete_ptr(                           \
3432       CHECKED_CAST(_STACK *, STACK_OF(X509_REVOKED) *, sk), \
3433       CHECKED_CAST(void *, X509_REVOKED *, p)))
3434 
3435 #define sk_X509_REVOKED_find(sk, out_index, p)                               \
3436   sk_find(CHECKED_CAST(_STACK *, STACK_OF(X509_REVOKED) *, sk), (out_index), \
3437           CHECKED_CAST(void *, X509_REVOKED *, p))
3438 
3439 #define sk_X509_REVOKED_shift(sk) \
3440   ((X509_REVOKED *)sk_shift(      \
3441       CHECKED_CAST(_STACK *, STACK_OF(X509_REVOKED) *, sk)))
3442 
3443 #define sk_X509_REVOKED_push(sk, p)                             \
3444   sk_push(CHECKED_CAST(_STACK *, STACK_OF(X509_REVOKED) *, sk), \
3445           CHECKED_CAST(void *, X509_REVOKED *, p))
3446 
3447 #define sk_X509_REVOKED_pop(sk) \
3448   ((X509_REVOKED *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(X509_REVOKED) *, sk)))
3449 
3450 #define sk_X509_REVOKED_dup(sk)      \
3451   ((STACK_OF(X509_REVOKED) *)sk_dup( \
3452       CHECKED_CAST(const _STACK *, const STACK_OF(X509_REVOKED) *, sk)))
3453 
3454 #define sk_X509_REVOKED_sort(sk) \
3455   sk_sort(CHECKED_CAST(_STACK *, STACK_OF(X509_REVOKED) *, sk))
3456 
3457 #define sk_X509_REVOKED_is_sorted(sk) \
3458   sk_is_sorted(CHECKED_CAST(const _STACK *, const STACK_OF(X509_REVOKED) *, sk))
3459 
3460 #define sk_X509_REVOKED_set_cmp_func(sk, comp)                               \
3461   ((int (*)(const X509_REVOKED **a, const X509_REVOKED **b))sk_set_cmp_func( \
3462       CHECKED_CAST(_STACK *, STACK_OF(X509_REVOKED) *, sk),                  \
3463       CHECKED_CAST(stack_cmp_func,                                           \
3464                    int (*)(const X509_REVOKED **a, const X509_REVOKED **b),  \
3465                    comp)))
3466 
3467 #define sk_X509_REVOKED_deep_copy(sk, copy_func, free_func)              \
3468   ((STACK_OF(X509_REVOKED) *)sk_deep_copy(                               \
3469       CHECKED_CAST(const _STACK *, const STACK_OF(X509_REVOKED) *, sk),  \
3470       CHECKED_CAST(void *(*)(void *), X509_REVOKED *(*)(X509_REVOKED *), \
3471                    copy_func),                                           \
3472       CHECKED_CAST(void (*)(void *), void (*)(X509_REVOKED *), free_func)))
3473 
3474 /* X509_TRUST */
3475 #define sk_X509_TRUST_new(comp)                                            \
3476   ((STACK_OF(X509_TRUST) *)sk_new(CHECKED_CAST(                            \
3477       stack_cmp_func, int (*)(const X509_TRUST **a, const X509_TRUST **b), \
3478       comp)))
3479 
3480 #define sk_X509_TRUST_new_null() ((STACK_OF(X509_TRUST) *)sk_new_null())
3481 
3482 #define sk_X509_TRUST_num(sk) \
3483   sk_num(CHECKED_CAST(const _STACK *, const STACK_OF(X509_TRUST) *, sk))
3484 
3485 #define sk_X509_TRUST_zero(sk) \
3486   sk_zero(CHECKED_CAST(_STACK *, STACK_OF(X509_TRUST) *, sk));
3487 
3488 #define sk_X509_TRUST_value(sk, i) \
3489   ((X509_TRUST *)sk_value(         \
3490       CHECKED_CAST(const _STACK *, const STACK_OF(X509_TRUST) *, sk), (i)))
3491 
3492 #define sk_X509_TRUST_set(sk, i, p)                                         \
3493   ((X509_TRUST *)sk_set(CHECKED_CAST(_STACK *, STACK_OF(X509_TRUST) *, sk), \
3494                         (i), CHECKED_CAST(void *, X509_TRUST *, p)))
3495 
3496 #define sk_X509_TRUST_free(sk) \
3497   sk_free(CHECKED_CAST(_STACK *, STACK_OF(X509_TRUST) *, sk))
3498 
3499 #define sk_X509_TRUST_pop_free(sk, free_func)             \
3500   sk_pop_free(                                            \
3501       CHECKED_CAST(_STACK *, STACK_OF(X509_TRUST) *, sk), \
3502       CHECKED_CAST(void (*)(void *), void (*)(X509_TRUST *), free_func))
3503 
3504 #define sk_X509_TRUST_insert(sk, p, where)                      \
3505   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(X509_TRUST) *, sk), \
3506             CHECKED_CAST(void *, X509_TRUST *, p), (where))
3507 
3508 #define sk_X509_TRUST_delete(sk, where)                                        \
3509   ((X509_TRUST *)sk_delete(CHECKED_CAST(_STACK *, STACK_OF(X509_TRUST) *, sk), \
3510                            (where)))
3511 
3512 #define sk_X509_TRUST_delete_ptr(sk, p)                   \
3513   ((X509_TRUST *)sk_delete_ptr(                           \
3514       CHECKED_CAST(_STACK *, STACK_OF(X509_TRUST) *, sk), \
3515       CHECKED_CAST(void *, X509_TRUST *, p)))
3516 
3517 #define sk_X509_TRUST_find(sk, out_index, p)                               \
3518   sk_find(CHECKED_CAST(_STACK *, STACK_OF(X509_TRUST) *, sk), (out_index), \
3519           CHECKED_CAST(void *, X509_TRUST *, p))
3520 
3521 #define sk_X509_TRUST_shift(sk) \
3522   ((X509_TRUST *)sk_shift(CHECKED_CAST(_STACK *, STACK_OF(X509_TRUST) *, sk)))
3523 
3524 #define sk_X509_TRUST_push(sk, p)                             \
3525   sk_push(CHECKED_CAST(_STACK *, STACK_OF(X509_TRUST) *, sk), \
3526           CHECKED_CAST(void *, X509_TRUST *, p))
3527 
3528 #define sk_X509_TRUST_pop(sk) \
3529   ((X509_TRUST *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(X509_TRUST) *, sk)))
3530 
3531 #define sk_X509_TRUST_dup(sk)      \
3532   ((STACK_OF(X509_TRUST) *)sk_dup( \
3533       CHECKED_CAST(const _STACK *, const STACK_OF(X509_TRUST) *, sk)))
3534 
3535 #define sk_X509_TRUST_sort(sk) \
3536   sk_sort(CHECKED_CAST(_STACK *, STACK_OF(X509_TRUST) *, sk))
3537 
3538 #define sk_X509_TRUST_is_sorted(sk) \
3539   sk_is_sorted(CHECKED_CAST(const _STACK *, const STACK_OF(X509_TRUST) *, sk))
3540 
3541 #define sk_X509_TRUST_set_cmp_func(sk, comp)                             \
3542   ((int (*)(const X509_TRUST **a, const X509_TRUST **b))sk_set_cmp_func( \
3543       CHECKED_CAST(_STACK *, STACK_OF(X509_TRUST) *, sk),                \
3544       CHECKED_CAST(stack_cmp_func,                                       \
3545                    int (*)(const X509_TRUST **a, const X509_TRUST **b),  \
3546                    comp)))
3547 
3548 #define sk_X509_TRUST_deep_copy(sk, copy_func, free_func)             \
3549   ((STACK_OF(X509_TRUST) *)sk_deep_copy(                              \
3550       CHECKED_CAST(const _STACK *, const STACK_OF(X509_TRUST) *, sk), \
3551       CHECKED_CAST(void *(*)(void *), X509_TRUST *(*)(X509_TRUST *),  \
3552                    copy_func),                                        \
3553       CHECKED_CAST(void (*)(void *), void (*)(X509_TRUST *), free_func)))
3554 
3555 /* X509_VERIFY_PARAM */
3556 #define sk_X509_VERIFY_PARAM_new(comp)                                   \
3557   ((STACK_OF(X509_VERIFY_PARAM) *)sk_new(CHECKED_CAST(                   \
3558       stack_cmp_func,                                                    \
3559       int (*)(const X509_VERIFY_PARAM **a, const X509_VERIFY_PARAM **b), \
3560       comp)))
3561 
3562 #define sk_X509_VERIFY_PARAM_new_null() \
3563   ((STACK_OF(X509_VERIFY_PARAM) *)sk_new_null())
3564 
3565 #define sk_X509_VERIFY_PARAM_num(sk) \
3566   sk_num(CHECKED_CAST(const _STACK *, const STACK_OF(X509_VERIFY_PARAM) *, sk))
3567 
3568 #define sk_X509_VERIFY_PARAM_zero(sk) \
3569   sk_zero(CHECKED_CAST(_STACK *, STACK_OF(X509_VERIFY_PARAM) *, sk));
3570 
3571 #define sk_X509_VERIFY_PARAM_value(sk, i)                                    \
3572   ((X509_VERIFY_PARAM *)sk_value(                                            \
3573       CHECKED_CAST(const _STACK *, const STACK_OF(X509_VERIFY_PARAM) *, sk), \
3574       (i)))
3575 
3576 #define sk_X509_VERIFY_PARAM_set(sk, i, p)                            \
3577   ((X509_VERIFY_PARAM *)sk_set(                                       \
3578       CHECKED_CAST(_STACK *, STACK_OF(X509_VERIFY_PARAM) *, sk), (i), \
3579       CHECKED_CAST(void *, X509_VERIFY_PARAM *, p)))
3580 
3581 #define sk_X509_VERIFY_PARAM_free(sk) \
3582   sk_free(CHECKED_CAST(_STACK *, STACK_OF(X509_VERIFY_PARAM) *, sk))
3583 
3584 #define sk_X509_VERIFY_PARAM_pop_free(sk, free_func)                        \
3585   sk_pop_free(CHECKED_CAST(_STACK *, STACK_OF(X509_VERIFY_PARAM) *, sk),    \
3586               CHECKED_CAST(void (*)(void *), void (*)(X509_VERIFY_PARAM *), \
3587                            free_func))
3588 
3589 #define sk_X509_VERIFY_PARAM_insert(sk, p, where)                      \
3590   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(X509_VERIFY_PARAM) *, sk), \
3591             CHECKED_CAST(void *, X509_VERIFY_PARAM *, p), (where))
3592 
3593 #define sk_X509_VERIFY_PARAM_delete(sk, where) \
3594   ((X509_VERIFY_PARAM *)sk_delete(             \
3595       CHECKED_CAST(_STACK *, STACK_OF(X509_VERIFY_PARAM) *, sk), (where)))
3596 
3597 #define sk_X509_VERIFY_PARAM_delete_ptr(sk, p)                   \
3598   ((X509_VERIFY_PARAM *)sk_delete_ptr(                           \
3599       CHECKED_CAST(_STACK *, STACK_OF(X509_VERIFY_PARAM) *, sk), \
3600       CHECKED_CAST(void *, X509_VERIFY_PARAM *, p)))
3601 
3602 #define sk_X509_VERIFY_PARAM_find(sk, out_index, p)                  \
3603   sk_find(CHECKED_CAST(_STACK *, STACK_OF(X509_VERIFY_PARAM) *, sk), \
3604           (out_index), CHECKED_CAST(void *, X509_VERIFY_PARAM *, p))
3605 
3606 #define sk_X509_VERIFY_PARAM_shift(sk) \
3607   ((X509_VERIFY_PARAM *)sk_shift(      \
3608       CHECKED_CAST(_STACK *, STACK_OF(X509_VERIFY_PARAM) *, sk)))
3609 
3610 #define sk_X509_VERIFY_PARAM_push(sk, p)                             \
3611   sk_push(CHECKED_CAST(_STACK *, STACK_OF(X509_VERIFY_PARAM) *, sk), \
3612           CHECKED_CAST(void *, X509_VERIFY_PARAM *, p))
3613 
3614 #define sk_X509_VERIFY_PARAM_pop(sk) \
3615   ((X509_VERIFY_PARAM *)sk_pop(      \
3616       CHECKED_CAST(_STACK *, STACK_OF(X509_VERIFY_PARAM) *, sk)))
3617 
3618 #define sk_X509_VERIFY_PARAM_dup(sk)      \
3619   ((STACK_OF(X509_VERIFY_PARAM) *)sk_dup( \
3620       CHECKED_CAST(const _STACK *, const STACK_OF(X509_VERIFY_PARAM) *, sk)))
3621 
3622 #define sk_X509_VERIFY_PARAM_sort(sk) \
3623   sk_sort(CHECKED_CAST(_STACK *, STACK_OF(X509_VERIFY_PARAM) *, sk))
3624 
3625 #define sk_X509_VERIFY_PARAM_is_sorted(sk) \
3626   sk_is_sorted(                            \
3627       CHECKED_CAST(const _STACK *, const STACK_OF(X509_VERIFY_PARAM) *, sk))
3628 
3629 #define sk_X509_VERIFY_PARAM_set_cmp_func(sk, comp)                           \
3630   ((int (*)(const X509_VERIFY_PARAM **a, const X509_VERIFY_PARAM **b))        \
3631        sk_set_cmp_func(                                                       \
3632            CHECKED_CAST(_STACK *, STACK_OF(X509_VERIFY_PARAM) *, sk),         \
3633            CHECKED_CAST(stack_cmp_func, int (*)(const X509_VERIFY_PARAM **a,  \
3634                                                 const X509_VERIFY_PARAM **b), \
3635                         comp)))
3636 
3637 #define sk_X509_VERIFY_PARAM_deep_copy(sk, copy_func, free_func)             \
3638   ((STACK_OF(X509_VERIFY_PARAM) *)sk_deep_copy(                              \
3639       CHECKED_CAST(const _STACK *, const STACK_OF(X509_VERIFY_PARAM) *, sk), \
3640       CHECKED_CAST(void *(*)(void *),                                        \
3641                    X509_VERIFY_PARAM *(*)(X509_VERIFY_PARAM *), copy_func),  \
3642       CHECKED_CAST(void (*)(void *), void (*)(X509_VERIFY_PARAM *),          \
3643                    free_func)))
3644 
3645 /* void */
3646 #define sk_void_new(comp)                 \
3647   ((STACK_OF(void) *)sk_new(CHECKED_CAST( \
3648       stack_cmp_func, int (*)(const void **a, const void **b), comp)))
3649 
3650 #define sk_void_new_null() ((STACK_OF(void) *)sk_new_null())
3651 
3652 #define sk_void_num(sk) \
3653   sk_num(CHECKED_CAST(const _STACK *, const STACK_OF(void) *, sk))
3654 
3655 #define sk_void_zero(sk) sk_zero(CHECKED_CAST(_STACK *, STACK_OF(void) *, sk));
3656 
3657 #define sk_void_value(sk, i)                                                  \
3658   ((void *)sk_value(CHECKED_CAST(const _STACK *, const STACK_OF(void) *, sk), \
3659                     (i)))
3660 
3661 #define sk_void_set(sk, i, p)                                        \
3662   ((void *)sk_set(CHECKED_CAST(_STACK *, STACK_OF(void) *, sk), (i), \
3663                   CHECKED_CAST(void *, void *, p)))
3664 
3665 #define sk_void_free(sk) sk_free(CHECKED_CAST(_STACK *, STACK_OF(void) *, sk))
3666 
3667 #define sk_void_pop_free(sk, free_func)                     \
3668   sk_pop_free(CHECKED_CAST(_STACK *, STACK_OF(void) *, sk), \
3669               CHECKED_CAST(void (*)(void *), void (*)(void *), free_func))
3670 
3671 #define sk_void_insert(sk, p, where)                      \
3672   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(void) *, sk), \
3673             CHECKED_CAST(void *, void *, p), (where))
3674 
3675 #define sk_void_delete(sk, where) \
3676   ((void *)sk_delete(CHECKED_CAST(_STACK *, STACK_OF(void) *, sk), (where)))
3677 
3678 #define sk_void_delete_ptr(sk, p)                                      \
3679   ((void *)sk_delete_ptr(CHECKED_CAST(_STACK *, STACK_OF(void) *, sk), \
3680                          CHECKED_CAST(void *, void *, p)))
3681 
3682 #define sk_void_find(sk, out_index, p)                               \
3683   sk_find(CHECKED_CAST(_STACK *, STACK_OF(void) *, sk), (out_index), \
3684           CHECKED_CAST(void *, void *, p))
3685 
3686 #define sk_void_shift(sk) \
3687   ((void *)sk_shift(CHECKED_CAST(_STACK *, STACK_OF(void) *, sk)))
3688 
3689 #define sk_void_push(sk, p)                             \
3690   sk_push(CHECKED_CAST(_STACK *, STACK_OF(void) *, sk), \
3691           CHECKED_CAST(void *, void *, p))
3692 
3693 #define sk_void_pop(sk) \
3694   ((void *)sk_pop(CHECKED_CAST(_STACK *, STACK_OF(void) *, sk)))
3695 
3696 #define sk_void_dup(sk)      \
3697   ((STACK_OF(void) *)sk_dup( \
3698       CHECKED_CAST(const _STACK *, const STACK_OF(void) *, sk)))
3699 
3700 #define sk_void_sort(sk) sk_sort(CHECKED_CAST(_STACK *, STACK_OF(void) *, sk))
3701 
3702 #define sk_void_is_sorted(sk) \
3703   sk_is_sorted(CHECKED_CAST(const _STACK *, const STACK_OF(void) *, sk))
3704 
3705 #define sk_void_set_cmp_func(sk, comp)                                      \
3706   ((int (*)(const void **a, const void **b))sk_set_cmp_func(                \
3707       CHECKED_CAST(_STACK *, STACK_OF(void) *, sk),                         \
3708       CHECKED_CAST(stack_cmp_func, int (*)(const void **a, const void **b), \
3709                    comp)))
3710 
3711 #define sk_void_deep_copy(sk, copy_func, free_func)                  \
3712   ((STACK_OF(void) *)sk_deep_copy(                                   \
3713       CHECKED_CAST(const _STACK *, const STACK_OF(void) *, sk),      \
3714       CHECKED_CAST(void *(*)(void *), void *(*)(void *), copy_func), \
3715       CHECKED_CAST(void (*)(void *), void (*)(void *), free_func)))
3716 
3717 /* SRTP_PROTECTION_PROFILE */
3718 #define sk_SRTP_PROTECTION_PROFILE_new(comp)                            \
3719   ((STACK_OF(SRTP_PROTECTION_PROFILE) *)sk_new(CHECKED_CAST(            \
3720       stack_cmp_func, int (*)(const const SRTP_PROTECTION_PROFILE **a,  \
3721                               const const SRTP_PROTECTION_PROFILE **b), \
3722       comp)))
3723 
3724 #define sk_SRTP_PROTECTION_PROFILE_new_null() \
3725   ((STACK_OF(SRTP_PROTECTION_PROFILE) *)sk_new_null())
3726 
3727 #define sk_SRTP_PROTECTION_PROFILE_num(sk) \
3728   sk_num(CHECKED_CAST(const _STACK *,      \
3729                       const STACK_OF(SRTP_PROTECTION_PROFILE) *, sk))
3730 
3731 #define sk_SRTP_PROTECTION_PROFILE_zero(sk) \
3732   sk_zero(CHECKED_CAST(_STACK *, STACK_OF(SRTP_PROTECTION_PROFILE) *, sk));
3733 
3734 #define sk_SRTP_PROTECTION_PROFILE_value(sk, i)                               \
3735   ((const SRTP_PROTECTION_PROFILE *)sk_value(                                 \
3736       CHECKED_CAST(const _STACK *, const STACK_OF(SRTP_PROTECTION_PROFILE) *, \
3737                    sk),                                                       \
3738       (i)))
3739 
3740 #define sk_SRTP_PROTECTION_PROFILE_set(sk, i, p)                            \
3741   ((const SRTP_PROTECTION_PROFILE *)sk_set(                                 \
3742       CHECKED_CAST(_STACK *, STACK_OF(SRTP_PROTECTION_PROFILE) *, sk), (i), \
3743       CHECKED_CAST(void *, const SRTP_PROTECTION_PROFILE *, p)))
3744 
3745 #define sk_SRTP_PROTECTION_PROFILE_free(sk) \
3746   sk_free(CHECKED_CAST(_STACK *, STACK_OF(SRTP_PROTECTION_PROFILE) *, sk))
3747 
3748 #define sk_SRTP_PROTECTION_PROFILE_pop_free(sk, free_func)             \
3749   sk_pop_free(                                                         \
3750       CHECKED_CAST(_STACK *, STACK_OF(SRTP_PROTECTION_PROFILE) *, sk), \
3751       CHECKED_CAST(void (*)(void *),                                   \
3752                    void (*)(const SRTP_PROTECTION_PROFILE *), free_func))
3753 
3754 #define sk_SRTP_PROTECTION_PROFILE_insert(sk, p, where)                      \
3755   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(SRTP_PROTECTION_PROFILE) *, sk), \
3756             CHECKED_CAST(void *, const SRTP_PROTECTION_PROFILE *, p), (where))
3757 
3758 #define sk_SRTP_PROTECTION_PROFILE_delete(sk, where)                   \
3759   ((const SRTP_PROTECTION_PROFILE *)sk_delete(                         \
3760       CHECKED_CAST(_STACK *, STACK_OF(SRTP_PROTECTION_PROFILE) *, sk), \
3761       (where)))
3762 
3763 #define sk_SRTP_PROTECTION_PROFILE_delete_ptr(sk, p)                   \
3764   ((const SRTP_PROTECTION_PROFILE *)sk_delete_ptr(                     \
3765       CHECKED_CAST(_STACK *, STACK_OF(SRTP_PROTECTION_PROFILE) *, sk), \
3766       CHECKED_CAST(void *, const SRTP_PROTECTION_PROFILE *, p)))
3767 
3768 #define sk_SRTP_PROTECTION_PROFILE_find(sk, out_index, p)                  \
3769   sk_find(CHECKED_CAST(_STACK *, STACK_OF(SRTP_PROTECTION_PROFILE) *, sk), \
3770           (out_index),                                                     \
3771           CHECKED_CAST(void *, const SRTP_PROTECTION_PROFILE *, p))
3772 
3773 #define sk_SRTP_PROTECTION_PROFILE_shift(sk)  \
3774   ((const SRTP_PROTECTION_PROFILE *)sk_shift( \
3775       CHECKED_CAST(_STACK *, STACK_OF(SRTP_PROTECTION_PROFILE) *, sk)))
3776 
3777 #define sk_SRTP_PROTECTION_PROFILE_push(sk, p)                             \
3778   sk_push(CHECKED_CAST(_STACK *, STACK_OF(SRTP_PROTECTION_PROFILE) *, sk), \
3779           CHECKED_CAST(void *, const SRTP_PROTECTION_PROFILE *, p))
3780 
3781 #define sk_SRTP_PROTECTION_PROFILE_pop(sk)  \
3782   ((const SRTP_PROTECTION_PROFILE *)sk_pop( \
3783       CHECKED_CAST(_STACK *, STACK_OF(SRTP_PROTECTION_PROFILE) *, sk)))
3784 
3785 #define sk_SRTP_PROTECTION_PROFILE_dup(sk)                   \
3786   ((STACK_OF(SRTP_PROTECTION_PROFILE) *)sk_dup(CHECKED_CAST( \
3787       const _STACK *, const STACK_OF(SRTP_PROTECTION_PROFILE) *, sk)))
3788 
3789 #define sk_SRTP_PROTECTION_PROFILE_sort(sk) \
3790   sk_sort(CHECKED_CAST(_STACK *, STACK_OF(SRTP_PROTECTION_PROFILE) *, sk))
3791 
3792 #define sk_SRTP_PROTECTION_PROFILE_is_sorted(sk) \
3793   sk_is_sorted(CHECKED_CAST(const _STACK *,      \
3794                             const STACK_OF(SRTP_PROTECTION_PROFILE) *, sk))
3795 
3796 #define sk_SRTP_PROTECTION_PROFILE_set_cmp_func(sk, comp)                   \
3797   ((int (*)(const SRTP_PROTECTION_PROFILE **a,                              \
3798             const SRTP_PROTECTION_PROFILE **b))                             \
3799        sk_set_cmp_func(                                                     \
3800            CHECKED_CAST(_STACK *, STACK_OF(SRTP_PROTECTION_PROFILE) *, sk), \
3801            CHECKED_CAST(stack_cmp_func,                                     \
3802                         int (*)(const SRTP_PROTECTION_PROFILE **a,          \
3803                                 const SRTP_PROTECTION_PROFILE **b),         \
3804                         comp)))
3805 
3806 #define sk_SRTP_PROTECTION_PROFILE_deep_copy(sk, copy_func, free_func)         \
3807   ((STACK_OF(SRTP_PROTECTION_PROFILE) *)sk_deep_copy(                          \
3808       CHECKED_CAST(const _STACK *, const STACK_OF(SRTP_PROTECTION_PROFILE) *,  \
3809                    sk),                                                        \
3810       CHECKED_CAST(                                                            \
3811           void *(*)(void *),                                                   \
3812           const SRTP_PROTECTION_PROFILE *(*)(const SRTP_PROTECTION_PROFILE *), \
3813           copy_func),                                                          \
3814       CHECKED_CAST(void (*)(void *),                                           \
3815                    void (*)(const SRTP_PROTECTION_PROFILE *), free_func)))
3816 
3817 /* SSL_CIPHER */
3818 #define sk_SSL_CIPHER_new(comp)                 \
3819   ((STACK_OF(SSL_CIPHER) *)sk_new(CHECKED_CAST( \
3820       stack_cmp_func,                           \
3821       int (*)(const const SSL_CIPHER **a, const const SSL_CIPHER **b), comp)))
3822 
3823 #define sk_SSL_CIPHER_new_null() ((STACK_OF(SSL_CIPHER) *)sk_new_null())
3824 
3825 #define sk_SSL_CIPHER_num(sk) \
3826   sk_num(CHECKED_CAST(const _STACK *, const STACK_OF(SSL_CIPHER) *, sk))
3827 
3828 #define sk_SSL_CIPHER_zero(sk) \
3829   sk_zero(CHECKED_CAST(_STACK *, STACK_OF(SSL_CIPHER) *, sk));
3830 
3831 #define sk_SSL_CIPHER_value(sk, i) \
3832   ((const SSL_CIPHER *)sk_value(   \
3833       CHECKED_CAST(const _STACK *, const STACK_OF(SSL_CIPHER) *, sk), (i)))
3834 
3835 #define sk_SSL_CIPHER_set(sk, i, p)                            \
3836   ((const SSL_CIPHER *)sk_set(                                 \
3837       CHECKED_CAST(_STACK *, STACK_OF(SSL_CIPHER) *, sk), (i), \
3838       CHECKED_CAST(void *, const SSL_CIPHER *, p)))
3839 
3840 #define sk_SSL_CIPHER_free(sk) \
3841   sk_free(CHECKED_CAST(_STACK *, STACK_OF(SSL_CIPHER) *, sk))
3842 
3843 #define sk_SSL_CIPHER_pop_free(sk, free_func)             \
3844   sk_pop_free(                                            \
3845       CHECKED_CAST(_STACK *, STACK_OF(SSL_CIPHER) *, sk), \
3846       CHECKED_CAST(void (*)(void *), void (*)(const SSL_CIPHER *), free_func))
3847 
3848 #define sk_SSL_CIPHER_insert(sk, p, where)                      \
3849   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(SSL_CIPHER) *, sk), \
3850             CHECKED_CAST(void *, const SSL_CIPHER *, p), (where))
3851 
3852 #define sk_SSL_CIPHER_delete(sk, where) \
3853   ((const SSL_CIPHER *)sk_delete(       \
3854       CHECKED_CAST(_STACK *, STACK_OF(SSL_CIPHER) *, sk), (where)))
3855 
3856 #define sk_SSL_CIPHER_delete_ptr(sk, p)                   \
3857   ((const SSL_CIPHER *)sk_delete_ptr(                     \
3858       CHECKED_CAST(_STACK *, STACK_OF(SSL_CIPHER) *, sk), \
3859       CHECKED_CAST(void *, const SSL_CIPHER *, p)))
3860 
3861 #define sk_SSL_CIPHER_find(sk, out_index, p)                               \
3862   sk_find(CHECKED_CAST(_STACK *, STACK_OF(SSL_CIPHER) *, sk), (out_index), \
3863           CHECKED_CAST(void *, const SSL_CIPHER *, p))
3864 
3865 #define sk_SSL_CIPHER_shift(sk)  \
3866   ((const SSL_CIPHER *)sk_shift( \
3867       CHECKED_CAST(_STACK *, STACK_OF(SSL_CIPHER) *, sk)))
3868 
3869 #define sk_SSL_CIPHER_push(sk, p)                             \
3870   sk_push(CHECKED_CAST(_STACK *, STACK_OF(SSL_CIPHER) *, sk), \
3871           CHECKED_CAST(void *, const SSL_CIPHER *, p))
3872 
3873 #define sk_SSL_CIPHER_pop(sk)  \
3874   ((const SSL_CIPHER *)sk_pop( \
3875       CHECKED_CAST(_STACK *, STACK_OF(SSL_CIPHER) *, sk)))
3876 
3877 #define sk_SSL_CIPHER_dup(sk)      \
3878   ((STACK_OF(SSL_CIPHER) *)sk_dup( \
3879       CHECKED_CAST(const _STACK *, const STACK_OF(SSL_CIPHER) *, sk)))
3880 
3881 #define sk_SSL_CIPHER_sort(sk) \
3882   sk_sort(CHECKED_CAST(_STACK *, STACK_OF(SSL_CIPHER) *, sk))
3883 
3884 #define sk_SSL_CIPHER_is_sorted(sk) \
3885   sk_is_sorted(CHECKED_CAST(const _STACK *, const STACK_OF(SSL_CIPHER) *, sk))
3886 
3887 #define sk_SSL_CIPHER_set_cmp_func(sk, comp)                             \
3888   ((int (*)(const SSL_CIPHER **a, const SSL_CIPHER **b))sk_set_cmp_func( \
3889       CHECKED_CAST(_STACK *, STACK_OF(SSL_CIPHER) *, sk),                \
3890       CHECKED_CAST(stack_cmp_func,                                       \
3891                    int (*)(const SSL_CIPHER **a, const SSL_CIPHER **b),  \
3892                    comp)))
3893 
3894 #define sk_SSL_CIPHER_deep_copy(sk, copy_func, free_func)                 \
3895   ((STACK_OF(SSL_CIPHER) *)sk_deep_copy(                                  \
3896       CHECKED_CAST(const _STACK *, const STACK_OF(SSL_CIPHER) *, sk),     \
3897       CHECKED_CAST(void *(*)(void *),                                     \
3898                    const SSL_CIPHER *(*)(const SSL_CIPHER *), copy_func), \
3899       CHECKED_CAST(void (*)(void *), void (*)(const SSL_CIPHER *),        \
3900                    free_func)))
3901 
3902 /* OPENSSL_STRING */
3903 #define sk_OPENSSL_STRING_new(comp)                 \
3904   ((STACK_OF(OPENSSL_STRING) *)sk_new(CHECKED_CAST( \
3905       stack_cmp_func,                               \
3906       int (*)(const OPENSSL_STRING *a, const OPENSSL_STRING *b), comp)))
3907 
3908 #define sk_OPENSSL_STRING_new_null() ((STACK_OF(OPENSSL_STRING) *)sk_new_null())
3909 
3910 #define sk_OPENSSL_STRING_num(sk) \
3911   sk_num(CHECKED_CAST(const _STACK *, const STACK_OF(OPENSSL_STRING) *, sk))
3912 
3913 #define sk_OPENSSL_STRING_zero(sk) \
3914   sk_zero(CHECKED_CAST(_STACK *, STACK_OF(OPENSSL_STRING) *, sk));
3915 
3916 #define sk_OPENSSL_STRING_value(sk, i)                                    \
3917   ((OPENSSL_STRING)sk_value(                                              \
3918       CHECKED_CAST(const _STACK *, const STACK_OF(OPENSSL_STRING) *, sk), \
3919       (i)))
3920 
3921 #define sk_OPENSSL_STRING_set(sk, i, p)                            \
3922   ((OPENSSL_STRING)sk_set(                                         \
3923       CHECKED_CAST(_STACK *, STACK_OF(OPENSSL_STRING) *, sk), (i), \
3924       CHECKED_CAST(void *, OPENSSL_STRING, p)))
3925 
3926 #define sk_OPENSSL_STRING_free(sk) \
3927   sk_free(CHECKED_CAST(_STACK *, STACK_OF(OPENSSL_STRING) *, sk))
3928 
3929 #define sk_OPENSSL_STRING_pop_free(sk, free_func)             \
3930   sk_pop_free(                                                \
3931       CHECKED_CAST(_STACK *, STACK_OF(OPENSSL_STRING) *, sk), \
3932       CHECKED_CAST(void (*)(void *), void (*)(OPENSSL_STRING), free_func))
3933 
3934 #define sk_OPENSSL_STRING_insert(sk, p, where)                      \
3935   sk_insert(CHECKED_CAST(_STACK *, STACK_OF(OPENSSL_STRING) *, sk), \
3936             CHECKED_CAST(void *, OPENSSL_STRING, p), (where))
3937 
3938 #define sk_OPENSSL_STRING_delete(sk, where) \
3939   ((OPENSSL_STRING)sk_delete(               \
3940       CHECKED_CAST(_STACK *, STACK_OF(OPENSSL_STRING) *, sk), (where)))
3941 
3942 #define sk_OPENSSL_STRING_delete_ptr(sk, p)                   \
3943   ((OPENSSL_STRING)sk_delete_ptr(                             \
3944       CHECKED_CAST(_STACK *, STACK_OF(OPENSSL_STRING) *, sk), \
3945       CHECKED_CAST(void *, OPENSSL_STRING, p)))
3946 
3947 #define sk_OPENSSL_STRING_find(sk, out_index, p)                               \
3948   sk_find(CHECKED_CAST(_STACK *, STACK_OF(OPENSSL_STRING) *, sk), (out_index), \
3949           CHECKED_CAST(void *, OPENSSL_STRING, p))
3950 
3951 #define sk_OPENSSL_STRING_shift(sk) \
3952   ((OPENSSL_STRING)sk_shift(        \
3953       CHECKED_CAST(_STACK *, STACK_OF(OPENSSL_STRING) *, sk)))
3954 
3955 #define sk_OPENSSL_STRING_push(sk, p)                             \
3956   sk_push(CHECKED_CAST(_STACK *, STACK_OF(OPENSSL_STRING) *, sk), \
3957           CHECKED_CAST(void *, OPENSSL_STRING, p))
3958 
3959 #define sk_OPENSSL_STRING_pop(sk) \
3960   ((OPENSSL_STRING)sk_pop(        \
3961       CHECKED_CAST(_STACK *, STACK_OF(OPENSSL_STRING) *, sk)))
3962 
3963 #define sk_OPENSSL_STRING_dup(sk)      \
3964   ((STACK_OF(OPENSSL_STRING) *)sk_dup( \
3965       CHECKED_CAST(const _STACK *, const STACK_OF(OPENSSL_STRING) *, sk)))
3966 
3967 #define sk_OPENSSL_STRING_sort(sk) \
3968   sk_sort(CHECKED_CAST(_STACK *, STACK_OF(OPENSSL_STRING) *, sk))
3969 
3970 #define sk_OPENSSL_STRING_is_sorted(sk) \
3971   sk_is_sorted(                         \
3972       CHECKED_CAST(const _STACK *, const STACK_OF(OPENSSL_STRING) *, sk))
3973 
3974 #define sk_OPENSSL_STRING_set_cmp_func(sk, comp)                           \
3975   ((int (*)(const OPENSSL_STRING **a, const OPENSSL_STRING **b))           \
3976        sk_set_cmp_func(                                                    \
3977            CHECKED_CAST(_STACK *, STACK_OF(OPENSSL_STRING) *, sk),         \
3978            CHECKED_CAST(stack_cmp_func, int (*)(const OPENSSL_STRING **a,  \
3979                                                 const OPENSSL_STRING **b), \
3980                         comp)))
3981 
3982 #define sk_OPENSSL_STRING_deep_copy(sk, copy_func, free_func)             \
3983   ((STACK_OF(OPENSSL_STRING) *)sk_deep_copy(                              \
3984       CHECKED_CAST(const _STACK *, const STACK_OF(OPENSSL_STRING) *, sk), \
3985       CHECKED_CAST(void *(*)(void *), OPENSSL_STRING (*)(OPENSSL_STRING), \
3986                    copy_func),                                            \
3987       CHECKED_CAST(void (*)(void *), void (*)(OPENSSL_STRING), free_func)))
3988