Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switching Sysno to usize #50

Merged
merged 1 commit into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
),
feature(asm_experimental_arch)
)]
#![cfg_attr(doc_cfg, feature(doc_cfg))]

Check warning on line 27 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Check

unexpected `cfg` condition name: `doc_cfg`

Check warning on line 27 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (riscv64gc-unknown-linux-gnu)

unexpected `cfg` condition name: `doc_cfg`

Check warning on line 27 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (riscv64gc-unknown-linux-gnu)

unexpected `cfg` condition name: `doc_cfg`

Check warning on line 27 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (i686-unknown-linux-gnu)

unexpected `cfg` condition name: `doc_cfg`

Check warning on line 27 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (i686-unknown-linux-gnu)

unexpected `cfg` condition name: `doc_cfg`

Check warning on line 27 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (armv7-unknown-linux-gnueabi)

unexpected `cfg` condition name: `doc_cfg`

Check warning on line 27 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (armv7-unknown-linux-gnueabi)

unexpected `cfg` condition name: `doc_cfg`

Check warning on line 27 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (aarch64-unknown-linux-gnu)

unexpected `cfg` condition name: `doc_cfg`

Check warning on line 27 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (aarch64-unknown-linux-gnu)

unexpected `cfg` condition name: `doc_cfg`

Check warning on line 27 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (arm-unknown-linux-gnueabi)

unexpected `cfg` condition name: `doc_cfg`

Check warning on line 27 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (arm-unknown-linux-gnueabi)

unexpected `cfg` condition name: `doc_cfg`

Check warning on line 27 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (Nightly) (powerpc-unknown-linux-gnu)

unexpected `cfg` condition name: `doc_cfg`

Check warning on line 27 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (Nightly) (powerpc-unknown-linux-gnu)

unexpected `cfg` condition name: `doc_cfg`

Check warning on line 27 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (thumbv7neon-unknown-linux-gnueabihf)

unexpected `cfg` condition name: `doc_cfg`

Check warning on line 27 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (thumbv7neon-unknown-linux-gnueabihf)

unexpected `cfg` condition name: `doc_cfg`

Check warning on line 27 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (armv5te-unknown-linux-gnueabi)

unexpected `cfg` condition name: `doc_cfg`

Check warning on line 27 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (armv5te-unknown-linux-gnueabi)

unexpected `cfg` condition name: `doc_cfg`

Check warning on line 27 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (armv7-linux-androideabi)

unexpected `cfg` condition name: `doc_cfg`

Check warning on line 27 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (armv7-linux-androideabi)

unexpected `cfg` condition name: `doc_cfg`

Check warning on line 27 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (Nightly) (arm-unknown-linux-gnueabi)

unexpected `cfg` condition name: `doc_cfg`

Check warning on line 27 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (Nightly) (arm-unknown-linux-gnueabi)

unexpected `cfg` condition name: `doc_cfg`

Check warning on line 27 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (Nightly) (armv5te-unknown-linux-gnueabi)

unexpected `cfg` condition name: `doc_cfg`

Check warning on line 27 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (Nightly) (armv5te-unknown-linux-gnueabi)

unexpected `cfg` condition name: `doc_cfg`

Check warning on line 27 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (thumbv7neon-linux-androideabi)

unexpected `cfg` condition name: `doc_cfg`

Check warning on line 27 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (thumbv7neon-linux-androideabi)

unexpected `cfg` condition name: `doc_cfg`

Check warning on line 27 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (arm-linux-androideabi)

unexpected `cfg` condition name: `doc_cfg`

Check warning on line 27 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (arm-linux-androideabi)

unexpected `cfg` condition name: `doc_cfg`

Check warning on line 27 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (Nightly) (armv7-unknown-linux-gnueabi)

unexpected `cfg` condition name: `doc_cfg`

Check warning on line 27 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (Nightly) (armv7-unknown-linux-gnueabi)

unexpected `cfg` condition name: `doc_cfg`

Check warning on line 27 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (x86_64-unknown-linux-gnu)

unexpected `cfg` condition name: `doc_cfg`

Check warning on line 27 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (x86_64-unknown-linux-gnu)

unexpected `cfg` condition name: `doc_cfg`

Check warning on line 27 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (Nightly) (riscv64gc-unknown-linux-gnu)

unexpected `cfg` condition name: `doc_cfg`

Check warning on line 27 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (Nightly) (riscv64gc-unknown-linux-gnu)

unexpected `cfg` condition name: `doc_cfg`

Check warning on line 27 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (Nightly) (arm-linux-androideabi)

unexpected `cfg` condition name: `doc_cfg`

Check warning on line 27 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (Nightly) (arm-linux-androideabi)

