Mail Archives: djgpp-workers/1997/04/14/18:12:57
Thanks for your feedback. After investigating src/libc/crt0/crt0.s I've
come to the following solution which works fine on my machine.
It looks pretty simple, though, so is there something I might have missed ?
/* make return value signed, just in case we already overflowed the stack */
extern __inline__ int _stackavail(void)
{
extern unsigned __djgpp_stack_limit;
unsigned sp;
__asm__ __volatile__ ("movl %%esp,%k0\n" : "=r" (sp) : );
return sp - __djgpp_stack_limit;
}
#ifdef TEST
/* compile with 'gcc -Wall -O2' */
#include <stdio.h>
#include <stdlib.h>
extern int _stklen;
int main()
{
printf("stack: %d total, %d available\n", _stklen, _stackavail());
return 0;
}
#endif
- Raw text -