1168404Spjd/*
2168404Spjd * CDDL HEADER START
3168404Spjd *
4168404Spjd * The contents of this file are subject to the terms of the
5168404Spjd * Common Development and Distribution License, Version 1.0 only
6168404Spjd * (the "License").  You may not use this file except in compliance
7168404Spjd * with the License.
8168404Spjd *
9168404Spjd * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10168404Spjd * or http://www.opensolaris.org/os/licensing.
11168404Spjd * See the License for the specific language governing permissions
12168404Spjd * and limitations under the License.
13168404Spjd *
14168404Spjd * When distributing Covered Code, include this CDDL HEADER in each
15168404Spjd * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16168404Spjd * If applicable, add the following below this CDDL HEADER, with the
17168404Spjd * fields enclosed by brackets "[]" replaced with your own identifying
18168404Spjd * information: Portions Copyright [yyyy] [name of copyright owner]
19168404Spjd *
20168404Spjd * CDDL HEADER END
21168404Spjd */
22168404Spjd/*
23168404Spjd * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24168404Spjd * Use is subject to license terms.
25168404Spjd */
26168404Spjd
27339146Smav/*
28339146Smav * Copyright (c) 2017 by Delphix. All rights reserved.
29339146Smav */
30339146Smav
31168404Spjd#ifndef	_NVPAIR_IMPL_H
32168404Spjd#define	_NVPAIR_IMPL_H
33168404Spjd
34168404Spjd#ifdef __cplusplus
35168404Spjdextern "C" {
36168404Spjd#endif
37168404Spjd
38168404Spjd#include <sys/nvpair.h>
39168404Spjd
40168404Spjd/*
41168404Spjd * The structures here provided for information and debugging purposes only
42168404Spjd * may be changed in the future.
43168404Spjd */
44168404Spjd
45168404Spjd/*
46168404Spjd * implementation linked list for pre-packed data
47168404Spjd */
48168404Spjdtypedef struct i_nvp i_nvp_t;
49168404Spjd
50168404Spjdstruct i_nvp {
51168404Spjd	union {
52339146Smav		/* ensure alignment */
53339146Smav		uint64_t	_nvi_align;
54339146Smav
55168404Spjd		struct {
56339146Smav			/* pointer to next nvpair */
57339146Smav			i_nvp_t	*_nvi_next;
58339146Smav
59339146Smav			/* pointer to prev nvpair */
60339146Smav			i_nvp_t	*_nvi_prev;
61339146Smav
62339146Smav			/* next pair in table bucket */
63339146Smav			i_nvp_t	*_nvi_hashtable_next;
64168404Spjd		} _nvi;
65168404Spjd	} _nvi_un;
66339146Smav
67339146Smav	/* nvpair */
68339146Smav	nvpair_t nvi_nvp;
69168404Spjd};
70168404Spjd#define	nvi_next	_nvi_un._nvi._nvi_next
71168404Spjd#define	nvi_prev	_nvi_un._nvi._nvi_prev
72339146Smav#define	nvi_hashtable_next	_nvi_un._nvi._nvi_hashtable_next
73168404Spjd
74168404Spjdtypedef struct {
75168404Spjd	i_nvp_t		*nvp_list;	/* linked list of nvpairs */
76168404Spjd	i_nvp_t		*nvp_last;	/* last nvpair */
77168404Spjd	i_nvp_t		*nvp_curr;	/* current walker nvpair */
78168404Spjd	nv_alloc_t	*nvp_nva;	/* pluggable allocator */
79168404Spjd	uint32_t	nvp_stat;	/* internal state */
80339146Smav
81339146Smav	i_nvp_t		**nvp_hashtable; /* table of entries used for lookup */
82339146Smav	uint32_t	nvp_nbuckets;	/* # of buckets in hash table */
83339146Smav	uint32_t	nvp_nentries;	/* # of entries in hash table */
84168404Spjd} nvpriv_t;
85168404Spjd
86168404Spjd#ifdef	__cplusplus
87168404Spjd}
88168404Spjd#endif
89168404Spjd
90168404Spjd#endif	/* _NVPAIR_IMPL_H */
91