authorgravatar for kbutcher6200@gmail.comkprotty <kbutcher6200@gmail.com> 2021-06-30 21:49:38-05:00
committergravatar for kbutcher6200@gmail.comkprotty <kbutcher6200@gmail.com> 2021-06-30 21:49:38-05:00
log98106b09d5bf1bcc1be4fe09a7fa645b3b343732
treedb18bed90eb340101127f42f300cc6edc0fc38b0
parent2309c81a7812fab071fd2994bb3074edf748de63

zig fmt


3 files changed, 12 insertions(+), 13 deletions(-)

lib/std/Thread.zig+3-3
...@@ -792,7 +792,7 @@ test "Thread.join" {...@@ -792,7 +792,7 @@ test "Thread.join" {
792 try event.init();792 try event.init();
793 defer event.deinit();793 defer event.deinit();
794794
795 const thread = try Thread.spawn(.{}, testIncrementNotify, .{&value, &event});795 const thread = try Thread.spawn(.{}, testIncrementNotify, .{ &value, &event });
796 thread.join();796 thread.join();
797797
798 try std.testing.expectEqual(value, 1);798 try std.testing.expectEqual(value, 1);
...@@ -806,9 +806,9 @@ test "Thread.detach" {...@@ -806,9 +806,9 @@ test "Thread.detach" {
806 try event.init();806 try event.init();
807 defer event.deinit();807 defer event.deinit();
808808
809 const thread = try Thread.spawn(.{}, testIncrementNotify, .{&value, &event});809 const thread = try Thread.spawn(.{}, testIncrementNotify, .{ &value, &event });
810 thread.detach();810 thread.detach();
811811
812 event.wait();812 event.wait();
813 try std.testing.expectEqual(value, 1);813 try std.testing.expectEqual(value, 1);
814}
\ No newline at end of file
814}
lib/std/Thread/Futex.zig+8-9
...@@ -66,7 +66,7 @@ pub fn wait(ptr: *const Atomic(u32), expect: u32, timeout: ?u64) error{TimedOut}...@@ -66,7 +66,7 @@ pub fn wait(ptr: *const Atomic(u32), expect: u32, timeout: ?u64) error{TimedOut}
66pub fn wake(ptr: *const Atomic(u32), num_waiters: u32) void {66pub fn wake(ptr: *const Atomic(u32), num_waiters: u32) void {
67 if (single_threaded) return;67 if (single_threaded) return;
68 if (num_waiters == 0) return;68 if (num_waiters == 0) return;
69 69
70 return OsFutex.wake(ptr, num_waiters);70 return OsFutex.wake(ptr, num_waiters);
71}71}
7272
...@@ -83,11 +83,11 @@ else...@@ -83,11 +83,11 @@ else
8383
84const UnsupportedFutex = struct {84const UnsupportedFutex = struct {
85 fn wait(ptr: *const Atomic(u32), expect: u32, timeout: ?u64) error{TimedOut}!void {85 fn wait(ptr: *const Atomic(u32), expect: u32, timeout: ?u64) error{TimedOut}!void {
86 return unsupported(.{ptr, expect, timeout});86 return unsupported(.{ ptr, expect, timeout });
87 }87 }
8888
89 fn wake(ptr: *const Atomic(u32), num_waiters: u32) void {89 fn wake(ptr: *const Atomic(u32), num_waiters: u32) void {
90 return unsupported(.{ptr, num_waiters});90 return unsupported(.{ ptr, num_waiters });
91 }91 }
9292
93 fn unsupported(unused: anytype) noreturn {93 fn unsupported(unused: anytype) noreturn {
...@@ -417,7 +417,6 @@ test "Futex - Signal" {...@@ -417,7 +417,6 @@ test "Futex - Signal" {
417 fn run(self: *@This(), hit_to: *@This()) !void {417 fn run(self: *@This(), hit_to: *@This()) !void {
418 var iterations: usize = 4;418 var iterations: usize = 4;
419 while (iterations > 0) : (iterations -= 1) {419 while (iterations > 0) : (iterations -= 1) {
420
421 var value: u32 = undefined;420 var value: u32 = undefined;
422 while (true) {421 while (true) {
423 value = self.value.load(.Acquire);422 value = self.value.load(.Acquire);
...@@ -427,7 +426,7 @@ test "Futex - Signal" {...@@ -427,7 +426,7 @@ test "Futex - Signal" {
427426
428 try testing.expectEqual(value, self.current + 1);427 try testing.expectEqual(value, self.current + 1);
429 self.current = value;428 self.current = value;
430 429
431 _ = hit_to.value.fetchAdd(1, .Release);430 _ = hit_to.value.fetchAdd(1, .Release);
432 Futex.wake(&hit_to.value, 1);431 Futex.wake(&hit_to.value, 1);
433 }432 }
...@@ -437,10 +436,10 @@ test "Futex - Signal" {...@@ -437,10 +436,10 @@ test "Futex - Signal" {
437 var ping = Paddle{};436 var ping = Paddle{};
438 var pong = Paddle{};437 var pong = Paddle{};
439438
440 const t1 = try std.Thread.spawn(.{}, Paddle.run, .{&ping, &pong});439 const t1 = try std.Thread.spawn(.{}, Paddle.run, .{ &ping, &pong });
441 defer t1.join();440 defer t1.join();
442441
443 const t2 = try std.Thread.spawn(.{}, Paddle.run, .{&pong, &ping});442 const t2 = try std.Thread.spawn(.{}, Paddle.run, .{ &pong, &ping });
444 defer t2.join();443 defer t2.join();
445444
446 _ = ping.value.fetchAdd(1, .Release);445 _ = ping.value.fetchAdd(1, .Release);
...@@ -497,7 +496,7 @@ test "Futex - Broadcast" {...@@ -497,7 +496,7 @@ test "Futex - Broadcast" {
497496
498 // Try to wait for the threads to start before running runSender().497 // Try to wait for the threads to start before running runSender().
499 // NOTE: not actually needed for correctness.498 // NOTE: not actually needed for correctness.
500 std.time.sleep(16 * std.time.ns_per_ms); 499 std.time.sleep(16 * std.time.ns_per_ms);
501 try ctx.runSender();500 try ctx.runSender();
502501
503 const notified = ctx.notified.load(.Monotonic);502 const notified = ctx.notified.load(.Monotonic);
...@@ -551,7 +550,7 @@ test "Futex - Chain" {...@@ -551,7 +550,7 @@ test "Futex - Chain" {
551 var ctx = Context{};550 var ctx = Context{};
552 for (ctx.threads) |*entry, index| {551 for (ctx.threads) |*entry, index| {
553 entry.signal = .{};552 entry.signal = .{};
554 entry.thread = try std.Thread.spawn(.{}, Context.run, .{&ctx, index});553 entry.thread = try std.Thread.spawn(.{}, Context.run, .{ &ctx, index });
555 }554 }
556555
557 ctx.threads[0].signal.notify();556 ctx.threads[0].signal.notify();
tools/update_cpu_features.zig+1-1
...@@ -819,7 +819,7 @@ pub fn main() anyerror!void {...@@ -819,7 +819,7 @@ pub fn main() anyerror!void {
819 var threads = try arena.alloc(std.Thread, llvm_targets.len);819 var threads = try arena.alloc(std.Thread, llvm_targets.len);
820 for (llvm_targets) |llvm_target, i| {820 for (llvm_targets) |llvm_target, i| {
821 threads[i] = try std.Thread.spawn(.{}, processOneTarget, .{821 threads[i] = try std.Thread.spawn(.{}, processOneTarget, .{
822 Job{822 Job{
823 .llvm_tblgen_exe = llvm_tblgen_exe,823 .llvm_tblgen_exe = llvm_tblgen_exe,
824 .llvm_src_root = llvm_src_root,824 .llvm_src_root = llvm_src_root,
825 .zig_src_dir = zig_src_dir,825 .zig_src_dir = zig_src_dir,