ZTS: Fix io_uring support check
[zfs.git] / include / libuutil_impl.h
blobb9907447afd92f4653d7f7de3cb1b0384c190b8a
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or https://opensource.org/licenses/CDDL-1.0.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
20 * CDDL HEADER END
23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _LIBUUTIL_IMPL_H
28 #define _LIBUUTIL_IMPL_H
32 #include <libuutil.h>
33 #include <pthread.h>
35 #include <sys/avl_impl.h>
36 #include <sys/byteorder.h>
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
42 void uu_set_error(uint_t);
45 void uu_panic(const char *format, ...) __attribute__((format(printf, 1, 2)));
49 * For debugging purposes, libuutil keeps around linked lists of all uu_lists
50 * and uu_avls, along with pointers to their parents. These can cause false
51 * negatives when looking for memory leaks, so we encode the pointers by
52 * storing them with swapped endianness; this is not perfect, but it's about
53 * the best we can do without wasting a lot of space.
55 #ifdef _LP64
56 #define UU_PTR_ENCODE(ptr) BSWAP_64((uintptr_t)(void *)(ptr))
57 #else
58 #define UU_PTR_ENCODE(ptr) BSWAP_32((uintptr_t)(void *)(ptr))
59 #endif
61 #define UU_PTR_DECODE(ptr) ((void *)UU_PTR_ENCODE(ptr))
64 * uu_list structures
66 typedef struct uu_list_node_impl {
67 struct uu_list_node_impl *uln_next;
68 struct uu_list_node_impl *uln_prev;
69 } uu_list_node_impl_t;
71 struct uu_list_walk {
72 uu_list_walk_t *ulw_next;
73 uu_list_walk_t *ulw_prev;
75 uu_list_t *ulw_list;
76 int8_t ulw_dir;
77 uint8_t ulw_robust;
78 uu_list_node_impl_t *ulw_next_result;
81 struct uu_list {
82 uintptr_t ul_next_enc;
83 uintptr_t ul_prev_enc;
85 uu_list_pool_t *ul_pool;
86 uintptr_t ul_parent_enc; /* encoded parent pointer */
87 size_t ul_offset;
88 size_t ul_numnodes;
89 uint8_t ul_debug;
90 uint8_t ul_sorted;
91 uint8_t ul_index; /* mark for uu_list_index_ts */
93 uu_list_node_impl_t ul_null_node;
94 uu_list_walk_t ul_null_walk; /* for robust walkers */
97 #define UU_LIST_PTR(ptr) ((uu_list_t *)UU_PTR_DECODE(ptr))
99 #define UU_LIST_POOL_MAXNAME 64
101 struct uu_list_pool {
102 uu_list_pool_t *ulp_next;
103 uu_list_pool_t *ulp_prev;
105 char ulp_name[UU_LIST_POOL_MAXNAME];
106 size_t ulp_nodeoffset;
107 size_t ulp_objsize;
108 uu_compare_fn_t *ulp_cmp;
109 uint8_t ulp_debug;
110 uint8_t ulp_last_index;
111 pthread_mutex_t ulp_lock; /* protects null_list */
112 uu_list_t ulp_null_list;
116 * uu_avl structures
118 typedef struct avl_node uu_avl_node_impl_t;
120 struct uu_avl_walk {
121 uu_avl_walk_t *uaw_next;
122 uu_avl_walk_t *uaw_prev;
124 uu_avl_t *uaw_avl;
125 void *uaw_next_result;
126 int8_t uaw_dir;
127 uint8_t uaw_robust;
130 struct uu_avl {
131 uintptr_t ua_next_enc;
132 uintptr_t ua_prev_enc;
134 uu_avl_pool_t *ua_pool;
135 uintptr_t ua_parent_enc;
136 uint8_t ua_debug;
137 uint8_t ua_index; /* mark for uu_avl_index_ts */
139 struct avl_tree ua_tree;
140 uu_avl_walk_t ua_null_walk;
143 #define UU_AVL_PTR(x) ((uu_avl_t *)UU_PTR_DECODE(x))
145 #define UU_AVL_POOL_MAXNAME 64
147 struct uu_avl_pool {
148 uu_avl_pool_t *uap_next;
149 uu_avl_pool_t *uap_prev;
151 char uap_name[UU_AVL_POOL_MAXNAME];
152 size_t uap_nodeoffset;
153 size_t uap_objsize;
154 uu_compare_fn_t *uap_cmp;
155 uint8_t uap_debug;
156 uint8_t uap_last_index;
157 pthread_mutex_t uap_lock; /* protects null_avl */
158 uu_avl_t uap_null_avl;
162 * atfork() handlers
164 void uu_avl_lockup(void);
165 void uu_avl_release(void);
167 void uu_list_lockup(void);
168 void uu_list_release(void);
170 #ifdef __cplusplus
172 #endif
174 #endif /* _LIBUUTIL_IMPL_H */