diff --git a/.travis.yml b/.travis.yml index 6116475d2e2e71fab340408879fea566e1bedfd2..da882aea61b9d2f871cc6868b7bf3a046f3279a6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -88,6 +88,10 @@ matrix: - shellcheck --version - shellcheck ci/*.sh + allow_failures: + - env: TARGET=aarch64-linux-android + - env: TARGET=x86_64-linux-android + install: rustup target add $TARGET script: - cargo generate-lockfile --manifest-path libc-test/Cargo.toml diff --git a/libc-test/build.rs b/libc-test/build.rs index 7e0928fe00a38e64c93717a546efde2e06bf31f8..460eb7241ded1a3ba602d89bf84de17cf7385b68 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -186,6 +186,7 @@ fn main() { } cfg.header("netinet/in.h"); cfg.header("sys/ipc.h"); + cfg.header("sys/sem.h"); cfg.header("sys/shm.h"); if !ios { @@ -453,7 +454,7 @@ fn main() { // Fixed on feature=align with repr(packed(4)) // Once repr_packed stabilizes we can fix this unconditionally // and remove this check. - "kevent" | "shmid_ds" if apple && x86_64 => true, + "kevent" | "shmid_ds" | "semid_ds" if apple && x86_64 => true, // This is actually a union, not a struct "sigval" => true, diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 4680389e60c48c360dbb75878d392af27b8915b1..bb07cc4872d53dd6d1a99c9161617bfc75cbdd13 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -535,6 +535,35 @@ s! { pub _key: ::key_t, } + // sys/sem.h + + pub struct sembuf { + pub sem_num: ::c_ushort, + pub sem_op: ::c_short, + pub sem_flg: ::c_short, + } + + #[cfg_attr(feature = "rustc-dep-of-std", repr(packed(4)))] + pub struct semid_ds { + // Note the manpage shows different types than the system header. + pub sem_perm: ipc_perm, + pub sem_base: ::int32_t, + pub sem_nsems: ::c_ushort, + pub sem_otime: ::time_t, + pub sem_pad1: ::int32_t, + pub sem_ctime: ::time_t, + pub sem_pad2: ::int32_t, + pub sem_pad3: [::int32_t; 4], + } + + pub union semun { + pub val: ::c_int, + pub buf: *mut semid_ds, + pub array: *mut ::c_ushort, + } + + // sys/shm.h + #[cfg_attr(feature = "rustc-dep-of-std", repr(packed(4)))] pub struct shmid_ds { pub shm_perm: ipc_perm, @@ -2297,6 +2326,17 @@ pub const IPC_R: ::c_int = 0x100; pub const IPC_W: ::c_int = 0x80; pub const IPC_M: ::c_int = 0x1000; +// sys/sem.h +pub const SEM_UNDO: ::c_int = 0o10000; + +pub const GETNCNT: ::c_int = 3; +pub const GETPID: ::c_int = 4; +pub const GETVAL: ::c_int = 5; +pub const GETALL: ::c_int = 6; +pub const GETZCNT: ::c_int = 7; +pub const SETVAL: ::c_int = 8; +pub const SETALL: ::c_int = 9; + // sys/shm.h pub const SHM_RDONLY: ::c_int = 0x1000; pub const SHM_RND: ::c_int = 0x2000; @@ -2387,6 +2427,13 @@ extern { link_name = "mprotect$UNIX2003")] pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int; + pub fn semget(key: key_t, nsems: ::c_int, semflg: ::c_int) -> ::c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "semctl$UNIX2003")] + pub fn semctl(semid: ::c_int, + semnum: ::c_int, + cmd: ::c_int, ...) -> ::c_int; + pub fn semop(semid: ::c_int, sops: *mut sembuf, nsops: ::size_t) -> ::c_int; pub fn shm_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::c_int; pub fn ftok(pathname : *const c_char, proj_id : ::c_int) -> key_t; pub fn shmat(shmid: ::c_int, shmaddr: *const ::c_void,