| author | |
| committer | |
| log | bf8e419d2b7853f5cb5aba4dcba45ae28a3840aa |
| tree | dca5260dd4a11773fec68dd5973201be6f61b725 |
| parent | abf90eaa674782e092e49bb23c4c7da0f581f604 |
5 files changed, 10 insertions(+), 20 deletions(-)
src/all_types.hpp-1| ... | ... | @@ -1486,7 +1486,6 @@ struct CodeGen { |
| 1486 | 1486 | |
| 1487 | 1487 | ZigList<LinkLib *> link_libs_list; |
| 1488 | 1488 | LinkLib *libc_link_lib; |
| 1489 | LinkLib *pthread_link_lib; | |
| 1490 | 1489 | |
| 1491 | 1490 | // add -framework [name] args to linker |
| 1492 | 1491 | ZigList<Buf *> darwin_frameworks; |
src/analyze.cpp-8| ... | ... | @@ -6049,15 +6049,10 @@ LinkLib *create_link_lib(Buf *name) { |
| 6049 | 6049 | |
| 6050 | 6050 | LinkLib *add_link_lib(CodeGen *g, Buf *name) { |
| 6051 | 6051 | bool is_libc = buf_eql_str(name, "c"); |
| 6052 | bool is_pthread = buf_eql_str(name, "pthread"); | |
| 6053 | 6052 | |
| 6054 | 6053 | if (is_libc && g->libc_link_lib != nullptr) |
| 6055 | 6054 | return g->libc_link_lib; |
| 6056 | 6055 | |
| 6057 | if (is_pthread && g->pthread_link_lib != nullptr) { | |
| 6058 | return g->pthread_link_lib; | |
| 6059 | } | |
| 6060 | ||
| 6061 | 6056 | for (size_t i = 0; i < g->link_libs_list.length; i += 1) { |
| 6062 | 6057 | LinkLib *existing_lib = g->link_libs_list.at(i); |
| 6063 | 6058 | if (buf_eql_buf(existing_lib->name, name)) { |
| ... | ... | @@ -6071,9 +6066,6 @@ LinkLib *add_link_lib(CodeGen *g, Buf *name) { |
| 6071 | 6066 | if (is_libc) |
| 6072 | 6067 | g->libc_link_lib = link_lib; |
| 6073 | 6068 | |
| 6074 | if (is_pthread) | |
| 6075 | g->pthread_link_lib = link_lib; | |
| 6076 | ||
| 6077 | 6069 | return link_lib; |
| 6078 | 6070 | } |
| 6079 | 6071 |
src/codegen.cpp-2| ... | ... | @@ -145,7 +145,6 @@ CodeGen *codegen_create(Buf *root_src_path, const ZigTarget *target, OutType out |
| 145 | 145 | { |
| 146 | 146 | g->libc_link_lib = create_link_lib(buf_create_from_str("c")); |
| 147 | 147 | g->link_libs_list.append(g->libc_link_lib); |
| 148 | g->pthread_link_lib = create_link_lib(buf_create_from_str("pthread")); | |
| 149 | 148 | } |
| 150 | 149 | |
| 151 | 150 | return g; |
| ... | ... | @@ -6374,7 +6373,6 @@ static void define_builtin_compile_vars(CodeGen *g) { |
| 6374 | 6373 | buf_appendf(contents, "pub const object_format = ObjectFormat.%s;\n", cur_obj_fmt); |
| 6375 | 6374 | buf_appendf(contents, "pub const mode = %s;\n", build_mode_to_str(g->build_mode)); |
| 6376 | 6375 | buf_appendf(contents, "pub const link_libc = %s;\n", bool_to_str(g->libc_link_lib != nullptr)); |
| 6377 | buf_appendf(contents, "pub const link_pthread = %s;\n", bool_to_str(g->pthread_link_lib != nullptr)); | |
| 6378 | 6376 | buf_appendf(contents, "pub const have_error_return_tracing = %s;\n", bool_to_str(g->have_err_ret_tracing)); |
| 6379 | 6377 | |
| 6380 | 6378 | buf_appendf(contents, "pub const __zig_test_fn_slice = {}; // overwritten later\n"); |
std/c/index.zig+5-5| ... | ... | @@ -54,12 +54,12 @@ pub extern "c" fn realloc(&c_void, usize) ?&c_void; |
| 54 | 54 | pub extern "c" fn free(&c_void) void; |
| 55 | 55 | pub extern "c" fn posix_memalign(memptr: &&c_void, alignment: usize, size: usize) c_int; |
| 56 | 56 | |
| 57 | pub extern "c" fn pthread_create(noalias newthread: &pthread_t, | |
| 57 | pub extern "pthread" fn pthread_create(noalias newthread: &pthread_t, | |
| 58 | 58 | noalias attr: ?&const pthread_attr_t, start_routine: extern fn(?&c_void) ?&c_void, |
| 59 | 59 | noalias arg: ?&c_void) c_int; |
| 60 | pub extern "c" fn pthread_attr_init(attr: &pthread_attr_t) c_int; | |
| 61 | pub extern "c" fn pthread_attr_setstack(attr: &pthread_attr_t, stackaddr: &c_void, stacksize: usize) c_int; | |
| 62 | pub extern "c" fn pthread_attr_destroy(attr: &pthread_attr_t) c_int; | |
| 63 | pub extern "c" fn pthread_join(thread: pthread_t, arg_return: ?&?&c_void) c_int; | |
| 60 | pub extern "pthread" fn pthread_attr_init(attr: &pthread_attr_t) c_int; | |
| 61 | pub extern "pthread" fn pthread_attr_setstack(attr: &pthread_attr_t, stackaddr: &c_void, stacksize: usize) c_int; | |
| 62 | pub extern "pthread" fn pthread_attr_destroy(attr: &pthread_attr_t) c_int; | |
| 63 | pub extern "pthread" fn pthread_join(thread: pthread_t, arg_return: ?&?&c_void) c_int; | |
| 64 | 64 | |
| 65 | 65 | pub const pthread_t = &@OpaqueType(); |
std/os/index.zig+5-4| ... | ... | @@ -2352,11 +2352,12 @@ pub const Thread = struct { |
| 2352 | 2352 | stack: []u8, |
| 2353 | 2353 | pthread_handle: pthread_t, |
| 2354 | 2354 | |
| 2355 | const pthread_t = if (builtin.link_pthread) c.pthread_t else void; | |
| 2356 | const pid_t = if (!builtin.link_pthread) i32 else void; | |
| 2355 | pub const use_pthreads = is_posix and builtin.link_libc; | |
| 2356 | const pthread_t = if (use_pthreads) c.pthread_t else void; | |
| 2357 | const pid_t = if (!use_pthreads) i32 else void; | |
| 2357 | 2358 | |
| 2358 | 2359 | pub fn wait(self: &const Thread) void { |
| 2359 | if (builtin.link_pthread) { | |
| 2360 | if (use_pthreads) { | |
| 2360 | 2361 | const err = c.pthread_join(self.pthread_handle, null); |
| 2361 | 2362 | switch (err) { |
| 2362 | 2363 | 0 => {}, |
| ... | ... | @@ -2475,7 +2476,7 @@ pub fn spawnThread(stack: []align(os.page_size) u8, context: var, comptime start |
| 2475 | 2476 | if (builtin.os == builtin.Os.windows) { |
| 2476 | 2477 | // use windows API directly |
| 2477 | 2478 | @compileError("TODO support spawnThread for Windows"); |
| 2478 | } else if (builtin.link_pthread) { | |
| 2479 | } else if (Thread.use_pthreads) { | |
| 2479 | 2480 | // use pthreads |
| 2480 | 2481 | var attr: c.pthread_attr_t = undefined; |
| 2481 | 2482 | if (c.pthread_attr_init(&attr) != 0) return SpawnThreadError.SystemResources; |