authorgravatar for marc@tiehu.isMarc Tiehuis <marc@tiehu.is> 2023-02-04 10:58:03+13:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-02-04 00:29:04-05:00
log4009e0d2b1ac5b0a9a0caff676d5c73ae18c6e9e
tree77ec981ac2d71d7e20a053d491f5c9cdaaac3d3e
parentc9b957c937ef457083f1a00c1343239086ef8796

remove stage1 workaround for big int set

Underlying fix should have been https://github.com/ziglang/zig/commit/d7b029995c8ac678598de39aa106076dca232902. u128 limb sizes are still not fully tested as we are missing compiler-rt support (__divei4, __modei4 on x86_64). Should be no zig blockers so the assertion has been removed.

2 files changed, 3 insertions(+), 9 deletions(-)

lib/std/math/big.zig-1
...@@ -13,7 +13,6 @@ pub const Log2Limb = std.math.Log2Int(Limb);...@@ -13,7 +13,6 @@ pub const Log2Limb = std.math.Log2Int(Limb);
1313
14comptime {14comptime {
15 assert(std.math.floorPowerOfTwo(usize, limb_info.bits) == limb_info.bits);15 assert(std.math.floorPowerOfTwo(usize, limb_info.bits) == limb_info.bits);
16 assert(limb_info.bits <= 64); // u128 set is unsupported
17 assert(limb_info.signedness == .unsigned);16 assert(limb_info.signedness == .unsigned);
18}17}
1918
lib/std/math/big/int.zig+3-8
...@@ -30,7 +30,7 @@ pub fn calcLimbLen(scalar: anytype) usize {...@@ -30,7 +30,7 @@ pub fn calcLimbLen(scalar: anytype) usize {
30 }30 }
3131
32 const w_value = std.math.absCast(scalar);32 const w_value = std.math.absCast(scalar);
33 return @divFloor(@intCast(Limb, math.log2(w_value)), limb_bits) + 1;33 return @intCast(usize, @divFloor(@intCast(Limb, math.log2(w_value)), limb_bits) + 1);
34}34}
3535
36pub fn calcToStringLimbsBufferLen(a_len: usize, base: u8) usize {36pub fn calcToStringLimbsBufferLen(a_len: usize, base: u8) usize {
...@@ -238,10 +238,7 @@ pub const Mutable = struct {...@@ -238,10 +238,7 @@ pub const Mutable = struct {
238 var i: usize = 0;238 var i: usize = 0;
239 while (true) : (i += 1) {239 while (true) : (i += 1) {
240 self.limbs[i] = @truncate(Limb, w_value);240 self.limbs[i] = @truncate(Limb, w_value);
241241 w_value >>= limb_bits;
242 // TODO: shift == 64 at compile-time fails. Fails on u128 limbs.
243 w_value >>= limb_bits / 2;
244 w_value >>= limb_bits / 2;
245242
246 if (w_value == 0) break;243 if (w_value == 0) break;
247 }244 }
...@@ -258,9 +255,7 @@ pub const Mutable = struct {...@@ -258,9 +255,7 @@ pub const Mutable = struct {
258 comptime var i = 0;255 comptime var i = 0;
259 inline while (true) : (i += 1) {256 inline while (true) : (i += 1) {
260 self.limbs[i] = w_value & mask;257 self.limbs[i] = w_value & mask;
261258 w_value >>= limb_bits;
262 w_value >>= limb_bits / 2;
263 w_value >>= limb_bits / 2;
264259
265 if (w_value == 0) break;260 if (w_value == 0) break;
266 }261 }