Mesa (master): glsl: simplify the M_PI*f macros, fixes build on OpenBSD

Matt Turner mattst88 at kemper.freedesktop.org
Wed May 14 05:30:19 UTC 2014


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

Author: Jonathan Gray <jsg at jsg.id.au>
Date:   Wed May 14 15:13:55 2014 +1000

glsl: simplify the M_PI*f macros, fixes build on OpenBSD

The M_PI*f macros used a preprocessor paste to append 'f'
to M_PI defines, which works if the values are only numbers
but breaks on OpenBSD where M_PI definitions have casts
and brackets to meet requirements of a future version of POSIX,

http://austingroupbugs.net/view.php?id=801
http://austingroupbugs.net/view.php?id=828

Simplify the M_PI*f macros by using casts directly in the defines
as suggested by Kenneth Graunke.

Cc: "10.2" <mesa-stable at lists.freedesktop.org>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=78665
Reviewed-by: Matt Turner <mattst88 at gmail.com>
Signed-off-by: Jonathan Gray <jsg at jsg.id.au>

---

 src/glsl/builtin_functions.cpp |    8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/glsl/builtin_functions.cpp b/src/glsl/builtin_functions.cpp
index 3991f9d..f9f0686 100644
--- a/src/glsl/builtin_functions.cpp
+++ b/src/glsl/builtin_functions.cpp
@@ -62,11 +62,9 @@
 #include "program/prog_instruction.h"
 #include <limits>
 
-#define f(x) join(x)
-#define join(x) x ## f
-#define M_PIf f(M_PI)
-#define M_PI_2f f(M_PI_2)
-#define M_PI_4f f(M_PI_4)
+#define M_PIf   ((float) M_PI)
+#define M_PI_2f ((float) M_PI_2)
+#define M_PI_4f ((float) M_PI_4)
 
 using namespace ir_builder;
 




More information about the mesa-commit mailing list