-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Add std
support for armv7a-vex-v5
#145973
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Tropix126
wants to merge
24
commits into
rust-lang:master
Choose a base branch
from
vexide:vex-std
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
29a29f8
wip: port some old std work
lewisfm 75569a6
vexos: move fs and stdio into respective modules
Tropix126 02ba7f3
vexos: implement global dlmalloc fallback
Tropix126 38a4fc8
vexos: finish bringing modules up to date
Tropix126 d01ce78
vexos: provide `dlmalloc::Allocator` implementation
Tropix126 26f0a65
vexos: block on stdout writes with size>2048
Tropix126 2d29e16
bump to vex-sdk 0.27.0
Tropix126 63dc910
vexos: simplify logic by casting `count` to usize early
Tropix126 02af5a3
vexos: remove accidental semicolon
Tropix126 041877e
vexos: fix file opening logic
Tropix126 330b4f1
vexos: improve error message when opening files in RW mode
Tropix126 bb9cf5d
vexos: fix logic regarding `create` and `create_new`
Tropix126 d7497ff
update `armv7a-vex-v5` target documentation
Tropix126 9da82f3
clarify details regarding system ABI, fix typos
Tropix126 964b521
simplify `vexFileStatus` check in `fs::exists`
Tropix126 645cad6
remove unnecessary allocator lock on VEXos
Tropix126 e270713
switch to `run_path_with_cstr` for path conversion
Tropix126 7513b28
vexos: refactor `FileAttr`, clean up `open` logic
Tropix126 3669261
vexos: improve unsafe hygiene in alloc and PAL, fix fs issues
Tropix126 2521f24
re-export relevant items from `unsupported` in vexos modules
Tropix126 b12dee6
fix type incompatibilities from `unsupported` re-exports
Tropix126 270ff62
Resolve std warnings on VEXos
lewisfm e08dea6
impl Send/Sync for VEXos files
lewisfm 63b2758
vexos: move `thread` from `sys::pal` to `sys::thread`
Tropix126 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Tropix126 marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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,96 @@ | ||
// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint | ||
#![allow(static_mut_refs)] | ||
|
||
use crate::alloc::{GlobalAlloc, Layout, System}; | ||
use crate::ptr; | ||
use crate::sync::atomic::{AtomicBool, Ordering}; | ||
|
||
// Symbols for heap section boundaries defined in the target's linkerscript | ||
unsafe extern "C" { | ||
static mut __heap_start: u8; | ||
static mut __heap_end: u8; | ||
} | ||
|
||
static mut DLMALLOC: dlmalloc::Dlmalloc<Vexos> = dlmalloc::Dlmalloc::new_with_allocator(Vexos); | ||
Tropix126 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
struct Vexos; | ||
|
||
unsafe impl dlmalloc::Allocator for Vexos { | ||
/// Allocs system resources | ||
fn alloc(&self, _size: usize) -> (*mut u8, usize, u32) { | ||
static INIT: AtomicBool = AtomicBool::new(false); | ||
|
||
if !INIT.swap(true, Ordering::Relaxed) { | ||
// This target has no growable heap, as user memory has a fixed | ||
// size/location and VEXos does not manage allocation for us. | ||
unsafe { | ||
( | ||
(&raw mut __heap_start).cast::<u8>(), | ||
(&raw const __heap_end).offset_from_unsigned(&raw const __heap_start), | ||
0, | ||
) | ||
} | ||
} else { | ||
(ptr::null_mut(), 0, 0) | ||
} | ||
} | ||
|
||
fn remap(&self, _ptr: *mut u8, _oldsize: usize, _newsize: usize, _can_move: bool) -> *mut u8 { | ||
ptr::null_mut() | ||
} | ||
|
||
fn free_part(&self, _ptr: *mut u8, _oldsize: usize, _newsize: usize) -> bool { | ||
false | ||
} | ||
|
||
fn free(&self, _ptr: *mut u8, _size: usize) -> bool { | ||
return false; | ||
} | ||
|
||
fn can_release_part(&self, _flags: u32) -> bool { | ||
false | ||
} | ||
|
||
fn allocates_zeros(&self) -> bool { | ||
false | ||
} | ||
|
||
fn page_size(&self) -> usize { | ||
0x1000 | ||
} | ||
} | ||
|
||
#[stable(feature = "alloc_system_type", since = "1.28.0")] | ||
unsafe impl GlobalAlloc for System { | ||
#[inline] | ||
unsafe fn alloc(&self, layout: Layout) -> *mut u8 { | ||
// SAFETY: DLMALLOC access is guaranteed to be safe because we are a single-threaded target, which | ||
// guarantees unique and non-reentrant access to the allocator. As such, no allocator lock is used. | ||
// Calling malloc() is safe because preconditions on this function match the trait method preconditions. | ||
unsafe { DLMALLOC.malloc(layout.size(), layout.align()) } | ||
} | ||
|
||
#[inline] | ||
unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 { | ||
// SAFETY: DLMALLOC access is guaranteed to be safe because we are a single-threaded target, which | ||
// guarantees unique and non-reentrant access to the allocator. As such, no allocator lock is used. | ||
// Calling calloc() is safe because preconditions on this function match the trait method preconditions. | ||
unsafe { DLMALLOC.calloc(layout.size(), layout.align()) } | ||
} | ||
|
||
#[inline] | ||
unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { | ||
// SAFETY: DLMALLOC access is guaranteed to be safe because we are a single-threaded target, which | ||
// guarantees unique and non-reentrant access to the allocator. As such, no allocator lock is used. | ||
// Calling free() is safe because preconditions on this function match the trait method preconditions. | ||
unsafe { DLMALLOC.free(ptr, layout.size(), layout.align()) } | ||
} | ||
|
||
#[inline] | ||
unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 { | ||
// SAFETY: DLMALLOC access is guaranteed to be safe because we are a single-threaded target, which | ||
// guarantees unique and non-reentrant access to the allocator. As such, no allocator lock is used. | ||
// Calling realloc() is safe because preconditions on this function match the trait method preconditions. | ||
unsafe { DLMALLOC.realloc(ptr, layout.size(), layout.align(), new_size) } | ||
} | ||
} |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.