about summary refs log tree commit diff
path: root/src/libnative
diff options
context:
space:
mode:
authorValerii Hiora <valerii.hiora@gmail.com>2014-05-05 10:07:49 +0300
committerValerii Hiora <valerii.hiora@gmail.com>2014-06-12 21:15:14 +0300
commita49b765f9a5b5926e338da30fcaae59ff1ae5c02 (patch)
tree489f1930d52ae1e9050e840940b3bcb1daedb615 /src/libnative
parent0c10c686824bf37084af87af84f338bcd2a7551a (diff)
downloadrust-a49b765f9a5b5926e338da30fcaae59ff1ae5c02.tar.gz
rust-a49b765f9a5b5926e338da30fcaae59ff1ae5c02.zip
Basic iOS support
Diffstat (limited to 'src/libnative')
-rw-r--r--src/libnative/io/c_unix.rs7
-rw-r--r--src/libnative/io/file_unix.rs3
-rw-r--r--src/libnative/io/mod.rs1
-rw-r--r--src/libnative/io/net.rs3
-rw-r--r--src/libnative/io/process.rs1
-rw-r--r--src/libnative/io/timer_unix.rs19
6 files changed, 30 insertions, 4 deletions
diff --git a/src/libnative/io/c_unix.rs b/src/libnative/io/c_unix.rs
index e6cb5cb76f1..70fd6310070 100644
--- a/src/libnative/io/c_unix.rs
+++ b/src/libnative/io/c_unix.rs
@@ -20,6 +20,7 @@ pub use self::signal::{SA_NODEFER, SA_NOCLDWAIT, SA_SIGINFO, SIGCHLD};
 use libc;
 
 #[cfg(target_os = "macos")]
+#[cfg(target_os = "ios")]
 #[cfg(target_os = "freebsd")]
 pub static FIONBIO: libc::c_ulong = 0x8004667e;
 #[cfg(target_os = "linux", not(target_arch = "mips"))]
@@ -29,6 +30,7 @@ pub static FIONBIO: libc::c_ulong = 0x5421;
 pub static FIONBIO: libc::c_ulong = 0x667e;
 
 #[cfg(target_os = "macos")]
+#[cfg(target_os = "ios")]
 #[cfg(target_os = "freebsd")]
 pub static FIOCLEX: libc::c_ulong = 0x20006601;
 #[cfg(target_os = "linux", not(target_arch = "mips"))]
@@ -38,6 +40,7 @@ pub static FIOCLEX: libc::c_ulong = 0x5451;
 pub static FIOCLEX: libc::c_ulong = 0x6601;
 
 #[cfg(target_os = "macos")]
+#[cfg(target_os = "ios")]
 #[cfg(target_os = "freebsd")]
 pub static MSG_DONTWAIT: libc::c_int = 0x80;
 #[cfg(target_os = "linux")]
@@ -75,6 +78,7 @@ extern {
 }
 
 #[cfg(target_os = "macos")]
