Stop openbios-unix from crashing when auto-boot? is enabled.
[openbios.git] / include / kernel / stack.h
blob9fe52ce8f081ebca97fa64ecd01173116ed3e6cd
1 /* stack.h
2 * tag: stack and stack access functions
4 * Copyright (C) 2003 Patrick Mauritz, Stefan Reinauer
6 * See the file "COPYING" for further information about
7 * the copyright and warranty status of this work.
8 */
10 #ifndef __STACK_H
11 #define __STACK_H
13 #define dstacksize 512
14 extern int dstackcnt;
15 extern cell dstack[dstacksize];
17 #define rstacksize 512
18 extern int rstackcnt;
19 extern cell rstack[rstacksize];
21 extern int dbgrstackcnt;
23 //typedef struct opaque_xt *xt_t;
24 //typedef struct opaque_ihandle *ihandle_t;
25 //typedef struct opaque_phandle *phandle_t;
27 typedef ucell xt_t;
28 typedef ucell ihandle_t;
29 typedef ucell phandle_t;
34 static inline void PUSH(ucell value) {
35 dstack[++dstackcnt] = (value);
37 static inline void PUSH_xt( xt_t xt ) { PUSH( (ucell)xt ); }
38 static inline void PUSH_ih( ihandle_t ih ) { PUSH( (ucell)ih ); }
39 static inline void PUSH_ph( phandle_t ph ) { PUSH( (ucell)ph ); }
41 static inline ucell POP(void) {
42 return (ucell) dstack[dstackcnt--];
44 static inline xt_t POP_xt( void ) { return (xt_t)POP(); }
45 static inline ihandle_t POP_ih( void ) { return (ihandle_t)POP(); }
46 static inline phandle_t POP_ph( void ) { return (phandle_t)POP(); }
48 static inline void DROP(void) {
49 dstackcnt--;
52 static inline void DDROP(void) {
53 dstackcnt -= 2;
56 static inline void DPUSH(ducell value) {
57 #ifdef NEED_FAKE_INT128_T
58 dstack[++dstackcnt] = (cell) value.lo;
59 dstack[++dstackcnt] = (cell) value.hi;
60 #else
61 dstack[++dstackcnt] = (cell) value;
62 dstack[++dstackcnt] = (cell) (value >> bitspercell);
63 #endif
66 static inline ducell DPOP(void) {
67 #ifdef NEED_FAKE_INT128_T
68 ducell du;
69 du.hi = (ucell) dstack[dstackcnt--];
70 du.lo = (ucell) dstack[dstackcnt--];
71 return du;
72 #else
73 ducell du;
74 du = ((ducell)(ucell) dstack[dstackcnt--]) << bitspercell;
75 du |= (ucell) dstack[dstackcnt--];
76 return du;
77 #endif
80 static inline ucell GETTOS(void) {
81 return dstack[dstackcnt];
84 #define GETITEM(number) (dstack[dstackcnt - number])
85 static inline void PUSHR(ucell value) {
86 rstack[++rstackcnt] = (value);
89 static inline ucell POPR(void) {
90 return (ucell) rstack[rstackcnt--];
92 static inline ucell GETTORS(void) {
93 return rstack[rstackcnt];
97 #if defined(DEBUG_DSTACK) || defined(FCOMPILER)
98 void printdstack(void);
99 #endif
100 #if defined(DEBUG_RSTACK) || defined(FCOMPILER)
101 void printrstack(void);
102 #endif
104 #endif