delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1997/09/02/10:17:43

Message-Id: <199709021417.KAA11308@delorie.com>
From: Oberhumer Markus <k3040e4 AT c210 DOT edvz DOT uni-linz DOT ac DOT at>
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

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019