Skip to content

Commit 9afa02e

Browse files
committed
update zig sources to 0.8.0-dev.1416+584cb2e4f
1 parent 147014d commit 9afa02e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+827
-171
lines changed

build

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ TARGET="$2" # Example: riscv64-linux-gnu
77
MCPU="$3" # Examples: `baseline`, `native`, `generic+v7a`, or `arm1176jzf_s`
88

99
ROOTDIR="$(pwd)"
10-
ZIG_VERSION="0.8.0-dev.1400+85eb05e9a"
10+
ZIG_VERSION="0.8.0-dev.1416+584cb2e4f"
1111

1212
TARGET_OS_AND_ABI=${TARGET#*-} # Example: linux-gnu
1313

zig/doc/langref.html.in

+2-2
Original file line numberDiff line numberDiff line change
@@ -933,8 +933,8 @@ const assert = std.debug.assert;
933933
threadlocal var x: i32 = 1234;
934934

935935
test "thread local storage" {
936-
const thread1 = try std.Thread.spawn({}, testTls);
937-
const thread2 = try std.Thread.spawn({}, testTls);
936+
const thread1 = try std.Thread.spawn(testTls, {});
937+
const thread2 = try std.Thread.spawn(testTls, {});
938938
testTls({});
939939
thread1.wait();
940940
thread2.wait();

zig/lib/std/Thread.zig

+20-6
Original file line numberDiff line numberDiff line change
@@ -165,18 +165,32 @@ pub const SpawnError = error{
165165
Unexpected,
166166
};
167167

168-
/// caller must call wait on the returned thread
169-
/// fn startFn(@TypeOf(context)) T
170-
/// where T is u8, noreturn, void, or !void
171-
/// caller must call wait on the returned thread
172-
pub fn spawn(context: anytype, comptime startFn: anytype) SpawnError!*Thread {
168+
// Given `T`, the type of the thread startFn, extract the expected type for the
169+
// context parameter.
170+
fn SpawnContextType(comptime T: type) type {
171+
const TI = @typeInfo(T);
172+
if (TI != .Fn)
173+
@compileError("expected function type, found " ++ @typeName(T));
174+
175+
if (TI.Fn.args.len != 1)
176+
@compileError("expected function with single argument, found " ++ @typeName(T));
177+
178+
return TI.Fn.args[0].arg_type orelse
179+
@compileError("cannot use a generic function as thread startFn");
180+
}
181+
182+
/// Spawns a new thread executing startFn, returning an handle for it.
183+
/// Caller must call wait on the returned thread.
184+
/// The `startFn` function must take a single argument of type T and return a
185+
/// value of type u8, noreturn, void or !void.
186+
/// The `context` parameter is of type T and is passed to the spawned thread.
187+
pub fn spawn(comptime startFn: anytype, context: SpawnContextType(@TypeOf(startFn))) SpawnError!*Thread {
173188
if (builtin.single_threaded) @compileError("cannot spawn thread when building in single-threaded mode");
174189
// TODO compile-time call graph analysis to determine stack upper bound
175190
// https://github.com/ziglang/zig/issues/157
176191
const default_stack_size = 16 * 1024 * 1024;
177192

178193
const Context = @TypeOf(context);
179-
comptime assert(@typeInfo(@TypeOf(startFn)).Fn.args[0].arg_type.? == Context);
180194

181195
if (std.Target.current.os.tag == .windows) {
182196
const WinThread = struct {

zig/lib/std/Thread/AutoResetEvent.zig

+2-2
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ test "basic usage" {
220220
};
221221

222222
var context = Context{};
223-
const send_thread = try std.Thread.spawn(&context, Context.sender);
224-
const recv_thread = try std.Thread.spawn(&context, Context.receiver);
223+
const send_thread = try std.Thread.spawn(Context.sender, &context);
224+
const recv_thread = try std.Thread.spawn(Context.receiver, &context);
225225

226226
send_thread.wait();
227227
recv_thread.wait();

zig/lib/std/Thread/Mutex.zig

+1-1
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ test "basic usage" {
299299
const thread_count = 10;
300300
var threads: [thread_count]*std.Thread = undefined;
301301
for (threads) |*t| {
302-
t.* = try std.Thread.spawn(&context, worker);
302+
t.* = try std.Thread.spawn(worker, &context);
303303
}
304304
for (threads) |t|
305305
t.wait();

zig/lib/std/Thread/ResetEvent.zig

+2-2
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ test "basic usage" {
281281
var context: Context = undefined;
282282
try context.init();
283283
defer context.deinit();
284-
const receiver = try std.Thread.spawn(&context, Context.receiver);
284+
const receiver = try std.Thread.spawn(Context.receiver, &context);
285285
defer receiver.wait();
286286
context.sender();
287287

@@ -290,7 +290,7 @@ test "basic usage" {
290290
// https://github.com/ziglang/zig/issues/7009
291291
var timed = Context.init();
292292
defer timed.deinit();
293-
const sleeper = try std.Thread.spawn(&timed, Context.sleeper);
293+
const sleeper = try std.Thread.spawn(Context.sleeper, &timed);
294294
defer sleeper.wait();
295295
try timed.timedWaiter();
296296
}

zig/lib/std/Thread/StaticResetEvent.zig

+2-2
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ test "basic usage" {
379379
};
380380

381381
var context = Context{};
382-
const receiver = try std.Thread.spawn(&context, Context.receiver);
382+
const receiver = try std.Thread.spawn(Context.receiver, &context);
383383
defer receiver.wait();
384384
context.sender();
385385

@@ -388,7 +388,7 @@ test "basic usage" {
388388
// https://github.com/ziglang/zig/issues/7009
389389
var timed = Context.init();
390390
defer timed.deinit();
391-
const sleeper = try std.Thread.spawn(&timed, Context.sleeper);
391+
const sleeper = try std.Thread.spawn(Context.sleeper, &timed);
392392
defer sleeper.wait();
393393
try timed.timedWaiter();
394394
}

zig/lib/std/atomic/queue.zig

+2-2
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,11 @@ test "std.atomic.Queue" {
216216

217217
var putters: [put_thread_count]*std.Thread = undefined;
218218
for (putters) |*t| {
219-
t.* = try std.Thread.spawn(&context, startPuts);
219+
t.* = try std.Thread.spawn(startPuts, &context);
220220
}
221221
var getters: [put_thread_count]*std.Thread = undefined;
222222
for (getters) |*t| {
223-
t.* = try std.Thread.spawn(&context, startGets);
223+
t.* = try std.Thread.spawn(startGets, &context);
224224
}
225225

226226
for (putters) |t|

zig/lib/std/atomic/stack.zig

+2-2
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,11 @@ test "std.atomic.stack" {
123123
} else {
124124
var putters: [put_thread_count]*std.Thread = undefined;
125125
for (putters) |*t| {
126-
t.* = try std.Thread.spawn(&context, startPuts);
126+
t.* = try std.Thread.spawn(startPuts, &context);
127127
}
128128
var getters: [put_thread_count]*std.Thread = undefined;
129129
for (getters) |*t| {
130-
t.* = try std.Thread.spawn(&context, startGets);
130+
t.* = try std.Thread.spawn(startGets, &context);
131131
}
132132

133133
for (putters) |t|

zig/lib/std/buf_set.zig

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub const BufSet = struct {
3232
if (self.hash_map.get(key) == null) {
3333
const key_copy = try self.copy(key);
3434
errdefer self.free(key_copy);
35-
_ = try self.hash_map.put(key_copy, {});
35+
try self.hash_map.put(key_copy, {});
3636
}
3737
}
3838

zig/lib/std/build.zig

+2-2
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ pub const Builder = struct {
790790
var list = ArrayList([]const u8).init(self.allocator);
791791
list.append(s) catch unreachable;
792792
list.append(value) catch unreachable;
793-
_ = self.user_input_options.put(name, UserInputOption{
793+
self.user_input_options.put(name, UserInputOption{
794794
.name = name,
795795
.value = UserValue{ .List = list },
796796
.used = false,
@@ -799,7 +799,7 @@ pub const Builder = struct {
799799
UserValue.List => |*list| {
800800
// append to the list
801801
list.append(value) catch unreachable;
802-
_ = self.user_input_options.put(name, UserInputOption{
802+
self.user_input_options.put(name, UserInputOption{
803803
.name = name,
804804
.value = UserValue{ .List = list.* },
805805
.used = false,

zig/lib/std/c/builtins.zig

+6
Original file line numberDiff line numberDiff line change
@@ -182,3 +182,9 @@ pub fn __builtin_memcpy(
182182
@memcpy(dst_cast, src_cast, len);
183183
return dst;
184184
}
185+
186+
/// The return value of __builtin_expect is `expr`. `c` is the expected value
187+
/// of `expr` and is used as a hint to the compiler in C. Here it is unused.
188+
pub fn __builtin_expect(expr: c_long, c: c_long) callconv(.Inline) c_long {
189+
return expr;
190+
}

zig/lib/std/crypto.zig

+8-22
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ pub const aead = struct {
1616
pub const Aes256Gcm = @import("crypto/aes_gcm.zig").Aes256Gcm;
1717
};
1818

19+
pub const aes_ocb = struct {
20+
pub const Aes128Ocb = @import("crypto/aes_ocb.zig").Aes128Ocb;
21+
pub const Aes256Ocb = @import("crypto/aes_ocb.zig").Aes256Ocb;
22+
};
23+
1924
pub const Gimli = @import("crypto/gimli.zig").Aead;
2025

2126
pub const chacha_poly = struct {
@@ -157,30 +162,11 @@ test "crypto" {
157162
}
158163
}
159164

160-
_ = @import("crypto/aes.zig");
161-
_ = @import("crypto/bcrypt.zig");
165+
_ = @import("crypto/aegis.zig");
166+
_ = @import("crypto/aes_gcm.zig");
167+
_ = @import("crypto/aes_ocb.zig");
162168
_ = @import("crypto/blake2.zig");
163-
_ = @import("crypto/blake3.zig");
164169
_ = @import("crypto/chacha20.zig");
165-
_ = @import("crypto/gimli.zig");
166-
_ = @import("crypto/hmac.zig");
167-
_ = @import("crypto/isap.zig");
168-
_ = @import("crypto/md5.zig");
169-
_ = @import("crypto/modes.zig");
170-
_ = @import("crypto/pbkdf2.zig");
171-
_ = @import("crypto/poly1305.zig");
172-
_ = @import("crypto/sha1.zig");
173-
_ = @import("crypto/sha2.zig");
174-
_ = @import("crypto/sha3.zig");
175-
_ = @import("crypto/salsa20.zig");
176-
_ = @import("crypto/siphash.zig");
177-
_ = @import("crypto/25519/curve25519.zig");
178-
_ = @import("crypto/25519/ed25519.zig");
179-
_ = @import("crypto/25519/edwards25519.zig");
180-
_ = @import("crypto/25519/field.zig");
181-
_ = @import("crypto/25519/scalar.zig");
182-
_ = @import("crypto/25519/x25519.zig");
183-
_ = @import("crypto/25519/ristretto255.zig");
184170
}
185171

186172
test "CSPRNG" {

zig/lib/std/crypto/aes/aesni.zig

+2-8
Original file line numberDiff line numberDiff line change
@@ -313,10 +313,7 @@ pub fn AesEncryptCtx(comptime Aes: type) type {
313313
inline while (i < rounds) : (i += 1) {
314314
ts = Block.parallel.encryptWide(count, ts, round_keys[i]);
315315
}
316-
i = 1;
317-
inline while (i < count) : (i += 1) {
318-
ts = Block.parallel.encryptLastWide(count, ts, round_keys[i]);
319-
}
316+
ts = Block.parallel.encryptLastWide(count, ts, round_keys[i]);
320317
j = 0;
321318
inline while (j < count) : (j += 1) {
322319
dst[16 * j .. 16 * j + 16].* = ts[j].toBytes();
@@ -392,10 +389,7 @@ pub fn AesDecryptCtx(comptime Aes: type) type {
392389
inline while (i < rounds) : (i += 1) {
393390
ts = Block.parallel.decryptWide(count, ts, inv_round_keys[i]);
394391
}
395-
i = 1;
396-
inline while (i < count) : (i += 1) {
397-
ts = Block.parallel.decryptLastWide(count, ts, inv_round_keys[i]);
398-
}
392+
ts = Block.parallel.decryptLastWide(count, ts, inv_round_keys[i]);
399393
j = 0;
400394
inline while (j < count) : (j += 1) {
401395
dst[16 * j .. 16 * j + 16].* = ts[j].toBytes();

zig/lib/std/crypto/aes/armcrypto.zig

+2-8
Original file line numberDiff line numberDiff line change
@@ -364,10 +364,7 @@ pub fn AesEncryptCtx(comptime Aes: type) type {
364364
inline while (i < rounds) : (i += 1) {
365365
ts = Block.parallel.encryptWide(count, ts, round_keys[i]);
366366
}
367-
i = 1;
368-
inline while (i < count) : (i += 1) {
369-
ts = Block.parallel.encryptLastWide(count, ts, round_keys[i]);
370-
}
367+
ts = Block.parallel.encryptLastWide(count, ts, round_keys[i]);
371368
j = 0;
372369
inline while (j < count) : (j += 1) {
373370
dst[16 * j .. 16 * j + 16].* = ts[j].toBytes();
@@ -443,10 +440,7 @@ pub fn AesDecryptCtx(comptime Aes: type) type {
443440
inline while (i < rounds) : (i += 1) {
444441
ts = Block.parallel.decryptWide(count, ts, inv_round_keys[i]);
445442
}
446-
i = 1;
447-
inline while (i < count) : (i += 1) {
448-
ts = Block.parallel.decryptLastWide(count, ts, inv_round_keys[i]);
449-
}
443+
ts = Block.parallel.decryptLastWide(count, ts, inv_round_keys[i]);
450444
j = 0;
451445
inline while (j < count) : (j += 1) {
452446
dst[16 * j .. 16 * j + 16].* = ts[j].toBytes();

0 commit comments

Comments
 (0)