Mesa (main): nir/spirv: guard macros in case of redefinition

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Feb 21 20:41:45 UTC 2022


Module: Mesa
Branch: main
Commit: 2cd0779f831819d58994d15da23dbe49a8b7c992
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=2cd0779f831819d58994d15da23dbe49a8b7c992

Author: Erik Faye-Lund <kusmabite at gmail.com>
Date:   Fri Feb 18 18:29:34 2022 +0100

nir/spirv: guard macros in case of redefinition

On some systems, these macros are already defined, and being defined
slightly differently causes them to emit redefinition-warnings.

Let's wrap them in ifdefs to avoid the warnings.

Acked-by: Caio Oliveira <caio.oliveira at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15084>

---

 src/compiler/glsl/builtin_functions.cpp | 6 ++++++
 src/compiler/spirv/vtn_glsl450.c        | 6 ++++++
 2 files changed, 12 insertions(+)

diff --git a/src/compiler/glsl/builtin_functions.cpp b/src/compiler/glsl/builtin_functions.cpp
index d41516a74f4..0f9db2ab5fb 100644
--- a/src/compiler/glsl/builtin_functions.cpp
+++ b/src/compiler/glsl/builtin_functions.cpp
@@ -85,9 +85,15 @@
 #include "builtin_functions.h"
 #include "util/hash_table.h"
 
+#ifndef M_PIf
 #define M_PIf   ((float) M_PI)
+#endif
+#ifndef M_PI_2f
 #define M_PI_2f ((float) M_PI_2)
+#endif
+#ifndef M_PI_4f
 #define M_PI_4f ((float) M_PI_4)
+#endif
 
 using namespace ir_builder;
 
diff --git a/src/compiler/spirv/vtn_glsl450.c b/src/compiler/spirv/vtn_glsl450.c
index 16ef20f97c3..a8446f50a34 100644
--- a/src/compiler/spirv/vtn_glsl450.c
+++ b/src/compiler/spirv/vtn_glsl450.c
@@ -32,9 +32,15 @@
 #include "vtn_private.h"
 #include "GLSL.std.450.h"
 
+#ifndef M_PIf
 #define M_PIf   ((float) M_PI)
+#endif
+#ifndef M_PI_2f
 #define M_PI_2f ((float) M_PI_2)
+#endif
+#ifndef M_PI_4f
 #define M_PI_4f ((float) M_PI_4)
+#endif
 
 static nir_ssa_def *build_det(nir_builder *b, nir_ssa_def **col, unsigned cols);
 



More information about the mesa-commit mailing list