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