diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-04-29 00:40:04 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-04-29 00:40:04 -0400 |
| commit | bf8e419d2b7853f5cb5aba4dcba45ae28a3840aa (patch) | |
| tree | dca5260dd4a11773fec68dd5973201be6f61b725 /std/os | |
| parent | abf90eaa674782e092e49bb23c4c7da0f581f604 (diff) | |
| download | zig-bf8e419d2b7853f5cb5aba4dcba45ae28a3840aa.tar.gz zig-bf8e419d2b7853f5cb5aba4dcba45ae28a3840aa.zip | |
linux uses pthreads when linking against libc
Diffstat (limited to 'std/os')
| -rw-r--r-- | std/os/index.zig | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/std/os/index.zig b/std/os/index.zig index 8681a018b9..85e46a1bf9 100644 --- a/std/os/index.zig +++ b/std/os/index.zig @@ -2352,11 +2352,12 @@ pub const Thread = struct { stack: []u8, pthread_handle: pthread_t, - const pthread_t = if (builtin.link_pthread) c.pthread_t else void; - const pid_t = if (!builtin.link_pthread) i32 else void; + pub const use_pthreads = is_posix and builtin.link_libc; + const pthread_t = if (use_pthreads) c.pthread_t else void; + const pid_t = if (!use_pthreads) i32 else void; pub fn wait(self: &const Thread) void { - if (builtin.link_pthread) { + if (use_pthreads) { const err = c.pthread_join(self.pthread_handle, null); switch (err) { 0 => {}, @@ -2475,7 +2476,7 @@ pub fn spawnThread(stack: []align(os.page_size) u8, context: var, comptime start if (builtin.os == builtin.Os.windows) { // use windows API directly @compileError("TODO support spawnThread for Windows"); - } else if (builtin.link_pthread) { + } else if (Thread.use_pthreads) { // use pthreads var attr: c.pthread_attr_t = undefined; if (c.pthread_attr_init(&attr) != 0) return SpawnThreadError.SystemResources; |
