File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -63,12 +63,20 @@ fn set_stack_limit(l: usize) {
63
63
pub fn maybe_grow < R , F : FnOnce ( ) -> R > ( red_zone : usize ,
64
64
stack_size : usize ,
65
65
f : F ) -> R {
66
+ if remaining_stack ( ) >= red_zone {
67
+ f ( )
68
+ } else {
69
+ grow_the_stack ( stack_size, f)
70
+ }
71
+ }
72
+
73
+ /// Queries the amount of remaining stack as interpreted by this library.
74
+ ///
75
+ /// This function will return the amount of stack space left which will be used
76
+ /// to determine whether a stack switch should be made or not.
77
+ pub fn remaining_stack ( ) -> usize {
66
78
unsafe {
67
- if __stacker_stack_pointer ( ) - get_stack_limit ( ) >= red_zone {
68
- f ( )
69
- } else {
70
- grow_the_stack ( stack_size, f)
71
- }
79
+ __stacker_stack_pointer ( ) - get_stack_limit ( )
72
80
}
73
81
}
74
82
You can’t perform that action at this time.
0 commit comments