diff options
| author | LemonBoy <thatlemon@gmail.com> | 2019-10-06 16:45:51 +0200 |
|---|---|---|
| committer | LemonBoy <thatlemon@gmail.com> | 2019-10-06 16:45:51 +0200 |
| commit | 6a687bda76a34775bde35ee386e59f53961341f7 (patch) | |
| tree | b6ed1c723a5cdc2655e68ceea5c7dd4e609d0c71 /lib/std | |
| parent | 93a49076f725e6e64f05b6be8422312c7dcda6d0 (diff) | |
| download | zig-6a687bda76a34775bde35ee386e59f53961341f7.tar.gz zig-6a687bda76a34775bde35ee386e59f53961341f7.zip | |
Support for TLS on Win32
Diffstat (limited to 'lib/std')
| -rw-r--r-- | lib/std/os/test.zig | 1 | ||||
| -rw-r--r-- | lib/std/special/start_windows_tls.zig | 12 |
2 files changed, 12 insertions, 1 deletions
diff --git a/lib/std/os/test.zig b/lib/std/os/test.zig index 7a6d359236..d886597a38 100644 --- a/lib/std/os/test.zig +++ b/lib/std/os/test.zig @@ -116,7 +116,6 @@ test "AtomicFile" { test "thread local storage" { if (builtin.single_threaded) return error.SkipZigTest; - if (builtin.os == .windows) return error.SkipZigTest; const thread1 = try Thread.spawn({}, testTls); const thread2 = try Thread.spawn({}, testTls); testTls({}); diff --git a/lib/std/special/start_windows_tls.zig b/lib/std/special/start_windows_tls.zig index 71165d355b..bfd0e44122 100644 --- a/lib/std/special/start_windows_tls.zig +++ b/lib/std/special/start_windows_tls.zig @@ -1,4 +1,5 @@ const std = @import("std"); +const builtin = @import("builtin"); export var _tls_index: u32 = std.os.windows.TLS_OUT_OF_INDEXES; export var _tls_start: u8 linksection(".tls") = 0; @@ -6,6 +7,17 @@ export var _tls_end: u8 linksection(".tls$ZZZ") = 0; export var __xl_a: std.os.windows.PIMAGE_TLS_CALLBACK linksection(".CRT$XLA") = null; export var __xl_z: std.os.windows.PIMAGE_TLS_CALLBACK linksection(".CRT$XLZ") = null; +comptime { + if (builtin.arch == .i386) { + // The __tls_array is the offset of the ThreadLocalStoragePointer field + // in the TEB block whose base address held in the %fs segment. + asm ( + \\ .global __tls_array + \\ __tls_array = 0x2C + ); + } +} + // TODO this is how I would like it to be expressed // TODO also note, ReactOS has a +1 on StartAddressOfRawData and AddressOfCallBacks. Investigate // why they do that. |
