From 6eca76726bae6ebe4e30350cd8c760a42109b241 Mon Sep 17 00:00:00 2001 From: coolreader18 <33094578+coolreader18@users.noreply.github.com> Date: Sat, 7 Dec 2019 22:24:47 -0600 Subject: [PATCH 1/2] Add AI_* constants on android; taken from netdb.h --- src/unix/linux_like/android/mod.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index a40b77e82d69d..0afd14a7e4c99 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -1157,6 +1157,21 @@ pub const RTLD_NOLOAD: ::c_int = 0x4; pub const SEM_FAILED: *mut sem_t = 0 as *mut sem_t; +pub const AI_PASSIVE: ::c_int = 0x00000001; +pub const AI_CANONNAME: ::c_int = 0x00000002; +pub const AI_NUMERICHOST: ::c_int = 0x00000004; +pub const AI_NUMERICSERV: ::c_int = 0x00000008; +pub const AI_MASK: ::c_int = AI_PASSIVE + | AI_CANONNAME + | AI_NUMERICHOST + | AI_NUMERICSERV + | AI_ADDRCONFIG; +pub const AI_ALL: ::c_int = 0x00000100; +pub const AI_V4MAPPED_CFG: ::c_int = 0x00000200; +pub const AI_ADDRCONFIG: ::c_int = 0x00000400; +pub const AI_V4MAPPED: ::c_int = 0x00000800; +pub const AI_DEFAULT: ::c_int = AI_V4MAPPED_CFG | AI_ADDRCONFIG; + pub const LINUX_REBOOT_MAGIC1: ::c_int = 0xfee1dead; pub const LINUX_REBOOT_MAGIC2: ::c_int = 672274793; pub const LINUX_REBOOT_MAGIC2A: ::c_int = 85072278; From aa6f5e2b38dc1d70b8b79543f4b84bb97856c92f Mon Sep 17 00:00:00 2001 From: coolreader18 <33094578+coolreader18@users.noreply.github.com> Date: Sat, 7 Dec 2019 22:31:45 -0600 Subject: [PATCH 2/2] Add FD_* functions/macros for redox; implementations copied from linux_like --- src/unix/redox/mod.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index b00a191c9b955..4ea52e37981c6 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -839,6 +839,32 @@ f! { pub fn WCOREDUMP(status: ::c_int) -> bool { (status & 0x80) != 0 } + + pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () { + let fd = fd as usize; + let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8; + (*set).fds_bits[fd / size] &= !(1 << (fd % size)); + return + } + + pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool { + let fd = fd as usize; + let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8; + return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0 + } + + pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () { + let fd = fd as usize; + let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8; + (*set).fds_bits[fd / size] |= 1 << (fd % size); + return + } + + pub fn FD_ZERO(set: *mut fd_set) -> () { + for slot in (*set).fds_bits.iter_mut() { + *slot = 0; + } + } } extern "C" {