agileRTOS (zrtos)  Version 0.8.0 (ghostbuster)
stack.h File Reference
#include <zrtos/zrtos.h>
#include <zrtos/types.h>
#include <zrtos/mem.h>
Include dependency graph for stack.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  _zrtos_stack_t
 

Typedefs

typedef struct _zrtos_stack_t zrtos_stack_t
 

Functions

bool zrtos_stack__init (zrtos_stack_t *thiz, void *data, size_t length)
 
static bool _zrtos_stack__cpy (zrtos_stack_t *thiz, void *dest, void *src, size_t length, size_t offset_plus_length)
 
static bool zrtos_stack__get_offset_ex (zrtos_stack_t *thiz, size_t offset, bool is_relative, bool is_negative, size_t *new_offset)
 
bool zrtos_stack__set_offset_ex (zrtos_stack_t *thiz, size_t offset, bool is_relative, bool is_negative)
 
bool zrtos_stack__read (zrtos_stack_t *thiz, void *data, size_t length, size_t offset)
 
bool zrtos_stack__read_ex (zrtos_stack_t *thiz, void *data, size_t length, size_t offset, bool is_relative, bool is_negative)
 
bool zrtos_stack__write (zrtos_stack_t *thiz, void *data, size_t length, size_t offset)
 
bool zrtos_stack__write_ex (zrtos_stack_t *thiz, void *data, size_t length, size_t offset, bool is_relative, bool is_negative)
 
bool zrtos_stack__push (zrtos_stack_t *thiz, void *data, size_t length)
 
bool zrtos_stack__pop (zrtos_stack_t *thiz, void *data, size_t length)
 
bool zrtos_stack__shift (zrtos_stack_t *thiz, void *data, size_t length)
 
bool zrtos_stack__set_offset (zrtos_stack_t *thiz, size_t offset)
 
size_t zrtos_stack__get_offset (zrtos_stack_t *thiz)
 

Typedef Documentation

◆ zrtos_stack_t

typedef struct _zrtos_stack_t zrtos_stack_t

Function Documentation

◆ _zrtos_stack__cpy()

static bool _zrtos_stack__cpy ( zrtos_stack_t thiz,
void *  dest,
void *  src,
size_t  length,
size_t  offset_plus_length 
)
static

Definition at line 36 of file stack.h.

42  {
43  if(offset_plus_length <= thiz->length){
45  dest
46  ,src
47  ,length
48  );
49  return true;
50  }
51  return false;
52 }
void zrtos_mem__cpy(void *dest, void *src, size_t length)
Definition: mem.h:105
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zrtos_stack__get_offset()

size_t zrtos_stack__get_offset ( zrtos_stack_t thiz)

Definition at line 254 of file stack.h.

256  {
257  return thiz->offset;
258 }
size_t offset
Definition: stack.h:21

◆ zrtos_stack__get_offset_ex()

static bool zrtos_stack__get_offset_ex ( zrtos_stack_t thiz,
size_t  offset,
bool  is_relative,
bool  is_negative,
size_t new_offset 
)
static

Definition at line 54 of file stack.h.

60  {
61  bool ret = true;
62  size_t thiz_offset = thiz->offset;
63  if(is_relative){
64  if(is_negative
65  && thiz_offset >= offset){
66  *new_offset = thiz_offset - offset;
67  }else if(thiz->length - thiz_offset >= offset){
68  *new_offset = thiz_offset + offset;
69  }else{
70  ret = false;
71  }
72  }else{
73  if(offset <= thiz->length){
74  *new_offset = offset;
75  }else{
76  ret = false;
77  }
78  }
79  return ret;
80 }
size_t length
Definition: stack.h:22
size_t offset
Definition: stack.h:21
Here is the caller graph for this function:

◆ zrtos_stack__init()

bool zrtos_stack__init ( zrtos_stack_t thiz,
void *  data,
size_t  length 
)

Definition at line 25 of file stack.h.

29  {
30  thiz->data = data;
31  thiz->offset = 0;
32  thiz->length = length;
33  return true;
34 }
size_t length
Definition: stack.h:22
void * data
Definition: stack.h:20
size_t offset
Definition: stack.h:21

◆ zrtos_stack__pop()

bool zrtos_stack__pop ( zrtos_stack_t thiz,
void *  data,
size_t  length 
)

Definition at line 201 of file stack.h.

205  {
206  size_t offset = thiz->offset;
207  if(offset >= length){
208  offset = (thiz->offset = offset - length);
210  data
212  thiz->data
213  ,offset
214  )
215  ,length
216  );
217  return true;
218  }
219  return false;
220 }
void * data
Definition: stack.h:20
void zrtos_mem__cpy(void *dest, void *src, size_t length)
Definition: mem.h:105
void * zrtos_types__ptr_add(void *ptr, size_t byte_len)
Definition: types.h:35
size_t offset
Definition: stack.h:21
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zrtos_stack__push()

bool zrtos_stack__push ( zrtos_stack_t thiz,
void *  data,
size_t  length 
)

Definition at line 179 of file stack.h.

