File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change
1
+ #ifndef RUST_STACK_H
2
+ #define RUST_STACK_H
3
+
1
4
struct stk_seg {
2
5
stk_seg *prev;
3
6
stk_seg *next;
@@ -10,6 +13,19 @@ struct stk_seg {
10
13
uint8_t data[];
11
14
};
12
15
16
+ template <class T >
17
+ stk_seg *
18
+ create_stack (T allocer, size_t sz) {
19
+ size_t total_sz = sizeof (stk_seg) + sz;
20
+ return (stk_seg *)allocer->malloc (total_sz, " stack" );
21
+ }
22
+
23
+ template <class T >
24
+ void
25
+ destroy_stack (T allocer, stk_seg *stk) {
26
+ allocer->free (stk);
27
+ }
28
+
13
29
void
14
30
config_valgrind_stack (stk_seg *stk);
15
31
@@ -21,3 +37,5 @@ add_stack_canary(stk_seg *stk);
21
37
22
38
void
23
39
check_stack_canary (stk_seg *stk);
40
+
41
+ #endif /* RUST_STACK_H */
Original file line number Diff line number Diff line change 538
538
rust_task::free_stack (stk_seg *stk) {
539
539
LOGPTR (thread, " freeing stk segment" , (uintptr_t )stk);
540
540
total_stack_sz -= user_stack_size (stk);
541
- free ( stk);
541
+ destroy_stack ( this , stk);
542
542
}
543
543
544
544
void
@@ -581,8 +581,8 @@ rust_task::new_stack(size_t requested_sz) {
581
581
fail ();
582
582
}
583
583
584
- size_t sz = sizeof (stk_seg) + rust_stk_sz + RED_ZONE_SIZE;
585
- stk_seg *new_stk = (stk_seg *) malloc (sz, " stack " );
584
+ size_t sz = rust_stk_sz + RED_ZONE_SIZE;
585
+ stk_seg *new_stk = create_stack ( this , sz );
586
586
LOGPTR (thread, " new stk" , (uintptr_t )new_stk);
587
587
memset (new_stk, 0 , sizeof (stk_seg));
588
588
add_stack_canary (new_stk);
You can’t perform that action at this time.
0 commit comments