Skip to content

Commit eae2705

Browse files
authored
Merge pull request #45 from JuliaPerf/ct/fixup-32-bit
Fix-up i686/armv7 support
2 parents 360c63c + c102c6e commit eae2705

File tree

3 files changed

+40
-7
lines changed

3 files changed

+40
-7
lines changed

.buildkite/pipeline.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,29 @@
11
steps:
2-
- label: "Julia v1.6"
2+
- label: "Julia v1.6 (x86-64)"
33
plugins:
44
- JuliaCI/julia#v1:
55
version: "1.6"
6+
arch: "x86_64"
7+
- JuliaCI/julia-test#v1:
8+
agents:
9+
queue: "juliaecosystem"
10+
sandbox.jl: "true"
11+
os: "linux"
12+
arch: "x86_64"
13+
timeout_in_minutes: 60
14+
- label: "Julia v1.6 (i686)"
15+
plugins:
16+
- JuliaCI/julia:
17+
version: "1.6"
18+
- staticfloat/sandbox#v1:
19+
rootfs_url: "https://github.com/JuliaCI/rootfs-images/releases/download/v5.44/agent_linux.i686.tar.gz"
20+
rootfs_treehash: "c0e2d7ef8f233d978c15e61734f0dfa25aba7536"
21+
workspaces:
22+
- "/cache:/cache"
23+
# Once inside the sandbox, install a different version of Julia to run our tests
24+
- JuliaCI/julia:
25+
version: "1.6"
26+
arch: "i686"
627
- JuliaCI/julia-test#v1:
728
agents:
829
queue: "juliaecosystem"

src/LinuxPerf.jl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ elseif Sys.ARCH === :aarch64
165165
Clong(241)
166166
elseif Sys.ARCH === :arm
167167
Clong(364)
168+
elseif Sys.ARCH === :powerpc64le || Sys.ARCH === :ppc64le
169+
Clong(319)
168170
else
169171
Clong(-1) # sentinel for unknown syscall ID
170172
end
@@ -179,7 +181,7 @@ function perf_event_open(attr::perf_event_attr, pid, cpu, leader_fd, flags)
179181
# Have to do a manual conversion, since the ABI is a vararg call
180182
ptr = Base.unsafe_convert(Ptr{Cvoid}, Base.cconvert(Ptr{Cvoid}, r_attr))
181183
fd = ccall(:syscall, Cint, (Clong, Clong...), SYS_perf_event_open,
182-
ptr, pid, cpu, leader_fd, flags)
184+
reinterpret(Clong, ptr), pid, cpu, leader_fd, flags)
183185
end
184186
return fd
185187
end
@@ -346,6 +348,8 @@ elseif Sys.ARCH === :aarch64
346348
Clong(167)
347349
elseif Sys.ARCH === :arm
348350
Clong(172)
351+
elseif Sys.ARCH === :powerpc64le || Sys.ARCH === :ppc64le
352+
Clong(171)
349353
else
350354
Clong(-1) # sentinel for unknown syscall ID
351355
end
@@ -360,10 +364,18 @@ const PR_TASK_PERF_EVENTS_ENABLE = Cint(32)
360364
res = Base.llvmcall("""%val = call i64 asm sideeffect "syscall", "={rax},{rax},{rdi},~{rcx},~{r11},~{memory}"(i64 %0, i64 %1)
361365
ret i64 %val""", Int64, Tuple{Int64, Int64}, SYS_prctl, Int64(op))
362366
return (res >= 0) ? nothing : throw(Base.SystemError("prctl", -res, nothing))
367+
elseif Sys.ARCH == :i686
368+
res = Base.llvmcall("""%val = call i32 asm sideeffect "int \$\$0x80", "={eax},{eax},{ebx},~{memory}"(i32 %0, i32 %1)
369+
ret i32 %val""", Int32, Tuple{Int32, Int32}, SYS_prctl, Int32(op))
370+
return (res >= 0) ? nothing : throw(Base.SystemError("prctl", -res, nothing))
363371
elseif Sys.ARCH == :aarch64
364372
res = Base.llvmcall("""%val = call i64 asm sideeffect "svc #0", "={x0},{x8},{x0},~{memory}"(i64 %0, i64 %1)
365373
ret i64 %val""", Int64, Tuple{Int64, Int64}, SYS_prctl, Int64(op))
366374
return (res >= 0) ? nothing : throw(Base.SystemError("prctl", -res, nothing))
375+
elseif Sys.ARCH == :arm
376+
res = Base.llvmcall("""%val = call i32 asm sideeffect "swi 0", "={r0},{r7},{r0},~{memory}"(i32 %0, i32 %1)
377+
ret i32 %val""", Int32, Tuple{Int32, Int32}, SYS_prctl, Int32(op))
378+
return (res >= 0) ? nothing : throw(Base.SystemError("prctl", -res, nothing))
367379
else
368380
# syscall is lower overhead than calling libc's prctl
369381
res = ccall(:syscall, Cint, (Clong, Clong...), SYS_prctl, op)

test/runtests.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,11 @@ end
120120
end
121121

122122
@testset "_addcommas" begin
123-
@test LinuxPerf._addcommas(1) == "1"
124-
@test LinuxPerf._addcommas(12) == "12"
125-
@test LinuxPerf._addcommas(123) == "123"
126-
@test LinuxPerf._addcommas(1234) == "1,234"
127-
@test LinuxPerf._addcommas(12345) == "12,345"
123+
@test LinuxPerf._addcommas(Int64(1)) == "1"
124+
@test LinuxPerf._addcommas(Int64(12)) == "12"
125+
@test LinuxPerf._addcommas(Int64(123)) == "123"
126+
@test LinuxPerf._addcommas(Int64(1234)) == "1,234"
127+
@test LinuxPerf._addcommas(Int64(12345)) == "12,345"
128128
@test LinuxPerf._addcommas(typemin(Int64)) == "-9,223,372,036,854,775,808"
129129
end
130130

0 commit comments

Comments
 (0)