math-emu: Use statement expressions to fix Wshift-count-overflow warning

To avoid "shift count >= width of type" warning, using statement
expressions to implement the conditional controlling before constant shift

The modification in op-2.h is taken from the glibc
commit 'sysdeps/unix/sysv/lin ("fe0b1e854ad32")'.

Signed-off-by: Vincent Chen <vincentc@andestech.com>
Acked-by: Greentime Hu <greentime@andestech.com>
Signed-off-by: Greentime Hu <greentime@andestech.com>
This commit is contained in:
Vincent Chen 2019-05-27 14:17:21 +08:00 committed by Greentime Hu
parent a188339ca5
commit 8183db10db
2 changed files with 13 additions and 15 deletions

View File

@ -567,16 +567,13 @@
*/ */
#define _FP_FRAC_ASSEMBLE_2(r, X, rsize) \ #define _FP_FRAC_ASSEMBLE_2(r, X, rsize) \
do { \ (void) (((rsize) <= _FP_W_TYPE_SIZE) \
if (rsize <= _FP_W_TYPE_SIZE) \ ? ({ (r) = X##_f0; }) \
r = X##_f0; \ : ({ \
else \ (r) = X##_f1; \
{ \ (r) <<= _FP_W_TYPE_SIZE; \
r = X##_f1; \ (r) += X##_f0; \
r <<= _FP_W_TYPE_SIZE; \ }))
r += X##_f0; \
} \
} while (0)
#define _FP_FRAC_DISASSEMBLE_2(X, r, rsize) \ #define _FP_FRAC_DISASSEMBLE_2(X, r, rsize) \
do { \ do { \

View File

@ -795,11 +795,12 @@ do { \
ur_ = (unsigned rtype) -r; \ ur_ = (unsigned rtype) -r; \
else \ else \
ur_ = (unsigned rtype) r; \ ur_ = (unsigned rtype) r; \
if (rsize <= _FP_W_TYPE_SIZE) \ (void) (((rsize) <= _FP_W_TYPE_SIZE) \
__FP_CLZ(X##_e, ur_); \ ? ({ __FP_CLZ(X##_e, ur_); }) \
else \ : ({ \
__FP_CLZ_2(X##_e, (_FP_W_TYPE)(ur_ >> _FP_W_TYPE_SIZE), \ __FP_CLZ_2(X##_e, (_FP_W_TYPE)(ur_ >> _FP_W_TYPE_SIZE), \
(_FP_W_TYPE)ur_); \ (_FP_W_TYPE)ur_); \
})); \
if (rsize < _FP_W_TYPE_SIZE) \ if (rsize < _FP_W_TYPE_SIZE) \
X##_e -= (_FP_W_TYPE_SIZE - rsize); \ X##_e -= (_FP_W_TYPE_SIZE - rsize); \
X##_e = rsize - X##_e - 1; \ X##_e = rsize - X##_e - 1; \