about summary refs log tree commit diff stats
path: root/lib/quickjs/@cha
diff options
context:
space:
mode:
authorbellard <6490144+bellard@users.noreply.github.com>2023-12-04 19:26:32 +0100
committerbptato <nincsnevem662@gmail.com>2023-12-05 16:32:18 +0100
commita7ded568d2c31e286f6e3fdcd341948978624eb6 (patch)
treed789be20c42676e8f77aafbf1240a31cdd4df47d /lib/quickjs/@cha
parent416a222d732f6e02d5404ac5308b51ab3d9ffd82 (diff)
downloadchawan-a7ded568d2c31e286f6e3fdcd341948978624eb6.tar.gz
the BigInt support is now always included
Diffstat (limited to 'lib/quickjs/@cha')
-rw-r--r--lib/quickjs/@cha69
1 files changed, 69 insertions, 0 deletions
diff --git a/lib/quickjs/@cha b/lib/quickjs/@cha
new file mode 100644
index 00000000..c76e4cee
--- /dev/null
+++ b/lib/quickjs/@cha
@@ -0,0 +1,69 @@
+From 6de52d878ae8ee06e4a59cbd2e77d84704c9f602 Mon Sep 17 00:00:00 2001
+From: bellard <6490144+bellard@users.noreply.github.com>
+Date: Fri, 1 Dec 2023 17:56:22 +0100
+Subject: [PATCH] bf_set_ui() fix (github issue #133)
+
+---
+ libbf.c | 32 ++++++++++++++++----------------
+ 1 file changed, 16 insertions(+), 16 deletions(-)
+
+diff --git a/libbf.c b/libbf.c
+index fe1628e..c48fdbb 100644
+--- a/libbf.c
++++ b/libbf.c
+@@ -164,6 +164,21 @@ static inline slimb_t sat_add(slimb_t a, slimb_t b)
+     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 free(p) free_is_forbidden(p)
+ #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;
+         shift = clz(a1);
+         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;
+     }
+ #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 */
+ 
+-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
+ 
+ /* WARNING: hardcoded for b = 1e19. It is assumed that:
+-- 
+2.43.0
+