unexpected `cfg` condition name: `doc_cfg`

Check warning on line 27 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (Nightly) (thumbv7neon-unknown-linux-gnueabihf)

unexpected `cfg` condition name: `doc_cfg`

Check warning on line 27 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (Nightly) (thumbv7neon-unknown-linux-gnueabihf)

unexpected `cfg` condition name: `doc_cfg`

Check warning on line 27 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (Nightly) (thumbv7neon-linux-androideabi)

unexpected `cfg` condition name: `doc_cfg`

Check warning on line 27 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (Nightly) (thumbv7neon-linux-androideabi)

unexpected `cfg` condition name: `doc_cfg`

Check warning on line 27 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (Nightly) (x86_64-unknown-linux-gnu)

unexpected `cfg` condition name: `doc_cfg`

Check warning on line 27 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (Nightly) (x86_64-unknown-linux-gnu)

unexpected `cfg` condition name: `doc_cfg`

Check warning on line 27 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (Nightly) (armv7-linux-androideabi)

unexpected `cfg` condition name: `doc_cfg`

Check warning on line 27 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (Nightly) (armv7-linux-androideabi)

unexpected `cfg` condition name: `doc_cfg`

Check warning on line 27 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (Nightly) (s390x-unknown-linux-gnu)

unexpected `cfg` condition name: `doc_cfg`

Check warning on line 27 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (Nightly) (s390x-unknown-linux-gnu)

unexpected `cfg` condition name: `doc_cfg`

#[macro_use]
mod macros;
Expand Down Expand Up @@ -62,7 +62,7 @@
/// responsibility to ensure safety.
#[inline]
pub unsafe fn syscall0(nr: Sysno) -> Result<usize, Errno> {
Errno::from_ret(raw::syscall0(nr))
Errno::from_ret(raw::syscall0(nr as usize))
}

/// Issues a system call with 1 argument.
Expand All @@ -73,7 +73,7 @@
/// responsibility to ensure safety.
#[inline]
pub unsafe fn syscall1(nr: Sysno, a1: usize) -> Result<usize, Errno> {
Errno::from_ret(raw::syscall1(nr, a1))
Errno::from_ret(raw::syscall1(nr as usize, a1))
}

/// Issues a system call with 2 arguments.
Expand All @@ -88,7 +88,7 @@
a1: usize,
a2: usize,
) -> Result<usize, Errno> {
Errno::from_ret(raw::syscall2(nr, a1, a2))
Errno::from_ret(raw::syscall2(nr as usize, a1, a2))
}

/// Issues a system call with 3 arguments.
Expand All @@ -104,7 +104,7 @@
a2: usize,
a3: usize,
) -> Result<usize, Errno> {
Errno::from_ret(raw::syscall3(nr, a1, a2, a3))
Errno::from_ret(raw::syscall3(nr as usize, a1, a2, a3))
}

/// Issues a system call with 4 arguments.
Expand All @@ -121,7 +121,7 @@
a3: usize,
a4: usize,
) -> Result<usize, Errno> {
Errno::from_ret(raw::syscall4(nr, a1, a2, a3, a4))
Errno::from_ret(raw::syscall4(nr as usize, a1, a2, a3, a4))
}

/// Issues a system call with 5 arguments.
Expand All @@ -139,7 +139,7 @@
a4: usize,
a5: usize,
) -> Result<usize, Errno> {
Errno::from_ret(raw::syscall5(nr, a1, a2, a3, a4, a5))
Errno::from_ret(raw::syscall5(nr as usize, a1, a2, a3, a4, a5))
}

/// Issues a system call with 6 arguments.
Expand All @@ -158,7 +158,7 @@
a5: usize,
a6: usize,
) -> Result<usize, Errno> {
Errno::from_ret(raw::syscall6(nr, a1, a2, a3, a4, a5, a6))
Errno::from_ret(raw::syscall6(nr as usize, a1, a2, a3, a4, a5, a6))
}

