From 517e86dfe6755cd41d72f1c6eadfaf43b0ad3887 Mon Sep 17 00:00:00 2001 From: Raph Levien Date: Tue, 11 Oct 2016 15:26:47 -0700 Subject: [PATCH 1/4] Add support for Fuchsia These patches add support for the Fuchsia operating system. For the time being, it shares a lot of infrastructure with the Linux target, because of the use of a musl-based libc. --- src/unix/mod.rs | 8 +++++++- src/unix/notbsd/linux/mod.rs | 1 + src/unix/notbsd/mod.rs | 5 +++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/unix/mod.rs b/src/unix/mod.rs index e31920d512fbd..fa485ecd5f81d 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -228,6 +228,11 @@ cfg_if! { #[link(name = "root")] #[link(name = "network")] extern {} + } else if #[cfg(target_os = "fuchsia")] { + #[link(name = "c")] + #[link(name = "mxio")] + #[link(name = "unwind")] + extern {} } else { #[link(name = "c")] #[link(name = "m")] @@ -843,7 +848,8 @@ extern { cfg_if! { if #[cfg(any(target_os = "linux", target_os = "android", - target_os = "emscripten"))] { + target_os = "emscripten", + target_os = "fuchsia"))] { mod notbsd; pub use self::notbsd::*; } else if #[cfg(any(target_os = "macos", diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index ea820ea5c6c2c..f1cccad637911 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -728,6 +728,7 @@ extern { cfg_if! { if #[cfg(any(target_env = "musl", + target_os = "fuchsia", target_os = "emscripten"))] { mod musl; pub use self::musl::*; diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index 343c312674091..2ccb4fe593e02 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -53,7 +53,7 @@ s! { pub ai_protocol: ::c_int, pub ai_addrlen: socklen_t, - #[cfg(any(target_os = "linux", target_os = "emscripten"))] + #[cfg(any(target_os = "linux", target_os = "emscripten", target_os = "fuchsia"))] pub ai_addr: *mut ::sockaddr, pub ai_canonname: *mut c_char, @@ -858,7 +858,8 @@ extern { cfg_if! { if #[cfg(any(target_os = "linux", - target_os = "emscripten"))] { + target_os = "emscripten", + target_os = "fuchsia"))] { mod linux; pub use self::linux::*; } else if #[cfg(target_os = "android")] { From 6d24c4be08c6e25ed559d0f8c369727f4630518a Mon Sep 17 00:00:00 2001 From: Raph Levien Date: Thu, 20 Oct 2016 09:53:42 -0700 Subject: [PATCH 2/4] Remove unwind from link libs The reference to the unwind lib belongs in libstd, not here. Also fix lint error. --- src/unix/mod.rs | 1 - src/unix/notbsd/mod.rs | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/unix/mod.rs b/src/unix/mod.rs index fa485ecd5f81d..3e03eea675232 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -231,7 +231,6 @@ cfg_if! { } else if #[cfg(target_os = "fuchsia")] { #[link(name = "c")] #[link(name = "mxio")] - #[link(name = "unwind")] extern {} } else { #[link(name = "c")] diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index 2ccb4fe593e02..d11202b7b7003 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -53,7 +53,9 @@ s! { pub ai_protocol: ::c_int, pub ai_addrlen: socklen_t, - #[cfg(any(target_os = "linux", target_os = "emscripten", target_os = "fuchsia"))] + #[cfg(any(target_os = "linux", + target_os = "emscripten", + target_os = "fuchsia"))] pub ai_addr: *mut ::sockaddr, pub ai_canonname: *mut c_char, From 7ac91c6d01e841e75134225aadac0e4bbe704399 Mon Sep 17 00:00:00 2001 From: Raph Levien Date: Thu, 20 Oct 2016 15:28:06 -0700 Subject: [PATCH 3/4] Simplify configuration of ai_addr Merge two separate config blocks for conditionally including ai_addr in the addrinfo struct for unix/notbsd. --- src/unix/notbsd/mod.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index d11202b7b7003..7c07cd78da560 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -54,15 +54,13 @@ s! { pub ai_addrlen: socklen_t, #[cfg(any(target_os = "linux", + target_os = "android", target_os = "emscripten", target_os = "fuchsia"))] pub ai_addr: *mut ::sockaddr, pub ai_canonname: *mut c_char, - #[cfg(target_os = "android")] - pub ai_addr: *mut ::sockaddr, - pub ai_next: *mut addrinfo, } From 8c06e14b68bd0b11a831b06c525116702799d358 Mon Sep 17 00:00:00 2001 From: Raph Levien Date: Thu, 20 Oct 2016 18:22:43 -0700 Subject: [PATCH 4/4] Revert "Simplify configuration of ai_addr" This reverts commit 7ac91c6d01e841e75134225aadac0e4bbe704399. --- src/unix/notbsd/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index 7c07cd78da560..d11202b7b7003 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -54,13 +54,15 @@ s! { pub ai_addrlen: socklen_t, #[cfg(any(target_os = "linux", - target_os = "android", target_os = "emscripten", target_os = "fuchsia"))] pub ai_addr: *mut ::sockaddr, pub ai_canonname: *mut c_char, + #[cfg(target_os = "android")] + pub ai_addr: *mut ::sockaddr, + pub ai_next: *mut addrinfo, }