From 043bd716210b0233f1bc0bb90a8fb063cd63d0b8 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Tue, 7 May 2019 13:19:38 +0200 Subject: [PATCH] Add ARCH_SET_* definitions for x86_64 --- std/os/linux/tls.zig | 5 ++--- std/os/linux/x86_64.zig | 5 +++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/std/os/linux/tls.zig b/std/os/linux/tls.zig index 5e81661f49..9c8d816f05 100644 --- a/std/os/linux/tls.zig +++ b/std/os/linux/tls.zig @@ -109,9 +109,8 @@ pub var tls_image: ?TLSImage = null; pub fn setThreadPointer(addr: usize) void { switch (builtin.arch) { .x86_64 => { - const ARCH_SET_FS = 0x1002; - const rc = std.os.linux.syscall2(std.os.linux.SYS_arch_prctl, ARCH_SET_FS, addr); - // arch_prctl is documented to never fail + const rc = std.os.linux.syscall2(std.os.linux.SYS_arch_prctl, + std.os.linux.ARCH_SET_FS, addr); assert(rc == 0); }, .aarch64 => { diff --git a/std/os/linux/x86_64.zig b/std/os/linux/x86_64.zig index dc7fe60128..621783d572 100644 --- a/std/os/linux/x86_64.zig +++ b/std/os/linux/x86_64.zig @@ -388,6 +388,11 @@ pub const VDSO_CGT_VER = "LINUX_2.6"; pub const VDSO_GETCPU_SYM = "__vdso_getcpu"; pub const VDSO_GETCPU_VER = "LINUX_2.6"; +pub const ARCH_SET_GS = 0x1001; +pub const ARCH_SET_FS = 0x1002; +pub const ARCH_GET_FS = 0x1003; +pub const ARCH_GET_GS = 0x1004; + pub fn syscall0(number: usize) usize { return asm volatile ("syscall" : [ret] "={rax}" (-> usize)