aboutsummaryrefslogtreecommitdiff
path: root/lib/std/Thread/ResetEvent.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-08-28 12:41:24 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-08-28 12:41:24 -0700
commit6aeab0f323ff14d7ad248e18c372573f7a5a8cd1 (patch)
tree7080297f629f39baa0b742985c5804cf6a2047e8 /lib/std/Thread/ResetEvent.zig
parent47f7ed1c4cb8acf7fed99a057fb84202962e4b1b (diff)
parent05cf44933d753f7a5a53ab289ea60fd43761de57 (diff)
downloadzig-6aeab0f323ff14d7ad248e18c372573f7a5a8cd1.tar.gz
zig-6aeab0f323ff14d7ad248e18c372573f7a5a8cd1.zip
Merge remote-tracking branch 'origin/master' into llvm13
Conflicts: lib/libcxx/include/__config d57c0cc3bfeff9af297279759ec2b631e6d95140 added support for DragonFlyBSD to libc++ by updating some ifdefs. This needed to be synced with llvm13.
Diffstat (limited to 'lib/std/Thread/ResetEvent.zig')
-rw-r--r--lib/std/Thread/ResetEvent.zig30
1 files changed, 12 insertions, 18 deletions
diff --git a/lib/std/Thread/ResetEvent.zig b/lib/std/Thread/ResetEvent.zig
index 356b8eb78d..d9304dd70b 100644
--- a/lib/std/Thread/ResetEvent.zig
+++ b/lib/std/Thread/ResetEvent.zig
@@ -1,9 +1,3 @@
-// SPDX-License-Identifier: MIT
-// Copyright (c) 2015-2021 Zig Contributors
-// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
-// The MIT license requires this copyright notice to be included in all copies
-// and substantial portions of the software.
-
//! A thread-safe resource which supports blocking until signaled.
//! This API is for kernel threads, not evented I/O.
//! This API requires being initialized at runtime, and initialization
@@ -130,7 +124,7 @@ pub const PosixEvent = struct {
pub fn init(ev: *PosixEvent) !void {
switch (c.getErrno(c.sem_init(&ev.sem, 0, 0))) {
- 0 => return,
+ .SUCCESS => return,
else => return error.SystemResources,
}
}
@@ -147,9 +141,9 @@ pub const PosixEvent = struct {
pub fn wait(ev: *PosixEvent) void {
while (true) {
switch (c.getErrno(c.sem_wait(&ev.sem))) {
- 0 => return,
- c.EINTR => continue,
- c.EINVAL => unreachable,
+ .SUCCESS => return,
+ .INTR => continue,
+ .INVAL => unreachable,
else => unreachable,
}
}
@@ -165,10 +159,10 @@ pub const PosixEvent = struct {
ts.tv_nsec = @intCast(@TypeOf(ts.tv_nsec), @mod(timeout_abs, time.ns_per_s));
while (true) {
switch (c.getErrno(c.sem_timedwait(&ev.sem, &ts))) {
- 0 => return .event_set,
- c.EINTR => continue,
- c.EINVAL => unreachable,
- c.ETIMEDOUT => return .timed_out,
+ .SUCCESS => return .event_set,
+ .INTR => continue,
+ .INVAL => unreachable,
+ .TIMEDOUT => return .timed_out,
else => unreachable,
}
}
@@ -177,10 +171,10 @@ pub const PosixEvent = struct {
pub fn reset(ev: *PosixEvent) void {
while (true) {
switch (c.getErrno(c.sem_trywait(&ev.sem))) {
- 0 => continue, // Need to make it go to zero.
- c.EINTR => continue,
- c.EINVAL => unreachable,
- c.EAGAIN => return, // The semaphore currently has the value zero.
+ .SUCCESS => continue, // Need to make it go to zero.
+ .INTR => continue,
+ .INVAL => unreachable,
+ .AGAIN => return, // The semaphore currently has the value zero.
else => unreachable,
}
}