This patch introduces a highly-shareable version of AVL trees both for RTL usage and for ARM3's MM_AVL_TABLE/MMADDRESS_NODE structures used by VADs on Windows (and soon, ReactOS):
[RTL]: Uncouple generic table from AVL table implementation into its own avltable.c
[RTL]: Get rid of "Austin" and fix prototypes of AVL table functions.
[RTL]: Re-implement AVL table functions, sharing as much code as possible with the SPLAY tree implementation which is pretty decent. Lookup, insert, enumeration are implemented, but not delete.
[RTL]: Make large part of the RTL AVL package into its own "support" file that can work both with MMADDRESS_NODE and RTL_BALANCED_LINKS structures. The former is used by ARM3 for VADs.
[NTOS]: Implement basic VAD AVL tree routines (Insert, LookupEmpty, GetPrevious, CheckForConflict, Locate). This is enough to insert VADs, find a free address range, and locate a VAD by address. No delete yet
Thanks to Timo Kreuzer for some clever definitions, Knuth for his genius, several online C implementations for ideas, the HPI kernel blog for insight on how Windows does it, and others.
svn path=/trunk/; revision=48173
2010-07-22 01:41:45 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS Runtime Library
|
|
|
|
* LICENSE: BSD - See COPYING.ARM in the top level directory
|
|
|
|
* FILE: lib/rtl/rtlavl.h
|
|
|
|
* PURPOSE: RTL AVL Glue
|
|
|
|
* PROGRAMMERS: ReactOS Portable Systems Group
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES ******************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is the glue code for the AVL package in the RTL meant for external callers.
|
|
|
|
* It's not very exciting, it just uses the RTL-defined fields without any magic,
|
|
|
|
* unlike the Mm version which has special handling for balances and parents, and
|
|
|
|
* does not implement custom comparison callbacks.
|
|
|
|
*/
|
|
|
|
#define MI_ASSERT(x)
|
|
|
|
#define RtlLeftChildAvl(x) (PRTL_BALANCED_LINKS)(RtlLeftChild(x))
|
|
|
|
#define RtlRightChildAvl(x) (PRTL_BALANCED_LINKS)(RtlRightChild(x))
|
|
|
|
#define RtlParentAvl(x) (PRTL_BALANCED_LINKS)(RtlParent(x))
|
|
|
|
#define RtlRealPredecessorAvl(x) (PRTL_BALANCED_LINKS)(RtlRealPredecessor((PRTL_SPLAY_LINKS)(x)))
|
|
|
|
#define RtlRealSuccessorAvl(x) (PRTL_BALANCED_LINKS)(RtlRealSuccessor((PRTL_SPLAY_LINKS)(x)))
|
|
|
|
#define RtlInsertAsRightChildAvl RtlInsertAsRightChild
|
|
|
|
#define RtlInsertAsLeftChildAvl RtlInsertAsLeftChild
|
|
|
|
#define RtlIsLeftChildAvl RtlIsLeftChild
|
|
|
|
|
2010-07-24 04:00:22 +00:00
|
|
|
FORCEINLINE
|
2014-04-27 12:34:39 +00:00
|
|
|
VOID
|
2010-07-24 04:00:22 +00:00
|
|
|
RtlpCopyAvlNodeData(IN PRTL_BALANCED_LINKS Node1,
|
|
|
|
IN PRTL_BALANCED_LINKS Node2)
|
|
|
|
{
|
|
|
|
*Node1 = *Node2;
|
|
|
|
}
|
2021-06-11 12:29:21 +00:00
|
|
|
|
This patch introduces a highly-shareable version of AVL trees both for RTL usage and for ARM3's MM_AVL_TABLE/MMADDRESS_NODE structures used by VADs on Windows (and soon, ReactOS):
[RTL]: Uncouple generic table from AVL table implementation into its own avltable.c
[RTL]: Get rid of "Austin" and fix prototypes of AVL table functions.
[RTL]: Re-implement AVL table functions, sharing as much code as possible with the SPLAY tree implementation which is pretty decent. Lookup, insert, enumeration are implemented, but not delete.
[RTL]: Make large part of the RTL AVL package into its own "support" file that can work both with MMADDRESS_NODE and RTL_BALANCED_LINKS structures. The former is used by ARM3 for VADs.
[NTOS]: Implement basic VAD AVL tree routines (Insert, LookupEmpty, GetPrevious, CheckForConflict, Locate). This is enough to insert VADs, find a free address range, and locate a VAD by address. No delete yet
Thanks to Timo Kreuzer for some clever definitions, Knuth for his genius, several online C implementations for ideas, the HPI kernel blog for insight on how Windows does it, and others.
svn path=/trunk/; revision=48173
2010-07-22 01:41:45 +00:00
|
|
|
FORCEINLINE
|
2014-04-27 12:34:39 +00:00
|
|
|
RTL_GENERIC_COMPARE_RESULTS
|
This patch introduces a highly-shareable version of AVL trees both for RTL usage and for ARM3's MM_AVL_TABLE/MMADDRESS_NODE structures used by VADs on Windows (and soon, ReactOS):
[RTL]: Uncouple generic table from AVL table implementation into its own avltable.c
[RTL]: Get rid of "Austin" and fix prototypes of AVL table functions.
[RTL]: Re-implement AVL table functions, sharing as much code as possible with the SPLAY tree implementation which is pretty decent. Lookup, insert, enumeration are implemented, but not delete.
[RTL]: Make large part of the RTL AVL package into its own "support" file that can work both with MMADDRESS_NODE and RTL_BALANCED_LINKS structures. The former is used by ARM3 for VADs.
[NTOS]: Implement basic VAD AVL tree routines (Insert, LookupEmpty, GetPrevious, CheckForConflict, Locate). This is enough to insert VADs, find a free address range, and locate a VAD by address. No delete yet
Thanks to Timo Kreuzer for some clever definitions, Knuth for his genius, several online C implementations for ideas, the HPI kernel blog for insight on how Windows does it, and others.
svn path=/trunk/; revision=48173
2010-07-22 01:41:45 +00:00
|
|
|
RtlpAvlCompareRoutine(IN PRTL_AVL_TABLE Table,
|
|
|
|
IN PVOID Buffer,
|
|
|
|
IN PVOID UserData)
|
|
|
|
{
|
|
|
|
/* Do the compare */
|
|
|
|
return Table->CompareRoutine(Table,
|
|
|
|
Buffer,
|
|
|
|
UserData);
|
|
|
|
}
|
|
|
|
|
|
|
|
FORCEINLINE
|
2014-04-27 12:34:39 +00:00
|
|
|
VOID
|
This patch introduces a highly-shareable version of AVL trees both for RTL usage and for ARM3's MM_AVL_TABLE/MMADDRESS_NODE structures used by VADs on Windows (and soon, ReactOS):
[RTL]: Uncouple generic table from AVL table implementation into its own avltable.c
[RTL]: Get rid of "Austin" and fix prototypes of AVL table functions.
[RTL]: Re-implement AVL table functions, sharing as much code as possible with the SPLAY tree implementation which is pretty decent. Lookup, insert, enumeration are implemented, but not delete.
[RTL]: Make large part of the RTL AVL package into its own "support" file that can work both with MMADDRESS_NODE and RTL_BALANCED_LINKS structures. The former is used by ARM3 for VADs.
[NTOS]: Implement basic VAD AVL tree routines (Insert, LookupEmpty, GetPrevious, CheckForConflict, Locate). This is enough to insert VADs, find a free address range, and locate a VAD by address. No delete yet
Thanks to Timo Kreuzer for some clever definitions, Knuth for his genius, several online C implementations for ideas, the HPI kernel blog for insight on how Windows does it, and others.
svn path=/trunk/; revision=48173
2010-07-22 01:41:45 +00:00
|
|
|
RtlSetParent(IN PRTL_BALANCED_LINKS Node,
|
|
|
|
IN PRTL_BALANCED_LINKS Parent)
|
|
|
|
{
|
|
|
|
Node->Parent = Parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
FORCEINLINE
|
2014-04-27 12:34:39 +00:00
|
|
|
VOID
|
This patch introduces a highly-shareable version of AVL trees both for RTL usage and for ARM3's MM_AVL_TABLE/MMADDRESS_NODE structures used by VADs on Windows (and soon, ReactOS):
[RTL]: Uncouple generic table from AVL table implementation into its own avltable.c
[RTL]: Get rid of "Austin" and fix prototypes of AVL table functions.
[RTL]: Re-implement AVL table functions, sharing as much code as possible with the SPLAY tree implementation which is pretty decent. Lookup, insert, enumeration are implemented, but not delete.
[RTL]: Make large part of the RTL AVL package into its own "support" file that can work both with MMADDRESS_NODE and RTL_BALANCED_LINKS structures. The former is used by ARM3 for VADs.
[NTOS]: Implement basic VAD AVL tree routines (Insert, LookupEmpty, GetPrevious, CheckForConflict, Locate). This is enough to insert VADs, find a free address range, and locate a VAD by address. No delete yet
Thanks to Timo Kreuzer for some clever definitions, Knuth for his genius, several online C implementations for ideas, the HPI kernel blog for insight on how Windows does it, and others.
svn path=/trunk/; revision=48173
2010-07-22 01:41:45 +00:00
|
|
|
RtlSetBalance(IN PRTL_BALANCED_LINKS Node,
|
|
|
|
IN CHAR Balance)
|
|
|
|
{
|
|
|
|
Node->Balance = Balance;
|
|
|
|
}
|
|
|
|
|
|
|
|
FORCEINLINE
|
2014-04-27 12:34:39 +00:00
|
|
|
CHAR
|
This patch introduces a highly-shareable version of AVL trees both for RTL usage and for ARM3's MM_AVL_TABLE/MMADDRESS_NODE structures used by VADs on Windows (and soon, ReactOS):
[RTL]: Uncouple generic table from AVL table implementation into its own avltable.c
[RTL]: Get rid of "Austin" and fix prototypes of AVL table functions.
[RTL]: Re-implement AVL table functions, sharing as much code as possible with the SPLAY tree implementation which is pretty decent. Lookup, insert, enumeration are implemented, but not delete.
[RTL]: Make large part of the RTL AVL package into its own "support" file that can work both with MMADDRESS_NODE and RTL_BALANCED_LINKS structures. The former is used by ARM3 for VADs.
[NTOS]: Implement basic VAD AVL tree routines (Insert, LookupEmpty, GetPrevious, CheckForConflict, Locate). This is enough to insert VADs, find a free address range, and locate a VAD by address. No delete yet
Thanks to Timo Kreuzer for some clever definitions, Knuth for his genius, several online C implementations for ideas, the HPI kernel blog for insight on how Windows does it, and others.
svn path=/trunk/; revision=48173
2010-07-22 01:41:45 +00:00
|
|
|
RtlBalance(IN PRTL_BALANCED_LINKS Node)
|
|
|
|
{
|
|
|
|
return Node->Balance;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|