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 Kernel
|
|
|
|
* LICENSE: BSD - See COPYING.ARM in the top level directory
|
|
|
|
* FILE: ntoskrnl/mm/ARM3/miavl.h
|
|
|
|
* PURPOSE: ARM Memory Manager VAD Node Algorithms
|
|
|
|
* PROGRAMMERS: ReactOS Portable Systems Group
|
|
|
|
*/
|
|
|
|
|
2017-12-12 11:42:13 +00:00
|
|
|
#pragma once
|
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
|
|
|
|
|
|
|
/*
|
|
|
|
* This is the glue code for the Memory Manager version of AVL Trees that is used
|
|
|
|
* to store the MM_AVL_TABLE for Virtual Address Descriptors (VAD) in the VadRoot
|
|
|
|
* field in EPROCESS.
|
|
|
|
*
|
|
|
|
* In this version of the package, the balance and parent pointers are stored in
|
|
|
|
* the same field as a union (since we know the parent will be at least 8-byte
|
|
|
|
* aligned), saving some space, but requiring special logic to handle setting and
|
|
|
|
* querying the parent and balance.
|
|
|
|
*
|
|
|
|
* The other difference is that the AVL package for Rtl has custom callbacks for
|
|
|
|
* comparison purposes (which would access some internal, opaque, user data) while
|
2011-07-04 16:26:52 +00:00
|
|
|
* the Mm package stores the user-data inline as StartingVpn and EndingVpn. So
|
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
|
|
|
* when a compare is being made, RtlpAvlCompareRoutine is called, which will either
|
|
|
|
* perform the Mm work, or call the user-specified callback in the Rtl case.
|
|
|
|
*/
|
|
|
|
#define PRTL_AVL_TABLE PMM_AVL_TABLE
|
|
|
|
#define PRTL_BALANCED_LINKS PMMADDRESS_NODE
|
|
|
|
#define MI_ASSERT(x) ASSERT(x)
|
|
|
|
|
2014-10-11 12:40:24 +00:00
|
|
|
/* We need to rename the functions to prevent conflicts when not inlined! */
|
|
|
|
#define RtlpFindAvlTableNodeOrParent MiFindAvlTableNodeOrParent
|
|
|
|
#define RtlpPromoteAvlTreeNode MiPromoteAvlTreeNode
|
|
|
|
#define RtlpRebalanceAvlTreeNode MiRebalanceAvlTreeNode
|
|
|
|
#define RtlpInsertAvlTreeNode MiInsertAvlTreeNode
|
|
|
|
#define RtlpDeleteAvlTreeNode MiDeleteAvlTreeNode
|
|
|
|
|
|
|
|
/* These are implementation specific */
|
|
|
|
#define RtlpCopyAvlNodeData MiCopyAvlNodeData
|
|
|
|
#define RtlpAvlCompareRoutine MiAvlCompareRoutine
|
|
|
|
#define RtlSetParent MiSetParent
|
|
|
|
#define RtlSetBalance MiSetBalance
|
|
|
|
#define RtlBalance MiBalance
|
|
|
|
#define RtlParentAvl MiParentAvl
|
|
|
|
#define RtlRightChildAvl MiRightChildAvl
|
|
|
|
#define RtlLeftChildAvl MiLeftChildAvl
|
|
|
|
#define RtlIsLeftChildAvl MiIsLeftChildAvl
|
|
|
|
#define RtlIsRightChildAvl MiIsRightChildAvl
|
|
|
|
#define RtlInsertAsLeftChildAvl MiInsertAsLeftChildAvl
|
|
|
|
#define RtlInsertAsRightChildAvl MiInsertAsRightChildAvl
|
|
|
|
|
2010-07-24 04:00:22 +00:00
|
|
|
FORCEINLINE
|
2013-11-26 13:45:33 +00:00
|
|
|
VOID
|
2014-10-11 12:40:24 +00:00
|
|
|
MiCopyAvlNodeData(IN PRTL_BALANCED_LINKS Node1,
|
2010-07-24 04:00:22 +00:00
|
|
|
IN PRTL_BALANCED_LINKS Node2)
|
|
|
|
{
|
|
|
|
Node1->u1.Parent = Node2->u1.Parent;
|
|
|
|
Node1->LeftChild = Node2->LeftChild;
|
|
|
|
Node1->RightChild = Node2->RightChild;
|
|
|
|
}
|
|
|
|
|
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
|
2013-11-26 13:45:33 +00:00
|
|
|
RTL_GENERIC_COMPARE_RESULTS
|
2014-10-11 12:40:24 +00:00
|
|
|
MiAvlCompareRoutine(IN PRTL_AVL_TABLE Table,
|
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
|
|
|
IN PVOID Buffer,
|
|
|
|
IN PVOID UserData)
|
|
|
|
{
|
2011-02-17 21:58:08 +00:00
|
|
|
PRTL_BALANCED_LINKS CurrentNode = (PVOID)((ULONG_PTR)UserData - sizeof(RTL_BALANCED_LINKS));
|
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
|
|
|
ULONG_PTR StartingVpn = (ULONG_PTR)Buffer;
|
|
|
|
if (StartingVpn < CurrentNode->StartingVpn)
|
|
|
|
{
|
|
|
|
return GenericLessThan;
|
|
|
|
}
|
|
|
|
else if (StartingVpn <= CurrentNode->EndingVpn)
|
|
|
|
{
|
|
|
|
return GenericEqual;
|
|
|
|
}
|
2011-07-04 16:26:52 +00:00
|
|
|
else
|
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
|
|
|
{
|
|
|
|
return GenericGreaterThan;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
FORCEINLINE
|
2013-11-26 13:45:33 +00:00
|
|
|
VOID
|
2014-10-11 12:40:24 +00:00
|
|
|
MiSetParent(IN PRTL_BALANCED_LINKS Node,
|
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
|
|
|
IN PRTL_BALANCED_LINKS Parent)
|
|
|
|
{
|
|
|
|
Node->u1.Parent = (PRTL_BALANCED_LINKS)((ULONG_PTR)Parent | (Node->u1.Balance & 0x3));
|
|
|
|
}
|
|
|
|
|
|
|
|
FORCEINLINE
|
2013-11-26 13:45:33 +00:00
|
|
|
VOID
|
2014-10-11 12:40:24 +00:00
|
|
|
MiSetBalance(IN PRTL_BALANCED_LINKS Node,
|
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
|
|
|
IN SCHAR Balance)
|
|
|
|
{
|
|
|
|
Node->u1.Balance = Balance;
|
|
|
|
}
|
|
|
|
|
|
|
|
FORCEINLINE
|
2013-11-26 13:45:33 +00:00
|
|
|
SCHAR
|
2014-10-11 12:40:24 +00:00
|
|
|
MiBalance(IN PRTL_BALANCED_LINKS Node)
|
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
|
|
|
{
|
2011-07-04 16:26:52 +00:00
|
|
|
return (SCHAR)Node->u1.Balance;
|
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
|
2013-11-26 13:45:33 +00:00
|
|
|
PRTL_BALANCED_LINKS
|
2014-10-11 12:40:24 +00:00
|
|
|
MiParentAvl(IN PRTL_BALANCED_LINKS Node)
|
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
|
|
|
{
|
|
|
|
return (PRTL_BALANCED_LINKS)((ULONG_PTR)Node->u1.Parent & ~3);
|
|
|
|
}
|
|
|
|
|
|
|
|
FORCEINLINE
|
2013-11-26 13:45:33 +00:00
|
|
|
PRTL_BALANCED_LINKS
|
2014-10-11 12:40:24 +00:00
|
|
|
MiRightChildAvl(IN PRTL_BALANCED_LINKS Node)
|
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
|
|
|
{
|
|
|
|
return Node->RightChild;
|
|
|
|
}
|
|
|
|
|
|
|
|
FORCEINLINE
|
2013-11-26 13:45:33 +00:00
|
|
|
PRTL_BALANCED_LINKS
|
2014-10-11 12:40:24 +00:00
|
|
|
MiLeftChildAvl(IN PRTL_BALANCED_LINKS Node)
|
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
|
|
|
{
|
|
|
|
return Node->LeftChild;
|
|
|
|
}
|
|
|
|
|
|
|
|
FORCEINLINE
|
2013-11-26 13:45:33 +00:00
|
|
|
BOOLEAN
|
2014-10-11 12:40:24 +00:00
|
|
|
MiIsLeftChildAvl(IN PRTL_BALANCED_LINKS Node)
|
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
|
|
|
{
|
|
|
|
return (RtlLeftChildAvl(RtlParentAvl(Node)) == Node);
|
|
|
|
}
|
|
|
|
|
|
|
|
FORCEINLINE
|
2013-11-26 13:45:33 +00:00
|
|
|
BOOLEAN
|
2014-10-11 12:40:24 +00:00
|
|
|
MiIsRightChildAvl(IN PRTL_BALANCED_LINKS Node)
|
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
|
|
|
{
|
|
|
|
return (RtlRightChildAvl(RtlParentAvl(Node)) == Node);
|
|
|
|
}
|
|
|
|
|
|
|
|
FORCEINLINE
|
2013-11-26 13:45:33 +00:00
|
|
|
VOID
|
2014-10-11 12:40:24 +00:00
|
|
|
MiInsertAsLeftChildAvl(IN PRTL_BALANCED_LINKS Parent,
|
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
|
|
|
IN PRTL_BALANCED_LINKS Node)
|
|
|
|
{
|
|
|
|
Parent->LeftChild = Node;
|
|
|
|
RtlSetParent(Node, Parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
FORCEINLINE
|
2013-11-26 13:45:33 +00:00
|
|
|
VOID
|
2014-10-11 12:40:24 +00:00
|
|
|
MiInsertAsRightChildAvl(IN PRTL_BALANCED_LINKS Parent,
|
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
|
|
|
IN PRTL_BALANCED_LINKS Node)
|
|
|
|
{
|
|
|
|
Parent->RightChild = Node;
|
|
|
|
RtlSetParent(Node, Parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|