From: Aleksey Bragin Date: Mon, 5 Feb 2007 20:14:59 +0000 (+0000) Subject: Merge 25584, 25588. X-Git-Tag: backups/alex-kd-branch@25995~25^2~30^2~14 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=0a0fa78d34885e529eb2323ad5eb38bb44b630ee Merge 25584, 25588. svn path=/branches/ros-branch-0_3_1/; revision=25730 --- 0a0fa78d34885e529eb2323ad5eb38bb44b630ee diff --cc reactos/ntoskrnl/include/internal/ex.h index bcf3471dbaf,002736ce6bb..f730c7a803a --- a/reactos/ntoskrnl/include/internal/ex.h +++ b/reactos/ntoskrnl/include/internal/ex.h @@@ -49,6 -75,57 +49,36 @@@ PVOID ExpNlsSectionPointer #define ExRundownCompleted _ExRundownCompleted #define ExGetPreviousMode KeGetPreviousMode - -// -// Various bits tagged on the handle or handle table -// -#define EXHANDLE_TABLE_ENTRY_LOCK_BIT 1 -#define FREE_HANDLE_MASK -1 - -// -// Number of entries in each table level -// -#define LOW_LEVEL_ENTRIES (PAGE_SIZE / sizeof(HANDLE_TABLE_ENTRY)) -#define MID_LEVEL_ENTRIES (PAGE_SIZE / sizeof(PHANDLE_TABLE_ENTRY)) -#define HIGH_LEVEL_ENTRIES (65535 / (LOW_LEVEL_ENTRIES * MID_LEVEL_ENTRIES)) - -// -// Maximum index in each table level before we need another table -// -#define MAX_LOW_INDEX LOW_LEVEL_ENTRIES -#define MAX_MID_INDEX (MID_LEVEL_ENTRIES * LOW_LEVEL_ENTRIES) -#define MAX_HIGH_INDEX (MID_LEVEL_ENTRIES * MID_LEVEL_ENTRIES * LOW_LEVEL_ENTRIES) - + // + // 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 @@@ -652,13 -819,17 +699,17 @@@ ExConvertPushLockSharedToExclusive(IN P 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); + } } /*++