Skip to content

Commit

Permalink
Merge pull request #26 from AgustinCB/master
Browse files Browse the repository at this point in the history
Replace asm with llvm_asm
  • Loading branch information
japaric authored Jul 28, 2020
2 parents 0d9cbef + 4454677 commit 6fa3d74
Show file tree
Hide file tree
Showing 13 changed files with 91 additions and 89 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ license = "MIT/Apache-2.0"
name = "sc"
readme = "README.md"
repository = "https://github.com/japaric/syscall.rs"
version = "0.2.2"
version = "0.2.3"
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// Reference http://man7.org/linux/man-pages/man2/syscall.2.html

#![deny(warnings)]
#![feature(asm)]
#![feature(llvm_asm)]
#![no_std]

#[cfg(test)]
Expand Down
14 changes: 7 additions & 7 deletions src/platform/freebsd-x86_64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub mod nr;
#[inline(always)]
pub unsafe fn syscall0(n: usize) -> usize {
let ret: usize;
asm!("syscall" : "={rax}"(ret)
llvm_asm!("syscall" : "={rax}"(ret)
: "{rax}"(n)
: "rcx", "r11", "memory"
: "volatile");
Expand All @@ -24,7 +24,7 @@ pub unsafe fn syscall0(n: usize) -> usize {
#[inline(always)]
pub unsafe fn syscall1(n: usize, a1: usize) -> usize {
let ret: usize;
asm!("syscall" : "={rax}"(ret)
llvm_asm!("syscall" : "={rax}"(ret)
: "{rax}"(n), "{rdi}"(a1)
: "rcx", "r11", "memory"
: "volatile");
Expand All @@ -34,7 +34,7 @@ pub unsafe fn syscall1(n: usize, a1: usize) -> usize {
#[inline(always)]
pub unsafe fn syscall2(n: usize, a1: usize, a2: usize) -> usize {
let ret: usize;
asm!("syscall" : "={rax}"(ret)
llvm_asm!("syscall" : "={rax}"(ret)
: "{rax}"(n), "{rdi}"(a1), "{rsi}"(a2)
: "rcx", "r11", "memory"
: "volatile");
Expand All @@ -44,7 +44,7 @@ pub unsafe fn syscall2(n: usize, a1: usize, a2: usize) -> usize {
#[inline(always)]
pub unsafe fn syscall3(n: usize, a1: usize, a2: usize, a3: usize) -> usize {
let ret: usize;
asm!("syscall" : "={rax}"(ret)
llvm_asm!("syscall" : "={rax}"(ret)
: "{rax}"(n), "{rdi}"(a1), "{rsi}"(a2), "{rdx}"(a3)
: "rcx", "r11", "memory"
: "volatile");
Expand All @@ -59,7 +59,7 @@ pub unsafe fn syscall4(n: usize,
a4: usize)
-> usize {
let ret: usize;
asm!("syscall" : "={rax}"(ret)
llvm_asm!("syscall" : "={rax}"(ret)
: "{rax}"(n), "{rdi}"(a1), "{rsi}"(a2), "{rdx}"(a3),
"{r10}"(a4)
: "rcx", "r11", "memory"
Expand All @@ -76,7 +76,7 @@ pub unsafe fn syscall5(n: usize,
a5: usize)
-> usize {
let ret: usize;
asm!("syscall" : "={rax}"(ret)
llvm_asm!("syscall" : "={rax}"(ret)
: "{rax}"(n), "{rdi}"(a1), "{rsi}"(a2), "{rdx}"(a3),
"{r10}"(a4), "{r8}"(a5)
: "rcx", "r11", "memory"
Expand All @@ -94,7 +94,7 @@ pub unsafe fn syscall6(n: usize,
a6: usize)
-> usize {
let ret: usize;
asm!("syscall" : "={rax}"(ret)
llvm_asm!("syscall" : "={rax}"(ret)
: "{rax}"(n), "{rdi}"(a1), "{rsi}"(a2), "{rdx}"(a3),
"{r10}"(a4), "{r8}"(a5), "{r9}"(a6)
: "rcx", "r11", "memory"
Expand Down
14 changes: 7 additions & 7 deletions src/platform/linux-aarch64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub mod nr;
#[inline(always)]
pub unsafe fn syscall0(n: usize) -> usize {
let ret: usize;
asm!("svc 0"
llvm_asm!("svc 0"
: "={x0}"(ret)
: "{x8}"(n)
: "memory" "cc"
Expand All @@ -25,7 +25,7 @@ pub unsafe fn syscall0(n: usize) -> usize {
#[inline(always)]
pub unsafe fn syscall1(n: usize, a1: usize) -> usize {
let ret: usize;
asm!("svc 0"
llvm_asm!("svc 0"
: "={x0}"(ret)
: "{x8}"(n) "{x0}"(a1)
: "memory" "cc"
Expand All @@ -36,7 +36,7 @@ pub unsafe fn syscall1(n: usize, a1: usize) -> usize {
#[inline(always)]
pub unsafe fn syscall2(n: usize, a1: usize, a2: usize) -> usize {
let ret: usize;
asm!("svc 0"
llvm_asm!("svc 0"
: "={x0}"(ret)
: "{x8}"(n) "{x0}"(a1) "{x1}"(a2)
: "memory" "cc"
Expand All @@ -47,7 +47,7 @@ pub unsafe fn syscall2(n: usize, a1: usize, a2: usize) -> usize {
#[inline(always)]
pub unsafe fn syscall3(n: usize, a1: usize, a2: usize, a3: usize) -> usize {
let ret: usize;
asm!("svc 0"
llvm_asm!("svc 0"
: "={x0}"(ret)
: "{x8}"(n) "{x0}"(a1) "{x1}"(a2) "{x2}"(a3)
: "memory" "cc"
Expand All @@ -63,7 +63,7 @@ pub unsafe fn syscall4(n: usize,
a4: usize)
-> usize {
let ret: usize;
asm!("svc 0"
llvm_asm!("svc 0"
: "={x0}"(ret)
: "{x8}"(n) "{x0}"(a1) "{x1}"(a2) "{x2}"(a3) "{x3}"(a4)
: "memory" "cc"
Expand All @@ -80,7 +80,7 @@ pub unsafe fn syscall5(n: usize,
a5: usize)
-> usize {
let ret: usize;
asm!("svc 0" : "={x0}"(ret)
llvm_asm!("svc 0" : "={x0}"(ret)
: "{x8}"(n) "{x0}"(a1) "{x1}"(a2) "{x2}"(a3) "{x3}"(a4) "{x4}"(a5)
: "memory" "cc"
: "volatile");
Expand All @@ -97,7 +97,7 @@ pub unsafe fn syscall6(n: usize,
a6: usize)
-> usize {
let ret: usize;
asm!("svc 0"
llvm_asm!("svc 0"
: "={x0}"(ret)
: "{x8}"(n) "{x0}"(a1) "{x1}"(a2) "{x2}"(a3) "{x3}"(a4) "{x4}"(a5)
"{x5}"(a6)
Expand Down
16 changes: 8 additions & 8 deletions src/platform/linux-armeabi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub mod nr;
#[inline(always)]
pub unsafe fn syscall0(n: usize) -> usize {
let ret: usize;
asm!("swi $$0"
llvm_asm!("swi $$0"
: "={r0}"(ret)
: "{r7}"(n)
: "memory" "cc"
Expand All @@ -25,7 +25,7 @@ pub unsafe fn syscall0(n: usize) -> usize {
#[inline(always)]
pub unsafe fn syscall1(n: usize, a1: usize) -> usize {
let ret: usize;
asm!("swi $$0"
llvm_asm!("swi $$0"
: "={r0}"(ret)
: "{r7}"(n) "{r0}"(a1)
: "memory" "cc"
Expand All @@ -36,7 +36,7 @@ pub unsafe fn syscall1(n: usize, a1: usize) -> usize {
#[inline(always)]
pub unsafe fn syscall2(n: usize, a1: usize, a2: usize) -> usize {
let ret: usize;
asm!("swi $$0"
llvm_asm!("swi $$0"
: "={r0}"(ret)
: "{r7}"(n) "{r0}"(a1) "{r1}"(a2)
: "memory" "cc"
Expand All @@ -47,7 +47,7 @@ pub unsafe fn syscall2(n: usize, a1: usize, a2: usize) -> usize {
#[inline(always)]
pub unsafe fn syscall3(n: usize, a1: usize, a2: usize, a3: usize) -> usize {
let ret: usize;
asm!("swi $$0"
llvm_asm!("swi $$0"
: "={r0}"(ret)
: "{r7}"(n) "{r0}"(a1) "{r1}"(a2) "{r2}"(a3)
: "memory" "cc"
Expand All @@ -63,7 +63,7 @@ pub unsafe fn syscall4(n: usize,
a4: usize)
-> usize {
let ret: usize;
asm!("swi $$0"
llvm_asm!("swi $$0"
: "={r0}"(ret)
: "{r7}"(n) "{r0}"(a1) "{r1}"(a2) "{r2}"(a3) "{r3}"(a4)
: "memory" "cc"
Expand All @@ -80,7 +80,7 @@ pub unsafe fn syscall5(n: usize,
a5: usize)
-> usize {
let ret: usize;
asm!("swi $$0" : "={r0}"(ret)
llvm_asm!("swi $$0" : "={r0}"(ret)
: "{r7}"(n) "{r0}"(a1) "{r1}"(a2) "{r2}"(a3) "{r3}"(a4) "{r4}"(a5)
: "memory" "cc"
: "volatile");
Expand All @@ -97,7 +97,7 @@ pub unsafe fn syscall6(n: usize,
a6: usize)
-> usize {
let ret: usize;
asm!("swi $$0"
llvm_asm!("swi $$0"
: "={r0}"(ret)
: "{r7}"(n) "{r0}"(a1) "{r1}"(a2) "{r2}"(a3) "{r3}"(a4) "{r4}"(a5)
"{r5}"(a6)
Expand All @@ -117,7 +117,7 @@ pub unsafe fn syscall7(n: usize,
a7: usize)
-> usize {
let ret: usize;
asm!("swi $$0"
llvm_asm!("swi $$0"
: "={r0}"(ret)
: "{r7}"(n) "{r0}"(a1) "{r1}"(a2) "{r2}"(a3) "{r3}"(a4) "{r4}"(a5)
"{r5}"(a6) "{r6}"(a7)
Expand Down
14 changes: 7 additions & 7 deletions src/platform/linux-mips/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub mod nr;
#[inline(always)]
pub unsafe fn syscall0(mut nr: usize) -> usize {
let success: usize;
asm!("syscall"
llvm_asm!("syscall"
: "+{$2}"(nr) "={$7}"(success)
:
: "$8" "$9" "$10" "$11" "$12" "$13" "$14" "$15" "$24" "$25" "memory"
Expand All @@ -35,7 +35,7 @@ pub unsafe fn syscall0(mut nr: usize) -> usize {
#[inline(always)]
pub unsafe fn syscall1(mut nr: usize, a1: usize) -> usize {
let success: usize;
asm!("syscall"
llvm_asm!("syscall"
: "+{$2}"(nr) "={$7}"(success)
: "{$4}"(a1)
: "$8" "$9" "$10" "$11" "$12" "$13" "$14" "$15" "$24" "$25" "memory"
Expand All @@ -50,7 +50,7 @@ pub unsafe fn syscall1(mut nr: usize, a1: usize) -> usize {
#[inline(always)]
pub unsafe fn syscall2(mut nr: usize, a1: usize, a2: usize) -> usize {
let success: usize;
asm!("syscall"
llvm_asm!("syscall"
: "+{$2}"(nr) "={$7}"(success)
: "{$4}"(a1) "{$5}"(a2)
: "$8" "$9" "$10" "$11" "$12" "$13" "$14" "$15" "$24" "$25" "memory"
Expand All @@ -69,7 +69,7 @@ pub unsafe fn syscall3(mut nr: usize,
a3: usize)
-> usize {
let success: usize;
asm!("syscall"
llvm_asm!("syscall"
: "+{$2}"(nr) "={$7}"(success)
: "{$4}"(a1) "{$5}"(a2) "{$6}"(a3)
: "$8" "$9" "$10" "$11" "$12" "$13" "$14" "$15" "$24" "$25" "memory"
Expand All @@ -88,7 +88,7 @@ pub unsafe fn syscall4(mut nr: usize,
a3: usize,
mut a4: usize)
-> usize {
asm!("syscall"
llvm_asm!("syscall"
: "+{$2}"(nr) "+{$7}"(a4)
: "{$4}"(a1) "{$5}"(a2) "{$6}"(a3)
: "$8" "$9" "$10" "$11" "$12" "$13" "$14" "$15" "$24" "$25" "memory"
Expand All @@ -104,7 +104,7 @@ pub unsafe fn syscall5(mut nr: usize,
mut a4: usize,
a5: usize)
-> usize {
asm!(".set noat
llvm_asm!(".set noat
subu $$29,20
sw $5, 16($$29)
syscall
Expand All @@ -126,7 +126,7 @@ pub unsafe fn syscall6(mut nr: usize,
a5: usize,
a6: usize)
-> usize {
asm!(".set noat
llvm_asm!(".set noat
subu $$29,24
sw $5, 16($$29)
sw $6, 20($$29)
Expand Down
14 changes: 7 additions & 7 deletions src/platform/linux-mips64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub mod nr;
#[inline(always)]
pub unsafe fn syscall0(mut nr: usize) -> usize {
let success: usize;
asm!("syscall"
llvm_asm!("syscall"
: "+{$2}"(nr) "={$7}"(success)
:
: "$8" "$9" "$10" "$11" "$12" "$13" "$14" "$15" "$24" "$25" "memory"
Expand All @@ -31,7 +31,7 @@ pub unsafe fn syscall0(mut nr: usize) -> usize {
#[inline(always)]
pub unsafe fn syscall1(mut nr: usize, a1: usize) -> usize {
let success: usize;
asm!("syscall"
llvm_asm!("syscall"
: "+{$2}"(nr) "={$7}"(success)
: "{$4}"(a1)
: "$8" "$9" "$10" "$11" "$12" "$13" "$14" "$15" "$24" "$25" "memory"
Expand All @@ -46,7 +46,7 @@ pub unsafe fn syscall1(mut nr: usize, a1: usize) -> usize {
#[inline(always)]
pub unsafe fn syscall2(mut nr: usize, a1: usize, a2: usize) -> usize {
let success: usize;
asm!("syscall"
llvm_asm!("syscall"
: "+{$2}"(nr) "={$7}"(success)
: "{$4}"(a1) "{$5}"(a2)
: "$8" "$9" "$10" "$11" "$12" "$13" "$14" "$15" "$24" "$25" "memory"
Expand All @@ -65,7 +65,7 @@ pub unsafe fn syscall3(mut nr: usize,
a3: usize)
-> usize {
let success: usize;
asm!("syscall"
llvm_asm!("syscall"
: "+{$2}"(nr) "={$7}"(success)
: "{$4}"(a1) "{$5}"(a2) "{$6}"(a3)
: "$8" "$9" "$10" "$11" "$12" "$13" "$14" "$15" "$24" "$25" "memory"
Expand All @@ -84,7 +84,7 @@ pub unsafe fn syscall4(mut nr: usize,
a3: usize,
mut a4: usize)
-> usize {
asm!("syscall"
llvm_asm!("syscall"
: "+{$2}"(nr) "+{$7}"(a4)
: "{$4}"(a1) "{$5}"(a2) "{$6}"(a3)
: "$8" "$9" "$10" "$11" "$12" "$13" "$14" "$15" "$24" "$25" "memory"
Expand All @@ -100,7 +100,7 @@ pub unsafe fn syscall5(mut nr: usize,
mut a4: usize,
a5: usize)
-> usize {
asm!("syscall"
llvm_asm!("syscall"
: "+{$2}"(nr) "+{$7}"(a4)
: "{$4}"(a1) "{$5}"(a2) "{$6}"(a3) "{$8}"(a5)
: "$9" "$10" "$11" "$12" "$13" "$14" "$15" "$24" "$25" "memory"
Expand All @@ -117,7 +117,7 @@ pub unsafe fn syscall6(mut nr: usize,
a5: usize,
a6: usize)
-> usize {
asm!("syscall"
llvm_asm!("syscall"
: "+{$2}"(nr) "+{$7}"(a4)
: "{$4}"(a1) "{$5}"(a2) "{$6}"(a3) "{$8}"(a5) "{$9}"(a6)
: "$10" "$11" "$12" "$13" "$14" "$15" "$24" "$25" "memory"
Expand Down
Loading

0 comments on commit 6fa3d74

Please sign in to comment.