Skip to content

Commit 995f38f

Browse files
giordanoZentrik
authored andcommitted
Add asm call for prctl syscall on riscv64
1 parent 34b905b commit 995f38f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/LinuxPerf.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,10 @@ const PR_TASK_PERF_EVENTS_ENABLE = Cint(32)
374374
res = Base.llvmcall("""%val = call i32 asm sideeffect "swi 0", "={r0},{r7},{r0},~{memory}"(i32 %0, i32 %1)
375375
ret i32 %val""", Int32, Tuple{Int32, Int32}, SYS_prctl, Int32(op))
376376
return (res >= 0) ? nothing : throw(Base.SystemError("prctl", -res, nothing))
377+
elseif Sys.ARCH === :riscv64 || Sys.ARCH === :rv64
378+
res = Base.llvmcall("""%val = call i64 asm sideeffect "ecall", "={a0},{a7},{a0},~{memory}"(i64 %0, i64 %1)
379+
ret i64 %val""", Int64, Tuple{Int64, Int64}, SYS_prctl, Int64(op))
380+
return (res >= 0) ? nothing : throw(Base.SystemError("prctl", -res, nothing))
377381
else
378382
# syscall is lower overhead than calling libc's prctl
379383
res = ccall(:syscall, Cint, (Clong, Clong...), SYS_prctl, op)

0 commit comments

Comments
 (0)