diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-11-30 22:00:00 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-11-30 22:00:00 -0500 |
| commit | 951dc451d6d49fca499e9a722a3f543d6e8bf7c1 (patch) | |
| tree | 766ef5f8c68186d3622b00f2e5e9546214e4fc48 /lib/std/thread.zig | |
| parent | 11b8d3ce9d7bc8e3ab16813fd5415c9d45dbb232 (diff) | |
| parent | cdeafe777a2fe707674cb44e4aa7b5a1b8319ec5 (diff) | |
| download | zig-951dc451d6d49fca499e9a722a3f543d6e8bf7c1.tar.gz zig-951dc451d6d49fca499e9a722a3f543d6e8bf7c1.zip | |
Merge pull request #3808 from LemonBoy/i386-for-ya
linux-i386 support
Diffstat (limited to 'lib/std/thread.zig')
| -rw-r--r-- | lib/std/thread.zig | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/lib/std/thread.zig b/lib/std/thread.zig index fe976a6839..571773dcae 100644 --- a/lib/std/thread.zig +++ b/lib/std/thread.zig @@ -314,11 +314,38 @@ pub const Thread = struct { os.CLONE_THREAD | os.CLONE_SYSVSEM | os.CLONE_PARENT_SETTID | os.CLONE_CHILD_CLEARTID | os.CLONE_DETACHED; var newtls: usize = undefined; + // This structure is only needed when targeting i386 + var user_desc: if (builtin.arch == .i386) os.linux.user_desc else void = undefined; + if (os.linux.tls.tls_image) |tls_img| { - newtls = os.linux.tls.copyTLS(mmap_addr + tls_start_offset); + if (builtin.arch == .i386) { + user_desc = os.linux.user_desc{ + .entry_number = tls_img.gdt_entry_number, + .base_addr = os.linux.tls.copyTLS(mmap_addr + tls_start_offset), + .limit = 0xfffff, + .seg_32bit = 1, + .contents = 0, // Data + .read_exec_only = 0, + .limit_in_pages = 1, + .seg_not_present = 0, + .useable = 1, + }; + newtls = @ptrToInt(&user_desc); + } else { + newtls = os.linux.tls.copyTLS(mmap_addr + tls_start_offset); + } flags |= os.CLONE_SETTLS; } - const rc = os.linux.clone(MainFuncs.linuxThreadMain, mmap_addr + stack_end_offset, flags, arg, &thread_ptr.data.handle, newtls, &thread_ptr.data.handle); + + const rc = os.linux.clone( + MainFuncs.linuxThreadMain, + mmap_addr + stack_end_offset, + flags, + arg, + &thread_ptr.data.handle, + newtls, + &thread_ptr.data.handle, + ); switch (os.errno(rc)) { 0 => return thread_ptr, os.EAGAIN => return error.ThreadQuotaExceeded, |
