X-Git-Url: https://git.reactos.org/?p=reactos.git;a=blobdiff_plain;f=reactos%2Fntoskrnl%2Finclude%2Finternal%2Fex.h;fp=reactos%2Fntoskrnl%2Finclude%2Finternal%2Fex.h;h=f730c7a803afaf2ad0f45023b969083d0bb6867f;hp=bcf3471dbafafc53d172fa507fc96005489cd803;hb=0a0fa78d34885e529eb2323ad5eb38bb44b630ee;hpb=b27a0418ec7d79234f69fdd4b83f534fd89169e7;ds=sidebyside diff --git a/reactos/ntoskrnl/include/internal/ex.h b/reactos/ntoskrnl/include/internal/ex.h index bcf3471dbaf..f730c7a803a 100644 --- a/reactos/ntoskrnl/include/internal/ex.h +++ b/reactos/ntoskrnl/include/internal/ex.h @@ -49,6 +49,36 @@ PVOID ExpNlsSectionPointer; #define ExRundownCompleted _ExRundownCompleted #define ExGetPreviousMode KeGetPreviousMode +// +// Detect GCC 4.1.2+ +// +#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40102 + +// +// Broken GCC with Alignment Bug. We'll do alignment ourselves at higher cost. +// +#define DEFINE_WAIT_BLOCK(x) \ + struct _AlignHack \ + { \ + UCHAR Hack[15]; \ + EX_PUSH_LOCK_WAIT_BLOCK UnalignedBlock; \ + } WaitBlockBuffer; \ + PEX_PUSH_LOCK_WAIT_BLOCK x = (PEX_PUSH_LOCK_WAIT_BLOCK) \ + ((ULONG_PTR)&WaitBlockBuffer.UnalignedBlock &~ 0xF); + +#else + +// +// This is only for compatibility; the compiler will optimize the extra +// local variable (the actual pointer) away, so we don't take any perf hit +// by doing this. +// +#define DEFINE_WAIT_BLOCK(x) \ + EX_PUSH_LOCK_WAIT_BLOCK WaitBlockBuffer; \ + PEX_PUSH_LOCK_WAIT_BLOCK x = &WaitBlockBuffer; + +#endif + /* INITIALIZATION FUNCTIONS *************************************************/ VOID @@ -498,6 +528,23 @@ _ExRundownCompleted(IN PEX_RUNDOWN_REF RunRef) /* PUSHLOCKS *****************************************************************/ +/* FIXME: VERIFY THESE! */ + +VOID +FASTCALL +ExBlockPushLock(PEX_PUSH_LOCK PushLock, + PVOID WaitBlock); + +VOID +FASTCALL +ExfUnblockPushLock(PEX_PUSH_LOCK PushLock, + PVOID CurrentWaitBlock); + +VOID +FASTCALL +ExWaitForUnblockPushLock(IN PEX_PUSH_LOCK PushLock, + IN PEX_PUSH_LOCK_WAIT_BLOCK WaitBlock); + /*++ * @name ExInitializePushLock * INTERNAL MACRO @@ -653,12 +700,16 @@ VOID FORCEINLINE ExWaitOnPushLock(PEX_PUSH_LOCK PushLock) { - /* Acquire the lock */ - ExfAcquirePushLockExclusive(PushLock); - ASSERT(PushLock->Locked); + /* Check if we're locked */ + if (PushLock->Locked) + { + /* Acquire the lock */ + ExfAcquirePushLockExclusive(PushLock); + ASSERT(PushLock->Locked); - /* Release it */ - ExfReleasePushLockExclusive(PushLock); + /* Release it */ + ExfReleasePushLockExclusive(PushLock); + } } /*++