authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-01-15 17:49:55+01:00
committergravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-01-15 17:50:51+01:00
logc5cfc9bf686b5d39d8524c72950eb332814f9707
tree1b5ebd5b7f160d2c5848c2b2c29e7c96ea5e144e
parent5d5345728a0bbcd397a7667148f0c87dd0d7d14d

Move definition of __aeabi_read_tp


4 files changed, 12 insertions(+), 11 deletions(-)

lib/std/os/linux/arm-eabi.zig-9
...@@ -88,15 +88,6 @@ pub fn syscall6(...@@ -88,15 +88,6 @@ pub fn syscall6(
88/// This matches the libc clone function.88/// This matches the libc clone function.
89pub extern fn clone(func: extern fn (arg: usize) u8, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize;89pub extern fn clone(func: extern fn (arg: usize) u8, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize;
9090
91// LLVM calls this when the read-tp-hard feature is set to false. Currently, there is no way to pass
92// that to llvm via zig, see https://github.com/ziglang/zig/issues/2883.
93// LLVM expects libc to provide this function as __aeabi_read_tp, so it is exported if needed from special/c.zig.
94pub fn getThreadPointer() callconv(.C) usize {
95 return asm volatile ("mrc p15, 0, %[ret], c13, c0, 3"
96 : [ret] "=r" (-> usize)
97 );
98}
99
100pub fn restore() callconv(.Naked) void {91pub fn restore() callconv(.Naked) void {
101 return asm volatile ("svc #0"92 return asm volatile ("svc #0"
102 :93 :
lib/std/special/c.zig-2
...@@ -32,8 +32,6 @@ comptime {...@@ -32,8 +32,6 @@ comptime {
32 @export(strlen, .{ .name = "strlen", .linkage = .Strong });32 @export(strlen, .{ .name = "strlen", .linkage = .Strong });
33 } else if (is_msvc) {33 } else if (is_msvc) {
34 @export(_fltused, .{ .name = "_fltused", .linkage = .Strong });34 @export(_fltused, .{ .name = "_fltused", .linkage = .Strong });
35 } else if (builtin.arch == builtin.Arch.arm and builtin.os == .linux) {
36 @export(std.os.linux.getThreadPointer, .{ .name = "__aeabi_read_tp", .linkage = .Strong });
37 }35 }
38}36}
3937
lib/std/special/compiler_rt.zig+2
...@@ -177,6 +177,8 @@ comptime {...@@ -177,6 +177,8 @@ comptime {
177 @export(@import("compiler_rt/arm.zig").__aeabi_memclr, .{ .name = "__aeabi_memclr4", .linkage = linkage });177 @export(@import("compiler_rt/arm.zig").__aeabi_memclr, .{ .name = "__aeabi_memclr4", .linkage = linkage });
178 @export(@import("compiler_rt/arm.zig").__aeabi_memclr, .{ .name = "__aeabi_memclr8", .linkage = linkage });178 @export(@import("compiler_rt/arm.zig").__aeabi_memclr, .{ .name = "__aeabi_memclr8", .linkage = linkage });
179179
180 @export(@import("compiler_rt/arm.zig").__aeabi_read_tp, .{ .name = "__aeabi_read_tp", .linkage = linkage });
181
180 @export(@import("compiler_rt/extendXfYf2.zig").__aeabi_f2d, .{ .name = "__aeabi_f2d", .linkage = linkage });182 @export(@import("compiler_rt/extendXfYf2.zig").__aeabi_f2d, .{ .name = "__aeabi_f2d", .linkage = linkage });
181 @export(@import("compiler_rt/floatsiXf.zig").__aeabi_i2d, .{ .name = "__aeabi_i2d", .linkage = linkage });183 @export(@import("compiler_rt/floatsiXf.zig").__aeabi_i2d, .{ .name = "__aeabi_i2d", .linkage = linkage });
182 @export(@import("compiler_rt/floatdidf.zig").__aeabi_l2d, .{ .name = "__aeabi_l2d", .linkage = linkage });184 @export(@import("compiler_rt/floatdidf.zig").__aeabi_l2d, .{ .name = "__aeabi_l2d", .linkage = linkage });
lib/std/special/compiler_rt/arm.zig+10
...@@ -32,6 +32,7 @@ pub fn __aeabi_memclr(dest: [*]u8, n: usize) callconv(.AAPCS) void {...@@ -32,6 +32,7 @@ pub fn __aeabi_memclr(dest: [*]u8, n: usize) callconv(.AAPCS) void {
32 @setRuntimeSafety(false);32 @setRuntimeSafety(false);
33 _ = memset(dest, 0, n);33 _ = memset(dest, 0, n);
34}34}
35
35pub fn __aeabi_unwind_cpp_pr0() callconv(.C) void {36pub fn __aeabi_unwind_cpp_pr0() callconv(.C) void {
36 unreachable;37 unreachable;
37}38}
...@@ -42,6 +43,15 @@ pub fn __aeabi_unwind_cpp_pr2() callconv(.C) void {...@@ -42,6 +43,15 @@ pub fn __aeabi_unwind_cpp_pr2() callconv(.C) void {
42 unreachable;43 unreachable;
43}44}
4445
46// This function can only clobber r0 according to the ABI
47pub fn __aeabi_read_tp() callconv(.Naked) void {
48 asm volatile (
49 \\ mrc p15, 0, r0, c13, c0, 3
50 \\ bx lr
51 );
52 unreachable;
53}
54
45// The following functions are wrapped in an asm block to ensure the required55// The following functions are wrapped in an asm block to ensure the required
46// calling convention is always respected56// calling convention is always respected
4757