/// Does a raw syscall.
Expand Down
19 changes: 12 additions & 7 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,24 +91,29 @@ macro_rules! syscall {
#[macro_export]
macro_rules! raw_syscall {
($nr:expr) => {
$crate::raw::syscall0($nr)
$crate::raw::syscall0($nr as usize)
};

($nr:expr, $a1:expr) => {
$crate::raw::syscall1($nr, $a1 as usize)
$crate::raw::syscall1($nr as usize, $a1 as usize)
};

($nr:expr, $a1:expr, $a2:expr) => {
$crate::raw::syscall2($nr, $a1 as usize, $a2 as usize)
$crate::raw::syscall2($nr as usize, $a1 as usize, $a2 as usize)
};

($nr:expr, $a1:expr, $a2:expr, $a3:expr) => {
$crate::raw::syscall3($nr, $a1 as usize, $a2 as usize, $a3 as usize)
$crate::raw::syscall3(
$nr as usize,
$a1 as usize,
$a2 as usize,
$a3 as usize,
)
};

($nr:expr, $a1:expr, $a2:expr, $a3:expr, $a4:expr) => {
$crate::raw::syscall4(
$nr,
$nr as usize,
$a1 as usize,
$a2 as usize,
$a3 as usize,
Expand All @@ -118,7 +123,7 @@ macro_rules! raw_syscall {

($nr:expr, $a1:expr, $a2:expr, $a3:expr, $a4:expr, $a5:expr) => {
$crate::raw::syscall5(
$nr,
$nr as usize,
$a1 as usize,
$a2 as usize,
$a3 as usize,
Expand All @@ -129,7 +134,7 @@ macro_rules! raw_syscall {

($nr:expr, $a1:expr, $a2:expr, $a3:expr, $a4:expr, $a5:expr, $a6:expr) => {
$crate::raw::syscall6(
$nr,
$nr as usize,
$a1 as usize,
$a2 as usize,
$a3 as usize,
Expand Down
30 changes: 14 additions & 16 deletions src/syscall/aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,18 @@
// No other registers are clobbered.
use core::arch::asm;

use crate::arch::aarch64::Sysno;

/// Issues a raw system call with 0 arguments.
///
/// # Safety
///
/// Running a system call is inherently unsafe. It is the caller's
/// responsibility to ensure safety.
#[inline]
pub unsafe fn syscall0(n: Sysno) -> usize {
pub unsafe fn syscall0(n: usize) -> usize {
let mut ret: usize;
asm!(
"svc 0",
in("x8") n as usize,
in("x8") n,
lateout("x0") ret,
options(nostack, preserves_flags)
);
Expand All @@ -40,11 +38,11 @@ pub unsafe fn syscall0(n: Sysno) -> usize {
/// Running a system call is inherently unsafe. It is the caller's
/// responsibility to ensure safety.
#[inline]
pub unsafe fn syscall1(n: Sysno, arg1: usize) -> usize {
pub unsafe fn syscall1(n: usize, arg1: usize) -> usize {
let mut ret: usize;
asm!(
"svc 0",
in("x8") n as usize,
in("x8") n,
inlateout("x0") arg1 => ret,
options(nostack, preserves_flags)
);
Expand All @@ -58,11 +56,11 @@ pub unsafe fn syscall1(n: Sysno, arg1: usize) -> usize {
/// Running a system call is inherently unsafe. It is the caller's
/// responsibility to ensure safety.
#[inline]
pub unsafe fn syscall2(n: Sysno, arg1: usize, arg2: usize) -> usize {
pub unsafe fn syscall2(n: usize, arg1: usize, arg2: usize) -> usize {
let mut ret: usize;
asm!(
"svc 0",
in("x8") n as usize,
in("x8") n,
inlateout("x0") arg1 => ret,
in("x1") arg2,
options(nostack, preserves_flags)
Expand All @@ -78,15 +76,15 @@ pub unsafe fn syscall2(n: Sysno, arg1: usize, arg2: usize) -> usize {
/// responsibility to ensure safety.
#[inline]
pub unsafe fn syscall3(
n: Sysno,
n: usize,
arg1: usize,
arg2: usize,
arg3: usize,
) -> usize {
let mut ret: usize;
asm!(
"svc 0",
in("x8") n as usize,
in("x8") n,
inlateout("x0") arg1 => ret,
in("x1") arg2,
in("x2") arg3,
Expand All @@ -103,7 +101,7 @@ pub unsafe fn syscall3(
/// responsibility to ensure safety.
#[inline]
pub unsafe fn syscall4(
n: Sysno,
n: usize,
arg1: usize,
arg2: usize,
arg3: usize,
Expand All @@ -112,7 +110,7 @@ pub unsafe fn syscall4(
let mut ret: usize;
asm!(
"svc 0",
in("x8") n as usize,
in("x8") n,
inlateout("x0") arg1 => ret,
in("x1") arg2,
in("x2") arg3,
Expand All @@ -130,7 +128,7 @@ pub unsafe fn syscall4(
/// responsibility to ensure safety.
#[inline]
pub unsafe fn syscall5(
n: Sysno,
n: usize,
arg1: usize,
arg2: usize,
arg3: usize,
Expand All @@ -140,7 +138,7 @@ pub unsafe fn syscall5(
let mut ret: usize;
asm!(
"svc 0",
in("x8") n as usize,
in("x8") n,
inlateout("x0") arg1 => ret,
in("x1") arg2,
in("x2") arg3,
Expand All @@ -159,7 +157,7 @@ pub unsafe fn syscall5(
/// responsibility to ensure safety.
#[inline]
pub unsafe fn syscall6(
n: Sysno,
n: usize,
arg1: usize,
arg2: usize,
arg3: usize,
Expand All @@ -170,7 +168,7 @@ pub unsafe fn syscall6(
let mut ret: usize;
asm!(
"svc 0",
in("x8") n as usize,
in("x8") n,
inlateout("x0") arg1 => ret,
in("x1") arg2,
in("x2") arg3,
Expand Down
30 changes: 14 additions & 16 deletions src/syscall/arm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,18 @@
// No other registers are clobbered.
use core::arch::asm;

use crate::arch::arm::Sysno;

/// Issues a raw system call with 0 arguments.
///
/// # Safety
///
/// Running a system call is inherently unsafe. It is the caller's
/// responsibility to ensure safety.
#[inline]
pub unsafe fn syscall0(n: Sysno) -> usize {
pub unsafe fn syscall0(n: usize) -> usize {
let mut ret: usize;
asm!(
"svc 0",
in("r7") n as usize,
in("r7") n,
lateout("r0") ret,
options(nostack, preserves_flags)
);
Expand All @@ -40,11 +38,11 @@ pub unsafe fn syscall0(n: Sysno) -> usize {
/// Running a system call is inherently unsafe. It is the caller's
/// responsibility to ensure safety.
#[inline]
pub unsafe fn syscall1(n: Sysno, arg1: usize) -> usize {
pub unsafe fn syscall1(n: usize, arg1: usize) -> usize {
let mut ret: usize;
asm!(
"svc 0",
in("r7") n as usize,
in("r7") n,
inlateout("r0") arg1 => ret,
options(nostack, preserves_flags)
);
Expand All @@ -58,11 +56,11 @@ pub unsafe fn syscall1(n: Sysno, arg1: usize) -> usize {
/// Running a system call is inherently unsafe. It is the caller's
/// responsibility to ensure safety.
#[inline]
pub unsafe fn syscall2(n: Sysno, arg1: usize, arg2: usize) -> usize {
pub unsafe fn syscall2(n: usize, arg1: usize, arg2: usize) -> usize {
let mut ret: usize;
asm!(
"svc 0",
in("r7") n as usize,
in("r7") n,
inlateout("r0") arg1 => ret,
in("r1") arg2,
options(nostack, preserves_flags)
Expand All @@ -78,15 +76,15 @@ pub unsafe fn syscall2(n: Sysno, arg1: usize, arg2: usize) -> usize {
/// responsibility to ensure safety.
#[inline]
pub unsafe fn syscall3(
n: Sysno,
n: usize,
arg1: usize,
arg2: usize,
arg3: usize,
) -> usize {
let mut ret: usize;
asm!(
"svc 0",
in("r7") n as usize,
in("r7") n,
inlateout("r0") arg1 => ret,
in("r1") arg2,
in("r2") arg3,
Expand All @@ -103,7 +101,7 @@ pub unsafe fn syscall3(
/// responsibility to ensure safety.
#[inline]
pub unsafe fn syscall4(
n: Sysno,
n: usize,
arg1: usize,
arg2: usize,
arg3: usize,
Expand All @@ -112,7 +110,7 @@ pub unsafe fn syscall4(
let mut ret: usize;
asm!(
"svc 0",
in("r7") n as usize,
in("r7") n,
inlateout("r0") arg1 => ret,
in("r1") arg2,
in("r2") arg3,
Expand All @@ -130,7 +128,7 @@ pub unsafe fn syscall4(
/// responsibility to ensure safety.
#[inline]
pub unsafe fn syscall5(
n: Sysno,
n: usize,
arg1: usize,
arg2: usize,
arg3: usize,
Expand All @@ -140,7 +138,7 @@ pub unsafe fn syscall5(
let mut ret: usize;
asm!(
"svc 0",
in("r7") n as usize,
in("r7") n,
inlateout("r0") arg1 => ret,
in("r1") arg2,
in("r2") arg3,
Expand All @@ -159,7 +157,7 @@ pub unsafe fn syscall5(
/// responsibility to ensure safety.
#[inline]
pub unsafe fn syscall6(
n: Sysno,
n: usize,
arg1: usize,
arg2: usize,
arg3: usize,
Expand All @@ -170,7 +168,7 @@ pub unsafe fn syscall6(
let mut ret: usize;
asm!(
"svc 0",
in("r7") n as usize,
in("r7") n,
inlateout("r0") arg1 => ret,
in("r1") arg2,
in("r2") arg3,
Expand Down
Loading
Loading