authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-03-22 16:06:18-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-03-22 16:06:18-04:00
log71c78cc9cfbcefa165882326a9b90efacf107216
tree817145a6d2dc74867fa814a65dfd21451d716103
parent4615ed5ea003516c8235728ac3f5f0ee2ccea8a7
signature Commit is signed but in an unrecognized format.

avoid quad float literal syntax for MSVC


1 files changed, 12 insertions(+), 11 deletions(-)

src/parse_f128.c+12-11
...@@ -347,10 +347,11 @@ static void mul_eq_f128_int(float128_t *y, int sign) {...@@ -347,10 +347,11 @@ static void mul_eq_f128_int(float128_t *y, int sign) {
347 *y = new_value;347 *y = new_value;
348}348}
349349
350static float128_t literal_f128(__float128 x) {350static float128_t make_f128(uint64_t hi, uint64_t lo) {
351 float128_t result;351 union ldshape ux;
352 memcpy(&result, &x, 16);352 ux.i2.hi = hi;
353 return result;353 ux.i2.lo = lo;
354 return ux.f;
354}355}
355356
356static void mul_eq_f128_f128(float128_t *a, float128_t b) {357static void mul_eq_f128_f128(float128_t *a, float128_t b) {
...@@ -377,11 +378,11 @@ static float128_t scalbnf128(float128_t x, int n)...@@ -377,11 +378,11 @@ static float128_t scalbnf128(float128_t x, int n)
377378
378 if (n > 16383) {379 if (n > 16383) {
379 //x *= 0x1p16383q;380 //x *= 0x1p16383q;
380 mul_eq_f128_f128(&x, literal_f128(0x1p16383q));381 mul_eq_f128_f128(&x, make_f128(0x7ffe000000000000, 0x0000000000000000));
381 n -= 16383;382 n -= 16383;
382 if (n > 16383) {383 if (n > 16383) {
383 //x *= 0x1p16383q;384 //x *= 0x1p16383q;
384 mul_eq_f128_f128(&x, literal_f128(0x1p16383q));385 mul_eq_f128_f128(&x, make_f128(0x7ffe000000000000, 0x0000000000000000));
385 n -= 16383;386 n -= 16383;
386 if (n > 16383)387 if (n > 16383)
387 n = 16383;388 n = 16383;
...@@ -390,8 +391,8 @@ static float128_t scalbnf128(float128_t x, int n)...@@ -390,8 +391,8 @@ static float128_t scalbnf128(float128_t x, int n)
390 //x *= 0x1p-16382q * 0x1p113q;391 //x *= 0x1p-16382q * 0x1p113q;
391 {392 {
392 float128_t mul_result;393 float128_t mul_result;
393 float128_t a = literal_f128(0x1p-16382q);394 float128_t a = make_f128(0x0001000000000000, 0x0000000000000000);
394 float128_t b = literal_f128(0x1p113q);395 float128_t b = make_f128(0x4070000000000000, 0x0000000000000000);
395 f128M_mul(&a, &b, &mul_result);396 f128M_mul(&a, &b, &mul_result);
396 mul_eq_f128_f128(&x, mul_result);397 mul_eq_f128_f128(&x, mul_result);
397 }398 }
...@@ -400,8 +401,8 @@ static float128_t scalbnf128(float128_t x, int n)...@@ -400,8 +401,8 @@ static float128_t scalbnf128(float128_t x, int n)
400 //x *= 0x1p-16382q * 0x1p113q;401 //x *= 0x1p-16382q * 0x1p113q;
401 {402 {
402 float128_t mul_result;403 float128_t mul_result;
403 float128_t a = literal_f128(0x1p-16382q);404 float128_t a = make_f128(0x0001000000000000, 0x0000000000000000);
404 float128_t b = literal_f128(0x1p113q);405 float128_t b = make_f128(0x4070000000000000, 0x0000000000000000);
405 f128M_mul(&a, &b, &mul_result);406 f128M_mul(&a, &b, &mul_result);
406 mul_eq_f128_f128(&x, mul_result);407 mul_eq_f128_f128(&x, mul_result);
407 }408 }
...@@ -728,7 +729,7 @@ static float128_t decfloat(struct MuslFILE *f, int c, int bits, int emin, int si...@@ -728,7 +729,7 @@ static float128_t decfloat(struct MuslFILE *f, int c, int bits, int emin, int si
728 if ((e2+LDBL_MANT_DIG & INT_MAX) > emax-5) {729 if ((e2+LDBL_MANT_DIG & INT_MAX) > emax-5) {
729 //if (fabsf128(y) >= 0x1p113) 730 //if (fabsf128(y) >= 0x1p113)
730 float128_t abs_y = fabsf128(y);731 float128_t abs_y = fabsf128(y);
731 float128_t mant_f128 = literal_f128(0x1p113q);732 float128_t mant_f128 = make_f128(0x4070000000000000, 0x0000000000000000);
732 if (!f128M_lt(&abs_y, &mant_f128)) {733 if (!f128M_lt(&abs_y, &mant_f128)) {
733 if (denormal && bits==LDBL_MANT_DIG+e2-emin)734 if (denormal && bits==LDBL_MANT_DIG+e2-emin)
734 denormal = 0;735 denormal = 0;