Skip to content

Commit 096d868

Browse files
committed
Auto merge of #1584 - psumbera:master, r=gnzlbg
Add support for shared memory operations for solaris/illumos This is needed because Firefox now uses slice-deque rust crate.
2 parents 88f6587 + 412dd4e commit 096d868

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

src/unix/solarish/mod.rs

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ pub type nl_item = ::c_int;
3434
pub type mqd_t = *mut ::c_void;
3535
pub type id_t = ::c_int;
3636
pub type idtype_t = ::c_uint;
37+
pub type shmatt_t = ::c_ulong;
3738

3839
pub type door_attr_t = ::c_uint;
3940
pub type door_id_t = ::c_ulonglong;
@@ -57,6 +58,16 @@ s! {
5758
pub imr_interface: in_addr,
5859
}
5960

61+
pub struct ipc_perm {
62+
pub uid: ::uid_t,
63+
pub gid: ::gid_t,
64+
pub cuid: ::uid_t,
65+
pub cgid: ::gid_t,
66+
pub mode: ::mode_t,
67+
pub seq: ::c_uint,
68+
pub key: ::key_t,
69+
}
70+
6071
pub struct sockaddr {
6172
pub sa_family: sa_family_t,
6273
pub sa_data: [::c_char; 14],
@@ -206,6 +217,33 @@ s! {
206217
pub ai_next: *mut addrinfo,
207218
}
208219

220+
pub struct shmid_ds {
221+
pub shm_perm: ipc_perm,
222+
pub shm_segsz: ::size_t,
223+
#[cfg(target_os = "illumos")]
224+
pub shm_amp: *mut ::c_void,
225+
#[cfg(target_os = "solaris")]
226+
pub shm_flags: ::uintptr_t,
227+
pub shm_lkcnt: ::c_ushort,
228+
pub shm_lpid: ::pid_t,
229+
pub shm_cpid: ::pid_t,
230+
pub shm_nattch: ::shmatt_t,
231+
pub shm_cnattch: ::c_ulong,
232+
pub shm_atime: ::time_t,
233+
pub shm_dtime: ::time_t,
234+
pub shm_ctime: ::time_t,
235+
#[cfg(target_os = "illumos")]
236+
pub shm_pad4: [i64; 4],
237+
#[cfg(target_os = "solaris")]
238+
pub shm_amp: *mut ::c_void,
239+
#[cfg(target_os = "solaris")]
240+
pub shm_gransize: u64,
241+
#[cfg(target_os = "solaris")]
242+
pub shm_allocated: u64,
243+
#[cfg(target_os = "solaris")]
244+
pub shm_pad4: [i64; 1],
245+
}
246+
209247
pub struct sigset_t {
210248
bits: [u32; 4],
211249
}
@@ -1066,6 +1104,7 @@ pub const MAP_PRIVATE: ::c_int = 0x0002;
10661104
pub const MAP_FIXED: ::c_int = 0x0010;
10671105
pub const MAP_NORESERVE: ::c_int = 0x40;
10681106
pub const MAP_ANON: ::c_int = 0x0100;
1107+
pub const MAP_ANONYMOUS: ::c_int = 0x0100;
10691108
pub const MAP_RENAME: ::c_int = 0x20;
10701109
pub const MAP_ALIGN: ::c_int = 0x200;
10711110
pub const MAP_TEXT: ::c_int = 0x400;
@@ -1437,6 +1476,16 @@ pub const IFF_VIRTUAL: ::c_longlong = 0x2000000000; // Cannot send/receive pkts
14371476
pub const IFF_DUPLICATE: ::c_longlong = 0x4000000000; // Local address in use
14381477
pub const IFF_IPMP: ::c_longlong = 0x8000000000; // IPMP IP interface
14391478

1479+
// sys/ipc.h:
1480+
pub const IPC_ALLOC: ::c_int = 0x8000;
1481+
pub const IPC_CREAT: ::c_int = 0x200;
1482+
pub const IPC_EXCL: ::c_int = 0x400;
1483+
pub const IPC_NOWAIT: ::c_int = 0x800;
1484+
pub const IPC_PRIVATE: key_t = 0;
1485+
pub const IPC_RMID: ::c_int = 10;
1486+
pub const IPC_SET: ::c_int = 11;
1487+
pub const IPC_SEAT: ::c_int = 12;
1488+
14401489
pub const SHUT_RD: ::c_int = 0;
14411490
pub const SHUT_WR: ::c_int = 1;
14421491
pub const SHUT_RDWR: ::c_int = 2;
@@ -2119,6 +2168,22 @@ extern "C" {
21192168
advice: ::c_int,
21202169
) -> ::c_int;
21212170

2171+
pub fn shmat(
2172+
shmid: ::c_int,
2173+
shmaddr: *const ::c_void,
2174+
shmflg: ::c_int,
2175+
) -> *mut ::c_void;
2176+
2177+
pub fn shmctl(
2178+
shmid: ::c_int,
2179+
cmd: ::c_int,
2180+
buf: *mut ::shmid_ds,
2181+
) -> ::c_int;
2182+
2183+
pub fn shmdt(shmaddr: *const ::c_void) -> ::c_int;
2184+
2185+
pub fn shmget(key: key_t, size: ::size_t, shmflg: ::c_int) -> ::c_int;
2186+
21222187
pub fn shm_open(
21232188
name: *const ::c_char,
21242189
oflag: ::c_int,

0 commit comments

Comments
 (0)