summaryrefslogtreecommitdiffstats
path: root/lib/msun
diff options
context:
space:
mode:
authortheraven <theraven@FreeBSD.org>2013-07-13 10:10:45 +0000
committertheraven <theraven@FreeBSD.org>2013-07-13 10:10:45 +0000
commitf60d437435df7f4222b46c78048510f29e6ff833 (patch)
tree3a656a4ac1c64bd52c187769b27784d0e1838795 /lib/msun
parent2336066e660dd1c960f1de33b206afdb3e7c1564 (diff)
downloadFreeBSD-src-f60d437435df7f4222b46c78048510f29e6ff833.zip
FreeBSD-src-f60d437435df7f4222b46c78048510f29e6ff833.tar.gz
Ensure that the _Generic() macro in math.h works with qualified types.
tgmath.h contains the same bugs and so should be fixed in the same way.
Diffstat (limited to 'lib/msun')
-rw-r--r--lib/msun/src/math.h43
1 files changed, 26 insertions, 17 deletions
diff --git a/lib/msun/src/math.h b/lib/msun/src/math.h
index 14073cb..abfdddb 100644
--- a/lib/msun/src/math.h
+++ b/lib/msun/src/math.h
@@ -83,22 +83,31 @@ extern const union __nan_un {
#if (__STDC_VERSION__ >= 201112L && defined(__clang__)) || \
__has_extension(c_generic_selections)
-#define __fp_type_select(x, f, d, ld) _Generic((x), \
- float: f(x), \
- double: d(x), \
- long double: ld(x))
+#define __fp_type_select(x, f, d, ld) _Generic((x), \
+ float: f(x), \
+ double: d(x), \
+ long double: ld(x), \
+ volatile float: f(x), \
+ volatile double: d(x), \
+ volatile long double: ld(x), \
+ volatile const float: f(x), \
+ volatile const double: d(x), \
+ volatile const long double: ld(x), \
+ const float: f(x), \
+ const double: d(x), \
+ const long double: ld(x))
#elif __GNUC_PREREQ__(3, 1) && !defined(__cplusplus)
-#define __fp_type_select(x, f, d, ld) __builtin_choose_expr( \
- __builtin_types_compatible_p(__typeof(x), long double), ld(x), \
- __builtin_choose_expr( \
- __builtin_types_compatible_p(__typeof(x), double), d(x), \
- __builtin_choose_expr( \
- __builtin_types_compatible_p(__typeof(x), float), f(x), (void)0)))
+#define __fp_type_select(x, f, d, ld) __builtin_choose_expr( \
+ __builtin_types_compatible_p(__typeof(x), long double), ld(x), \
+ __builtin_choose_expr( \
+ __builtin_types_compatible_p(__typeof(x), double), d(x), \
+ __builtin_choose_expr( \
+ __builtin_types_compatible_p(__typeof(x), float), f(x), (void)0)))
#else
-#define __fp_type_select(x, f, d, ld) \
- ((sizeof(x) == sizeof(float)) ? f(x) \
- : (sizeof(x) == sizeof(double)) ? d(x) \
- : ld(x))
+#define __fp_type_select(x, f, d, ld) \
+ ((sizeof(x) == sizeof(float)) ? f(x) \
+ : (sizeof(x) == sizeof(double)) ? d(x) \
+ : ld(x))
#endif
#define fpclassify(x) \
@@ -189,21 +198,21 @@ int __signbitf(float) __pure2;
int __signbitl(long double) __pure2;
static __inline int
-__inline_isnan(double __x)
+__inline_isnan(__const double __x)
{
return (__x != __x);
}
static __inline int
-__inline_isnanf(float __x)
+__inline_isnanf(__const float __x)
{
return (__x != __x);
}
static __inline int
-__inline_isnanl(long double __x)
+__inline_isnanl(__const long double __x)
{
return (__x != __x);
OpenPOWER on IntegriCloud