Mail Archives: djgpp-workers/1997/09/02/10:17:43
Subject: 970831: stackvail() patches
> There were multiple stackavail candidates, none of them "complete".
No, it was just one candiate. "Complete" patches follow.
Markus
##### DIFF: include/stdlib.h #####
*** stdlib.org Thu Sep 26 19:24:50 1996
--- stdlib.h Tue Sep 2 14:43:46 1997
***************
*** 96,99 ****
--- 96,106 ----
#endif
+ extern __inline__ int stackavail(void)
+ {
+ extern unsigned __djgpp_stack_limit; unsigned sp;
+ __asm__ __volatile__ ("movl %%esp,%k0\n" : "=r" (sp) : );
+ return (int) (sp - __djgpp_stack_limit);
+ }
+
/* BSD Random Number Generator */
char * initstate (unsigned _seed, char *_arg_state, int _n);
##### FILE: src/libc/compat/stkavail.c #####
/* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */
/* Do *not* include <stdlib.h> in this special case */
/* #include <stdlib.h> */
/* make return value signed, just in case we already overflowed the stack */
int stackavail(void)
{
extern unsigned __djgpp_stack_limit;
unsigned sp;
__asm__ __volatile__ ("movl %%esp,%k0\n" : "=r" (sp) : );
return (int) (sp - __djgpp_stack_limit);
}
##### FILE: src/libc/compat/stkavail.txh #####
@node stackavail, memory
@subheading Syntax
@example
#include <stdlib.h>
int stackavail(void);
@end example
@subheading Description
This function returns the number of bytes that are available on the stack.
@subheading Example
@example
printf("Available stack size is %d bytes\n", stackavail());
@end example
##### DIFF: src/libc/compat/makefile #####
*** makefile.org Sat Sep 30 21:40:42 1995
--- makefile Tue Sep 2 14:48:26 1997
***************
*** 9,12 ****
--- 9,13 ----
SRC += putenv.c
SRC += random.c
+ SRC += stkavail.c
SRC += swab.c
SRC += xfree.c
- Raw text -