[RTL]
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Wed, 24 Mar 2010 21:56:24 +0000 (21:56 +0000)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Wed, 24 Mar 2010 21:56:24 +0000 (21:56 +0000)
Fix RtlInitializeSListHead and RtlQueryDepthSList

svn path=/branches/ros-amd64-bringup/; revision=46405

reactos/lib/rtl/slist.c

index 4d291ab..8260a38 100644 (file)
 
 VOID
 NTAPI
-RtlInitializeSListHead(IN PSLIST_HEADER ListHead)
+RtlInitializeSListHead(
+  OUT PSLIST_HEADER SListHead)
 {
-#ifdef _WIN64
-    ListHead->Alignment = 0;
-    ListHead->Region = 0;
-    ListHead->Header8.Init = 1;
-    // ListHead->Header8.HeaderType = 1; // FIXME: depending on cmpxchg16b support?
-#else
-    ListHead->Alignment = 0;
+#if defined(_IA64_)
+    ULONG64 FeatureBits;
+#endif
+
+#if defined(_WIN64)
+    /* Make sure the alignment is ok */
+    if (((ULONG_PTR)SListHead & 0xf) != 0)
+    {
+        RtlRaiseStatus(STATUS_DATATYPE_MISALIGNMENT);
+    }
+#endif
+
+    /* Zero it */
+    SListHead->Alignment = 0;
+    SListHead->Region = 0;
+
+#if defined(_IA64_)
+    FeatureBits = __getReg(CV_IA64_CPUID4);
+    if (FeatureBits & KF_16BYTE_INSTR)
+    {
+        SListHead->Header16.HeaderType = 1;
+        SListHead->Header16.Init = 1;
+    }
 #endif
 }
 
@@ -64,7 +81,7 @@ RtlQueryDepthSList(IN PSLIST_HEADER ListHead)
 {
 #ifdef _WIN64
     return ListHead->Header8.HeaderType ? 
-        ListHead->Header16.Sequence : ListHead->Header8.Sequence;
+        ListHead->Header16.Depth : ListHead->Header8.Depth;
 #else
     return ListHead->Depth;
 #endif