diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 433499a90a4..115adf6e3f9 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -466,6 +466,7 @@ pub mod error; pub mod ffi; pub mod fs; pub mod io; +#[cfg(not(target_os = "l4re"))] pub mod net; pub mod num; pub mod os; diff --git a/src/libstd/os/mod.rs b/src/libstd/os/mod.rs index 72eed549f62..b460bd90f17 100644 --- a/src/libstd/os/mod.rs +++ b/src/libstd/os/mod.rs @@ -27,7 +27,7 @@ pub use sys::unix_ext as unix; #[stable(feature = "rust1", since = "1.0.0")] pub use sys::windows_ext as windows; -#[cfg(any(dox, target_os = "linux"))] +#[cfg(any(dox, target_os = "linux", target_os = "l4re"))] #[doc(cfg(target_os = "linux"))] pub mod linux; diff --git a/src/libstd/sys/unix/args.rs b/src/libstd/sys/unix/args.rs index 810d2d40c05..72169773df5 100644 --- a/src/libstd/sys/unix/args.rs +++ b/src/libstd/sys/unix/args.rs @@ -65,6 +65,7 @@ impl DoubleEndedIterator for Args { target_os = "solaris", target_os = "emscripten", target_os = "haiku", + target_os = "l4re", target_os = "fuchsia"))] mod imp { use os::unix::prelude::*; diff --git a/src/libstd/sys/unix/condvar.rs b/src/libstd/sys/unix/condvar.rs index b9ea573b323..89a44b97657 100644 --- a/src/libstd/sys/unix/condvar.rs +++ b/src/libstd/sys/unix/condvar.rs @@ -38,10 +38,16 @@ impl Condvar { Condvar { inner: UnsafeCell::new(libc::PTHREAD_COND_INITIALIZER) } } - #[cfg(any(target_os = "macos", target_os = "ios", target_os = "android"))] + #[cfg(any(target_os = "macos", + target_os = "ios", + target_os = "l4re", + target_os = "android"))] pub unsafe fn init(&mut self) {} - #[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "android")))] + #[cfg(not(any(target_os = "macos", + target_os = "ios", + target_os = "l4re", + target_os = "android")))] pub unsafe fn init(&mut self) { use mem; let mut attr: libc::pthread_condattr_t = mem::uninitialized(); diff --git a/src/libstd/sys/unix/env.rs b/src/libstd/sys/unix/env.rs index eff3a8c2a34..3d9a06bedd5 100644 --- a/src/libstd/sys/unix/env.rs +++ b/src/libstd/sys/unix/env.rs @@ -182,3 +182,14 @@ pub mod os { pub const EXE_SUFFIX: &'static str = ""; pub const EXE_EXTENSION: &'static str = ""; } + +#[cfg(target_os = "l4re")] +pub mod os { + pub const FAMILY: &'static str = "unix"; + pub const OS: &'static str = "l4re"; + pub const DLL_PREFIX: &'static str = "lib"; + pub const DLL_SUFFIX: &'static str = ".so"; + pub const DLL_EXTENSION: &'static str = "so"; + pub const EXE_SUFFIX: &'static str = ""; + pub const EXE_EXTENSION: &'static str = ""; +} diff --git a/src/libstd/sys/unix/fd.rs b/src/libstd/sys/unix/fd.rs index f50b093acc8..5dafc3251e7 100644 --- a/src/libstd/sys/unix/fd.rs +++ b/src/libstd/sys/unix/fd.rs @@ -144,6 +144,7 @@ impl FileDesc { target_os = "solaris", target_os = "emscripten", target_os = "fuchsia", + target_os = "l4re", target_os = "haiku")))] pub fn set_cloexec(&self) -> io::Result<()> { unsafe { @@ -155,6 +156,7 @@ impl FileDesc { target_os = "solaris", target_os = "emscripten", target_os = "fuchsia", + target_os = "l4re", target_os = "haiku"))] pub fn set_cloexec(&self) -> io::Result<()> { unsafe { diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs index f94af491332..13112fc1fa5 100644 --- a/src/libstd/sys/unix/fs.rs +++ b/src/libstd/sys/unix/fs.rs @@ -23,19 +23,21 @@ use sys::time::SystemTime; use sys::{cvt, cvt_r}; use sys_common::{AsInner, FromInner}; -#[cfg(any(target_os = "linux", target_os = "emscripten"))] +#[cfg(any(target_os = "linux", target_os = "emscripten", target_os = "l4re"))] use libc::{stat64, fstat64, lstat64, off64_t, ftruncate64, lseek64, dirent64, readdir64_r, open64}; #[cfg(target_os = "android")] use libc::{stat as stat64, fstat as fstat64, lstat as lstat64, lseek64, dirent as dirent64, open as open64}; #[cfg(not(any(target_os = "linux", target_os = "emscripten", + target_os = "l4re", target_os = "android")))] use libc::{stat as stat64, fstat as fstat64, lstat as lstat64, off_t as off64_t, ftruncate as ftruncate64, lseek as lseek64, dirent as dirent64, open as open64}; #[cfg(not(any(target_os = "linux", target_os = "emscripten", target_os = "solaris", + target_os = "l4re", target_os = "fuchsia")))] use libc::{readdir_r as readdir64_r}; @@ -316,6 +318,7 @@ impl DirEntry { target_os = "android", target_os = "solaris", target_os = "haiku", + target_os = "l4re", target_os = "fuchsia"))] pub fn ino(&self) -> u64 { self.entry.d_ino as u64 @@ -346,6 +349,7 @@ impl DirEntry { #[cfg(any(target_os = "android", target_os = "linux", target_os = "emscripten", + target_os = "l4re", target_os = "haiku"))] fn name_bytes(&self) -> &[u8] { unsafe { diff --git a/src/libstd/sys/unix/mod.rs b/src/libstd/sys/unix/mod.rs index efa14964604..697e9b962b1 100644 --- a/src/libstd/sys/unix/mod.rs +++ b/src/libstd/sys/unix/mod.rs @@ -28,6 +28,7 @@ use libc; #[cfg(all(not(dox), target_os = "solaris"))] pub use os::solaris as platform; #[cfg(all(not(dox), target_os = "emscripten"))] pub use os::emscripten as platform; #[cfg(all(not(dox), target_os = "fuchsia"))] pub use os::fuchsia as platform; +#[cfg(all(not(dox), target_os = "l4re"))] pub use os::linux as platform; #[macro_use] pub mod weak; diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs index 8e41fd009be..5ef98d24710 100644 --- a/src/libstd/sys/unix/os.rs +++ b/src/libstd/sys/unix/os.rs @@ -38,7 +38,10 @@ static ENV_LOCK: Mutex = Mutex::new(); extern { #[cfg(not(target_os = "dragonfly"))] - #[cfg_attr(any(target_os = "linux", target_os = "emscripten", target_os = "fuchsia"), + #[cfg_attr(any(target_os = "linux", + target_os = "emscripten", + target_os = "fuchsia", + target_os = "l4re"), link_name = "__errno_location")] #[cfg_attr(any(target_os = "bitrig", target_os = "netbsd", @@ -346,10 +349,10 @@ pub fn current_exe() -> io::Result { } } -#[cfg(target_os = "fuchsia")] +#[cfg(any(target_os = "fuchsia", target_os = "l4re"))] pub fn current_exe() -> io::Result { use io::ErrorKind; - Err(io::Error::new(ErrorKind::Other, "Not yet implemented on fuchsia")) + Err(io::Error::new(ErrorKind::Other, "Not yet implemented!")) } pub struct Env { diff --git a/src/libstd/sys/unix/thread.rs b/src/libstd/sys/unix/thread.rs index 40f1d6a6db1..5e2610736a8 100644 --- a/src/libstd/sys/unix/thread.rs +++ b/src/libstd/sys/unix/thread.rs @@ -52,6 +52,11 @@ impl Thread { assert_eq!(libc::pthread_attr_init(&mut attr), 0); let stack_size = cmp::max(stack, min_stack_size(&attr)); + + // L4Re only supports a maximum of 1Mb per default. + #[cfg(target_os = "l4re")] + let stack_size = cmp::min(stack_size, 1024 * 1024); + match pthread_attr_setstacksize(&mut attr, stack_size) { 0 => {} @@ -131,6 +136,7 @@ impl Thread { #[cfg(any(target_env = "newlib", target_os = "solaris", target_os = "haiku", + target_os = "l4re", target_os = "emscripten"))] pub fn set_name(_name: &CStr) { // Newlib, Illumos, Haiku, and Emscripten have no way to set a thread name. @@ -226,7 +232,7 @@ pub mod guard { } #[cfg(any(target_os = "android", target_os = "freebsd", - target_os = "linux", target_os = "netbsd"))] + target_os = "linux", target_os = "netbsd", target_os = "l4re"))] unsafe fn get_stack_start() -> Option<*mut libc::c_void> { let mut ret = None; let mut attr: libc::pthread_attr_t = ::mem::zeroed(); @@ -328,7 +334,7 @@ pub mod guard { } #[cfg(any(target_os = "android", target_os = "freebsd", - target_os = "linux", target_os = "netbsd"))] + target_os = "linux", target_os = "netbsd", target_os = "l4re"))] pub unsafe fn current() -> Option { let mut ret = None; let mut attr: libc::pthread_attr_t = ::mem::zeroed(); diff --git a/src/libstd/sys_common/mod.rs b/src/libstd/sys_common/mod.rs index ccd4b91a7b7..ae8d280d576 100644 --- a/src/libstd/sys_common/mod.rs +++ b/src/libstd/sys_common/mod.rs @@ -47,7 +47,7 @@ pub mod wtf8; #[cfg(target_os = "redox")] pub use sys::net; -#[cfg(not(target_os = "redox"))] +#[cfg(not(any(target_os = "redox", target_os = "l4re")))] pub mod net; #[cfg(feature = "backtrace")]