-
-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
206b2af
commit 4561833
Showing
10 changed files
with
79 additions
and
59 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
use lightproc::prelude::*; | ||
|
||
fn main() { | ||
LightProc::<()>::new() | ||
.with_future(async move { println!("test"); }); | ||
LightProc::<()>::new().with_future(async move { | ||
println!("test"); | ||
}); | ||
} |
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 |
---|---|---|
@@ -1,29 +1,31 @@ | ||
use std::alloc::{Layout, LayoutErr}; | ||
use std::alloc::Layout; | ||
use std::io::{Error, ErrorKind}; | ||
|
||
#[inline] | ||
pub fn extend(layout: Layout, next: Layout) -> (Layout, usize) { | ||
let new_align = std::cmp::max(layout.align(), next.align()); | ||
let pad = padding_needed_for(layout, next.align()); | ||
|
||
let offset = layout.size().checked_add(pad) | ||
.ok_or( | ||
Error::new(ErrorKind::Other, "Padding overflow check failed") | ||
).unwrap(); | ||
let new_size = offset.checked_add(next.size()) | ||
.ok_or( | ||
Error::new(ErrorKind::Other, "New size can't be computed") | ||
).unwrap(); | ||
let offset = layout | ||
.size() | ||
.checked_add(pad) | ||
.ok_or(Error::new( | ||
ErrorKind::Other, | ||
"Padding overflow check failed", | ||
)) | ||
.unwrap(); | ||
let new_size = offset | ||
.checked_add(next.size()) | ||
.ok_or(Error::new(ErrorKind::Other, "New size can't be computed")) | ||
.unwrap(); | ||
|
||
let layout = | ||
Layout::from_size_align(new_size, new_align).unwrap(); | ||
let layout = Layout::from_size_align(new_size, new_align).unwrap(); | ||
(layout, offset) | ||
} | ||
|
||
#[inline] | ||
pub fn padding_needed_for(layout: Layout, align: usize) -> usize { | ||
let len = layout.size(); | ||
let len_rounded_up = len.wrapping_add(align).wrapping_sub(1) | ||
& !align.wrapping_sub(1); | ||
let len_rounded_up = len.wrapping_add(align).wrapping_sub(1) & !align.wrapping_sub(1); | ||
len_rounded_up.wrapping_sub(len) | ||
} |
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 |
---|---|---|
@@ -1,18 +1,18 @@ | ||
use std::alloc::Layout; | ||
use crate::stack::ProcStack; | ||
use rustc_hash::FxHashMap; | ||
use std::alloc::Layout; | ||
|
||
#[derive(Clone)] | ||
pub struct ProcLayout { | ||
pub layout: Layout, | ||
pub offset_table: FxHashMap<&'static str, usize> | ||
pub offset_table: FxHashMap<&'static str, usize>, | ||
} | ||
|
||
impl Default for ProcLayout { | ||
fn default() -> Self { | ||
ProcLayout { | ||
layout: Layout::new::<ProcStack>(), | ||
offset_table: FxHashMap::default() | ||
offset_table: FxHashMap::default(), | ||
} | ||
} | ||
} |
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 @@ | ||
|