I’m working a lot with stack buffered allocators and they can get very large for my use case. I want to dynamically dispatch to heap memory at comptime if a requested buffer size is large enough to be compromising.
In C++, you have stuff like:
stackavail()
in C, you have this (can be used to find information about it):
#include <sys/resource.h>
int main (void)
{
struct rlimit limit;
getrlimit (RLIMIT_STACK, &limit);
printf ("\nStack Limit = %ld and %ld max\n", limit.rlim_cur, limit.rlim_max);
}
It doesn’t seem like it’d be possible to get this info at comptime, especially since setrlimit(.STACK, ...) is called in start.zig and can fail to change the stack size: