aboutsummaryrefslogtreecommitdiffstats
path: root/include/tgmath.h
diff options
context:
space:
mode:
authorEd Schouten <ed@FreeBSD.org>2012-01-06 16:20:17 +0000
committerEd Schouten <ed@FreeBSD.org>2012-01-06 16:20:17 +0000
commit81ec6b6b473e3989023b827aba390548fd6a5bb8 (patch)
tree37cedac536cc399d2ec786b1855ab3247b7bc825 /include/tgmath.h
parent48df024e0f01adba38156d2e07333a5254de9d18 (diff)
downloadsrc-81ec6b6b473e3989023b827aba390548fd6a5bb8.tar.gz
src-81ec6b6b473e3989023b827aba390548fd6a5bb8.zip
Add an even faster implementation of <tgmath.h> for the future.
Instead of using an exponential number of cases with respect to the number of arguments, this version only uses a linear number. Unfortunately, it works with Clang, GCC 4.6 and GCC 4.7, but not GCC 4.2. Therefore, leave it commented out.
Notes
Notes: svn path=/head/; revision=229704
Diffstat (limited to 'include/tgmath.h')
-rw-r--r--include/tgmath.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/include/tgmath.h b/include/tgmath.h
index 372274f5e162..9de0afe4248b 100644
--- a/include/tgmath.h
+++ b/include/tgmath.h
@@ -59,6 +59,25 @@
#error "<tgmath.h> not implemented for this compiler"
#endif
+#if 0 /* XXX: Much shorter and faster to compile, but broken with GCC 4.2. */
+#define __tg_generic(x, cfnl, cfn, cfnf, fnl, fn, fnf) \
+ __generic(x, long double _Complex, cfnl, \
+ __generic(x, double _Complex, cfn, \
+ __generic(x, float _Complex, cfnf, \
+ __generic(x, long double, fnl, \
+ __generic(x, float, fnf, fn)))))
+#define __tg_type(x) \
+ __tg_generic(x, (long double _Complex)0, (double _Complex)0, \
+ (float _Complex)0, (long double)0, (double)0, (float)0)
+#define __tg_impl_simple(x, y, z, fnl, fn, fnf, ...) \
+ __tg_generic( \
+ __tg_type(x) + __tg_type(y) + __tg_type(z), \
+ fnl, fn, fnf, fnl, fn, fnf)(__VA_ARGS__)
+#define __tg_impl_full(x, y, cfnl, cfn, cfnf, fnl, fn, fnf, ...) \
+ __tg_generic( \
+ __tg_type(x) + __tg_type(y), \
+ cfnl, cfn, cfnf, fnl, fn, fnf)(__VA_ARGS__)
+#else
#define __tg_generic_simple(x, fnl, fn, fnf) \
__generic(x, long double _Complex, fnl, \
__generic(x, double _Complex, fn, \
@@ -94,6 +113,7 @@
__tg_generic_full(y, cfnl, cfn , cfn , fnl , fn , fn ), \
__tg_generic_full(y, cfnl, cfn , cfnf, fnl , fn , fnf )) \
(__VA_ARGS__)
+#endif
/* Macros to save lots of repetition below */
#define __tg_simple(x, fn) \