mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 14:23:09 +00:00
Move definition of __aeabi_read_tp
This commit is contained in:
parent
5d5345728a
commit
c5cfc9bf68
@ -88,15 +88,6 @@ pub fn syscall6(
|
||||
/// This matches the libc clone function.
|
||||
pub extern fn clone(func: extern fn (arg: usize) u8, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize;
|
||||
|
||||
// LLVM calls this when the read-tp-hard feature is set to false. Currently, there is no way to pass
|
||||
// that to llvm via zig, see https://github.com/ziglang/zig/issues/2883.
|
||||
// LLVM expects libc to provide this function as __aeabi_read_tp, so it is exported if needed from special/c.zig.
|
||||
pub fn getThreadPointer() callconv(.C) usize {
|
||||
return asm volatile ("mrc p15, 0, %[ret], c13, c0, 3"
|
||||
: [ret] "=r" (-> usize)
|
||||
);
|
||||
}
|
||||
|
||||
pub fn restore() callconv(.Naked) void {
|
||||
return asm volatile ("svc #0"
|
||||
:
|
||||
|
||||
@ -32,8 +32,6 @@ comptime {
|
||||
@export(strlen, .{ .name = "strlen", .linkage = .Strong });
|
||||
} else if (is_msvc) {
|
||||
@export(_fltused, .{ .name = "_fltused", .linkage = .Strong });
|
||||
} else if (builtin.arch == builtin.Arch.arm and builtin.os == .linux) {
|
||||
@export(std.os.linux.getThreadPointer, .{ .name = "__aeabi_read_tp", .linkage = .Strong });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -177,6 +177,8 @@ comptime {
|
||||
@export(@import("compiler_rt/arm.zig").__aeabi_memclr, .{ .name = "__aeabi_memclr4", .linkage = linkage });
|
||||
@export(@import("compiler_rt/arm.zig").__aeabi_memclr, .{ .name = "__aeabi_memclr8", .linkage = linkage });
|
||||
|
||||
@export(@import("compiler_rt/arm.zig").__aeabi_read_tp, .{ .name = "__aeabi_read_tp", .linkage = linkage });
|
||||
|
||||
@export(@import("compiler_rt/extendXfYf2.zig").__aeabi_f2d, .{ .name = "__aeabi_f2d", .linkage = linkage });
|
||||
@export(@import("compiler_rt/floatsiXf.zig").__aeabi_i2d, .{ .name = "__aeabi_i2d", .linkage = linkage });
|
||||
@export(@import("compiler_rt/floatdidf.zig").__aeabi_l2d, .{ .name = "__aeabi_l2d", .linkage = linkage });
|
||||
|
||||
@ -32,6 +32,7 @@ pub fn __aeabi_memclr(dest: [*]u8, n: usize) callconv(.AAPCS) void {
|
||||
@setRuntimeSafety(false);
|
||||
_ = memset(dest, 0, n);
|
||||
}
|
||||
|
||||
pub fn __aeabi_unwind_cpp_pr0() callconv(.C) void {
|
||||
unreachable;
|
||||
}
|
||||
@ -42,6 +43,15 @@ pub fn __aeabi_unwind_cpp_pr2() callconv(.C) void {
|
||||
unreachable;
|
||||
}
|
||||
|
||||
// This function can only clobber r0 according to the ABI
|
||||
pub fn __aeabi_read_tp() callconv(.Naked) void {
|
||||
asm volatile (
|
||||
\\ mrc p15, 0, r0, c13, c0, 3
|
||||
\\ bx lr
|
||||
);
|
||||
unreachable;
|
||||
}
|
||||
|
||||
// The following functions are wrapped in an asm block to ensure the required
|
||||
// calling convention is always respected
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user