1 // SPDX-License-Identifier: CDDL-1.0 2 /* 3 * CDDL HEADER START 4 * 5 * The contents of this file are subject to the terms of the 6 * Common Development and Distribution License, Version 1.0 only 7 * (the "License"). You may not use this file except in compliance 8 * with the License. 9 * 10 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 11 * or https://opensource.org/licenses/CDDL-1.0. 12 * See the License for the specific language governing permissions 13 * and limitations under the License. 14 * 15 * When distributing Covered Code, include this CDDL HEADER in each 16 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 17 * If applicable, add the following below this CDDL HEADER, with the 18 * fields enclosed by brackets "[]" replaced with your own identifying 19 * information: Portions Copyright [yyyy] [name of copyright owner] 20 * 21 * CDDL HEADER END 22 */ 23 /* 24 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 25 * Use is subject to license terms. 26 */ 27 28 #ifndef _LIBUUTIL_IMPL_H 29 #define _LIBUUTIL_IMPL_H 30 31 32 33 #include <libuutil.h> 34 #include <pthread.h> 35 36 #include <sys/avl_impl.h> 37 #include <sys/byteorder.h> 38 39 #ifdef __cplusplus 40 extern "C" { 41 #endif 42 43 void uu_set_error(uint_t); 44 45 46 __attribute__((format(printf, 1, 2), __noreturn__)) 47 void uu_panic(const char *format, ...); 48 49 50 /* 51 * uu_list structures 52 */ 53 typedef struct uu_list_node_impl { 54 struct uu_list_node_impl *uln_next; 55 struct uu_list_node_impl *uln_prev; 56 } uu_list_node_impl_t; 57 58 struct uu_list_walk { 59 uu_list_walk_t *ulw_next; 60 uu_list_walk_t *ulw_prev; 61 62 uu_list_t *ulw_list; 63 int8_t ulw_dir; 64 uint8_t ulw_robust; 65 uu_list_node_impl_t *ulw_next_result; 66 }; 67 68 struct uu_list { 69 uu_list_t *ul_next; 70 uu_list_t *ul_prev; 71 72 uu_list_pool_t *ul_pool; 73 void *ul_parent; 74 size_t ul_offset; 75 size_t ul_numnodes; 76 uint8_t ul_debug; 77 uint8_t ul_sorted; 78 uint8_t ul_index; /* mark for uu_list_index_ts */ 79 80 uu_list_node_impl_t ul_null_node; 81 uu_list_walk_t ul_null_walk; /* for robust walkers */ 82 }; 83 84 #define UU_LIST_POOL_MAXNAME 64 85 86 struct uu_list_pool { 87 uu_list_pool_t *ulp_next; 88 uu_list_pool_t *ulp_prev; 89 90 char ulp_name[UU_LIST_POOL_MAXNAME]; 91 size_t ulp_nodeoffset; 92 size_t ulp_objsize; 93 uu_compare_fn_t *ulp_cmp; 94 uint8_t ulp_debug; 95 uint8_t ulp_last_index; 96 pthread_mutex_t ulp_lock; /* protects null_list */ 97 uu_list_t ulp_null_list; 98 }; 99 100 /* 101 * uu_avl structures 102 */ 103 typedef struct avl_node uu_avl_node_impl_t; 104 105 struct uu_avl_walk { 106 uu_avl_walk_t *uaw_next; 107 uu_avl_walk_t *uaw_prev; 108 109 uu_avl_t *uaw_avl; 110 void *uaw_next_result; 111 int8_t uaw_dir; 112 uint8_t uaw_robust; 113 }; 114 115 struct uu_avl { 116 uu_avl_t *ua_next; 117 uu_avl_t *ua_prev; 118 119 uu_avl_pool_t *ua_pool; 120 void *ua_parent; 121 uint8_t ua_debug; 122 uint8_t ua_index; /* mark for uu_avl_index_ts */ 123 124 struct avl_tree ua_tree; 125 uu_avl_walk_t ua_null_walk; 126 }; 127 128 #define UU_AVL_POOL_MAXNAME 64 129 130 struct uu_avl_pool { 131 uu_avl_pool_t *uap_next; 132 uu_avl_pool_t *uap_prev; 133 134 char uap_name[UU_AVL_POOL_MAXNAME]; 135 size_t uap_nodeoffset; 136 size_t uap_objsize; 137 uu_compare_fn_t *uap_cmp; 138 uint8_t uap_debug; 139 uint8_t uap_last_index; 140 pthread_mutex_t uap_lock; /* protects null_avl */ 141 uu_avl_t uap_null_avl; 142 }; 143 144 /* 145 * atfork() handlers 146 */ 147 void uu_avl_lockup(void); 148 void uu_avl_release(void); 149 150 void uu_list_lockup(void); 151 void uu_list_release(void); 152 153 #ifdef __cplusplus 154 } 155 #endif 156 157 #endif /* _LIBUUTIL_IMPL_H */ 158