Revert "Merge pull request #4807 from LemonBoy/tls-touchups"
This reverts commitee6fda2297, reversing changes made tof313ab18ae. This caused a test failure: ``` behavior.misc.test "behavior-arm-linux-none-Debug-bare-multi thread local variable"...test failure /home/vsts/work/1/s/lib/std/testing.zig:191:14: 0x4608f in std.testing.expect (test) if (!ok) @panic("test failure"); ^ /home/vsts/work/1/s/test/stage1/behavior/misc.zig:616:11: 0x53e93 in behavior.misc.test "behavior-arm-linux-none-Debug-bare-multi thread local variable" (test) expect(S.t == 1235); ^ ```
This commit is contained in:
@@ -286,10 +286,11 @@ pub const Thread = struct {
|
||||
}
|
||||
// Finally, the Thread Local Storage, if any.
|
||||
if (!Thread.use_pthreads) {
|
||||
// XXX: Is this alignment enough?
|
||||
l = mem.alignForward(l, @alignOf(usize));
|
||||
tls_start_offset = l;
|
||||
l += os.linux.tls.tls_image.alloc_size;
|
||||
if (os.linux.tls.tls_image) |tls_img| {
|
||||
l = mem.alignForward(l, @alignOf(usize));
|
||||
tls_start_offset = l;
|
||||
l += tls_img.alloc_size;
|
||||
}
|
||||
}
|
||||
// Round the size to the page size.
|
||||
break :blk mem.alignForward(l, mem.page_size);
|
||||
@@ -395,21 +396,18 @@ pub const Thread = struct {
|
||||
else => return os.unexpectedErrno(@intCast(usize, err)),
|
||||
}
|
||||
} else if (std.Target.current.os.tag == .linux) {
|
||||
const flags: u32 = os.CLONE_VM | os.CLONE_FS | os.CLONE_FILES |
|
||||
os.CLONE_SIGHAND | os.CLONE_THREAD | os.CLONE_SYSVSEM |
|
||||
os.CLONE_PARENT_SETTID | os.CLONE_CHILD_CLEARTID |
|
||||
os.CLONE_DETACHED | os.CLONE_SETTLS;
|
||||
var flags: u32 = os.CLONE_VM | os.CLONE_FS | os.CLONE_FILES | os.CLONE_SIGHAND |
|
||||
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 (std.Target.current.cpu.arch == .i386) os.linux.user_desc else void = undefined;
|
||||
|
||||
const tls_area = mmap_slice[tls_start_offset..];
|
||||
const tp_value = os.linux.tls.prepareTLS(tls_area);
|
||||
|
||||
const newtls = blk: {
|
||||
if (os.linux.tls.tls_image) |tls_img| {
|
||||
if (std.Target.current.cpu.arch == .i386) {
|
||||
user_desc = os.linux.user_desc{
|
||||
.entry_number = os.linux.tls.tls_image.gdt_entry_number,
|
||||
.base_addr = tp_value,
|
||||
.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
|
||||
@@ -418,11 +416,12 @@ pub const Thread = struct {
|
||||
.seg_not_present = 0,
|
||||
.useable = 1,
|
||||
};
|
||||
break :blk @ptrToInt(&user_desc);
|
||||
newtls = @ptrToInt(&user_desc);
|
||||
} else {
|
||||
break :blk tp_value;
|
||||
newtls = os.linux.tls.copyTLS(mmap_addr + tls_start_offset);
|
||||
}
|
||||
};
|
||||
flags |= os.CLONE_SETTLS;
|
||||
}
|
||||
|
||||
const rc = os.linux.clone(
|
||||
MainFuncs.linuxThreadMain,
|
||||
|
||||
Reference in New Issue
Block a user