-
Notifications
You must be signed in to change notification settings - Fork 13.7k
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
19
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.
+1,103
−10
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
c14c598
wip: port some old std work
lewisfm 7d1a5d5
vexos: move fs and stdio into respective modules
Tropix126 7dd7c4f
vexos: implement global dlmalloc fallback
Tropix126 7881f7d
vexos: finish bringing modules up to date
Tropix126 e8a6eeb
vexos: provide `dlmalloc::Allocator` implementation
Tropix126 3e9c48f
vexos: block on stdout writes with size>2048
Tropix126 14cce89
format, tidy
Tropix126 0c35573
bump to vex-sdk 0.27.0
Tropix126 a37c5a5
vexos: simplify logic by casting `count` to usize early
Tropix126 b7fd4ee
vexos: remove accidental semicolon
Tropix126 084c4b7
vexos: fix file opening logic
Tropix126 81429d9
vexos: improve error message when opening files in RW mode
Tropix126 5b78b10
vexos: fix logic regarding `create` and `create_new`
Tropix126 1e05bd4
update `armv7a-vex-v5` target documentation
Tropix126 b07ef19
clarify details regarding system ABI, fix typos
Tropix126 ba50a09
simplify `vexFileStatus` check in `fs::exists`
Tropix126 8a60e4f
remove unnecessary allocator lock on VEXos
Tropix126 bf8ba13
fmt
Tropix126 08829c2
switch to `run_path_with_cstr` for path conversion
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
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,94 @@ | ||
// 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 defined in the target 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) { | ||
unsafe { | ||
( | ||
(&raw mut __heap_start).cast(), | ||
(&raw const __heap_end).byte_offset_from(ptr::addr_of!(__heap_start)) as _, | ||
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. | ||
// 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. | ||
// 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. | ||
// 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. | ||
// 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.