#syscalls #system #call #raw #no-std

nightly no-std raw-syscall-enumerated

低级原始系统调用枚举

1 个不稳定版本

0.7.6 2018 年 10 月 4 日

#952 in Unix API

MIT-0 OR 0BSD

70KB
1.5K SLoC

raw-syscall-enumerated

低级系统调用。

Latest version Documentation Downloads License

用法

将以下内容添加到您的 Cargo.toml

raw-syscall-enumerated = "0.7.6"

支持的平台

  • x86_64-linux

目的

此包基于 raw-syscall-base 构建,为平台上的每个系统调用提供一个函数。

所有函数都被标记为不安全,并且不会对参数或返回值进行验证。

所有参数和返回值都使用最基本的可能类型,例如在 x86_64-linux 上一切都是 usize。所有参数都必须转换为此类型,是否表示指针或错误代码等则由调用者决定。

应该支持最新发布的平台上的所有系统调用。还应支持已弃用的系统调用。是否需要检查平台版本以防止调用不受支持的函数,则由高级库决定。

意图是提供一个最小化的稳定基础,没有不必要的开销,以便构建更高级的库。

x86_64-linux 示例

    use raw_syscall_enumerated::{write, exit_group};
    
    // attempts to write "hello" to STDOUT
    pub unsafe fn hello() -> usize {
        write(1, b"hello" as *const u8 as usize, 5)
    }

    // exits the program with a success code 
    pub unsafe fn exit_success() -> ! {
        exit_group(0)
    }

依赖项

~43KB