aboutsummaryrefslogtreecommitdiff
path: root/lib/std/Thread
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-09-15 14:46:31 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-09-15 14:51:08 -0700
commitf3ebfcae3882c03da84821abed40167ea07a8c78 (patch)
treef1b759c94cba5b020a9ffb141fc62cb686fc5f04 /lib/std/Thread
parent111a2dcf3ad53c0c8ad2c9e7c9bd042b81e90c82 (diff)
parent0395b35cee8d4082cc40b0dcd0298f797f42309d (diff)
downloadzig-f3ebfcae3882c03da84821abed40167ea07a8c78.tar.gz
zig-f3ebfcae3882c03da84821abed40167ea07a8c78.zip
Merge remote-tracking branch 'origin/master' into llvm13
Conflicts: * cmake/Findclang.cmake * cmake/Findlld.cmake * cmake/Findllvm.cmake In master branch, more search paths were added to these files with "12" in the path. In this commit I updated them to "13". * src/stage1/codegen.cpp * src/zig_llvm.cpp * src/zig_llvm.h In master branch, ZigLLVMBuildCmpXchg is improved to add `is_single_threaded`. However, the LLVM 13 C API has this already, and in the llvm13 branch, ZigLLVMBuildCmpXchg is deleted in favor of the C API. In this commit I updated stage2 to use the LLVM 13 C API rather than depending on an improved ZigLLVMBuildCmpXchg. Additionally, src/target.zig largestAtomicBits needed to be updated to include the new m68k ISA.
Diffstat (limited to 'lib/std/Thread')
-rw-r--r--lib/std/Thread/Futex.zig6
-rw-r--r--lib/std/Thread/Mutex.zig4
-rw-r--r--lib/std/Thread/ResetEvent.zig2
-rw-r--r--lib/std/Thread/StaticResetEvent.zig4
4 files changed, 8 insertions, 8 deletions
diff --git a/lib/std/Thread/Futex.zig b/lib/std/Thread/Futex.zig
index 5a3da5cd94..8411041166 100644
--- a/lib/std/Thread/Futex.zig
+++ b/lib/std/Thread/Futex.zig
@@ -142,7 +142,7 @@ const LinuxFutex = struct {
switch (linux.getErrno(linux.futex_wait(
@ptrCast(*const i32, ptr),
- linux.FUTEX_PRIVATE_FLAG | linux.FUTEX_WAIT,
+ linux.FUTEX.PRIVATE_FLAG | linux.FUTEX.WAIT,
@bitCast(i32, expect),
ts_ptr,
))) {
@@ -159,7 +159,7 @@ const LinuxFutex = struct {
fn wake(ptr: *const Atomic(u32), num_waiters: u32) void {
switch (linux.getErrno(linux.futex_wake(
@ptrCast(*const i32, ptr),
- linux.FUTEX_PRIVATE_FLAG | linux.FUTEX_WAKE,
+ linux.FUTEX.PRIVATE_FLAG | linux.FUTEX.WAKE,
std.math.cast(i32, num_waiters) catch std.math.maxInt(i32),
))) {
.SUCCESS => {}, // successful wake up
@@ -352,7 +352,7 @@ const PosixFutex = struct {
var ts_ptr: ?*const std.os.timespec = null;
if (timeout) |timeout_ns| {
ts_ptr = &ts;
- std.os.clock_gettime(std.os.CLOCK_REALTIME, &ts) catch unreachable;
+ std.os.clock_gettime(std.os.CLOCK.REALTIME, &ts) catch unreachable;
ts.tv_sec += @intCast(@TypeOf(ts.tv_sec), timeout_ns / std.time.ns_per_s);
ts.tv_nsec += @intCast(@TypeOf(ts.tv_nsec), timeout_ns % std.time.ns_per_s);
if (ts.tv_nsec >= std.time.ns_per_s) {
diff --git a/lib/std/Thread/Mutex.zig b/lib/std/Thread/Mutex.zig
index ee54a1582b..a337809a18 100644
--- a/lib/std/Thread/Mutex.zig
+++ b/lib/std/Thread/Mutex.zig
@@ -133,7 +133,7 @@ pub const AtomicMutex = struct {
.linux => {
switch (linux.getErrno(linux.futex_wait(
@ptrCast(*const i32, &m.state),
- linux.FUTEX_PRIVATE_FLAG | linux.FUTEX_WAIT,
+ linux.FUTEX.PRIVATE_FLAG | linux.FUTEX.WAIT,
@enumToInt(new_state),
null,
))) {
@@ -155,7 +155,7 @@ pub const AtomicMutex = struct {
.linux => {
switch (linux.getErrno(linux.futex_wake(
@ptrCast(*const i32, &m.state),
- linux.FUTEX_PRIVATE_FLAG | linux.FUTEX_WAKE,
+ linux.FUTEX.PRIVATE_FLAG | linux.FUTEX.WAKE,
1,
))) {
.SUCCESS => {},
diff --git a/lib/std/Thread/ResetEvent.zig b/lib/std/Thread/ResetEvent.zig
index d9304dd70b..d85cf7f133 100644
--- a/lib/std/Thread/ResetEvent.zig
+++ b/lib/std/Thread/ResetEvent.zig
@@ -152,7 +152,7 @@ pub const PosixEvent = struct {
pub fn timedWait(ev: *PosixEvent, timeout_ns: u64) TimedWaitResult {
var ts: os.timespec = undefined;
var timeout_abs = timeout_ns;
- os.clock_gettime(os.CLOCK_REALTIME, &ts) catch return .timed_out;
+ os.clock_gettime(os.CLOCK.REALTIME, &ts) catch return .timed_out;
timeout_abs += @intCast(u64, ts.tv_sec) * time.ns_per_s;
timeout_abs += @intCast(u64, ts.tv_nsec);
ts.tv_sec = @intCast(@TypeOf(ts.tv_sec), @divFloor(timeout_abs, time.ns_per_s));
diff --git a/lib/std/Thread/StaticResetEvent.zig b/lib/std/Thread/StaticResetEvent.zig
index d779a4de9e..29fdf3e489 100644
--- a/lib/std/Thread/StaticResetEvent.zig
+++ b/lib/std/Thread/StaticResetEvent.zig
@@ -194,7 +194,7 @@ pub const AtomicEvent = struct {
_ = wake_count;
const waiting = std.math.maxInt(i32); // wake_count
const ptr = @ptrCast(*const i32, waiters);
- const rc = linux.futex_wake(ptr, linux.FUTEX_WAKE | linux.FUTEX_PRIVATE_FLAG, waiting);
+ const rc = linux.futex_wake(ptr, linux.FUTEX.WAKE | linux.FUTEX.PRIVATE_FLAG, waiting);
assert(linux.getErrno(rc) == .SUCCESS);
}
@@ -213,7 +213,7 @@ pub const AtomicEvent = struct {
return;
const expected = @intCast(i32, waiting);
const ptr = @ptrCast(*const i32, waiters);
- const rc = linux.futex_wait(ptr, linux.FUTEX_WAIT | linux.FUTEX_PRIVATE_FLAG, expected, ts_ptr);
+ const rc = linux.futex_wait(ptr, linux.FUTEX.WAIT | linux.FUTEX.PRIVATE_FLAG, expected, ts_ptr);
switch (linux.getErrno(rc)) {
.SUCCESS => continue,
.TIMEDOUT => return error.TimedOut,