endif()
set(USE_DUMMY_PSEH FALSE CACHE BOOL
-"Whether to disable PSEH support.")
\ No newline at end of file
+"Whether to disable PSEH support.")
add_compile_flags("-march=${OARCH}")
endif()
-# Warnings
-add_compile_flags("-Werror -Wall -Wno-char-subscripts -Wpointer-arith -Wno-multichar -Wno-unused-value")
-
-if(GCC_VERSION VERSION_LESS 4.7)
- add_compile_flags("-Wno-error=uninitialized")
-elseif(GCC_VERSION VERSION_EQUAL 4.7 OR GCC_VERSION VERSION_GREATER 4.7)
- add_compile_flags("-Wno-error=unused-but-set-variable -Wno-maybe-uninitialized -Wno-error=narrowing")
-endif()
+# Warnings, errors
+add_compile_flags("-Werror -Wall -Wpointer-arith")
+add_compile_flags("-Wno-char-subscripts -Wno-multichar -Wno-unused-value -Wno-maybe-uninitialized")
+add_compile_flags("-Wno-error=unused-but-set-variable -Wno-error=narrowing")
if(ARCH STREQUAL "amd64")
add_compile_flags("-Wno-format")
elseif(OPTIMIZE STREQUAL "2")
add_compile_flags("-Os")
elseif(OPTIMIZE STREQUAL "3")
- add_compile_flags("-O1 -fno-inline-functions-called-once -fno-tree-sra")
+ add_compile_flags("-Og")
elseif(OPTIMIZE STREQUAL "4")
add_compile_flags("-O1")
elseif(OPTIMIZE STREQUAL "5")
/* BUGBUG: only good for use in macros. Cannot be taken the address of */
#define __noop(...) ((void)0)
-/* TODO: __assume. GCC only supports the weaker __builtin_expect */
+#define __assume(x) if (!(x)) __builtin_unreachable()
#endif
/* BUGBUG: only good for use in macros. Cannot be taken the address of */
#define __noop(...) ((void)0)
-/* TODO: __assume. GCC only supports the weaker __builtin_expect */
+#define __assume(x) if (!(x)) __builtin_unreachable()
#endif
/* EOF */
RTL_SRWLOCK_SHARED | RTL_SRWLOCK_CONTENTION_LOCK)
#define RTL_SRWLOCK_BITS 4
-#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ < 40300) || \
- (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ == 40303)
-/* This macro will cause the code to assert if compiled with a buggy
- version of GCC that doesn't align the wait blocks properly on the stack! */
-#define ASSERT_SRW_WAITBLOCK(ptr) \
- ASSERT(((ULONG_PTR)ptr & ((1 << RTL_SRWLOCK_BITS) - 1)) == 0)
-#else
-#define ASSERT_SRW_WAITBLOCK(ptr) ((void)0)
-#endif
-
typedef struct _RTLP_SRWLOCK_SHARED_WAKE
{
LONG Wake;
WaitBlock = (PRTLP_SRWLOCK_WAITBLOCK)(PrevValue & ~RTL_SRWLOCK_MASK);
- ASSERT_SRW_WAITBLOCK(WaitBlock);
return WaitBlock;
}
Shared->LastSharedWake = &SharedWake;
- ASSERT_SRW_WAITBLOCK(Shared);
-
RtlpReleaseWaitBlockLock(SRWLock);
RtlpAcquireSRWLockSharedWait(SRWLock,
Shared->LastSharedWake->Next = &SharedWake;
}
- ASSERT_SRW_WAITBLOCK(Shared);
-
Shared->SharedCount++;
Shared->LastSharedWake = &SharedWake;
StackWaitBlock.SharedWakeChain = &SharedWake;
StackWaitBlock.LastSharedWake = &SharedWake;
- ASSERT_SRW_WAITBLOCK(&StackWaitBlock);
-
NewValue = (ULONG_PTR)&StackWaitBlock | RTL_SRWLOCK_OWNED | RTL_SRWLOCK_CONTENDED;
if ((LONG_PTR)InterlockedCompareExchangePointer(&SRWLock->Ptr,
(PVOID)NewValue,
StackWaitBlock.Last = &StackWaitBlock;
StackWaitBlock.Wake = 0;
- ASSERT_SRW_WAITBLOCK(&StackWaitBlock);
-
NewValue = (ULONG_PTR)&StackWaitBlock | RTL_SRWLOCK_SHARED | RTL_SRWLOCK_CONTENDED | RTL_SRWLOCK_OWNED;
if ((LONG_PTR)InterlockedCompareExchangePointer(&SRWLock->Ptr,
StackWaitBlock.Last = &StackWaitBlock;
StackWaitBlock.Wake = 0;
- ASSERT_SRW_WAITBLOCK(&StackWaitBlock);
-
First = RtlpAcquireWaitBlockLock(SRWLock);
if (First != NULL)
{
StackWaitBlock.Last = &StackWaitBlock;
StackWaitBlock.Wake = 0;
- ASSERT_SRW_WAITBLOCK(&StackWaitBlock);
-
NewValue = (ULONG_PTR)&StackWaitBlock | RTL_SRWLOCK_OWNED | RTL_SRWLOCK_CONTENDED;
if ((LONG_PTR)InterlockedCompareExchangePointer(&SRWLock->Ptr,
(PVOID)NewValue,
IN PHANDLE_TABLE_ENTRY HandleTableEntry)
{
LONG_PTR OldValue;
- DEFINE_WAIT_BLOCK(WaitBlock);
+ EX_PUSH_LOCK_WAIT_BLOCK WaitBlock;
/* Block on the pushlock */
- ExBlockPushLock(&HandleTable->HandleContentionEvent, WaitBlock);
+ ExBlockPushLock(&HandleTable->HandleContentionEvent, &WaitBlock);
/* Get the current value and check if it's been unlocked */
OldValue = HandleTableEntry->Value;
if (!(OldValue) || (OldValue & EXHANDLE_TABLE_ENTRY_LOCK_BIT))
{
/* Unblock the pushlock and return */
- ExfUnblockPushLock(&HandleTable->HandleContentionEvent, WaitBlock);
+ ExfUnblockPushLock(&HandleTable->HandleContentionEvent, &WaitBlock);
}
else
{
/* Wait for it to be unblocked */
ExWaitForUnblockPushLock(&HandleTable->HandleContentionEvent,
- WaitBlock);
+ &WaitBlock);
}
}
{
EX_PUSH_LOCK OldValue = *PushLock, NewValue, TempValue;
BOOLEAN NeedWake;
- DEFINE_WAIT_BLOCK(WaitBlock);
+ EX_PUSH_LOCK_WAIT_BLOCK Block;
+ PEX_PUSH_LOCK_WAIT_BLOCK WaitBlock = &Block;
/* Start main loop */
for (;;)
{
EX_PUSH_LOCK OldValue = *PushLock, NewValue;
BOOLEAN NeedWake;
- DEFINE_WAIT_BLOCK(WaitBlock);
+ EX_PUSH_LOCK_WAIT_BLOCK Block;
+ PEX_PUSH_LOCK_WAIT_BLOCK WaitBlock = &Block;
/* Start main loop */
for (;;)
ASSERT(FileObject);
ASSERT(FileObject->FsContext);
-#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ == 405)
- /* Silence incorrect GCC 4.5.x warning */
- OldFileSize.LowPart = 0;
-#endif
-
/* Initialize some of the vars and pointers */
NewSize.QuadPart = 0;
Offset.QuadPart = FileOffset->QuadPart + Length;
{
LARGE_INTEGER OldFileSize;
-#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ == 405)
- /* Silence incorrect GCC 4.5.x warning */
- OldFileSize.QuadPart = 0;
-#endif
-
/* Sanity check */
ASSERT(!KeIsExecutingDpc());
#define MAX_MID_INDEX (MID_LEVEL_ENTRIES * LOW_LEVEL_ENTRIES)
#define MAX_HIGH_INDEX (MID_LEVEL_ENTRIES * MID_LEVEL_ENTRIES * LOW_LEVEL_ENTRIES)
-//
-// Detect old GCC
-//
-#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ < 40300) || \
- (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ == 40303)
-
-#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
-
#define ExpChangeRundown(x, y, z) (ULONG_PTR)InterlockedCompareExchangePointer(&x->Ptr, (PVOID)y, (PVOID)z)
#define ExpChangePushlock(x, y, z) InterlockedCompareExchangePointer((PVOID*)x, (PVOID)y, (PVOID)z)
#define ExpSetRundown(x, y) InterlockedExchangePointer(&x->Ptr, (PVOID)y)
#define TRAP_DEBUG 0
-//
-// Unreachable code hint for GCC 4.5.x, older GCC versions, and MSVC
-//
-#ifdef __GNUC__
-#if __GNUC__ * 100 + __GNUC_MINOR__ >= 405
-#define UNREACHABLE __builtin_unreachable()
-#else
-#define UNREACHABLE __builtin_trap()
-#endif
-#elif _MSC_VER
#define UNREACHABLE __assume(0)
+
+#if _MSC_VER
#define __builtin_expect(a,b) (a)
-#else
-#define UNREACHABLE
#endif
//