ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

miavl.h
Go to the documentation of this file.
00001 /*
00002  * PROJECT:         ReactOS Kernel
00003  * LICENSE:         BSD - See COPYING.ARM in the top level directory
00004  * FILE:            ntoskrnl/mm/ARM3/miavl.h
00005  * PURPOSE:         ARM Memory Manager VAD Node Algorithms
00006  * PROGRAMMERS:     ReactOS Portable Systems Group
00007  */
00008 
00009 /* INCLUDES ******************************************************************/
00010 
00011 /*
00012  * This is the glue code for the Memory Manager version of AVL Trees that is used
00013  * to store the MM_AVL_TABLE for Virtual Address Descriptors (VAD) in the VadRoot
00014  * field in EPROCESS.
00015  *
00016  * In this version of the package, the balance and parent pointers are stored in
00017  * the same field as a union (since we know the parent will be at least 8-byte
00018  * aligned), saving some space, but requiring special logic to handle setting and
00019  * querying the parent and balance.
00020  *
00021  * The other difference is that the AVL package for Rtl has custom callbacks for
00022  * comparison purposes (which would access some internal, opaque, user data) while
00023  * the Mm package stores the user-data inline as StartingVpn and EndingVpn. So
00024  * when a compare is being made, RtlpAvlCompareRoutine is called, which will either
00025  * perform the Mm work, or call the user-specified callback in the Rtl case.
00026  */
00027 #define PRTL_AVL_TABLE              PMM_AVL_TABLE
00028 #define PRTL_BALANCED_LINKS         PMMADDRESS_NODE
00029 #define MI_ASSERT(x)                ASSERT(x)
00030 
00031 VOID
00032 FORCEINLINE
00033 RtlpCopyAvlNodeData(IN PRTL_BALANCED_LINKS Node1,
00034                     IN PRTL_BALANCED_LINKS Node2)
00035 {
00036     Node1->u1.Parent = Node2->u1.Parent;
00037     Node1->LeftChild = Node2->LeftChild;
00038     Node1->RightChild = Node2->RightChild;
00039 }
00040 
00041 RTL_GENERIC_COMPARE_RESULTS
00042 FORCEINLINE
00043 RtlpAvlCompareRoutine(IN PRTL_AVL_TABLE Table,
00044                       IN PVOID Buffer,
00045                       IN PVOID UserData)
00046 {
00047     PRTL_BALANCED_LINKS CurrentNode = (PVOID)((ULONG_PTR)UserData - sizeof(RTL_BALANCED_LINKS));
00048     ULONG_PTR StartingVpn = (ULONG_PTR)Buffer;
00049     if (StartingVpn < CurrentNode->StartingVpn)
00050     {
00051         return GenericLessThan;
00052     }
00053     else if (StartingVpn <= CurrentNode->EndingVpn)
00054     {
00055         return GenericEqual;
00056     }
00057     else
00058     {
00059         return GenericGreaterThan;
00060     }
00061 }
00062 
00063 VOID
00064 FORCEINLINE
00065 RtlSetParent(IN PRTL_BALANCED_LINKS Node,
00066              IN PRTL_BALANCED_LINKS Parent)
00067 {
00068     Node->u1.Parent = (PRTL_BALANCED_LINKS)((ULONG_PTR)Parent | (Node->u1.Balance & 0x3));
00069 }
00070 
00071 VOID
00072 FORCEINLINE
00073 RtlSetBalance(IN PRTL_BALANCED_LINKS Node,
00074               IN SCHAR Balance)
00075 {
00076     Node->u1.Balance = Balance;
00077 }
00078 
00079 SCHAR
00080 FORCEINLINE
00081 RtlBalance(IN PRTL_BALANCED_LINKS Node)
00082 {
00083     return (SCHAR)Node->u1.Balance;
00084 }
00085 
00086 PRTL_BALANCED_LINKS
00087 FORCEINLINE
00088 RtlParentAvl(IN PRTL_BALANCED_LINKS Node)
00089 {
00090     return (PRTL_BALANCED_LINKS)((ULONG_PTR)Node->u1.Parent & ~3);
00091 }
00092 
00093 BOOLEAN
00094 FORCEINLINE
00095 RtlIsRootAvl(IN PRTL_BALANCED_LINKS Node)
00096 {
00097    return (RtlParentAvl(Node) == Node);
00098 }
00099 
00100 PRTL_BALANCED_LINKS
00101 FORCEINLINE
00102 RtlRightChildAvl(IN PRTL_BALANCED_LINKS Node)
00103 {
00104     return Node->RightChild;
00105 }
00106 
00107 PRTL_BALANCED_LINKS
00108 FORCEINLINE
00109 RtlLeftChildAvl(IN PRTL_BALANCED_LINKS Node)
00110 {
00111     return Node->LeftChild;
00112 }
00113 
00114 BOOLEAN
00115 FORCEINLINE
00116 RtlIsLeftChildAvl(IN PRTL_BALANCED_LINKS Node)
00117 {
00118    return (RtlLeftChildAvl(RtlParentAvl(Node)) == Node);
00119 }
00120 
00121 BOOLEAN
00122 FORCEINLINE
00123 RtlIsRightChildAvl(IN PRTL_BALANCED_LINKS Node)
00124 {
00125    return (RtlRightChildAvl(RtlParentAvl(Node)) == Node);
00126 }
00127 
00128 VOID
00129 FORCEINLINE
00130 RtlInsertAsLeftChildAvl(IN PRTL_BALANCED_LINKS Parent,
00131                         IN PRTL_BALANCED_LINKS Node)
00132 {
00133     Parent->LeftChild = Node;
00134     RtlSetParent(Node, Parent);
00135 }
00136 
00137 VOID
00138 FORCEINLINE
00139 RtlInsertAsRightChildAvl(IN PRTL_BALANCED_LINKS Parent,
00140                          IN PRTL_BALANCED_LINKS Node)
00141 {
00142     Parent->RightChild = Node;
00143     RtlSetParent(Node, Parent);
00144 }
00145 
00146 /* EOF */

Generated on Sun May 27 2012 04:37:34 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.