1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use core::ffi;

use super::raw;
use super::types::*;

/// Get the process id (PID) of the current process.
#[inline(always)]
pub unsafe fn getpid() -> pid_t {
    raw::syscall0(raw::GETPID) as pid_t
}

/// Read from a file descriptor.
#[inline(always)]
pub unsafe fn read(fd: int, buf: *const ffi::c_void, count: size_t) -> ssize_t {
    raw::syscall3(raw::READ, fd as raw::V, buf as raw::V, count as raw::V) as ssize_t
}

/// Write to a file descriptor.
#[inline(always)]
pub unsafe fn write(fd: int, buf: *const ffi::c_void, count: size_t) -> ssize_t {
    raw::syscall3(raw::WRITE, fd as raw::V, buf as raw::V, count as raw::V) as ssize_t
}