]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
Mask ftepp math constants with a compiler flag
authorDale Weiler <killfieldengine@gmail.com>
Sun, 1 Dec 2013 15:45:43 +0000 (10:45 -0500)
committerDale Weiler <killfieldengine@gmail.com>
Sun, 1 Dec 2013 15:45:43 +0000 (10:45 -0500)
doc/gmqcc.1
ftepp.c
gmqcc.ini.example
opts.def

index 2a205bbbeef634870e788eec0abfad1aa90185b9..7ee54c01cab814924cbc17f04fa67e903cd08b86 100644 (file)
@@ -397,6 +397,26 @@ only the first component will be 0, while the other two will become
 the first to of the global return value. This behavior is odd and
 relying on it should be discouraged, and thus is not supported by
 gmqcc.
+.It Fl f Ns Cm ftepp-mathdefs
+Enable math constant definitions. This only works in combination
+with \'\-fftepp' and is currently not included by '\-std=fteqcc'.
+The following macros will be added:
+.Bd -literal -offset indent
+M_E
+M_LOG2E
+M_LOG10E
+M_LN2
+M_LN10
+M_PI
+M_PI_2
+M_PI_4
+M_1_PI
+M_2_PI
+M_2_SQRTPI
+M_SQRT2
+M_SQRT1_2
+M_TAU
+.Ed
 .It Fl f Ns Cm relaxed-switch
 Allow switch cases to use non constant variables.
 .It Fl f Ns Cm short-logic
diff --git a/ftepp.c b/ftepp.c
index 82495b44e3c2353ebe101af7b43dd84359882c2e..496a46a337e5571ffacd95655183a638bfa92994 100644 (file)
--- a/ftepp.c
+++ b/ftepp.c
@@ -1900,9 +1900,11 @@ ftepp_t *ftepp_create()
     ftepp_add_macro(ftepp, "__NULL__", "nil");
 
     /* add all the math constants if they can be */
-    for (i = 0; i < GMQCC_ARRAY_COUNT(ftepp_math_constants); i++)
-        if (!ftepp_macro_find(ftepp, ftepp_math_constants[i][0]))
-            ftepp_add_macro(ftepp, ftepp_math_constants[i][0], ftepp_math_constants[i][1]);
+    if (OPTS_FLAG(FTEPP_MATHDEFS)) {
+        for (i = 0; i < GMQCC_ARRAY_COUNT(ftepp_math_constants); i++)
+            if (!ftepp_macro_find(ftepp, ftepp_math_constants[i][0]))
+                ftepp_add_macro(ftepp, ftepp_math_constants[i][0], ftepp_math_constants[i][1]);
+    }
 
     return ftepp;
 }
index 0a263df6da6631aeabfb159884ee30c3eb2bd093..20680d372771cc2d0972e8508fa3632ff2cc5849 100644 (file)
     FTEPP_PREDEFS = false
 
 
+    #Enable math constant definitions. This only works in combination
+    #with '-fftepp' and is currently not included by '-std=fteqcc'.
+    #The following macros will be added:
+    #
+    # M_E
+    # M_LOG2E
+    # M_LOG10E
+    # M_LN2
+    # M_LN10
+    # M_PI
+    # M_PI_2
+    # M_PI_4
+    # M_1_PI
+    # M_2_PI
+    # M_2_SQRTPI
+    # M_SQRT2
+    # M_SQRT1_2
+    # M_TAU
+
+    FTEPP_MATHDEFS = false
+
+
     #Allow switch cases to use non constant variables.
 
     RELAXED_SWITCH = true
index b2099886b0c7913ee028825fcb17bd5b84615fcf..4ccd409477391b3871a45983338b8ac3cce2ba34 100644 (file)
--- a/opts.def
+++ b/opts.def
@@ -31,6 +31,7 @@
     GMQCC_DEFINE_FLAG(ADJUST_VECTOR_FIELDS)
     GMQCC_DEFINE_FLAG(FTEPP)
     GMQCC_DEFINE_FLAG(FTEPP_PREDEFS)
+    GMQCC_DEFINE_FLAG(FTEPP_MATHDEFS)
     GMQCC_DEFINE_FLAG(RELAXED_SWITCH)
     GMQCC_DEFINE_FLAG(SHORT_LOGIC)
     GMQCC_DEFINE_FLAG(PERL_LOGIC)