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