Stack example.
static char altstack[0x1000];
static char altstack2[0x1000];
static void vf0() noexcept {}
static int f0() noexcept
{
return 1;
}
static void vf1(int i) noexcept
{
printf("%d\n", i);
}
static int f1(int ) noexcept
{
return 1;
}
static void vf2(int i, double d) noexcept
{
printf("%d %d\n", i, (int)(d * 100.0));
}
static int f2(int , double ) noexcept
{
return 1;
}
static void vf3(int i, double d, void* p) noexcept
{
printf("%d %d %p\n", i, (int)(d * 100.0), p);
}
static int f3(int , double , void* ) noexcept
{
return 1;
}
#if __cplusplus >= 201103L
static void vf4(int i, double d, void* p, int i2) noexcept
{
printf("%d %d %p %d\n", i, (int)(d * 100.0), p, i2);
}
static int f4(int , double , void* , int ) noexcept
{
return 1;
}
#endif
static void example_stack_switch()
{
vf0();
#if __cplusplus >= 201103L
#endif
}
static void overflow2(int i) noexcept
{
printf("overflow %d\n", i);
overflow2(i + 1);
}
static void overflow1(int i) noexcept
{
}
static void example_stack_overflow()
{
}
{
example_stack_switch();
example_stack_overflow();
return 0;
}
int main_fiber(int argc, char **argv)
std::enable_if<!std::is_void< R >::value, R >::type stack_switch(void *stack, size_t size, R(*f)(A...) noexcept, A_ &&... a) noexcept
Call the function f using the new stack pointer.
void stack_watermark_init(void *stack, size_t size) noexcept
Initialize the memory region for stack high water marking.
size_t stack_watermark_maxused(void *stack) noexcept
Return the high water mark of the stack.