+#[cfg(target_os = "ios")]
 mod select {
     pub static FD_SETSIZE: uint = 1024;
 
@@ -187,6 +191,7 @@ mod signal {
 }
 
 #[cfg(target_os = "macos")]
+#[cfg(target_os = "ios")]
 #[cfg(target_os = "freebsd")]
 mod signal {
     use libc;
@@ -201,6 +206,7 @@ mod signal {
     pub static SIGCHLD: libc::c_int = 20;
 
     #[cfg(target_os = "macos")]
+    #[cfg(target_os = "ios")]
     pub type sigset_t = u32;
     #[cfg(target_os = "freebsd")]
     pub struct sigset_t {
@@ -219,6 +225,7 @@ mod signal {
     }
 
     #[cfg(target_os = "macos")]
+    #[cfg(target_os = "ios")]
     pub struct sigaction {
         pub sa_handler: extern fn(libc::c_int),
         sa_tramp: *mut libc::c_void,
diff --git a/src/libnative/io/file_unix.rs b/src/libnative/io/file_unix.rs
index fda9b7b1932..f521934c0f9 100644
--- a/src/libnative/io/file_unix.rs
+++ b/src/libnative/io/file_unix.rs
@@ -133,6 +133,7 @@ impl rtio::RtioFileStream for FileDesc {
         return super::mkerr_libc(os_datasync(self.fd()));
 
         #[cfg(target_os = "macos")]
+        #[cfg(target_os = "ios")]
         fn os_datasync(fd: c_int) -> c_int {
             unsafe { libc::fcntl(fd, libc::F_FULLFSYNC) }
         }
@@ -140,7 +141,7 @@ impl rtio::RtioFileStream for FileDesc {
         fn os_datasync(fd: c_int) -> c_int {
             retry(|| unsafe { libc::fdatasync(fd) })
         }
-        #[cfg(not(target_os = "macos"), not(target_os = "linux"))]
+        #[cfg(not(target_os = "macos"), not(target_os = "ios"), not(target_os = "linux"))]
         fn os_datasync(fd: c_int) -> c_int {
             retry(|| unsafe { libc::fsync(fd) })
         }
diff --git a/src/libnative/io/mod.rs b/src/libnative/io/mod.rs
index 4158db7bb8e..6dc2482ab0c 100644
--- a/src/libnative/io/mod.rs
+++ b/src/libnative/io/mod.rs
@@ -50,6 +50,7 @@ pub mod file;
 pub mod file;
 
 #[cfg(target_os = "macos")]
+#[cfg(target_os = "ios")]
 #[cfg(target_os = "freebsd")]
 #[cfg(target_os = "android")]
 #[cfg(target_os = "linux")]
diff --git a/src/libnative/io/net.rs b/src/libnative/io/net.rs
index e7effbd6bdb..30ea80a1296 100644
--- a/src/libnative/io/net.rs
+++ b/src/libnative/io/net.rs
@@ -320,6 +320,7 @@ impl TcpStream {
     }
 
     #[cfg(target_os = "macos")]
+    #[cfg(target_os = "ios")]
     fn set_tcp_keepalive(&mut self, seconds: uint) -> IoResult<()> {
         setsockopt(self.fd(), libc::IPPROTO_TCP, libc::TCP_KEEPALIVE,
                    seconds as libc::c_int)
@@ -329,7 +330,7 @@ impl TcpStream {
         setsockopt(self.fd(), libc::IPPROTO_TCP, libc::TCP_KEEPIDLE,
                    seconds as libc::c_int)
     }
-    #[cfg(not(target_os = "macos"), not(target_os = "freebsd"))]
+    #[cfg(not(target_os = "macos"), not(target_os = "ios"), not(target_os = "freebsd"))]
     fn set_tcp_keepalive(&mut self, _seconds: uint) -> IoResult<()> {
         Ok(())
     }
diff --git a/src/libnative/io/process.rs b/src/libnative/io/process.rs
index d8486cb9f09..f26d87ba1b5 100644
--- a/src/libnative/io/process.rs
+++ b/src/libnative/io/process.rs
@@ -769,6 +769,7 @@ fn translate_status(status: c_int) -> rtio::ProcessExit {
     }
 
     #[cfg(target_os = "macos")]
+    #[cfg(target_os = "ios")]
     #[cfg(target_os = "freebsd")]
     mod imp {
         pub fn WIFEXITED(status: i32) -> bool { (status & 0x7f) == 0 }
diff --git a/src/libnative/io/timer_unix.rs b/src/libnative/io/timer_unix.rs
index 11f9c4b3d8c..ca0a810890c 100644
--- a/src/libnative/io/timer_unix.rs
+++ b/src/libnative/io/timer_unix.rs
@@ -93,7 +93,20 @@ pub fn now() -> u64 {
     }
 }
 
-fn helper(input: libc::c_int, messages: Receiver<Req>, _: ()) {
+
+// Note: although the last parameter isn't used there is no way now to
+// convert it to unit type, because LLVM dies in SjLj preparation
+// step (unfortunately iOS uses SjLJ exceptions)
+//
+// It's definitely a temporary workaround just to get it working.
+// So far it looks like an LLVM issue and it was reported:
+// http://llvm.org/bugs/show_bug.cgi?id=19855
+// Actually this issue is pretty common while compiling for armv7 iOS
+// and in most cases it is simply solved by using --opt-level=2 (or -O)
+//
+// For this specific case unfortunately turning optimizations wasn't
+// enough.
+fn helper(input: libc::c_int, messages: Receiver<Req>, _: int) {
     let mut set: c::fd_set = unsafe { mem::zeroed() };
 
     let mut fd = FileDesc::new(input, true);
@@ -202,7 +215,9 @@ fn helper(input: libc::c_int, messages: Receiver<Req>, _: ()) {
 
 impl Timer {
     pub fn new() -> IoResult<Timer> {
-        unsafe { HELPER.boot(|| {}, helper); }
+        // See notes above regarding using int return value
+        // instead of ()
+        unsafe { HELPER.boot(|| {0}, helper); }
 
         static mut ID: atomics::AtomicUint = atomics::INIT_ATOMIC_UINT;
         let id = unsafe { ID.fetch_add(1, atomics::Relaxed) };