mirror of
https://github.com/GnoConsortium/gno.git
synced 2025-01-02 23:31:56 +00:00
added a description and example of the _reportStack(3) routine
This commit is contained in:
parent
92ee492794
commit
1157a5530f
@ -1,8 +1,8 @@
|
||||
.\" Man page by Devin Reade.
|
||||
.\"
|
||||
.\" $Id: stack.3,v 1.2 1997/12/08 15:39:11 gdr Exp $
|
||||
.\" $Id: stack.3,v 1.3 1998/03/28 16:47:51 gdr-ftp Exp $
|
||||
.\"
|
||||
.TH STACK 3 "11 December 1996" GNO "Library Routines"
|
||||
.TH STACK 3 "26 March 1998" GNO "Library Routines"
|
||||
.SH NAME
|
||||
.BR _beginStackCheck ,
|
||||
.BR _endStackCheck
|
||||
@ -18,6 +18,8 @@ void \fB_beginStackCheck\fR (void);
|
||||
int \fB_endStackCheck\fR (void);
|
||||
.br
|
||||
unsigned int \fB_getStackBottom\fR (void);
|
||||
.br
|
||||
void \fB_reportStack\fR (void);
|
||||
.SH DESCRIPTION
|
||||
The
|
||||
.BR _beginStackCheck
|
||||
@ -40,6 +42,19 @@ flag, or the
|
||||
.I stacksize
|
||||
pragma for ORCA/C.
|
||||
.LP
|
||||
Since the procedure used by most programs is to call
|
||||
.BR _beginStackCheck
|
||||
and then immediately register with
|
||||
.BR atexit (3)
|
||||
a function which prints the stack usage on exit, this functionality has been
|
||||
provided by
|
||||
.BR _reportStack ;
|
||||
just call
|
||||
.BR _reportStack
|
||||
immediately after
|
||||
.IR main
|
||||
and nothing else is required.
|
||||
.LP
|
||||
The
|
||||
.BR _getStackBottom
|
||||
routine returns the lowest direct page address which can legally be used
|
||||
@ -88,28 +103,21 @@ The
|
||||
routine itself uses stack space, especially when printing out error
|
||||
messages. Ensure you allow at least 100 bytes extra to allow for this.
|
||||
.SH EXAMPLE
|
||||
An easy way to use the first two routines is to make use of the
|
||||
.BR atexit (3)
|
||||
function, so that you don't have to determine all the possible exit
|
||||
points of your program. The GNO base sources make use of the
|
||||
The most common way to make use of these routines is to call
|
||||
.BR _reportStack
|
||||
as your first step in
|
||||
.IR main .
|
||||
The GNO base sources make use of the
|
||||
macro __STACK_CHECK__ to control whether or not this check is done.
|
||||
You may want to use the same macro.
|
||||
.nf
|
||||
|
||||
#include <stdio.h>
|
||||
#include <gno/gno.h>
|
||||
|
||||
#ifdef __STACK_CHECK__
|
||||
void cleanup (void) {
|
||||
fprintf(stderr,"Stack Usage: %d bytes\n", _endStackCheck());
|
||||
}
|
||||
#endif
|
||||
|
||||
void main (int argc, char **argv) {
|
||||
|
||||
#ifdef __STACK_CHECK__
|
||||
_beginStackCheck();
|
||||
atexit(cleanup);
|
||||
_reportStack();
|
||||
#endif
|
||||
|
||||
... <program continues> ...
|
||||
|
Loading…
Reference in New Issue
Block a user