1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#[repr(C)]
#[derive(Copy, Clone)]
pub enum Shm {
READ = 0o0000400,
WRITE = 0o0000200,
RDONLY = 0o0010000,
REMAP = 0o0040000,
EXEC = 0o0100000,
LOCK = 0o0000011,
UNLOCK = 0o0000012,
STAT = 0o0000013,
INFO = 0o0000014,
DEST = 0o0001000,
LOCKED = 0o0002000,
HUGETLB = 0o0004000,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub enum Ipc {
CREAT = 0o0001000,
NOWAIT = 2048,
EXCL = 0o0002000,
RMID = 0o0000000,
SET = 0o0000001,
STAT = 0o0000002,
INFO = 0o0000003,
}
#[allow(dead_code)]
pub const TOK_PATHNAME: &'static [u8; 4] = b"/tmp";
pub const TOK_PROJ_ID: u32 = 0;
#[cfg(any(unix))]
extern "C" {
pub fn ftok(path: *mut i8, id: i32) -> i64;
pub fn shmget(key: i32, size: u64, flag: i32) -> i32;
pub fn shmat(id: i32, addr: *mut i32, flag: i32) -> *mut i32;
pub fn shmdt(addr: *const i32) -> i32;
pub fn shmctl(id: i32, cmd: i32, info: *mut ShmidDs) -> i32;
}
#[repr(C)]
pub struct ShmidDs {
pub shm_perm: IpcPerm,
pub shm_segsz: i32,
pub shm_atime: i64,
pub shm_dtime: i64,
pub shm_ctime: i64,
pub shm_cpid: u16,
pub shm_lpid: u16,
pub shm_nattch: i16,
pub shm_npages: u16,
}
#[repr(C)]
pub struct IpcPerm {
pub uid: i64,
pub gid: i64,
pub cuid: i64,
pub cgid: i64,
pub mode: u16,
pub seq: u16,
pub key: i64,
}