Merge 25584, 25588.
authorAleksey Bragin <aleksey@reactos.org>
Mon, 5 Feb 2007 20:14:59 +0000 (20:14 +0000)
committerAleksey Bragin <aleksey@reactos.org>
Mon, 5 Feb 2007 20:14:59 +0000 (20:14 +0000)
svn path=/branches/ros-branch-0_3_1/; revision=25730

1  2 
reactos/ntoskrnl/ex/init.c
reactos/ntoskrnl/include/internal/ex.h

Simple merge
@@@ -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);
+     }
  }
  
  /*++