/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _AVL_IMPL_H
#define _AVL_IMPL_H
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* This is a private header file. Applications should not directly include
* this file.
*/
#ifdef __cplusplus
extern "C" {
#endif
/*
* generic AVL tree implementation for kernel use
*
* There are 5 pieces of information stored for each node in an AVL tree
*
* pointer to less than child
* pointer to greater than child
* a pointer to the parent of this node
* an indication [0/1] of which child I am of my parent
* a "balance" (-1, 0, +1) indicating which child tree is taller
*
* Since they only need 3 bits, the last two fields are packed into the
* bottom bits of the parent pointer on 64 bit machines to save on space.
*/
#ifndef _LP64
struct avl_node {
};
#else /* _LP64 */
/*
* for 64 bit machines, avl_pcb contains parent pointer, balance and child_index
* values packed in the following manner:
*
* |63 3| 2 |1 0 |
* |-------------------------------------|-----------------|-------------|
* | avl_parent hi order bits | avl_child_index | avl_balance |
* | | | + 1 |
* |-------------------------------------|-----------------|-------------|
*
*/
struct avl_node {
};
/*
*
* pointer to the parent of the current node is the high order bits
*/
#define AVL_SETPARENT(n, p) \
/*
* index of this node in its parent's avl_child[]: bit #2
*/
#define AVL_SETCHILD(n, c) \
/*
* balance indication for a node, lowest 2 bits. A valid balance is
* -1, 0, or +1, and is encoded by adding 1 to the value to get the
* unsigned values of 0, 1, 2.
*/
#define AVL_SETBALANCE(n, b) \
#endif /* _LP64 */
/*
* switch between a node and data pointer for a given tree
* the value of "o" is tree->avl_offset
*/
/*
*/
/*
* The tree structure. The fields avl_root, avl_compar, and avl_offset come
* first since they are needed for avl_find(). We want them to fit into
* a single 64 byte cache line to make avl_find() as fast as possible.
*/
struct avl_tree {
int (*avl_compar)(const void *, const void *);
};
/*
* This will only by used via AVL_NEXT() or AVL_PREV()
*/
#ifdef __cplusplus
}
#endif
#endif /* _AVL_IMPL_H */