LispBM
Loading...
Searching...
No Matches
stack.h
Go to the documentation of this file.
1
2/*
3 Copyright 2019, 2024Joel Svensson svenssonjoel@yahoo.se
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18#ifndef STACK_H_
19#define STACK_H_
20
21
22#include <stdlib.h>
23#include <stdint.h>
24#include <stdbool.h>
25#include <stdio.h>
26
27#include "lbm_types.h"
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
38
45int lbm_stack_allocate(lbm_stack_t *s, lbm_uint stack_size);
82int lbm_push(lbm_stack_t *s, lbm_uint val);
89int lbm_pop(lbm_stack_t *s, lbm_uint *val);
90
96static inline int lbm_stack_is_empty(lbm_stack_t *s) {
97 if (s->sp == 0) return 1;
98 return 0;
99}
100
108int lbm_pop_2(lbm_stack_t *s, lbm_uint *r0, lbm_uint *r1);
109
118int lbm_pop_3(lbm_stack_t *s, lbm_uint *r0, lbm_uint *r1, lbm_uint *r2);
119
120#ifdef __cplusplus
121}
122#endif
123#endif
uint32_t lbm_uint
Definition lbm_types.h:48
void lbm_stack_free(lbm_stack_t *s)
Definition stack.c:64
int lbm_stack_create(lbm_stack_t *s, lbm_uint *data, lbm_uint size)
Definition stack.c:44
int lbm_stack_allocate(lbm_stack_t *s, lbm_uint stack_size)
Definition stack.c:32
int lbm_push(lbm_stack_t *s, lbm_uint val)
Definition stack.c:82
int lbm_stack_drop(lbm_stack_t *s, lbm_uint n)
Definition stack.c:74
void lbm_stack_clear(lbm_stack_t *s)
Definition stack.c:70
int lbm_pop_2(lbm_stack_t *s, lbm_uint *r0, lbm_uint *r1)
Definition stack.c:97
lbm_uint lbm_get_max_stack(lbm_stack_t *s)
Definition stack.c:52
int lbm_pop_3(lbm_stack_t *s, lbm_uint *r0, lbm_uint *r1, lbm_uint *r2)
Definition stack.c:104
static int lbm_stack_is_empty(lbm_stack_t *s)
Definition stack.h:96
int lbm_pop(lbm_stack_t *s, lbm_uint *val)
Definition stack.c:91
Definition stack.h:33
lbm_uint * data
Definition stack.h:34
lbm_uint sp
Definition stack.h:35
lbm_uint size
Definition stack.h:36