Message-Id: <199709021417.KAA11308@delorie.com> From: Oberhumer Markus Subject: 970831: stackavail() patches To: dj AT delorie DOT com (DJ Delorie), djgpp-workers AT delorie DOT com (djgpp-workers) Date: Tue, 2 Sep 1997 16:11:14 +0200 (METDST) Return-Read-To: markus DOT oberhumer AT jk DOT uni-linz DOT ac DOT at Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk 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 in this special case */ /* #include */ /* 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 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