mirror of
https://github.com/bellard/quickjs.git
synced 2024-11-22 21:58:12 +08:00
bf_set_ui() fix (github issue #133)
This commit is contained in:
parent
2788d71e82
commit
6de52d878a
32
libbf.c
32
libbf.c
@ -164,6 +164,21 @@ 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)
|
||||||
@ -236,7 +251,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] = (a1 << shift) | (a0 >> (LIMB_BITS - shift));
|
r->tab[1] = shld(a1, a0, shift);
|
||||||
r->expn = 2 * LIMB_BITS - shift;
|
r->expn = 2 * LIMB_BITS - shift;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -5392,21 +5407,6 @@ 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:
|
||||||
|
Loading…
Reference in New Issue
Block a user