summaryrefslogtreecommitdiff
path: root/math/tgmath.h
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2017-06-28 16:19:47 +0000
committerJoseph Myers <joseph@codesourcery.com>2017-06-28 16:19:47 +0000
commitcfa44345234e161cb59987ed70e04719ba155867 (patch)
treec7d4036635f771b556821b48edd2d800cf1cdb8b /math/tgmath.h
parent51737193a9810ceb1c516a2a71444fa70bcf8500 (diff)
downloadglibc-cfa44345234e161cb59987ed70e04719ba155867.tar.gz
Simplify tgmath.h for integer return types.
The tgmath.h macros for function with integer return types generate unnecessary casts to the return type. Since in those cases the return type does not depend on the argument type, all the cases in the conditional expressions already have the right type, and no casts are needed; this patch removes them. Tested for x86_64. * math/tgmath.h (__TGMATH_UNARY_REAL_RET_ONLY): Do not take or cast to return type argument. (__TGMATH_TERNARY_FIRST_REAL_RET_ONLY): Likewise. (lrint): Update call to __TGMATH_UNARY_REAL_RET_ONLY. (llrint): Likewise. (lround): Likewise. (llround): Likewise. (ilogb): Likewise. (llogb): Likewise. (fromfp): Update call to __TGMATH_TERNARY_FIRST_REAL_RET_ONLY. (ufromfp): Likewise. (fromfpx): Likewise. (ufromfpx): Likewise.
Diffstat (limited to 'math/tgmath.h')
-rw-r--r--math/tgmath.h36
1 files changed, 18 insertions, 18 deletions
diff --git a/math/tgmath.h b/math/tgmath.h
index 01730a44fc..a70dfe1f47 100644
--- a/math/tgmath.h
+++ b/math/tgmath.h
@@ -78,13 +78,13 @@
? (__tgmath_real_type (Val)) Fct##f (Val) \
: (__tgmath_real_type (Val)) __tgml(Fct) (Val)))
-# define __TGMATH_UNARY_REAL_RET_ONLY(Val, RetType, Fct) \
+# define __TGMATH_UNARY_REAL_RET_ONLY(Val, Fct) \
(__extension__ ((sizeof (Val) == sizeof (double) \
|| __builtin_classify_type (Val) != 8) \
- ? (RetType) Fct (Val) \
+ ? Fct (Val) \
: (sizeof (Val) == sizeof (float)) \
- ? (RetType) Fct##f (Val) \
- : (RetType) __tgml(Fct) (Val)))
+ ? Fct##f (Val) \
+ : __tgml(Fct) (Val)))
# define __TGMATH_BINARY_FIRST_REAL_ONLY(Val1, Val2, Fct) \
(__extension__ ((sizeof (Val1) == sizeof (double) \
@@ -155,13 +155,13 @@
+ (__tgmath_real_type (Val3)) 0)) \
Fct##f (Val1, Val2, Val3)))
-# define __TGMATH_TERNARY_FIRST_REAL_RET_ONLY(Val1, Val2, Val3, RetType, Fct) \
+# define __TGMATH_TERNARY_FIRST_REAL_RET_ONLY(Val1, Val2, Val3, Fct) \
(__extension__ ((sizeof (Val1) == sizeof (double) \
|| __builtin_classify_type (Val1) != 8) \
- ? (RetType) Fct (Val1, Val2, Val3) \
+ ? Fct (Val1, Val2, Val3) \
: (sizeof (Val1) == sizeof (float)) \
- ? (RetType) Fct##f (Val1, Val2, Val3) \
- : (RetType) __tgml(Fct) (Val1, Val2, Val3)))
+ ? Fct##f (Val1, Val2, Val3) \
+ : __tgml(Fct) (Val1, Val2, Val3)))
/* XXX This definition has to be changed as soon as the compiler understands
the imaginary keyword. */
@@ -377,13 +377,13 @@
/* Round X to nearest integral value according to current rounding
direction. */
-#define lrint(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, long int, lrint)
-#define llrint(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, long long int, llrint)
+#define lrint(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, lrint)
+#define llrint(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, llrint)
/* Round X to nearest integral value, rounding halfway cases away from
zero. */
-#define lround(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, long int, lround)
-#define llround(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, long long int, llround)
+#define lround(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, lround)
+#define llround(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, llround)
/* Return X with its signed changed to Y's. */
@@ -428,7 +428,7 @@
__TGMATH_BINARY_FIRST_REAL_ONLY (Val1, Val2, scalbln)
/* Return the binary exponent of X, which must be nonzero. */
-#define ilogb(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, int, ilogb)
+#define ilogb(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, ilogb)
/* Return positive difference between X and Y. */
@@ -450,19 +450,19 @@
# define roundeven(Val) __TGMATH_UNARY_REAL_ONLY (Val, roundeven)
# define fromfp(Val1, Val2, Val3) \
- __TGMATH_TERNARY_FIRST_REAL_RET_ONLY (Val1, Val2, Val3, __intmax_t, fromfp)
+ __TGMATH_TERNARY_FIRST_REAL_RET_ONLY (Val1, Val2, Val3, fromfp)
# define ufromfp(Val1, Val2, Val3) \
- __TGMATH_TERNARY_FIRST_REAL_RET_ONLY (Val1, Val2, Val3, __uintmax_t, ufromfp)
+ __TGMATH_TERNARY_FIRST_REAL_RET_ONLY (Val1, Val2, Val3, ufromfp)
# define fromfpx(Val1, Val2, Val3) \
- __TGMATH_TERNARY_FIRST_REAL_RET_ONLY (Val1, Val2, Val3, __intmax_t, fromfpx)
+ __TGMATH_TERNARY_FIRST_REAL_RET_ONLY (Val1, Val2, Val3, fromfpx)
# define ufromfpx(Val1, Val2, Val3) \
- __TGMATH_TERNARY_FIRST_REAL_RET_ONLY (Val1, Val2, Val3, __uintmax_t, ufromfpx)
+ __TGMATH_TERNARY_FIRST_REAL_RET_ONLY (Val1, Val2, Val3, ufromfpx)
/* Like ilogb, but returning long int. */
-# define llogb(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, long int, llogb)
+# define llogb(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, llogb)
/* Return value with maximum magnitude. */
# define fmaxmag(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fmaxmag)