mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 22:23:01 +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;
|
*ThreadKernelTime = Prcb->KernelTime + Prcb->UserTime;
|
||||||
*TotalCpuTime = Prcb->CurrentThread->KernelTime;
|
*TotalCpuTime = Prcb->CurrentThread->KernelTime;
|
||||||
*ProcessorNumber = KeGetCurrentKPCR()->Number;
|
*ProcessorNumber = KeGetCurrentProcessorNumber();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -35,8 +35,8 @@
|
||||||
/* Assert only on "checked" version */
|
/* Assert only on "checked" version */
|
||||||
#ifndef NASSERT
|
#ifndef NASSERT
|
||||||
#ifdef CONFIG_SMP
|
#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__, KeGetCurrentProcessorNumber()), 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(); }
|
||||||
#else
|
#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(); }
|
||||||
#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
|
#error Unknown compiler for inline assembler
|
||||||
#endif
|
#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
|
||||||
#endif /* __NTOSKRNL_INCLUDE_INTERNAL_I386_KE_H */
|
#endif /* __NTOSKRNL_INCLUDE_INTERNAL_I386_KE_H */
|
||||||
|
|
||||||
|
|
|
@ -1355,7 +1355,7 @@ KeSetAffinityThread(PKTHREAD Thread,
|
||||||
|
|
||||||
if (Thread->State == Running) {
|
if (Thread->State == Running) {
|
||||||
|
|
||||||
ProcessorMask = 1 << KeGetCurrentKPCR()->Number;
|
ProcessorMask = 1 << KeGetCurrentProcessorNumber();
|
||||||
if (Thread == KeGetCurrentThread()) {
|
if (Thread == KeGetCurrentThread()) {
|
||||||
|
|
||||||
if (!(Affinity & ProcessorMask)) {
|
if (!(Affinity & ProcessorMask)) {
|
||||||
|
|
|
@ -140,38 +140,6 @@ typedef ULONG LOGICAL;
|
||||||
*/
|
*/
|
||||||
#define NtCurrentThread() ( (HANDLE)(LONG_PTR) -2 )
|
#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
|
** Simple structures
|
||||||
*/
|
*/
|
||||||
|
@ -179,7 +147,6 @@ static __inline struct _KPRCB * KeGetCurrentPrcb(
|
||||||
typedef LONG KPRIORITY;
|
typedef LONG KPRIORITY;
|
||||||
typedef UCHAR KIRQL, *PKIRQL;
|
typedef UCHAR KIRQL, *PKIRQL;
|
||||||
typedef ULONG_PTR KSPIN_LOCK, *PKSPIN_LOCK;
|
typedef ULONG_PTR KSPIN_LOCK, *PKSPIN_LOCK;
|
||||||
typedef ULONG KAFFINITY, *PKAFFINITY;
|
|
||||||
typedef UCHAR KPROCESSOR_MODE;
|
typedef UCHAR KPROCESSOR_MODE;
|
||||||
|
|
||||||
typedef enum _MODE {
|
typedef enum _MODE {
|
||||||
|
@ -4976,13 +4943,29 @@ DDKAPI
|
||||||
KeGetCurrentIrql(
|
KeGetCurrentIrql(
|
||||||
VOID);
|
VOID);
|
||||||
|
|
||||||
/*
|
static __inline
|
||||||
* ULONG
|
ULONG
|
||||||
* KeGetCurrentProcessorNumber(
|
DDKAPI
|
||||||
* VOID)
|
KeGetCurrentProcessorNumber(VOID)
|
||||||
*/
|
{
|
||||||
#define KeGetCurrentProcessorNumber() \
|
#if defined(__GNUC__)
|
||||||
((ULONG)KeGetCurrentKPCR()->Number)
|
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)
|
#if !defined(__INTERLOCKED_DECLARED)
|
||||||
#define __INTERLOCKED_DECLARED
|
#define __INTERLOCKED_DECLARED
|
||||||
|
@ -8419,6 +8402,8 @@ DDKAPI
|
||||||
KeLeaveCriticalRegion(
|
KeLeaveCriticalRegion(
|
||||||
VOID);
|
VOID);
|
||||||
|
|
||||||
|
#ifdef _X86_
|
||||||
|
|
||||||
static __inline
|
static __inline
|
||||||
VOID
|
VOID
|
||||||
KeMemoryBarrier(
|
KeMemoryBarrier(
|
||||||
|
@ -8432,6 +8417,8 @@ KeMemoryBarrier(
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
NTOSAPI
|
NTOSAPI
|
||||||
LONG
|
LONG
|
||||||
DDKAPI
|
DDKAPI
|
||||||
|
|
|
@ -3609,6 +3609,16 @@ extern struct _TEB * NtCurrentTeb(void);
|
||||||
|
|
||||||
#elif defined(_MSC_VER)
|
#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)
|
static __inline PVOID GetCurrentFiber(void)
|
||||||
{
|
{
|
||||||
PVOID p;
|
PVOID p;
|
||||||
|
@ -3625,6 +3635,8 @@ static __inline struct _TEB * NtCurrentTeb(void)
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* _MSC_FULL_VER */
|
||||||
|
|
||||||
#endif /* __GNUC__/__WATCOMC__/_MSC_VER */
|
#endif /* __GNUC__/__WATCOMC__/_MSC_VER */
|
||||||
|
|
||||||
static __inline PVOID GetFiberData(void)
|
static __inline PVOID GetFiberData(void)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue