about summary refs log tree commit diff
path: root/math/math.h
diff options
context:
space:
mode:
Diffstat (limited to 'math/math.h')
-rw-r--r--math/math.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/math/math.h b/math/math.h
index 3b0bcadb00..5f006a8358 100644
--- a/math/math.h
+++ b/math/math.h
@@ -340,6 +340,27 @@ extern int signgam;
 #ifdef __NO_LONG_DOUBLE_MATH
 # define __MATH_TG(TG_ARG, FUNC, ARGS)					\
   (sizeof (TG_ARG) == sizeof (float) ? FUNC ## f ARGS : FUNC ARGS)
+#elif __HAVE_DISTINCT_FLOAT128
+# if __HAVE_GENERIC_SELECTION
+#  define __MATH_TG(TG_ARG, FUNC, ARGS)		\
+     _Generic ((TG_ARG),			\
+	       float: FUNC ## f ARGS,		\
+	       default: FUNC ARGS,		\
+	       long double: FUNC ## l ARGS,	\
+	       _Float128: FUNC ## f128 ARGS)
+# else
+#  define __MATH_TG(TG_ARG, FUNC, ARGS)					\
+     __builtin_choose_expr						\
+     (__builtin_types_compatible_p (__typeof (TG_ARG), float),		\
+      FUNC ## f ARGS,							\
+      __builtin_choose_expr						\
+      (__builtin_types_compatible_p (__typeof (TG_ARG), double),	\
+       FUNC ARGS,							\
+       __builtin_choose_expr						\
+       (__builtin_types_compatible_p (__typeof (TG_ARG), long double),	\
+	FUNC ## l ARGS,							\
+	FUNC ## f128 ARGS)))
+# endif
 #else
 # define __MATH_TG(TG_ARG, FUNC, ARGS)		\
   (sizeof (TG_ARG) == sizeof (float)		\