authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-05-04 14:46:35-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-05-04 14:46:35-04:00
log70a9ee3dd68d8ed28a9fd2dc29f6c88fee5d789e
tree5684fcc2a57f552ec87a064e864133a9d6522d11
parent6f0aa801c80a434b7cc931e879d234a8de501e38
parent98bc2b73bf6974a782e2df0ea71b409a68e030fd
signaturelock-open Commit is signed but in an unrecognized format.

Merge branch 'stdlib-32b' of https://github.com/LemonBoy/zig into LemonBoy-stdlib-32b


5 files changed, 26 insertions(+), 13 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
......@@ -603,7 +603,7 @@ test "ArenaAllocator" {
603603 try testAllocatorAlignedShrink(&arena_allocator.allocator);
604604}
605605
606var test_fixed_buffer_allocator_memory: [40000 * @sizeOf(usize)]u8 = undefined;
606var test_fixed_buffer_allocator_memory: [40000 * @sizeOf(u64)]u8 = undefined;
607607test "FixedBufferAllocator" {
608608 var fixed_buffer_allocator = FixedBufferAllocator.init(test_fixed_buffer_allocator_memory[0..]);
609609
std/os/linux.zig+2-2
......@@ -1101,8 +1101,8 @@ pub fn sigaction(sig: u6, noalias act: *const Sigaction, noalias oact: ?*Sigacti
11011101
11021102const NSIG = 65;
11031103const sigset_t = [128 / @sizeOf(usize)]usize;
1104const all_mask = []usize{maxInt(usize)};
1105const app_mask = []usize{0xfffffffc7fffffff};
1104const all_mask = []u32{0xffffffff, 0xffffffff};
1105const app_mask = []u32{0xfffffffc, 0x7fffffff};
11061106
11071107const k_sigaction = extern struct {
11081108 handler: extern fn (i32) void,
std/os/time.zig+18-6
......@@ -3,6 +3,7 @@ const builtin = @import("builtin");
33const Os = builtin.Os;
44const debug = std.debug;
55const testing = std.testing;
6const math = std.math;
67
78const windows = std.os.windows;
89const linux = std.os.linux;
......@@ -30,16 +31,26 @@ pub fn sleep(nanoseconds: u64) void {
3031}
3132
3233pub fn posixSleep(seconds: u63, nanoseconds: u63) void {
33 var req = posix.timespec{
34 .tv_sec = seconds,
35 .tv_nsec = nanoseconds,
36 };
34 var req: posix.timespec = undefined;
3735 var rem: posix.timespec = undefined;
36
37 var req_sec = seconds;
38 var req_nsec = nanoseconds;
39
3840 while (true) {
41 req.tv_sec = math.min(math.maxInt(isize), req_sec);
42 req.tv_nsec = @intCast(isize, req_nsec);
43
44 req_sec -= @intCast(u63, req.tv_sec);
45 req_nsec = 0;
46
3947 const ret_val = posix.nanosleep(&req, &rem);
4048 const err = posix.getErrno(ret_val);
41 if (err == 0) return;
4249 switch (err) {
50 0 => {
51 // If there's still time to wait keep running the loop
52 if (req_sec == 0 and req_nsec == 0) return;
53 },
4354 posix.EFAULT => unreachable,
4455 posix.EINVAL => {
4556 // Sometimes Darwin returns EINVAL for no reason.
......@@ -47,7 +58,8 @@ pub fn posixSleep(seconds: u63, nanoseconds: u63) void {
4758 return;
4859 },
4960 posix.EINTR => {
50 req = rem;
61 req_sec += @intCast(u63, rem.tv_sec);
62 req_nsec = @intCast(u63, rem.tv_nsec);
5163 continue;
5264 },
5365 else => return,
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