authorgravatar for jay@jayschwa.netJay Petacat <jay@jayschwa.net> 2022-05-04 10:43:27-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2022-05-04 09:43:27-05:00
log28ef79ea808fdb8e00b6d88d1565314a9e412768
treeef5a6579b9154d18234dc4736ac75468da7e0ccf
parent3ed9ef3e6bed3fef6d6cad07920d08b28e20ec3e
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

std: Single-threaded `panicImpl` sleep is unreachable (#11569)

Adding `unreachable` prevents the futex code from being inspected during a single-threaded build. Without futex, first draft BYOS packages don't need to implement `nanosleep` to get a single-threaded "hello world" program working. Use of `assert()` did not achieve the desired effect of avoiding futex in a single-threaded build.

1 files changed, 1 insertions(+), 0 deletions(-)

lib/std/debug.zig+1
......@@ -340,6 +340,7 @@ pub fn panicImpl(trace: ?*const std.builtin.StackTrace, first_trace_addr: ?usize
340340 if (panicking.fetchSub(1, .SeqCst) != 1) {
341341 // Another thread is panicking, wait for the last one to finish
342342 // and call abort()
343 if (builtin.single_threaded) unreachable;
343344
344345 // Sleep forever without hammering the CPU
345346 var futex = std.atomic.Atomic(u32).init(0);