summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgnzlbg <gonzalobg88@gmail.com>2018-02-02 17:07:12 +0100
committergnzlbg <gonzalobg88@gmail.com>2018-02-03 14:43:38 +0100
commit53e47331808799f5ad9998df986a192eedf82f6a (patch)
tree96ee1cd336b9770243e8a883b5578f1352326435 /src
parent782794985c91181f6f9ac8ba46f5bf720187d4e2 (diff)
downloadrust-libc-53e47331808799f5ad9998df986a192eedf82f6a.tar.gz
add macosx sysv ipc shared memory
Diffstat (limited to 'src')
-rw-r--r--src/unix/bsd/apple/mod.rs58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs
index a0bdc62c92..9cd5db6547 100644
--- a/src/unix/bsd/apple/mod.rs
+++ b/src/unix/bsd/apple/mod.rs
@@ -30,6 +30,8 @@ pub type cpu_subtype_t = integer_t;
pub type vm_prot_t = ::c_int;
pub type posix_spawnattr_t = *mut ::c_void;
pub type posix_spawn_file_actions_t = *mut ::c_void;
+pub type key_t = ::c_int;
+pub type shmatt_t = ::c_ushort;
pub enum timezone {}
@@ -509,6 +511,33 @@ s! {
pub sc_unit: ::uint32_t,
pub sc_reserved: [::uint32_t; 5],
}
+
+ // sys/ipc.h:
+
+ pub struct ipc_perm {
+ pub uid: ::uid_t,
+ pub gid: ::gid_t,
+ pub cuid: ::uid_t,
+ pub cgid: ::gid_t,
+ pub mode: ::mode_t,
+ pub _seq: ::c_ushort,
+ pub _key: ::key_t,
+ }
+
+ // FIXME: this should have align 4 but it's got align 8 on 64-bit
+ pub struct shmid_ds {
+ pub shm_perm: ipc_perm,
+ pub shm_segsz: ::size_t,
+ pub shm_lpid: ::pid_t,
+ pub shm_cpid: ::pid_t,
+ pub shm_nattch: ::shmatt_t,
+ pub shm_atime: ::time_t, // FIXME: 64-bit wrong align => wrong offset
+ pub shm_dtime: ::time_t, // FIXME: 64-bit wrong align => wrong offset
+ pub shm_ctime: ::time_t, // FIXME: 64-bit wrong align => wrong offset
+ // FIXME: 64-bit wrong align => wrong offset:
+ pub shm_internal: *mut ::c_void,
+
+ }
}
pub const _UTX_USERSIZE: usize = 256;
@@ -2203,6 +2232,27 @@ pub const POSIX_SPAWN_SETPGROUP: ::c_int = 0x02;
pub const POSIX_SPAWN_SETSIGDEF: ::c_int = 0x04;
pub const POSIX_SPAWN_SETSIGMASK: ::c_int = 0x08;
+// sys/ipc.h:
+pub const IPC_CREAT: ::c_int = 0x200;
+pub const IPC_EXCL: ::c_int = 0x400;
+pub const IPC_NOWAIT: ::c_int = 0x800;
+pub const IPC_PRIVATE: key_t = 0;
+
+pub const IPC_RMID: ::c_int = 0;
+pub const IPC_SET: ::c_int = 1;
+pub const IPC_STAT: ::c_int = 2;
+
+pub const IPC_R: ::c_int = 0x100;
+pub const IPC_W: ::c_int = 0x80;
+pub const IPC_M: ::c_int = 0x1000;
+
+// sys/shm.h
+pub const SHM_RDONLY: ::c_int = 0x1000;
+pub const SHM_RND: ::c_int = 0x2000;
+pub const SHMLBA: ::c_int = 4096;
+pub const SHM_R: ::c_int = IPC_R;
+pub const SHM_W: ::c_int = IPC_W;
+
f! {
pub fn WSTOPSIG(status: ::c_int) -> ::c_int {
status >> 8
@@ -2271,6 +2321,14 @@ extern {
pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int)
-> ::c_int;
pub fn shm_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::c_int;
+ pub fn shmat(shmid: ::c_int, shmaddr: *const ::c_void,
+ shmflg: ::c_int) -> *mut ::c_void;
+ pub fn shmdt(shmaddr: *const ::c_void) -> ::c_int;
+ #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
+ link_name = "shmctl$UNIX2003")]
+ pub fn shmctl(shmid: ::c_int, cmd: ::c_int,
+ buf: *mut ::shmid_ds) -> ::c_int;
+ pub fn shmget(key: key_t, size: ::size_t, shmflg: ::c_int) -> ::c_int;
pub fn sysctl(name: *mut ::c_int,
namelen: ::c_uint,
oldp: *mut ::c_void,