Add modifications needed for L4re in libstd
This commit adds the needed modifications to compile the std crate for the L4 Runtime environment (L4Re). A target for the L4Re was introduced in commit: c151220a84e40b65e45308cc0f3bbea4466d3acf In many aspects implementations for linux also apply for the L4Re microkernel. Two uncommon characteristics had to be resolved: * L4Re has no network funktionality * L4Re has a maximum stacksize of 1Mb for threads Co-authored-by: Sebastian Humenda <sebastian.humenda@tu-dresden.de>
This commit is contained in:
parent
2cf0a4ad46
commit
9bbc6dbde3
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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::*;
|
||||
|
@ -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();
|
||||
|
@ -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 = "";
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
|
@ -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<PathBuf> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "fuchsia")]
|
||||
#[cfg(any(target_os = "fuchsia", target_os = "l4re"))]
|
||||
pub fn current_exe() -> io::Result<PathBuf> {
|
||||
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 {
|
||||
|
@ -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<usize> {
|
||||
let mut ret = None;
|
||||
let mut attr: libc::pthread_attr_t = ::mem::zeroed();
|
||||
|
@ -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")]
|
||||
|
Loading…
x
Reference in New Issue
Block a user