1 /*
2  * BEGIN illumos section
3  *   This is an unstable interface; changes may be made
4  *   without notice.
5  * END illumos section
6  */
7 /***********************************************************************
8 *                                                                      *
9 *               This software is part of the ast package               *
10 *          Copyright (c) 1985-2011 AT&T Intellectual Property          *
11 *                      and is licensed under the                       *
12 *                 Eclipse Public License, Version 1.0                  *
13 *                    by AT&T Intellectual Property                     *
14 *                                                                      *
15 *                A copy of the License is available at                 *
16 *          http://www.eclipse.org/org/documents/epl-v10.html           *
17 *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         *
18 *                                                                      *
19 *              Information and Software Systems Research               *
20 *                            AT&T Research                             *
21 *                           Florham Park NJ                            *
22 *                                                                      *
23 *                 Glenn Fowler <gsf@research.att.com>                  *
24 *                  David Korn <dgk@research.att.com>                   *
25 *                   Phong Vo <kpv@research.att.com>                    *
26 *                                                                      *
27 ***********************************************************************/
28 #pragma prototyped
29 /*
30  * Glenn Fowler
31  * AT&T Research
32  *
33  * homogenous stack routine definitions
34  */
35 
36 #ifndef _STACK_H
37 #define _STACK_H
38 
39 typedef struct stacktable* STACK;	/* stack pointer		*/
40 typedef struct stackposition STACKPOS;	/* stack position		*/
41 
42 struct stackblock			/* stack block cell		*/
43 {
44 	void**		  stack;	/* actual stack			*/
45 	struct stackblock* prev;	/* previous block in list	*/
46 	struct stackblock* next;	/* next block in list		*/
47 };
48 
49 struct stackposition			/* stack position		*/
50 {
51 	struct stackblock* block;	/* current block pointer	*/
52 	int		index;		/* index within current block	*/
53 };
54 
55 struct stacktable			/* stack information		*/
56 {
57 	struct stackblock* blocks;	/* stack table blocks		*/
58 	void*		error;		/* error return value		*/
59 	int		size;		/* size of each block		*/
60 	STACKPOS	position;	/* current stack position	*/
61 };
62 
63 /*
64  * map old names to new
65  */
66 
67 #define mkstack		stackalloc
68 #define rmstack		stackfree
69 #define clrstack	stackclear
70 #define getstack	stackget
71 #define pushstack	stackpush
72 #define popstack	stackpop
73 #define posstack	stacktell
74 
75 #if _BLD_ast && defined(__EXPORT__)
76 #define extern		__EXPORT__
77 #endif
78 
79 extern STACK		stackalloc(int, void*);
80 extern void		stackfree(STACK);
81 extern void		stackclear(STACK);
82 extern void*		stackget(STACK);
83 extern int		stackpush(STACK, void*);
84 extern int		stackpop(STACK);
85 extern void		stacktell(STACK, int, STACKPOS*);
86 
87 #undef	extern
88 
89 #endif
90