authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2019-05-03 13:11:53+02:00
committergravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2019-05-04 08:44:26+02:00
logb612512bb500defd399a11dfa47c83cefe4d87b5
tree814da7387441ee9d5ee7498b7dd40c14492db3ab
parentfca3e3a73f157d93ae3d57f90c13512acfbe9aa4

std: Remove some assumptions about the host platform

The stdlib is now 32-bit friendly.

5 files changed, 10 insertions(+), 9 deletions(-)

std/crypto/chacha20.zig+3-2
......@@ -142,7 +142,7 @@ pub fn chaCha20With64BitNonce(out: []u8, in: []const u8, counter: u64, key: [32]
142142 assert(in.len >= out.len);
143143 assert(counter +% (in.len >> 6) >= counter);
144144
145 var cursor: u64 = 0;
145 var cursor: usize = 0;
146146 var k: [8]u32 = undefined;
147147 var c: [4]u32 = undefined;
148148
......@@ -161,7 +161,8 @@ pub fn chaCha20With64BitNonce(out: []u8, in: []const u8, counter: u64, key: [32]
161161 c[3] = mem.readIntSliceLittle(u32, nonce[4..8]);
162162
163163 const block_size = (1 << 6);
164 const big_block = (block_size << 32);
164 // The full block size is greater than the address space on a 32bit machine
165 const big_block = if (@sizeOf(usize) > 4) (block_size << 32) else maxInt(usize);
165166
166167 // first partial big block
167168 if (((@intCast(u64, maxInt(u32) - @truncate(u32, counter)) + 1) << 6) < in.len) {
std/heap.zig+1-1
......@@ -601,7 +601,7 @@ test "ArenaAllocator" {
601601 try testAllocatorAlignedShrink(&arena_allocator.allocator);
602602}
603603
604var test_fixed_buffer_allocator_memory: [40000 * @sizeOf(usize)]u8 = undefined;
604var test_fixed_buffer_allocator_memory: [40000 * @sizeOf(u64)]u8 = undefined;
605605test "FixedBufferAllocator" {
606606 var fixed_buffer_allocator = FixedBufferAllocator.init(test_fixed_buffer_allocator_memory[0..]);
607607
std/os/linux.zig+2-2
......@@ -1100,8 +1100,8 @@ pub fn sigaction(sig: u6, noalias act: *const Sigaction, noalias oact: ?*Sigacti
11001100
11011101const NSIG = 65;
11021102const sigset_t = [128 / @sizeOf(usize)]usize;
1103const all_mask = []usize{maxInt(usize)};
1104const app_mask = []usize{0xfffffffc7fffffff};
1103const all_mask = []u32{0xffffffff, 0xffffffff};
1104const app_mask = []u32{0xfffffffc, 0x7fffffff};
11051105
11061106const k_sigaction = extern struct {
11071107 handler: extern fn (i32) void,
std/os/time.zig+2-2
......@@ -31,8 +31,8 @@ pub fn sleep(nanoseconds: u64) void {
3131
3232pub fn posixSleep(seconds: u63, nanoseconds: u63) void {
3333 var req = posix.timespec{
34 .tv_sec = seconds,
35 .tv_nsec = nanoseconds,
34 .tv_sec = @intCast(isize, seconds),
35 .tv_nsec = @intCast(isize, nanoseconds),
3636 };
3737 var rem: posix.timespec = undefined;
3838 while (true) {
std/rand.zig+2-2
......@@ -768,10 +768,10 @@ pub const Isaac64 = struct {
768768 const x = self.m[base + m1];
769769 self.a = mix +% self.m[base + m2];
770770
771 const y = self.a +% self.b +% self.m[(x >> 3) % self.m.len];
771 const y = self.a +% self.b +% self.m[@intCast(usize, (x >> 3) % self.m.len)];
772772 self.m[base + m1] = y;
773773
774 self.b = x +% self.m[(y >> 11) % self.m.len];
774 self.b = x +% self.m[@intCast(usize, (y >> 11) % self.m.len)];
775775 self.r[self.r.len - 1 - base - m1] = self.b;
776776 }
777777