MCPcopy Index your code
hub / github.com/RustPython/RustPython / shm_open

Function shm_open

crates/stdlib/src/posixshmem.rs:27–39  ·  view source on GitHub ↗
(args: ShmOpenArgs, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

25
26 #[pyfunction]
27 fn shm_open(args: ShmOpenArgs, vm: &VirtualMachine) -> PyResult<libc::c_int> {
28 let name = CString::new(args.name.as_str()).map_err(|e| e.into_pyexception(vm))?;
29 let mode: libc::c_uint = args.mode as _;
30 #[cfg(target_os = "freebsd")]
31 let mode = mode.try_into().unwrap();
32 // SAFETY: `name` is a NUL-terminated string and `shm_open` does not write through it.
33 let fd = unsafe { libc::shm_open(name.as_ptr(), args.flags, mode) };
34 if fd == -1 {
35 Err(errno_io_error().into_pyexception(vm))
36 } else {
37 Ok(fd)
38 }
39 }
40
41 #[pyfunction]
42 fn shm_unlink(name: PyUtf8StrRef, vm: &VirtualMachine) -> PyResult<()> {

Callers

nothing calls this directly

Calls 7

newFunction · 0.85
errno_io_errorFunction · 0.85
ErrClass · 0.50
as_strMethod · 0.45
into_pyexceptionMethod · 0.45
unwrapMethod · 0.45
as_ptrMethod · 0.45

Tested by

no test coverage detected