Skip to main content

rustpython_host_env/
shm.rs

1use core::ffi::CStr;
2use std::io;
3
4use crate::os::CheckLibcResult;
5
6pub use libc::mode_t;
7
8pub fn shm_open(name: &CStr, flags: libc::c_int, mode: libc::c_uint) -> io::Result<libc::c_int> {
9    #[cfg(target_os = "freebsd")]
10    let mode = mode.try_into().unwrap();
11
12    unsafe { libc::shm_open(name.as_ptr(), flags, mode) }.check_libc_neg()
13}
14
15pub fn shm_unlink(name: &CStr) -> io::Result<()> {
16    unsafe { libc::shm_unlink(name.as_ptr()) }.check_libc_neg()?;
17    Ok(())
18}