File: stack.h

package info (click to toggle)
graywolf 0.1.6-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 6,424 kB
  • sloc: ansic: 84,358; sh: 216; awk: 36; makefile: 22
file content (41 lines) | stat: -rw-r--r-- 1,065 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* ----------------------------------------------------------------- 
FILE:	    stack.h
DESCRIPTION:Macro descriptions for implementing simple stack operations.
CONTENTS:   
DATE:	    Dec  6, 1989 
REVISIONS:  
----------------------------------------------------------------- */

#ifndef STACK_H

#define STACK_H

#define YSIZE_STACK 0 
#define YSTACK_POINT 1 
#include <yalecad/message.h>

#define YINITSTACK( stack_xyz, size_xyz ) \
{   \
    stack_xyz = (INT *) Ysafe_malloc( (size_xyz+2) * sizeof(int) ) ; \
    stack_xyz[YSIZE_STACK] = size_xyz + 1 ; \
    stack_xyz[YSTACK_POINT] = 1 ; \
}

#define YCLEARSTACK( stack_xyz ) \
{   \
    stack_xyz[YSTACK_POINT] = 1 ; \
}

#define YPOPSTACK( stack_xyz ) \
 ( stack_xyz[YSTACK_POINT] > YSTACK_POINT ? stack_xyz[stack_xyz[YSTACK_POINT]--] : 0 )

#define YPUSHSTACK( stack_xyz, data_xyz ) \
{   \
    if( ++stack_xyz[YSTACK_POINT] <= stack_xyz[YSIZE_STACK] ){ \
	stack_xyz[ stack_xyz[YSTACK_POINT] ] = data_xyz ; \
    } else { \
	M( ERRMSG, "YPUSHSTACK", "stack_overflow\n" ) ; \
    } \
}

#endif /* STACK_H */