27#ifndef __N_STACK_HEADER
28#define __N_STACK_HEADER
42#define STACK_ITEM_BOOL 1
44#define STACK_ITEM_CHAR 2
46#define STACK_ITEM_UINT8 3
48#define STACK_ITEM_INT8 4
50#define STACK_ITEM_UINT32 5
52#define STACK_ITEM_INT32 6
54#define STACK_ITEM_UINT64 7
56#define STACK_ITEM_INT64 8
58#define STACK_ITEM_FLOAT 9
60#define STACK_ITEM_DOUBLE 10
62#define STACK_ITEM_PTR 11
65#define STACK_IS_FULL 0
67#define STACK_IS_EMPTY 1
69#define STACK_IS_UNDEFINED 2
71#define STACK_ITEM_WRONG_TYPE 3
73#define STACK_ITEM_OK 4
136#if defined(__sun) && defined(__SVR4)
139#define stack_push(__STACK, __VAL) \
141 bool: stack_push_b, \
142 char: stack_push_c, \
143 signed char: stack_push_i8, \
144 unsigned char: stack_push_ui8, \
145 uint32_t: stack_push_ui32, \
146 int32_t: stack_push_i32, \
147 uint64_t: stack_push_ui64, \
148 int64_t: stack_push_i64, \
149 float: stack_push_f, \
150 double: stack_push_d, \
151 void*: stack_push_p_default)(__STACK, __VAL)
153#define stack_push(__STACK, __VAL) \
155 bool: stack_push_b, \
156 char: stack_push_c, \
157 signed char: stack_push_i8, \
158 unsigned char: stack_push_ui8, \
159 uint32_t: stack_push_ui32, \
160 int32_t: stack_push_i32, \
161 float: stack_push_f, \
162 double: stack_push_d, \
163 void*: stack_push_p_default)(__STACK, __VAL)
168#define stack_push(__STACK, __VAL) \
170 bool: stack_push_b, \
171 char: stack_push_c, \
172 uint8_t: stack_push_ui8, \
173 int8_t: stack_push_i8, \
174 uint32_t: stack_push_ui32, \
175 int32_t: stack_push_i32, \
176 uint64_t: stack_push_ui64, \
177 int64_t: stack_push_i64, \
178 float: stack_push_f, \
179 double: stack_push_d, \
180 void*: stack_push_p_default)(__STACK, __VAL)
182#define stack_push(__STACK, __VAL) \
184 bool: stack_push_b, \
185 char: stack_push_c, \
186 uint8_t: stack_push_ui8, \
187 int8_t: stack_push_i8, \
188 uint32_t: stack_push_ui32, \
189 int32_t: stack_push_i32, \
190 float: stack_push_f, \
191 double: stack_push_d, \
192 void*: stack_push_p_default)(__STACK, __VAL)
249bool stack_push_ui64(
STACK* stack, uint64_t ui64_t);
251bool stack_push_i64(
STACK* stack, int64_t i64);
253uint64_t stack_pop_ui64(
STACK* stack, uint8_t* status);
255int64_t stack_pop_i64(
STACK* stack, uint8_t* status);
size_t tail
position of tail
bool is_empty
is item empty ?
size_t head
position of head
size_t nb_items
number of item inside stack
STACK_ITEM * stack_array
STACK_ITEM array.
uint16_t p_type
if v_type is STACK_ITEM_PTR, user defined pointer type
union STACK_DATA data
union of different types
size_t size
Size of array.
uint8_t v_type
type of the item
uint32_t ui32
unsigned int 32
uint8_t ui8
unsigned int 8
bool stack_push_f(STACK *stack, float f)
push a float onto the stack
double stack_pop_d(STACK *stack, uint8_t *status)
pop a double from the stack
bool stack_pop_b(STACK *stack, uint8_t *status)
pop a bool from the stack
bool stack_push_d(STACK *stack, double d)
push a double onto the stack
bool stack_push_ui8(STACK *stack, uint8_t ui8)
push a uint8_t onto the stack
STACK_ITEM * stack_peek(STACK *stack, size_t position)
peek at an item at given position without removing it
bool stack_push_ui32(STACK *stack, uint32_t ui32)
push a uint32_t onto the stack
int8_t stack_pop_i8(STACK *stack, uint8_t *status)
pop an int8_t from the stack
char stack_pop_c(STACK *stack, uint8_t *status)
pop a char from the stack
bool stack_is_empty(const STACK *stack)
check if the stack is empty
float stack_pop_f(STACK *stack, uint8_t *status)
pop a float from the stack
uint8_t stack_pop_ui8(STACK *stack, uint8_t *status)
pop a uint8_t from the stack
bool stack_push_c(STACK *stack, char c)
push a char onto the stack
bool stack_is_full(const STACK *stack)
check if the stack is full
uint32_t stack_pop_ui32(STACK *stack, uint8_t *status)
pop a uint32_t from the stack
bool stack_push_b(STACK *stack, bool b)
push a bool onto the stack
bool stack_push_i32(STACK *stack, int32_t i32)
push an int32_t onto the stack
int32_t stack_pop_i32(STACK *stack, uint8_t *status)
pop an int32_t from the stack
bool delete_stack(STACK **stack)
delete a stack and free its memory
bool stack_push_i8(STACK *stack, int8_t i8)
push an int8_t onto the stack
STACK * new_stack(size_t nb_items)
allocate a new stack
bool stack_push_p(STACK *stack, void *p, uint16_t p_type)
push a pointer onto the stack with a custom type
void * stack_pop_p(STACK *stack, uint8_t *status)
pop a pointer from the stack
bool stack_push_p_default(STACK *stack, void *p)
push a pointer onto the stack with default type
structure of a STACK item
structure of a STACK_ITEM data
Common headers and low-level functions & define.