mirror of
https://github.com/reactos/reactos.git
synced 2025-02-25 01:39:30 +00:00
Change some FS:x reading macros for better compatibility with MSVC compiler and move KeGetCurrentKPCR/KeGetCurrentPrcb from DDK into ntoskrnl.
svn path=/trunk/; revision=19440
This commit is contained in:
parent
9ff8e85f1d
commit
8136033064
6 changed files with 75 additions and 44 deletions
|
@ -78,7 +78,7 @@ ExGetCurrentProcessorCounts (
|
|||
|
||||
*ThreadKernelTime = Prcb->KernelTime + Prcb->UserTime;
|
||||
*TotalCpuTime = Prcb->CurrentThread->KernelTime;
|
||||
*ProcessorNumber = KeGetCurrentKPCR()->Number;
|
||||
*ProcessorNumber = KeGetCurrentProcessorNumber();
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -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(); }
|
||||
|
|
|
@ -275,6 +275,38 @@ static __forceinline void Ke386SetPageTableDirectory(ULONG X)
|
|||
#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 */
|
||||
|
||||
|
|
|
@ -1355,7 +1355,7 @@ KeSetAffinityThread(PKTHREAD Thread,
|
|||
|
||||
if (Thread->State == Running) {
|
||||
|
||||
ProcessorMask = 1 << KeGetCurrentKPCR()->Number;
|
||||
ProcessorMask = 1 << KeGetCurrentProcessorNumber();
|
||||
if (Thread == KeGetCurrentThread()) {
|
||||
|
||||
if (!(Affinity & ProcessorMask)) {
|
||||
|
|
|
@ -140,38 +140,6 @@ typedef ULONG LOGICAL;
|
|||
*/
|
||||
#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 @@ static __inline struct _KPRCB * KeGetCurrentPrcb(
|
|||
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 @@ DDKAPI
|
|||
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 @@ DDKAPI
|
|||
KeLeaveCriticalRegion(
|
||||
VOID);
|
||||
|
||||
#ifdef _X86_
|
||||
|
||||
static __inline
|
||||
VOID
|
||||
KeMemoryBarrier(
|
||||
|
@ -8432,6 +8417,8 @@ KeMemoryBarrier(
|
|||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
NTOSAPI
|
||||
LONG
|
||||
DDKAPI
|
||||
|
|
|
@ -3609,6 +3609,16 @@ extern struct _TEB * NtCurrentTeb(void);
|
|||
|
||||
#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 @@ static __inline struct _TEB * NtCurrentTeb(void)
|
|||
return p;
|
||||
}
|
||||
|
||||
#endif /* _MSC_FULL_VER */
|
||||
|
||||
#endif /* __GNUC__/__WATCOMC__/_MSC_VER */
|
||||
|
||||
static __inline PVOID GetFiberData(void)
|
||||
|
|
Loading…
Reference in a new issue