Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Introduce restricted-std feature.
- Loading branch information
Showing
35 changed files
with
266 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use crate::alloc::{GlobalAlloc, Layout, System}; | ||
|
||
#[stable(feature = "alloc_system_type", since = "1.28.0")] | ||
unsafe impl GlobalAlloc for System { | ||
#[inline] | ||
unsafe fn alloc(&self, _layout: Layout) -> *mut u8 { | ||
0 as *mut u8 | ||
} | ||
|
||
#[inline] | ||
unsafe fn alloc_zeroed(&self, _layout: Layout) -> *mut u8 { | ||
0 as *mut u8 | ||
} | ||
|
||
#[inline] | ||
unsafe fn dealloc(&self, _ptr: *mut u8, _layout: Layout) {} | ||
|
||
#[inline] | ||
unsafe fn realloc(&self, _ptr: *mut u8, _layout: Layout, _new_size: usize) -> *mut u8 { | ||
0 as *mut u8 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use crate::ffi::OsString; | ||
|
||
pub unsafe fn init(_argc: isize, _argv: *const *const u8) {} | ||
pub unsafe fn cleanup() {} | ||
|
||
pub struct Args {} | ||
|
||
pub fn args() -> Args { | ||
Args {} | ||
} | ||
|
||
impl Args { | ||
pub fn inner_debug(&self) -> &[OsString] { | ||
&[] | ||
} | ||
} | ||
|
||
impl Iterator for Args { | ||
type Item = OsString; | ||
fn next(&mut self) -> Option<OsString> { | ||
None | ||
} | ||
fn size_hint(&self) -> (usize, Option<usize>) { | ||
(0, Some(0)) | ||
} | ||
} | ||
|
||
impl ExactSizeIterator for Args { | ||
fn len(&self) -> usize { | ||
0 | ||
} | ||
} | ||
|
||
impl DoubleEndedIterator for Args { | ||
fn next_back(&mut self) -> Option<OsString> { | ||
None | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
use crate::io as std_io; | ||
|
||
pub mod memchr { | ||
pub use core::slice::memchr::{memchr, memrchr}; | ||
} | ||
|
||
pub use crate::sys_common::os_str_bytes as os_str; | ||
|
||
// This is not necessarily correct. May want to consider making it part of the | ||
// spec definition? | ||
use crate::os::raw::c_char; | ||
|
||
#[cfg(not(test))] | ||
pub fn init() {} | ||
|
||
pub fn unsupported<T>() -> std_io::Result<T> { | ||
Err(unsupported_err()) | ||
} | ||
|
||
pub fn unsupported_err() -> std_io::Error { | ||
std_io::Error::new(std_io::ErrorKind::Other, "operation not supported on this platform") | ||
} | ||
|
||
pub fn decode_error_kind(_code: i32) -> crate::io::ErrorKind { | ||
crate::io::ErrorKind::Other | ||
} | ||
|
||
pub fn abort_internal() -> ! { | ||
core::intrinsics::abort(); | ||
} | ||
|
||
pub fn hashmap_random_keys() -> (u64, u64) { | ||
(1, 2) | ||
} | ||
|
||
// This enum is used as the storage for a bunch of types which can't actually | ||
// exist. | ||
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)] | ||
pub enum Void {} | ||
|
||
pub unsafe fn strlen(mut s: *const c_char) -> usize { | ||
let mut n = 0; | ||
while *s != 0 { | ||
n += 1; | ||
s = s.offset(1); | ||
} | ||
return n; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
pub mod os { | ||
pub const FAMILY: &str = ""; | ||
pub const OS: &str = ""; | ||
pub const DLL_PREFIX: &str = ""; | ||
pub const DLL_SUFFIX: &str = ""; | ||
pub const DLL_EXTENSION: &str = ""; | ||
pub const EXE_SUFFIX: &str = ""; | ||
pub const EXE_EXTENSION: &str = ""; | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
pub mod alloc; | ||
pub mod args; | ||
pub mod cmath; | ||
pub mod condvar; | ||
pub mod env; | ||
pub mod fs; | ||
pub mod io; | ||
pub mod mutex; | ||
pub mod net; | ||
pub mod os; | ||
pub mod path; | ||
pub mod pipe; | ||
pub mod process; | ||
pub mod rwlock; | ||
pub mod stack_overflow; | ||
pub mod stdio; | ||
pub mod thread; | ||
#[cfg(target_thread_local)] | ||
pub mod thread_local_dtor; | ||
pub mod thread_local_key; | ||
pub mod time; | ||
|
||
mod common; | ||
pub use common::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use super::{unsupported, Void}; | ||
use crate::ffi::CStr; | ||
use crate::io; | ||
use crate::time::Duration; | ||
|
||
pub struct Thread(Void); | ||
|
||
pub const DEFAULT_MIN_STACK_SIZE: usize = 4096; | ||
|
||
impl Thread { | ||
// unsafe: see thread::Builder::spawn_unchecked for safety requirements | ||
pub unsafe fn new(_stack: usize, _p: Box<dyn FnOnce()>) -> io::Result<Thread> { | ||
unsupported() | ||
} | ||
|
||
pub fn yield_now() { | ||
// do nothing | ||
} | ||
|
||
pub fn set_name(_name: &CStr) { | ||
// nope | ||
} | ||
|
||
pub fn sleep(_dur: Duration) { | ||
panic!("can't sleep"); | ||
} | ||
|
||
pub fn join(self) { | ||
match self.0 {} | ||
} | ||
} | ||
|
||
pub mod guard { | ||
pub type Guard = !; | ||
pub unsafe fn current() -> Option<Guard> { | ||
None | ||
} | ||
pub unsafe fn init() -> Option<Guard> { | ||
None | ||
} | ||
} |
File renamed without changes.
Oops, something went wrong.