libc/io.kur
//! Descriptors and errnos, the C half of `std::io`.
// io.c. A read or write a signal interrupted (EINTR) is made again, a
// close is not; descriptors are opened close-on-exec; and a failure is an
// errno (negative where the result is otherwise a count or a descriptor),
// so no variadic C function is called through a fixed prototype and no
// `errno` is read from Kursal. A path is its bytes and a NUL, with the
// length of the bytes; one holding a NUL of its own is EINVAL.
/// A fresh descriptor for reading the file at `path`, or a negative errno.
extern "C" fn kur_libc_fs_open_read(path: *u8, len: usize) -> i32;
/// A fresh descriptor for writing the file at `path`, made or emptied (mode
/// 0644, less the umask), or a negative errno.
extern "C" fn kur_libc_fs_create(path: *u8, len: usize) -> i32;
/// read(2): the count, 0 at the end, or a negative errno.
extern "C" fn kur_libc_fs_read(fd: i32, buf: *u8, count: usize) -> isize;
/// write(2): the count or a negative errno.
extern "C" fn kur_libc_fs_write(fd: i32, buf: *u8, count: usize) -> isize;
/// close(2), not retried: 0 or the errno.
extern "C" fn kur_libc_fs_close(fd: i32) -> i32;
/// The size of the regular file open on `fd`, written to `size`: 0, or the
/// errno: EISDIR for a directory, EINVAL for anything else.
extern "C" fn kur_libc_fs_regular_size(fd: i32, size: *u64) -> i32;
/// A regular file's size, 0 for a pipe, device or socket, or a negative
/// errno: EISDIR for a directory, EFBIG for one too large.
extern "C" fn kur_libc_fs_size_hint(fd: i32) -> isize;
/// Claims standard input for one reader: 0, or EBUSY while another holds it.
extern "C" fn kur_libc_stdin_claim() -> i32;
/// Gives standard input back.
extern "C" fn kur_libc_stdin_release() -> ();
/// The kind of an errno, numbered as `std::io::ErrorKind` orders its
/// variants from 1; 0 for any other.
extern "C" fn kur_libc_error_kind(code: i32) -> i32;
/// The C library's description of an errno, into `out`: how many bytes, at
/// most `cap`, and no NUL.
extern "C" fn kur_libc_error_message(code: i32, out: *u8, cap: usize) -> usize;