/* * By Ronald E. Jacobs. * For Allen Holub's C for Professionals class. * October 22, 1990. * Homework 5. * File name: framesize(x). * What it does: Returns the size of its own stack frame in bytes. * How it does it: Assumes that the size of the stack frame is the same as * the number of bytes from a local variable in the stack frame to the * same local variable in an identical contiguous stack frame. To get * identical contiguous stack frames, framesize() calls itself. A type * char variable is used so that the difference between the local * variable in the two stack frames will be measured in bytes. */ #include main() { printf("The stack frame length of framesize() is "); printf("%d bytes\n", framesize(0)); return; } /*--------------------------------------------------------------------*/ #include "types.h" framesize(mark) paddr_t mark; /* Caller must pass mark=0 */ { return(mark ? (mark - (paddr_t)&mark) : (framesize(&mark))); }