Mesa (master): main: Undefine MemoryBarrier for Windows

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Jan 22 17:55:20 UTC 2021


Module: Mesa
Branch: master
Commit: 86b4f6ad43d635b63adf7bfe99f9eeb103f99255
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=86b4f6ad43d635b63adf7bfe99f9eeb103f99255

Author: Jesse Natalie <jenatali at microsoft.com>
Date:   Wed Jan 13 14:42:08 2021 -0800

main: Undefine MemoryBarrier for Windows

In winnt.h, MemoryBarrier can be defined in one of 4 ways, depending
on which architecture is being targeted.
- For x86, it's an inline function.
- For x64, it's an object-like macro, which means that the MemoryBarrier
  function in the table actually ends up being called __faststorefence.
- For arm and arm64, it's a function-like macro, and the preprocessor fails
  because the function table entry doesn't call it.

Reviewed-by: Ilia Mirkin <imirkin at alum.mit.edu>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8485>

---

 src/mesa/main/dd.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 3eaf20f061d..32ab2793f88 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -36,6 +36,14 @@
 #include "menums.h"
 #include "compiler/shader_enums.h"
 
+/* Windows winnt.h defines MemoryBarrier as a macro on some platforms,
+ * including as a function-like macro in some cases. That either causes
+ * the table entry below to have a weird name, or fail to compile.
+ */
+#ifdef MemoryBarrier
+#undef MemoryBarrier
+#endif
+
 struct gl_bitmap_atlas;
 struct gl_buffer_object;
 struct gl_context;



More information about the mesa-commit mailing list