FreeRTOS Tetris
TUM_Utils.h
Go to the documentation of this file.
1 
24 #ifndef __TUM_UTILS_H__
25 #define __TUM_UTILS_H__
26 
27 #include <stdio.h>
28 #include <stdlib.h>
29 
30 #define PRINT_ERROR(msg, ...) \
31  fprintf(stderr, "[ERROR] " msg, ##__VA_ARGS__); \
32  fprintf(stderr, " @-> %s:%d, %s\n", __FILE__, __LINE__, __func__)
33 
40 int tumUtilIsCurGLThread(void);
41 
45 void tumUtilSetGLThread(void);
46 
54 char *tumUtilPrependPath(char *path, char *file);
55 
63 char *tumUtilGetBinFolderPath(char *bin_path);
64 
73 FILE *tumUtilFindResource(char *resource_name, const char *mode);
74 
85 char *tumUtilFindResourcePath(char *resource_name);
86 
90 typedef void *rbuf_handle_t;
91 
100 rbuf_handle_t rbuf_init(size_t item_size, size_t item_count);
101 
112 rbuf_handle_t rbuf_init_static(size_t item_size, size_t item_count, void *buffer);
113 
119 void rbuf_free(rbuf_handle_t rbuf);
120 
126 void rbuf_reset(rbuf_handle_t rbuf);
127 
136 
144 int rbuf_put(rbuf_handle_t rbuf, void *data);
145 
154 int rbuf_fput(rbuf_handle_t rbuf, void *data);
155 
165 void *rbuf_get_buffer(rbuf_handle_t rbuf);
166 
175 int rbuf_get(rbuf_handle_t rbuf, void *data);
176 
183 unsigned char rbuf_empty(rbuf_handle_t rbuf);
184 
191 unsigned char rbug_full(rbuf_handle_t rbuf);
192 
199 size_t rbuf_size(rbuf_handle_t rbuf);
200 
207 size_t rbuf_capacity(rbuf_handle_t rbuf);
208 
209 #endif
rbuf_put_buffer
int rbuf_put_buffer(rbuf_handle_t rbuf)
Used when a reference to the next buffer item is already filled, incrementing the next buffer item sh...
Definition: TUM_Utils.c:340
rbuf_free
void rbuf_free(rbuf_handle_t rbuf)
Frees a ring buffer.
Definition: TUM_Utils.c:313
rbug_full
unsigned char rbug_full(rbuf_handle_t rbuf)
Checks if the buffer is full.
Definition: TUM_Utils.c:461
tumUtilGetBinFolderPath
char * tumUtilGetBinFolderPath(char *bin_path)
Gets the execution folder of the current program, assumes that program is executing from a folder "bi...
Definition: TUM_Utils.c:93
rbuf_empty
unsigned char rbuf_empty(rbuf_handle_t rbuf)
Checks if the buffer is empty or not.
Definition: TUM_Utils.c:450
rbuf_capacity
size_t rbuf_capacity(rbuf_handle_t rbuf)
Returns the maximum number of elements that the ring buffer can store.
Definition: TUM_Utils.c:494
rbuf_size
size_t rbuf_size(rbuf_handle_t rbuf)
Returns the number of elements currently stored in the ring buffer.
Definition: TUM_Utils.c:473
rbuf_put
int rbuf_put(rbuf_handle_t rbuf, void *data)
Fills the next available buffer slot, if a slot is free.
Definition: TUM_Utils.c:354
rbuf_get
int rbuf_get(rbuf_handle_t rbuf, void *data)
Returns a copy of the next buffer item's data.
Definition: TUM_Utils.c:427
rbuf_handle_t
void * rbuf_handle_t
A handle to a ring buffer object, created using rbuf_init()
Definition: TUM_Utils.h:90
rbuf_reset
void rbuf_reset(rbuf_handle_t rbuf)
Resets the ring buffer to it's initial state.
Definition: TUM_Utils.c:324
tumUtilFindResourcePath
char * tumUtilFindResourcePath(char *resource_name)
Similar to tumUtilFindResource() only returning the file's path instead of the opened FILE's referenc...
Definition: TUM_Utils.c:207
tumUtilFindResource
FILE * tumUtilFindResource(char *resource_name, const char *mode)
Searches for a file in the RESOURCES_DIRECTORY and returns a FILE * if found.
Definition: TUM_Utils.c:193
tumUtilIsCurGLThread
int tumUtilIsCurGLThread(void)
Checks if the calling thread is the thread that currently holds the GL context.
Definition: TUM_Utils.c:61
rbuf_init
rbuf_handle_t rbuf_init(size_t item_size, size_t item_count)
Initialized a ring buffer object with a certain number of objects of a given size.
Definition: TUM_Utils.c:257
tumUtilPrependPath
char * tumUtilPrependPath(char *path, char *file)
Prepends a path string to a filename.
Definition: TUM_Utils.c:79
rbuf_fput
int rbuf_fput(rbuf_handle_t rbuf, void *data)
Fills the next available buffer, overwriting data if the ring buffer is full.
Definition: TUM_Utils.c:378
rbuf_get_buffer
void * rbuf_get_buffer(rbuf_handle_t rbuf)
Returns a reference to the data of the next ring buffer entry.
Definition: TUM_Utils.c:399
tumUtilSetGLThread
void tumUtilSetGLThread(void)
The calling thread is registered as holding the current GL context.
Definition: TUM_Utils.c:72
rbuf_init_static
rbuf_handle_t rbuf_init_static(size_t item_size, size_t item_count, void *buffer)
Initialized a ring buffer object with a certain number of objects of a given size into a statically a...
Definition: TUM_Utils.c:285