use super::raw;
use crate::{c_char, c_int, c_mode_t, c_off_t, c_void};
#[doc = crate::_tags!(platform namespace)]
#[doc = crate::_doc_location!("sys/os")]
#[derive(Debug)]
pub struct Libc;
impl Libc {
pub const O_RDONLY: c_int = 0o0;
pub const O_WRONLY: c_int = 0o1;
pub const O_RDWR: c_int = 0o2;
pub const O_CREAT: c_int = 0o100;
pub const PROT_READ: c_int = 0x1;
pub const PROT_WRITE: c_int = 0x2;
pub const MAP_SHARED: c_int = 0x01;
pub const MAP_FAILED: *mut c_void = !0 as *mut c_void;
}
impl Libc {
#[inline(always)]
pub fn is_map_failed(ptr: *mut c_void) -> bool {
ptr == Self::MAP_FAILED
}
}
#[allow(clippy::missing_safety_doc)]
impl Libc {
#[inline(always)]
pub unsafe fn shm_open(name: *const c_char, oflag: c_int, mode: c_mode_t) -> c_int {
unsafe { raw::shm_open(name, oflag, mode) }
}
#[inline(always)]
pub unsafe fn shm_unlink(name: *const c_char) -> c_int {
unsafe { raw::shm_unlink(name) }
}
#[inline(always)]
pub unsafe fn ftruncate(fd: c_int, length: c_off_t) -> c_int {
unsafe { raw::ftruncate(fd, length) }
}
#[inline(always)]
pub unsafe fn mmap(
addr: *mut c_void,
length: usize,
prot: c_int,
flags: c_int,
fd: c_int,
offset: c_off_t,
) -> *mut c_void {
unsafe { raw::mmap(addr, length, prot, flags, fd, offset) }
}
#[inline(always)]
pub unsafe fn munmap(addr: *mut c_void, length: usize) -> c_int {
unsafe { raw::munmap(addr, length) }
}
#[inline(always)]
pub unsafe fn free(ptr: *mut c_void) {
unsafe { raw::free(ptr) }
}
#[inline(always)]
pub unsafe fn close(fd: c_int) -> c_int {
unsafe { raw::close(fd) }
}
}