Take the 2-minute tour ×

I'm playing around with making an interpreter that does memory allocation in the style of Chicken Scheme. The basic idea is:

int main() {
    instruction instructions[] = { zero_root, print_root, hello_world,
                    hello_world, stop };

    top_ip.go = &instructions[0];



    return 0;
                                                          89,10-17      Bot


/* The following function is machine dependent */
static bool is_time_to_gc(){
    /* Is allocated on the stack */
    char stack_top;

    /* It's address is therefore the stack's top  */
    return &stack_top >= STACK_LIMIT;

static void goto_next_instruction(struct instruction_pointer ip) {

    if (is_time_to_gc()) {
             * Some complicated garbage collection stuff which I haven't
             * completed yet.

            top_ip.go = ip.go;
            longjmp(top, 0);


and a sample instruction is:

static void hello_world(struct instruction_pointer ip) {
    printf("Hello World!\n");


What I need to know is what the value for STACK_LIMIT should be (I also need to know if the stack grows up or downwards.) How can I get platform specific information on stack limits?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

man getrlimit. also check the limits imposed by your shell usually in /etc/login.conf (if it's an sh derivative you can view them by typing limit).

:) cheers.

share|improve this answer
add comment

Your Answer


