|
13 | 13 |
|
14 | 14 | #include "../include/yafl.h" |
15 | 15 |
|
| 16 | +#define TEST_STACK_TOUCH_COMPLETE 0x34 |
| 17 | +#define TEST_STACK_TOUCH_SUSPEND_BEFORE 0xC9 |
| 18 | +#define TEST_STACK_TOUCH_SUSPEND_AFTER 0x9C |
| 19 | + |
16 | 20 | static const char *alloc_name(yafl_stack_flags_t alloc_flag) { return alloc_flag == YAFL_STACK_FLAGS_VMEM ? "mmap" : "malloc"; } |
17 | 21 |
|
| 22 | +/* Force observable stack writes so YAFL's own watermark logic has real usage to measure. */ |
| 23 | +static void touch_volatile_stack_buffer(volatile unsigned char *buffer, size_t size, unsigned char value) { |
| 24 | + for(size_t index = 0; index < size; index++) { buffer[index] = value; } |
| 25 | +} |
| 26 | + |
18 | 27 | static void *complete_after_stack_use(void *arg) { |
19 | 28 | volatile unsigned char stack_buffer[1536]; |
20 | 29 |
|
21 | | - memset((void *)stack_buffer, (int)(uintptr_t)arg, sizeof(stack_buffer)); |
| 30 | + touch_volatile_stack_buffer(stack_buffer, sizeof(stack_buffer), TEST_STACK_TOUCH_COMPLETE); |
22 | 31 | return arg; |
23 | 32 | } |
24 | 33 |
|
25 | 34 | static void *suspend_after_stack_use(void *arg) { |
26 | 35 | volatile unsigned char stack_buffer[768]; |
27 | 36 |
|
28 | | - memset((void *)stack_buffer, 0x5A, sizeof(stack_buffer)); |
| 37 | + touch_volatile_stack_buffer(stack_buffer, sizeof(stack_buffer), TEST_STACK_TOUCH_SUSPEND_BEFORE); |
29 | 38 | arg = yafl_fiber_suspend(arg); |
30 | 39 |
|
31 | | - memset((void *)stack_buffer, 0xA5, sizeof(stack_buffer)); |
| 40 | + touch_volatile_stack_buffer(stack_buffer, sizeof(stack_buffer), TEST_STACK_TOUCH_SUSPEND_AFTER); |
32 | 41 | return arg; |
33 | 42 | } |
34 | 43 |
|
|
0 commit comments