diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-02-06 18:32:41 -0500 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-02-06 18:32:41 -0500 |
| commit | 89ffb5819703c81514e4f29d2cadb5b74ea1f840 (patch) | |
| tree | 455eda3ef65b2a2f08f292586b219468aa755f06 /src/codegen.cpp | |
| parent | d2602b442e7cdea2e74584f9529917d7a53625fd (diff) | |
| download | zig-89ffb5819703c81514e4f29d2cadb5b74ea1f840.tar.gz zig-89ffb5819703c81514e4f29d2cadb5b74ea1f840.zip | |
implement Thread Local Storage on Windows
Diffstat (limited to 'src/codegen.cpp')
| -rw-r--r-- | src/codegen.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp index 5e282160d6..7169669426 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -6365,6 +6365,12 @@ static void validate_inline_fns(CodeGen *g) { report_errors_and_maybe_exit(g); } +static void set_global_tls(CodeGen *g, ZigVar *var, LLVMValueRef global_value) { + if (var->is_thread_local && !g->is_single_threaded) { + LLVMSetThreadLocalMode(global_value, LLVMGeneralDynamicTLSModel); + } +} + static void do_code_gen(CodeGen *g) { assert(!g->errors.length); @@ -6449,9 +6455,7 @@ static void do_code_gen(CodeGen *g) { maybe_import_dll(g, global_value, GlobalLinkageIdStrong); LLVMSetAlignment(global_value, var->align_bytes); LLVMSetGlobalConstant(global_value, var->gen_is_const); - if (var->is_thread_local && !g->is_single_threaded) { - LLVMSetThreadLocalMode(global_value, LLVMGeneralDynamicTLSModel); - } + set_global_tls(g, var, global_value); } } else { bool exported = (var->linkage == VarLinkageExport); @@ -6477,9 +6481,7 @@ static void do_code_gen(CodeGen *g) { } LLVMSetGlobalConstant(global_value, var->gen_is_const); - if (var->is_thread_local && !g->is_single_threaded) { - LLVMSetThreadLocalMode(global_value, LLVMGeneralDynamicTLSModel); - } + set_global_tls(g, var, global_value); } var->value_ref = global_value; |
