Change some FS:x reading macros for better compatibility with MSVC compiler and move KeGetCurrentKPCR/KeGetCurrentPrcb from DDK into ntoskrnl.
Modified: trunk/reactos/ntoskrnl/ex/sysinfo.c
Modified: trunk/reactos/ntoskrnl/include/internal/debug.h
Modified: trunk/reactos/ntoskrnl/include/internal/i386/ke.h
Modified: trunk/reactos/ntoskrnl/ke/kthread.c
Modified: trunk/reactos/w32api/include/ddk/winddk.h
Modified: trunk/reactos/w32api/include/winnt.h

Modified: trunk/reactos/ntoskrnl/ex/sysinfo.c
--- trunk/reactos/ntoskrnl/ex/sysinfo.c	2005-11-22 00:38:45 UTC (rev 19439)
+++ trunk/reactos/ntoskrnl/ex/sysinfo.c	2005-11-22 00:47:58 UTC (rev 19440)
@@ -78,7 +78,7 @@
 
 	*ThreadKernelTime = Prcb->KernelTime + Prcb->UserTime;
 	*TotalCpuTime = Prcb->CurrentThread->KernelTime;
-	*ProcessorNumber = KeGetCurrentKPCR()->Number;
+	*ProcessorNumber = KeGetCurrentProcessorNumber();
 }
 
 /*

Modified: trunk/reactos/ntoskrnl/include/internal/debug.h
--- trunk/reactos/ntoskrnl/include/internal/debug.h	2005-11-22 00:38:45 UTC (rev 19439)
+++ trunk/reactos/ntoskrnl/include/internal/debug.h	2005-11-22 00:47:58 UTC (rev 19440)
@@ -35,8 +35,8 @@
 /* Assert only on "checked" version */
 #ifndef NASSERT
 #ifdef CONFIG_SMP
-#define assert(x) if (!(x)) {DbgPrint("Assertion "#x" failed at %s:%d for CPU%d\n", __FILE__,__LINE__, KeGetCurrentKPCR()->Number), DbgBreakPoint(); }
-#define ASSERT(x) if (!(x)) {DbgPrint("Assertion "#x" failed at %s:%d for CPU%d\n", __FILE__,__LINE__, KeGetCurrentKPCR()->Number), DbgBreakPoint(); }
+#define assert(x) if (!(x)) {DbgPrint("Assertion "#x" failed at %s:%d for CPU%d\n", __FILE__,__LINE__, KeGetCurrentProcessorNumber()), DbgBreakPoint(); }
+#define ASSERT(x) if (!(x)) {DbgPrint("Assertion "#x" failed at %s:%d for CPU%d\n", __FILE__,__LINE__, KeGetCurrentProcessorNumber()), DbgBreakPoint(); }
 #else
 #define assert(x) if (!(x)) {DbgPrint("Assertion "#x" failed at %s:%d\n", __FILE__,__LINE__); DbgBreakPoint(); }
 #define ASSERT(x) if (!(x)) {DbgPrint("Assertion "#x" failed at %s:%d\n", __FILE__,__LINE__); DbgBreakPoint(); }

Modified: trunk/reactos/ntoskrnl/include/internal/i386/ke.h
--- trunk/reactos/ntoskrnl/include/internal/i386/ke.h	2005-11-22 00:38:45 UTC (rev 19439)
+++ trunk/reactos/ntoskrnl/include/internal/i386/ke.h	2005-11-22 00:47:58 UTC (rev 19440)
@@ -275,7 +275,39 @@
 #error Unknown compiler for inline assembler
 #endif
 
+static __inline struct _KPCR * KeGetCurrentKPCR(
+  VOID)
+{
+  ULONG Value;
+#if defined(__GNUC__)
+  __asm__ __volatile__ ("movl %%fs:0x1C, %0\n\t"
+	  : "=r" (Value)
+    : /* no inputs */
+  );
+#elif defined(_MSC_VER)
+  __asm mov eax, fs:[1Ch]
+  __asm mov [Value], eax
 #endif
+  return (struct _KPCR *) Value;
+}
+
+static __inline struct _KPRCB * KeGetCurrentPrcb(
+  VOID)
+{
+  ULONG Value;
+#if defined(__GNUC__)
+  __asm__ __volatile__ ("movl %%fs:0x20, %0\n\t"
+	  : "=r" (Value)
+    : /* no inputs */
+  );
+#elif defined(_MSC_VER)
+  __asm mov eax, fs:[20h]
+  __asm mov [Value], eax
+#endif
+  return (struct _KPRCB *) Value;
+}
+
+#endif
 #endif /* __NTOSKRNL_INCLUDE_INTERNAL_I386_KE_H */
 
 /* EOF */

