add key_t to sys_types, cleanup sys_ipc and sys_shm

This commit is contained in:
auronandace
2026-05-21 08:50:15 +01:00
parent e3514fa329
commit 613ff4b860
7 changed files with 29 additions and 19 deletions
+2 -3
View File
@@ -1,14 +1,13 @@
# POSIX header spec: https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_ipc.h.html
#
# Spec quotations relating to includes:
# - The <sys/ipc.h> header shall define the uid_t, gid_t, mode_t, and key_t types as described in <sys/types.h>
sys_includes = []
# - "The <sys/ipc.h> header shall define the uid_t, gid_t, mode_t, and key_t types as described in <sys/types.h>."
include_guard = "_RELIBC_SYS_IPC_H"
after_includes = """
#include <bits/gid-t.h> // for gid_t from sys/types.h
#include <bits/uid-t.h> // for uid_t from sys/types.h
#include <bits/key-t.h> // for key_t from sys/types.h
#include <bits/mode-t.h> // for mode_t from sys/types.h
#include <bits/mode-t.h> // for mode_t from sys/types.h
"""
language = "C"
style = "Tag"
+9 -2
View File
@@ -13,15 +13,22 @@ pub const IPC_R: u32 = 0o400;
pub const IPC_W: u32 = 0o200;
pub const IPC_M: u32 = 0o10000;
/// Remove identifier.
pub const IPC_RMID: i32 = 0;
/// Set options.
pub const IPC_SET: i32 = 1;
/// Get options.
pub const IPC_STAT: i32 = 2;
// pub const IPC_INFO: i32 = 3; non posix unimplemented
/// Create entry if key does not exist.
pub const IPC_CREAT: i32 = 0o1000;
/// Fail if key exists.
pub const IPC_EXCL: i32 = 0o2000;
/// Error if request would need to wait.
pub const IPC_NOWAIT: i32 = 0o4000;
/// Private key.
pub const IPC_PRIVATE: key_t = 0;
#[repr(C)]
@@ -50,7 +57,7 @@ pub unsafe extern "C" fn ftok(path: *const c_char, id: c_int) -> key_t {
}
// Borrowed from musl
return (stat.st_ino & 0xffff) as key_t
(stat.st_ino & 0xffff) as key_t
| ((stat.st_dev & 0xff) << 16) as key_t
| ((id & 0xff) << 24);
| ((id & 0xff) << 24)
}