+//
+// 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
+