Modified: trunk/reactos/ntoskrnl/ke/kthread.c
--- trunk/reactos/ntoskrnl/ke/kthread.c	2005-11-22 00:38:45 UTC (rev 19439)
+++ trunk/reactos/ntoskrnl/ke/kthread.c	2005-11-22 00:47:58 UTC (rev 19440)
@@ -1355,7 +1355,7 @@
 
         if (Thread->State == Running) {
 
-            ProcessorMask = 1 << KeGetCurrentKPCR()->Number;
+            ProcessorMask = 1 << KeGetCurrentProcessorNumber();
             if (Thread == KeGetCurrentThread()) {
 
                 if (!(Affinity & ProcessorMask)) {

Modified: trunk/reactos/w32api/include/ddk/winddk.h
--- trunk/reactos/w32api/include/ddk/winddk.h	2005-11-22 00:38:45 UTC (rev 19439)
+++ trunk/reactos/w32api/include/ddk/winddk.h	2005-11-22 00:47:58 UTC (rev 19440)
@@ -140,38 +140,6 @@
 */
 #define NtCurrentThread() ( (HANDLE)(LONG_PTR) -2 )   
 
-static __inline struct _KPCR * KeGetCurrentKPCR(
-  VOID)
-{
-  ULONG Value;
-#if defined(__GNUC__)
-  __asm__ __volatile__ ("movl %%fs:0x1C, %0\n\t"
-	  : "=r" (Value)
-    : /* no inputs */
-  );
-#elif defined(_MSC_VER)
-  __asm mov eax, fs:[1Ch]
-  __asm mov [Value], eax
-#endif
-  return (struct _KPCR *) Value;
-}
-
-static __inline struct _KPRCB * KeGetCurrentPrcb(
-  VOID)
-{
-  ULONG Value;
-#if defined(__GNUC__)
-  __asm__ __volatile__ ("movl %%fs:0x20, %0\n\t"
-	  : "=r" (Value)
-    : /* no inputs */
-  );
-#elif defined(_MSC_VER)
-  __asm mov eax, fs:[20h]
-  __asm mov [Value], eax
-#endif
-  return (struct _KPRCB *) Value;
-}
-
 /*
 ** Simple structures
 */
@@ -179,7 +147,6 @@
 typedef LONG KPRIORITY;
 typedef UCHAR KIRQL, *PKIRQL;
 typedef ULONG_PTR KSPIN_LOCK, *PKSPIN_LOCK;
-typedef ULONG KAFFINITY, *PKAFFINITY;
 typedef UCHAR KPROCESSOR_MODE;
 
 typedef enum _MODE {
@@ -4976,13 +4943,29 @@
 KeGetCurrentIrql(
   VOID);
 
-/*
- * ULONG
- * KeGetCurrentProcessorNumber(
- *   VOID)
- */
-#define KeGetCurrentProcessorNumber() \
-  ((ULONG)KeGetCurrentKPCR()->Number)
+static __inline
+ULONG
+DDKAPI
+KeGetCurrentProcessorNumber(VOID)
+{
+#if defined(__GNUC__)
+  ULONG ret;
+  __asm__ __volatile__ (
+    "movl %%fs:%c1, %0\n"
+    : "=r" (ret)
+    : "i" (FIELD_OFFSET(KPCR, Number))
+  );
+  return ret;
+#elif defined(_MSC_VER)
+#if _MSC_FULL_VER >= 13012035
+  return (ULONG)__readfsbyte(FIELD_OFFSET(KPCR, Number));
+#else
+  __asm { movzx eax, _PCR KPCR.Number }
+#endif
+#else
+#error Unknown compiler
+#endif
+}
 
 #if !defined(__INTERLOCKED_DECLARED)
 #define __INTERLOCKED_DECLARED
@@ -8419,6 +8402,8 @@
 KeLeaveCriticalRegion(
   VOID);
 
+#ifdef _X86_
+
 static __inline
 VOID
 KeMemoryBarrier(
@@ -8432,6 +8417,8 @@
 #endif
 }
 
+#endif
+
 NTOSAPI
 LONG
 DDKAPI

Modified: trunk/reactos/w32api/include/winnt.h
--- trunk/reactos/w32api/include/winnt.h	2005-11-22 00:38:45 UTC (rev 19439)
+++ trunk/reactos/w32api/include/winnt.h	2005-11-22 00:47:58 UTC (rev 19440)
@@ -3609,6 +3609,16 @@
 
 #elif defined(_MSC_VER)
 
+#if (_MSC_FULL_VER >= 13012035)
+
+DWORD __readfsdword(DWORD);
+#pragma intrinsic(__readfsdword)
+
+__inline PVOID GetCurrentFiber(void) { return (PVOID)(ULONG_PTR)__readfsdword(0x10); }
+__inline struct _TEB * NtCurrentTeb(void) { return (PVOID)(ULONG_PTR)__readfsdword(0x18); }
+
+#else
+
 static __inline PVOID GetCurrentFiber(void)
 {
     PVOID p;
@@ -3625,6 +3635,8 @@
     return p;
 }
 
+#endif /* _MSC_FULL_VER */
+
 #endif /* __GNUC__/__WATCOMC__/_MSC_VER */
 
 static __inline PVOID GetFiberData(void)