mirror of
https://github.com/wgh136/flutter_qjs.git
synced 2025-09-27 13:27:24 +00:00
enable msvc build
This commit is contained in:
@@ -37,12 +37,10 @@
|
|||||||
|
|
||||||
/* enable it to check the multiplication result */
|
/* enable it to check the multiplication result */
|
||||||
//#define USE_MUL_CHECK
|
//#define USE_MUL_CHECK
|
||||||
#ifdef CONFIG_BIGNUM
|
|
||||||
/* enable it to use FFT/NTT multiplication */
|
/* enable it to use FFT/NTT multiplication */
|
||||||
#define USE_FFT_MUL
|
#define USE_FFT_MUL
|
||||||
/* enable decimal floating point support */
|
/* enable decimal floating point support */
|
||||||
#define USE_BF_DEC
|
#define USE_BF_DEC
|
||||||
#endif
|
|
||||||
|
|
||||||
//#define inline __attribute__((always_inline))
|
//#define inline __attribute__((always_inline))
|
||||||
|
|
||||||
@@ -136,7 +134,6 @@ static inline slimb_t ceil_div(slimb_t a, slimb_t b)
|
|||||||
return a / b;
|
return a / b;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_BF_DEC
|
|
||||||
/* b must be >= 1 */
|
/* b must be >= 1 */
|
||||||
static inline slimb_t floor_div(slimb_t a, slimb_t b)
|
static inline slimb_t floor_div(slimb_t a, slimb_t b)
|
||||||
{
|
{
|
||||||
@@ -146,7 +143,6 @@ static inline slimb_t floor_div(slimb_t a, slimb_t b)
|
|||||||
return (a - b + 1) / b;
|
return (a - b + 1) / b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* return r = a modulo b (0 <= r <= b - 1. b must be >= 1 */
|
/* return r = a modulo b (0 <= r <= b - 1. b must be >= 1 */
|
||||||
static inline limb_t smod(slimb_t a, slimb_t b)
|
static inline limb_t smod(slimb_t a, slimb_t b)
|
||||||
@@ -168,21 +164,6 @@ static inline slimb_t sat_add(slimb_t a, slimb_t b)
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline __maybe_unused limb_t shrd(limb_t low, limb_t high, long shift)
|
|
||||||
{
|
|
||||||
if (shift != 0)
|
|
||||||
low = (low >> shift) | (high << (LIMB_BITS - shift));
|
|
||||||
return low;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline __maybe_unused limb_t shld(limb_t a1, limb_t a0, long shift)
|
|
||||||
{
|
|
||||||
if (shift != 0)
|
|
||||||
return (a1 << shift) | (a0 >> (LIMB_BITS - shift));
|
|
||||||
else
|
|
||||||
return a1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define malloc(s) malloc_is_forbidden(s)
|
#define malloc(s) malloc_is_forbidden(s)
|
||||||
#define free(p) free_is_forbidden(p)
|
#define free(p) free_is_forbidden(p)
|
||||||
#define realloc(p, s) realloc_is_forbidden(p, s)
|
#define realloc(p, s) realloc_is_forbidden(p, s)
|
||||||
@@ -255,7 +236,7 @@ int bf_set_ui(bf_t *r, uint64_t a)
|
|||||||
a1 = a >> 32;
|
a1 = a >> 32;
|
||||||
shift = clz(a1);
|
shift = clz(a1);
|
||||||
r->tab[0] = a0 << shift;
|
r->tab[0] = a0 << shift;
|
||||||
r->tab[1] = shld(a1, a0, shift);
|
r->tab[1] = (a1 << shift) | (a0 >> (LIMB_BITS - shift));
|
||||||
r->expn = 2 * LIMB_BITS - shift;
|
r->expn = 2 * LIMB_BITS - shift;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -311,7 +292,7 @@ int bf_set(bf_t *r, const bf_t *a)
|
|||||||
}
|
}
|
||||||
r->sign = a->sign;
|
r->sign = a->sign;
|
||||||
r->expn = a->expn;
|
r->expn = a->expn;
|
||||||
memcpy_no_ub(r->tab, a->tab, a->len * sizeof(limb_t));
|
memcpy(r->tab, a->tab, a->len * sizeof(limb_t));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1604,9 +1585,7 @@ int bf_mul(bf_t *r, const bf_t *a, const bf_t *b, limb_t prec,
|
|||||||
r = &tmp;
|
r = &tmp;
|
||||||
}
|
}
|
||||||
if (bf_resize(r, a_len + b_len)) {
|
if (bf_resize(r, a_len + b_len)) {
|
||||||
#ifdef USE_FFT_MUL
|
|
||||||
fail:
|
fail:
|
||||||
#endif
|
|
||||||
bf_set_nan(r);
|
bf_set_nan(r);
|
||||||
ret = BF_ST_MEM_ERROR;
|
ret = BF_ST_MEM_ERROR;
|
||||||
goto done;
|
goto done;
|
||||||
@@ -2303,14 +2282,11 @@ static int bf_pow_ui_ui(bf_t *r, limb_t a1, limb_t b,
|
|||||||
bf_t a;
|
bf_t a;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
#ifdef USE_BF_DEC
|
|
||||||
if (a1 == 10 && b <= LIMB_DIGITS) {
|
if (a1 == 10 && b <= LIMB_DIGITS) {
|
||||||
/* use precomputed powers. We do not round at this point
|
/* use precomputed powers. We do not round at this point
|
||||||
because we expect the caller to do it */
|
because we expect the caller to do it */
|
||||||
ret = bf_set_ui(r, mp_pow_dec[b]);
|
ret = bf_set_ui(r, mp_pow_dec[b]);
|
||||||
} else
|
} else {
|
||||||
#endif
|
|
||||||
{
|
|
||||||
bf_init(r->ctx, &a);
|
bf_init(r->ctx, &a);
|
||||||
ret = bf_set_ui(&a, a1);
|
ret = bf_set_ui(&a, a1);
|
||||||
ret |= bf_pow_ui(r, &a, b, prec, flags);
|
ret |= bf_pow_ui(r, &a, b, prec, flags);
|
||||||
@@ -2899,7 +2875,7 @@ static int strcasestart(const char *str, const char *val, const char **ptr)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bf_atof_internal(bf_t *r, slimb_t *pexponent,
|
static int bf_atof_internal(bf_t *r, slimb_t *pexponent,
|
||||||
const char *str, const char **pnext, int radix,
|
const char *str, const char **pnext, int radix,
|
||||||
limb_t prec, bf_flags_t flags, BOOL is_dec)
|
limb_t prec, bf_flags_t flags, BOOL is_dec)
|
||||||
{
|
{
|
||||||
@@ -5416,6 +5392,21 @@ int bf_acos(bf_t *r, const bf_t *a, limb_t prec, bf_flags_t flags)
|
|||||||
|
|
||||||
#endif /* LIMB_BITS != 64 */
|
#endif /* LIMB_BITS != 64 */
|
||||||
|
|
||||||
|
static inline __maybe_unused limb_t shrd(limb_t low, limb_t high, long shift)
|
||||||
|
{
|
||||||
|
if (shift != 0)
|
||||||
|
low = (low >> shift) | (high << (LIMB_BITS - shift));
|
||||||
|
return low;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline __maybe_unused limb_t shld(limb_t a1, limb_t a0, long shift)
|
||||||
|
{
|
||||||
|
if (shift != 0)
|
||||||
|
return (a1 << shift) | (a0 >> (LIMB_BITS - shift));
|
||||||
|
else
|
||||||
|
return a1;
|
||||||
|
}
|
||||||
|
|
||||||
#if LIMB_DIGITS == 19
|
#if LIMB_DIGITS == 19
|
||||||
|
|
||||||
/* WARNING: hardcoded for b = 1e19. It is assumed that:
|
/* WARNING: hardcoded for b = 1e19. It is assumed that:
|
||||||
|
Reference in New Issue
Block a user