183  {
184  size_t offset = thiz->offset;
185  bool ret = _zrtos_stack__cpy(
186  thiz
188  thiz->data
189  ,offset
190  )
191  ,data
192  ,length
193  ,offset + length
194  );
195  if(ret){
196  thiz->offset += length;
197  }
198  return ret;
199 }
static bool _zrtos_stack__cpy(zrtos_stack_t *thiz, void *dest, void *src, size_t length, size_t offset_plus_length)
Definition: stack.h:36
void * data
Definition: stack.h:20
void * zrtos_types__ptr_add(void *ptr, size_t byte_len)
Definition: types.h:35
size_t offset
Definition: stack.h:21
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zrtos_stack__read()

bool zrtos_stack__read ( zrtos_stack_t thiz,
void *  data,
size_t  length,
size_t  offset 
)

Definition at line 97 of file stack.h.

102  {
103  return _zrtos_stack__cpy(
104  thiz
105  ,data
107  thiz->data
108  ,offset
109  )
110  ,length
111  ,offset + length
112  );
113 }
static bool _zrtos_stack__cpy(zrtos_stack_t *thiz, void *dest, void *src, size_t length, size_t offset_plus_length)
Definition: stack.h:36
void * data
Definition: stack.h:20
void * zrtos_types__ptr_add(void *ptr, size_t byte_len)
Definition: types.h:35
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zrtos_stack__read_ex()

bool zrtos_stack__read_ex ( zrtos_stack_t thiz,
void *  data,
size_t  length,
size_t  offset,
bool  is_relative,
bool  is_negative 
)

Definition at line 115 of file stack.h.

122  {
123  size_t new_offset;
125  thiz
126  ,offset
127  ,is_relative
128  ,is_negative
129  ,&new_offset
130  ) && zrtos_stack__read(
131  thiz
132  ,data
133  ,length
134  ,new_offset
135  );
136 }
bool zrtos_stack__read(zrtos_stack_t *thiz, void *data, size_t length, size_t offset)
Definition: stack.h:97
static bool zrtos_stack__get_offset_ex(zrtos_stack_t *thiz, size_t offset, bool is_relative, bool is_negative, size_t *new_offset)
Definition: stack.h:54
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zrtos_stack__set_offset()

bool zrtos_stack__set_offset ( zrtos_stack_t thiz,
size_t  offset 
)

Definition at line 243 of file stack.h.

246  {
247  if(offset <= thiz->length){
248  thiz->offset = offset;
249  return true;
250  }
251  return false;
252 }
size_t offset
Definition: stack.h:21

◆ zrtos_stack__set_offset_ex()

bool zrtos_stack__set_offset_ex ( zrtos_stack_t thiz,
size_t  offset,
bool  is_relative,
bool  is_negative 
)

Definition at line 82 of file stack.h.

87  {
89  thiz
90  ,offset
91  ,is_relative
92  ,is_negative
93  ,&thiz->offset
94  );
95 }
size_t offset
Definition: stack.h:21
static bool zrtos_stack__get_offset_ex(zrtos_stack_t *thiz, size_t offset, bool is_relative, bool is_negative, size_t *new_offset)
Definition: stack.h:54
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zrtos_stack__shift()

bool zrtos_stack__shift ( zrtos_stack_t thiz,
void *  data,
size_t  length 
)

Definition at line 222 of file stack.h.

226  {
227  size_t offset = thiz->offset;
228  if(offset + length <= thiz->length){
229  thiz->offset += length;
231  data
233  thiz->data
234  ,offset
235  )
236  ,length
237  );
238  return true;
239  }
240  return false;
241 }
void * data
Definition: stack.h:20
void zrtos_mem__cpy(void *dest, void *src, size_t length)
Definition: mem.h:105
void * zrtos_types__ptr_add(void *ptr, size_t byte_len)
Definition: types.h:35
size_t offset
Definition: stack.h:21
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zrtos_stack__write()

bool zrtos_stack__write ( zrtos_stack_t thiz,
void *  data,
size_t  length,
size_t  offset 
)

Definition at line 138 of file stack.h.

143  {
144  return _zrtos_stack__cpy(
145  thiz
147  thiz->data
148  ,offset
149  )
150  ,data
151  ,length
152  ,offset + length
153  );
154 }
static bool _zrtos_stack__cpy(zrtos_stack_t *thiz, void *dest, void *src, size_t length, size_t offset_plus_length)
Definition: stack.h:36
void * data
Definition: stack.h:20
void * zrtos_types__ptr_add(void *ptr, size_t byte_len)
Definition: types.h:35
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zrtos_stack__write_ex()

bool zrtos_stack__write_ex ( zrtos_stack_t thiz,
void *  data,
size_t  length,
size_t  offset,
bool  is_relative,
bool  is_negative 
)

Definition at line 156 of file stack.h.

163  {
164  size_t new_offset;
166  thiz
167  ,offset
168  ,is_relative
169  ,is_negative
170  ,&new_offset
171  ) && zrtos_stack__write(
172  thiz
173  ,data
174  ,length
175  ,new_offset
176  );
177 }
bool zrtos_stack__write(zrtos_stack_t *thiz, void *data, size_t length, size_t offset)
Definition: stack.h:138
static bool zrtos_stack__get_offset_ex(zrtos_stack_t *thiz, size_t offset, bool is_relative, bool is_negative, size_t *new_offset)
Definition: stack.h:54
Here is the call graph for this function:
Here is the caller graph for this function: