]> gcc.gnu.org Git - gcc.git/blame - gcc/m2/mc-boot/GmcStack.c
Remove unused parameter warning via introducing attribute unused.
[gcc.git] / gcc / m2 / mc-boot / GmcStack.c
CommitLineData
7401123f
GM
1/* do not edit automatically generated by mc from mcStack. */
2/* This file is part of GNU Modula-2.
3
4GNU Modula-2 is free software; you can redistribute it and/or modify it under
5the terms of the GNU General Public License as published by the Free
6Software Foundation; either version 3, or (at your option) any later
7version.
8
9GNU Modula-2 is distributed in the hope that it will be useful, but WITHOUT ANY
10WARRANTY; without even the implied warranty of MERCHANTABILITY or
11FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12for more details.
13
14You should have received a copy of the GNU General Public License along
15with gm2; see the file COPYING. If not, write to the Free Software
16Foundation, 51 Franklin Street, Fifth Floor,
17Boston, MA 02110-1301, USA. */
18
19#include "config.h"
20#include "system.h"
21# if !defined (PROC_D)
22# define PROC_D
23 typedef void (*PROC_t) (void);
24 typedef struct { PROC_t proc; } PROC;
25# endif
26
27# include "GStorage.h"
28# include "Gmcrts.h"
29#if defined(__cplusplus)
30# undef NULL
31# define NULL 0
32#endif
33#define _mcStack_H
34#define _mcStack_C
35
36# include "GStorage.h"
37# include "GIndexing.h"
38# include "GM2RTS.h"
39
40typedef struct _T1_r _T1;
41
42typedef _T1 *mcStack_stack;
43
44struct _T1_r {
45 Indexing_Index list;
46 unsigned int count;
47 };
48
49
50/*
51 init - create and return a stack.
52*/
53
51bc4b81 54extern "C" mcStack_stack mcStack_init (void);
7401123f
GM
55
56/*
57 kill - deletes stack, s.
58*/
59
51bc4b81 60extern "C" void mcStack_kill (mcStack_stack *s);
7401123f
GM
61
62/*
63 push - an address, a, onto the stack, s.
64 It returns, a.
65*/
66
51bc4b81 67extern "C" void * mcStack_push (mcStack_stack s, void * a);
7401123f
GM
68
69/*
70 pop - and return the top element from stack, s.
71*/
72
51bc4b81 73extern "C" void * mcStack_pop (mcStack_stack s);
7401123f
GM
74
75/*
76 replace - performs a pop; push (a); return a.
77*/
78
51bc4b81 79extern "C" void * mcStack_replace (mcStack_stack s, void * a);
7401123f
GM
80
81/*
82 depth - returns the depth of the stack.
83*/
84
51bc4b81 85extern "C" unsigned int mcStack_depth (mcStack_stack s);
7401123f
GM
86
87/*
88 access - returns the, i, th stack element.
89 The top of stack is defined by:
90
91 access (s, depth (s)).
92*/
93
51bc4b81 94extern "C" void * mcStack_access (mcStack_stack s, unsigned int i);
7401123f
GM
95
96
97/*
98 init - create and return a stack.
99*/
100
51bc4b81 101extern "C" mcStack_stack mcStack_init (void)
7401123f
GM
102{
103 mcStack_stack s;
104
105 Storage_ALLOCATE ((void **) &s, sizeof (_T1));
dce2ffd5 106 s->list = Indexing_InitIndex (1);
d08981bf 107 s->count = 0;
7401123f
GM
108 return s;
109 /* static analysis guarentees a RETURN statement will be used before here. */
110 __builtin_unreachable ();
111}
112
113
114/*
115 kill - deletes stack, s.
116*/
117
51bc4b81 118extern "C" void mcStack_kill (mcStack_stack *s)
7401123f 119{
dce2ffd5 120 (*s)->list = Indexing_KillIndex ((*s)->list);
7401123f 121 Storage_DEALLOCATE ((void **) &(*s), sizeof (_T1));
d08981bf 122 (*s) = NULL;
7401123f
GM
123}
124
125
126/*
127 push - an address, a, onto the stack, s.
128 It returns, a.
129*/
130
51bc4b81 131extern "C" void * mcStack_push (mcStack_stack s, void * a)
7401123f
GM
132{
133 if (s->count == 0)
134 {
135 Indexing_PutIndice (s->list, Indexing_LowIndice (s->list), a);
136 }
137 else
138 {
139 Indexing_PutIndice (s->list, (Indexing_HighIndice (s->list))+1, a);
140 }
141 s->count += 1;
142 return a;
143 /* static analysis guarentees a RETURN statement will be used before here. */
144 __builtin_unreachable ();
145}
146
147
148/*
149 pop - and return the top element from stack, s.
150*/
151
51bc4b81 152extern "C" void * mcStack_pop (mcStack_stack s)
7401123f
GM
153{
154 void * a;
155
156 if (s->count == 0)
157 {
158 M2RTS_HALT (-1);
159 __builtin_unreachable ();
160 }
161 else
162 {
163 s->count -= 1;
dce2ffd5 164 a = Indexing_GetIndice (s->list, Indexing_HighIndice (s->list));
7401123f
GM
165 Indexing_DeleteIndice (s->list, Indexing_HighIndice (s->list));
166 return a;
167 }
06c977f8 168 ReturnException ("../../gcc-git-devel-modula2/gcc/m2/mc/mcStack.def", 20, 1);
7401123f
GM
169 __builtin_unreachable ();
170}
171
172
173/*
174 replace - performs a pop; push (a); return a.
175*/
176
51bc4b81 177extern "C" void * mcStack_replace (mcStack_stack s, void * a)
7401123f
GM
178{
179 void * b;
180
dce2ffd5
GM
181 b = mcStack_pop (s);
182 return mcStack_push (s, a);
7401123f
GM
183 /* static analysis guarentees a RETURN statement will be used before here. */
184 __builtin_unreachable ();
185}
186
187
188/*
189 depth - returns the depth of the stack.
190*/
191
51bc4b81 192extern "C" unsigned int mcStack_depth (mcStack_stack s)
7401123f
GM
193{
194 return s->count;
195 /* static analysis guarentees a RETURN statement will be used before here. */
196 __builtin_unreachable ();
197}
198
199
200/*
201 access - returns the, i, th stack element.
202 The top of stack is defined by:
203
204 access (s, depth (s)).
205*/
206
51bc4b81 207extern "C" void * mcStack_access (mcStack_stack s, unsigned int i)
7401123f
GM
208{
209 if ((i > s->count) || (i == 0))
210 {
211 M2RTS_HALT (-1);
212 __builtin_unreachable ();
213 }
214 else
215 {
dce2ffd5 216 return Indexing_GetIndice (s->list, i);
7401123f 217 }
06c977f8 218 ReturnException ("../../gcc-git-devel-modula2/gcc/m2/mc/mcStack.def", 20, 1);
7401123f
GM
219 __builtin_unreachable ();
220}
221
206c4f77 222extern "C" void _M2_mcStack_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
7401123f
GM
223{
224}
225
206c4f77 226extern "C" void _M2_mcStack_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
7401123f
GM
227{
228}
This page took 0.109565 seconds and 5 git commands to generate.