Skip to content

Commit

Permalink
Auto merge of rust-lang#43972 - TobiasSchaffner:std_clean, r=alexcric…
Browse files Browse the repository at this point in the history
…hton

 Add the libstd-modifications needed for the L4Re target

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: c151220

In many aspects implementations for linux also apply for the L4Re microkernel.

Some uncommon characteristics had to be resolved:
 * L4Re has no network funktionality
 * L4Re has a maximum stacksize of 1Mb for threads
 * L4Re has no uid or gid

Co-authored-by: Sebastian Humenda <sebastian.humenda@tu-dresden.de>
  • Loading branch information
bors and Sebastian Humenda committed Sep 14, 2017
2 parents d1ca653 + b2b5063 commit 84bbd14
Show file tree
Hide file tree
Showing 20 changed files with 538 additions and 47 deletions.
2 changes: 1 addition & 1 deletion src/libstd/os/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 2 additions & 0 deletions src/libstd/os/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use fmt;
target_arch = "s390x")),
all(target_os = "android", any(target_arch = "aarch64",
target_arch = "arm")),
all(target_os = "l4re", target_arch = "x86_64"),
all(target_os = "fuchsia", target_arch = "aarch64")))]
#[stable(feature = "raw_os", since = "1.1.0")] pub type c_char = u8;
#[cfg(not(any(all(target_os = "linux", any(target_arch = "aarch64",
Expand All @@ -30,6 +31,7 @@ use fmt;
target_arch = "s390x")),
all(target_os = "android", any(target_arch = "aarch64",
target_arch = "arm")),
all(target_os = "l4re", target_arch = "x86_64"),
all(target_os = "fuchsia", target_arch = "aarch64"))))]
#[stable(feature = "raw_os", since = "1.1.0")] pub type c_char = i8;
#[stable(feature = "raw_os", since = "1.1.0")] pub type c_schar = i8;
Expand Down
2 changes: 2 additions & 0 deletions src/libstd/sys/redox/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ use sys_common::thread::start_thread;
use sys::{cvt, syscall};
use time::Duration;

pub const DEFAULT_MIN_STACK_SIZE: usize = 2 * 1024 * 1024;

pub struct Thread {
id: usize,
}
Expand Down
1 change: 1 addition & 0 deletions src/libstd/sys/unix/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down
10 changes: 8 additions & 2 deletions src/libstd/sys/unix/condvar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
11 changes: 11 additions & 0 deletions src/libstd/sys/unix/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";
}
2 changes: 2 additions & 0 deletions src/libstd/sys/unix/fd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
6 changes: 5 additions & 1 deletion src/libstd/sys/unix/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
Loading

0 comments on commit 84bbd14

Please sign in to comment.