From 7b28032f5c0434a3460bdf01a96d73079612ee29 Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Sat, 5 Jan 2019 21:58:39 -0500 Subject: [PATCH] More explicit casts to please Microsoft compiler. --- src/core/io.c | 2 +- src/core/string.c | 4 ++-- src/core/strtod.c | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/core/io.c b/src/core/io.c index 71abcbfc..c61425df 100644 --- a/src/core/io.c +++ b/src/core/io.c @@ -293,7 +293,7 @@ static Janet janet_io_fseek(int32_t argc, Janet *argv) { janet_panicf("expected one of :cur, :set, :end, got %v", argv[1]); } if (argc == 3) { - offset = janet_getinteger64(argv, 2); + offset = (long) janet_getinteger64(argv, 2); } } if (fseek(iof->file, offset, whence)) janet_panic("error seeking file"); diff --git a/src/core/string.c b/src/core/string.c index 1a38ea83..19bc1648 100644 --- a/src/core/string.c +++ b/src/core/string.c @@ -183,7 +183,7 @@ static void string_description_b(JanetBuffer *buffer, const char *title, void *p *c++ = HEX(byte & 0xF); } *c++ = '>'; - buffer->count = c - buffer->data; + buffer->count = (int32_t)(c - buffer->data); #undef POINTSIZE } @@ -966,7 +966,7 @@ static Janet cfun_join(int32_t argc, Janet *argv) { janet_panic("result string too long"); } uint8_t *buf, *out; - out = buf = janet_string_begin(finallen); + out = buf = janet_string_begin((int32_t) finallen); for (i = 0; i < parts.len; i++) { const uint8_t *chunk = NULL; int32_t chunklen = 0; diff --git a/src/core/strtod.c b/src/core/strtod.c index a53b3d06..3e8e87bf 100644 --- a/src/core/strtod.c +++ b/src/core/strtod.c @@ -116,7 +116,7 @@ static void bignat_muladd(struct BigNat *mant, uint32_t factor, uint32_t term) { mant->digits[i] = carry % BIGNAT_BASE; carry /= BIGNAT_BASE; } - if (carry) bignat_append(mant, carry); + if (carry) bignat_append(mant, (uint32_t) carry); } /* Divide the mantissa mant by a factor. Drop the remainder. */ @@ -128,13 +128,13 @@ static void bignat_div(struct BigNat *mant, uint32_t divisor) { for (i = mant->n - 1; i >= 0; i--) { dividend = ((uint64_t)remainder * BIGNAT_BASE) + mant->digits[i]; if (i < mant->n - 1) mant->digits[i + 1] = quotient; - quotient = dividend / divisor; - remainder = dividend % divisor; + quotient = (uint32_t)(dividend / divisor); + remainder = (uint32_t)(dividend % divisor); mant->digits[i] = remainder; } dividend = ((uint64_t)remainder * BIGNAT_BASE) + mant->first_digit; if (mant->n && mant->digits[mant->n - 1] == 0) mant->n--; - mant->first_digit = dividend / divisor; + mant->first_digit = (uint32_t)(dividend / divisor); } /* Shift left by a multiple of BIGNAT_NBIT */ @@ -173,7 +173,7 @@ static double bignat_extract(struct BigNat *mant, int32_t exponent2) { uint64_t d1 = mant->digits[n - 1]; /* MSD (non-zero) */ uint64_t d2 = (n == 1) ? mant->first_digit : mant->digits[n - 2]; uint64_t d3 = (n > 2) ? mant->digits[n - 3] : (n == 2) ? mant->first_digit : 0; - int lz = clz(d1); + int lz = clz((uint32_t) d1); int nbits = 32 - lz; /* First get 54 bits */ top53 = (d2 << (54 - BIGNAT_NBIT)) + (d3 >> (2 * BIGNAT_NBIT - 54)); @@ -192,7 +192,7 @@ static double bignat_extract(struct BigNat *mant, int32_t exponent2) { /* One digit */ top53 = mant->first_digit; } - return ldexp(top53, exponent2); + return ldexp((double)top53, exponent2); } /* Read in a mantissa and exponent of a certain base, and give