Path: blob/main/sys/contrib/openzfs/include/libuutil_impl.h
48254 views
// SPDX-License-Identifier: CDDL-1.01/*2* CDDL HEADER START3*4* The contents of this file are subject to the terms of the5* Common Development and Distribution License, Version 1.0 only6* (the "License"). You may not use this file except in compliance7* with the License.8*9* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE10* or https://opensource.org/licenses/CDDL-1.0.11* See the License for the specific language governing permissions12* and limitations under the License.13*14* When distributing Covered Code, include this CDDL HEADER in each15* file and include the License file at usr/src/OPENSOLARIS.LICENSE.16* If applicable, add the following below this CDDL HEADER, with the17* fields enclosed by brackets "[]" replaced with your own identifying18* information: Portions Copyright [yyyy] [name of copyright owner]19*20* CDDL HEADER END21*/22/*23* Copyright 2005 Sun Microsystems, Inc. All rights reserved.24* Use is subject to license terms.25*/2627#ifndef _LIBUUTIL_IMPL_H28#define _LIBUUTIL_IMPL_H29303132#include <libuutil.h>33#include <pthread.h>3435#include <sys/avl_impl.h>36#include <sys/byteorder.h>3738#ifdef __cplusplus39extern "C" {40#endif4142void uu_set_error(uint_t);434445__attribute__((format(printf, 1, 2), __noreturn__))46void uu_panic(const char *format, ...);474849/*50* uu_list structures51*/52typedef struct uu_list_node_impl {53struct uu_list_node_impl *uln_next;54struct uu_list_node_impl *uln_prev;55} uu_list_node_impl_t;5657struct uu_list_walk {58uu_list_walk_t *ulw_next;59uu_list_walk_t *ulw_prev;6061uu_list_t *ulw_list;62int8_t ulw_dir;63uint8_t ulw_robust;64uu_list_node_impl_t *ulw_next_result;65};6667struct uu_list {68uu_list_t *ul_next;69uu_list_t *ul_prev;7071uu_list_pool_t *ul_pool;72void *ul_parent;73size_t ul_offset;74size_t ul_numnodes;75uint8_t ul_debug;76uint8_t ul_sorted;77uint8_t ul_index; /* mark for uu_list_index_ts */7879uu_list_node_impl_t ul_null_node;80uu_list_walk_t ul_null_walk; /* for robust walkers */81};8283#define UU_LIST_POOL_MAXNAME 648485struct uu_list_pool {86uu_list_pool_t *ulp_next;87uu_list_pool_t *ulp_prev;8889char ulp_name[UU_LIST_POOL_MAXNAME];90size_t ulp_nodeoffset;91size_t ulp_objsize;92uu_compare_fn_t *ulp_cmp;93uint8_t ulp_debug;94uint8_t ulp_last_index;95pthread_mutex_t ulp_lock; /* protects null_list */96uu_list_t ulp_null_list;97};9899/*100* uu_avl structures101*/102typedef struct avl_node uu_avl_node_impl_t;103104struct uu_avl_walk {105uu_avl_walk_t *uaw_next;106uu_avl_walk_t *uaw_prev;107108uu_avl_t *uaw_avl;109void *uaw_next_result;110int8_t uaw_dir;111uint8_t uaw_robust;112};113114struct uu_avl {115uu_avl_t *ua_next;116uu_avl_t *ua_prev;117118uu_avl_pool_t *ua_pool;119void *ua_parent;120uint8_t ua_debug;121uint8_t ua_index; /* mark for uu_avl_index_ts */122123struct avl_tree ua_tree;124uu_avl_walk_t ua_null_walk;125};126127#define UU_AVL_POOL_MAXNAME 64128129struct uu_avl_pool {130uu_avl_pool_t *uap_next;131uu_avl_pool_t *uap_prev;132133char uap_name[UU_AVL_POOL_MAXNAME];134size_t uap_nodeoffset;135size_t uap_objsize;136uu_compare_fn_t *uap_cmp;137uint8_t uap_debug;138uint8_t uap_last_index;139pthread_mutex_t uap_lock; /* protects null_avl */140uu_avl_t uap_null_avl;141};142143/*144* atfork() handlers145*/146void uu_avl_lockup(void);147void uu_avl_release(void);148149void uu_list_lockup(void);150void uu_list_release(void);151152#ifdef __cplusplus153}154#endif155156#endif /* _LIBUUTIL_IMPL_H */157158159