26#ifndef __N_STACK_HEADER
27#define __N_STACK_HEADER
41#define STACK_ITEM_BOOL 1
43#define STACK_ITEM_CHAR 2
45#define STACK_ITEM_UINT8 3
47#define STACK_ITEM_INT8 4
49#define STACK_ITEM_UINT32 5
51#define STACK_ITEM_INT32 6
53#define STACK_ITEM_UINT64 7
55#define STACK_ITEM_INT64 8
57#define STACK_ITEM_FLOAT 9
59#define STACK_ITEM_DOUBLE 10
61#define STACK_ITEM_PTR 11
64#define STACK_IS_FULL 0
66#define STACK_IS_EMPTY 1
68#define STACK_IS_UNDEFINED 2
70#define STACK_ITEM_WRONG_TYPE 3
72#define STACK_ITEM_OK 4
135#if defined(__sun) && defined(__SVR4)
138#define stack_push(__STACK, __VAL) \
140 bool: stack_push_b, \
141 char: stack_push_c, \
142 signed char: stack_push_i8, \
143 unsigned char: stack_push_ui8, \
144 uint32_t: stack_push_ui32, \
145 int32_t: stack_push_i32, \
146 uint64_t: stack_push_ui64, \
147 int64_t: stack_push_i64, \
148 float: stack_push_f, \
149 double: stack_push_d, \
150 void*: stack_push_p_default)(__STACK, __VAL)
152#define stack_push(__STACK, __VAL) \
154 bool: stack_push_b, \
155 char: stack_push_c, \
156 signed char: stack_push_i8, \
157 unsigned char: stack_push_ui8, \
158 uint32_t: stack_push_ui32, \
159 int32_t: stack_push_i32, \
160 float: stack_push_f, \
161 double: stack_push_d, \
162 void*: stack_push_p_default)(__STACK, __VAL)
167#define stack_push(__STACK, __VAL) \
169 bool: stack_push_b, \
170 char: stack_push_c, \
171 uint8_t: stack_push_ui8, \
172 int8_t: stack_push_i8, \
173 uint32_t: stack_push_ui32, \
174 int32_t: stack_push_i32, \
175 uint64_t: stack_push_ui64, \
176 int64_t: stack_push_i64, \
177 float: stack_push_f, \
178 double: stack_push_d, \
179 void*: stack_push_p_default)(__STACK, __VAL)
181#define stack_push(__STACK, __VAL) \
183 bool: stack_push_b, \
184 char: stack_push_c, \
185 uint8_t: stack_push_ui8, \
186 int8_t: stack_push_i8, \
187 uint32_t: stack_push_ui32, \
188 int32_t: stack_push_i32, \
189 float: stack_push_f, \
190 double: stack_push_d, \
191 void*: stack_push_p_default)(__STACK, __VAL)
248bool stack_push_ui64(
STACK* stack, uint64_t ui64_t);
250bool stack_push_i64(
STACK* stack, int64_t i64);
252uint64_t stack_pop_ui64(
STACK* stack, uint8_t* status);
254int64_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.