Skip to content

Commit 84bbd14

Browse files
borsSebastian Humenda
and
Sebastian Humenda
committed
Auto merge of #43972 - TobiasSchaffner:std_clean, r=alexcrichton
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 <[email protected]>
2 parents d1ca653 + b2b5063 commit 84bbd14

File tree

20 files changed

+538
-47
lines changed

20 files changed

+538
-47
lines changed

src/libstd/os/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub use sys::unix_ext as unix;
2727
#[stable(feature = "rust1", since = "1.0.0")]
2828
pub use sys::windows_ext as windows;
2929

30-
#[cfg(any(dox, target_os = "linux"))]
30+
#[cfg(any(dox, target_os = "linux", target_os = "l4re"))]
3131
#[doc(cfg(target_os = "linux"))]
3232
pub mod linux;
3333

src/libstd/os/raw.rs

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use fmt;
2121
target_arch = "s390x")),
2222
all(target_os = "android", any(target_arch = "aarch64",
2323
target_arch = "arm")),
24+
all(target_os = "l4re", target_arch = "x86_64"),
2425
all(target_os = "fuchsia", target_arch = "aarch64")))]
2526
#[stable(feature = "raw_os", since = "1.1.0")] pub type c_char = u8;
2627
#[cfg(not(any(all(target_os = "linux", any(target_arch = "aarch64",
@@ -30,6 +31,7 @@ use fmt;
3031
target_arch = "s390x")),
3132
all(target_os = "android", any(target_arch = "aarch64",
3233
target_arch = "arm")),
34+
all(target_os = "l4re", target_arch = "x86_64"),
3335
all(target_os = "fuchsia", target_arch = "aarch64"))))]
3436
#[stable(feature = "raw_os", since = "1.1.0")] pub type c_char = i8;
3537
#[stable(feature = "raw_os", since = "1.1.0")] pub type c_schar = i8;

src/libstd/sys/redox/thread.rs

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ use sys_common::thread::start_thread;
1616
use sys::{cvt, syscall};
1717
use time::Duration;
1818

19+
pub const DEFAULT_MIN_STACK_SIZE: usize = 2 * 1024 * 1024;
20+
1921
pub struct Thread {
2022
id: usize,
2123
}

src/libstd/sys/unix/args.rs

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ impl DoubleEndedIterator for Args {
6565
target_os = "solaris",
6666
target_os = "emscripten",
6767
target_os = "haiku",
68+
target_os = "l4re",
6869
target_os = "fuchsia"))]
6970
mod imp {
7071
use os::unix::prelude::*;

src/libstd/sys/unix/condvar.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,16 @@ impl Condvar {
3838
Condvar { inner: UnsafeCell::new(libc::PTHREAD_COND_INITIALIZER) }
3939
}
4040

41-
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "android"))]
41+
#[cfg(any(target_os = "macos",
42+
target_os = "ios",
43+
target_os = "l4re",
44+
target_os = "android"))]
4245
pub unsafe fn init(&mut self) {}
4346

44-
#[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "android")))]
47+
#[cfg(not(any(target_os = "macos",
48+
target_os = "ios",
49+
target_os = "l4re",
50+
target_os = "android")))]
4551
pub unsafe fn init(&mut self) {
4652
use mem;
4753
let mut attr: libc::pthread_condattr_t = mem::uninitialized();

src/libstd/sys/unix/env.rs

+11
Original file line numberDiff line numberDiff line change
@@ -182,3 +182,14 @@ pub mod os {
182182
pub const EXE_SUFFIX: &'static str = "";
183183
pub const EXE_EXTENSION: &'static str = "";
184184
}
185+
186+
#[cfg(target_os = "l4re")]
187+
pub mod os {
188+
pub const FAMILY: &'static str = "unix";
189+
pub const OS: &'static str = "l4re";
190+
pub const DLL_PREFIX: &'static str = "lib";
191+
pub const DLL_SUFFIX: &'static str = ".so";
192+
pub const DLL_EXTENSION: &'static str = "so";
193+
pub const EXE_SUFFIX: &'static str = "";
194+
pub const EXE_EXTENSION: &'static str = "";
195+
}

src/libstd/sys/unix/fd.rs

+2
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ impl FileDesc {
144144
target_os = "solaris",
145145
target_os = "emscripten",
146146
target_os = "fuchsia",
147+
target_os = "l4re",
147148
target_os = "haiku")))]
148149
pub fn set_cloexec(&self) -> io::Result<()> {
149150
unsafe {
@@ -155,6 +156,7 @@ impl FileDesc {
155156
target_os = "solaris",
156157
target_os = "emscripten",
157158
target_os = "fuchsia",
159+
target_os = "l4re",
158160
target_os = "haiku"))]
159161
pub fn set_cloexec(&self) -> io::Result<()> {
160162
unsafe {

src/libstd/sys/unix/fs.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,21 @@ use sys::time::SystemTime;
2323
use sys::{cvt, cvt_r};
2424
use sys_common::{AsInner, FromInner};
2525

26-
#[cfg(any(target_os = "linux", target_os = "emscripten"))]
26+
#[cfg(any(target_os = "linux", target_os = "emscripten", target_os = "l4re"))]
2727
use libc::{stat64, fstat64, lstat64, off64_t, ftruncate64, lseek64, dirent64, readdir64_r, open64};
2828
#[cfg(target_os = "android")]
2929
use libc::{stat as stat64, fstat as fstat64, lstat as lstat64, lseek64,
3030
dirent as dirent64, open as open64};
3131
#[cfg(not(any(target_os = "linux",
3232
target_os = "emscripten",
33+
target_os = "l4re",
3334
target_os = "android")))]
3435
use libc::{stat as stat64, fstat as fstat64, lstat as lstat64, off_t as off64_t,
3536
ftruncate as ftruncate64, lseek as lseek64, dirent as dirent64, open as open64};
3637
#[cfg(not(any(target_os = "linux",
3738
target_os = "emscripten",
3839
target_os = "solaris",
40+
target_os = "l4re",
3941
target_os = "fuchsia")))]
4042
use libc::{readdir_r as readdir64_r};
4143

@@ -316,6 +318,7 @@ impl DirEntry {
316318
target_os = "android",
317319
target_os = "solaris",
318320
target_os = "haiku",
321+
target_os = "l4re",
319322
target_os = "fuchsia"))]
320323
pub fn ino(&self) -> u64 {
321324
self.entry.d_ino as u64
@@ -346,6 +349,7 @@ impl DirEntry {
346349
#[cfg(any(target_os = "android",
347350
target_os = "linux",
348351
target_os = "emscripten",
352+
target_os = "l4re",
349353
target_os = "haiku"))]
350354
fn name_bytes(&self) -> &[u8] {
351355
unsafe {

0 commit comments

Comments
 (0)