unified indentation

This commit is contained in:
bit-cyber-fh
2024-03-28 15:25:58 +08:00
parent 8779c9855e
commit 16d1ad30a7
14 changed files with 1019 additions and 1030 deletions
+21 -22
View File
@@ -29,71 +29,70 @@
#include <stddef.h>
/**
* opaque structure
* @struct CircularQueueInst
*/
typedef struct
{
void **data;
volatile uint32_t nelts; /**< # elements */
uint32_t in; /**< next empty location */
uint32_t out; /**< next filled location */
uint32_t bounds; /**< max size of queue */
void **data;
volatile uint32_t nelts; /**< # elements */
uint32_t in; /**< next empty location */
uint32_t out; /**< next filled location */
uint32_t bounds; /**< max size of queue */
} CIRC_QUEUE;
/**
* create a FIFO queue
* @brief create a FIFO queue
* @param queue The new queue
* @param queue_capacity maximum size of the queue
* @param a pool to allocate queue from
*/
bool CircQueueCreate(CIRC_QUEUE **queue, uint32_t queue_capacity);
/** free queue memory -- call after destroy
/**
* @brief free queue memory -- call after destroy
* @note we do not free in destroy() to follow pthreads convention
*/
void CircQueueFree(CIRC_QUEUE *queue);
/**
* Detects when the CIRC_QUEUE is full. This utility function is expected
* @brief Detects when the CIRC_QUEUE is full. This utility function is expected
* to be called from within critical sections, and is not threadsafe.
*/
bool isCircQueueFull(CIRC_QUEUE *queue);
/**
* Detects when the CIRC_QUEUE is empty. This utility function is expected
* @brief Detects when the CIRC_QUEUE is empty. This utility function is expected
* to be called from within critical sections, and is not threadsafe.
*/
bool isCircQueueEmpty(CIRC_QUEUE *queue);
/**
* push/add an object to the queue, blocking if the queue is already full
* @brief push/add an object to the queue, blocking if the queue is already full
*
* @param queue the queue
* @param data the data
* @returns RPA_EINTR the blocking was interrupted (try again)
* @returns RPA_EOF the queue has been terminated
* @returns RPA_SUCCESS on a successful push
* @return RPA_EINTR the blocking was interrupted (try again)
* @return RPA_EOF the queue has been terminated
* @return RPA_SUCCESS on a successful push
*/
bool CircQueuePush(CIRC_QUEUE *queue, void *data);
/**
* pop/get an object from the queue, blocking if the queue is already empty
* @brief pop/get an object from the queue, blocking if the queue is already empty
*
* @param queue the queue
* @param data the data
* @returns RPA_EINTR the blocking was interrupted (try again)
* @returns RPA_EOF if the queue has been terminated
* @returns RPA_SUCCESS on a successful pop
* @return RPA_EINTR the blocking was interrupted (try again)
* @return RPA_EOF if the queue has been terminated
* @return RPA_SUCCESS on a successful pop
*/
bool CircQueuePop(CIRC_QUEUE *queue, void **data);
/**
* returns the size of the queue.
* @brief returns the size of the queue.
*
* @warning this is not threadsafe, and is intended for reporting/monitoring
* of the queue.
* @param queue the queue
* @returns the size of the queue
* @return the size of the queue
*/
uint32_t CircQueueSize(CIRC_QUEUE *queue);
+73 -69
View File
@@ -32,100 +32,104 @@ extern "C"
#include <stdlib.h>
#include <stdint.h>
/*
* clist_t iterator direction.
*/
/**
* @enum cListDirection
* @brief clist_t iterator direction.
*/
typedef enum
{
LIST_HEAD,
LIST_TAIL
} clist_direction_t;
typedef enum
{
LIST_HEAD,
LIST_TAIL
} clist_direction_t;
/*
* clist_t node struct.
*/
/**
* @struct cListNode
* @brief clist_t node struct.
*/
typedef struct clist_node
{
struct clist_node *prev;
struct clist_node *next;
void *val;
} clist_node_t;
typedef struct clist_node
{
struct clist_node *prev;
struct clist_node *next;
void *val;
} clist_node_t;
/*
* clist_t struct.
*/
/**
* @struct cListInst
* @brief clist_t struct.
*/
typedef struct
{
clist_node_t *head;
clist_node_t *tail;
uint32_t len;
void (*free)(void *val);
int8_t (*compare)(void *a, void *b);
} clist_t;
typedef struct
{
clist_node_t *head;
clist_node_t *tail;
uint32_t len;
void (*free)(void *val);
int8_t (*compare)(void *a, void *b);
} clist_t;
/*
* clist_t iterator struct.
*/
/**
* @struct cListIter
* @brief clist_t iterator struct.
*/
typedef struct
{
clist_node_t *next;
clist_direction_t direction;
} clist_iterator_t;
typedef struct
{
clist_node_t *next;
clist_direction_t direction;
} clist_iterator_t;
// Node prototypes.
// Node prototypes.
clist_node_t *
clist_node_new(void *val);
clist_node_t *
clist_node_new(void *val);
// clist_t prototypes.
// clist_t prototypes.
clist_t *
clist_new(void);
clist_t *
clist_new(void);
clist_node_t *
clist_rpush(clist_t *self, clist_node_t *node);
clist_node_t *
clist_rpush(clist_t *self, clist_node_t *node);
clist_node_t *
clist_lpush(clist_t *self, clist_node_t *node);
clist_node_t *
clist_lpush(clist_t *self, clist_node_t *node);
clist_node_t *
clist_find(clist_t *self, void *val);
clist_node_t *
clist_find(clist_t *self, void *val);
clist_node_t *
clist_at(clist_t *self, int index);
clist_node_t *
clist_at(clist_t *self, int index);
clist_node_t *
clist_rpop(clist_t *self);
clist_node_t *
clist_rpop(clist_t *self);
clist_node_t *
clist_lpop(clist_t *self);
clist_node_t *
clist_lpop(clist_t *self);
void
clist_remove(clist_t *self, clist_node_t *node);
void
clist_remove(clist_t *self, clist_node_t *node);
void
clist_clear(clist_t *self);
void
clist_clear(clist_t *self);
void
clist_destroy(clist_t *self);
void
clist_destroy(clist_t *self);
// clist_t iterator prototypes.
// clist_t iterator prototypes.
clist_iterator_t *
clist_iterator_new(clist_t *list, clist_direction_t direction);
clist_iterator_t *
clist_iterator_new(clist_t *list, clist_direction_t direction);
clist_iterator_t *
clist_iterator_new_from_node(clist_node_t *node, clist_direction_t direction);
clist_iterator_t *
clist_iterator_new_from_node(clist_node_t *node, clist_direction_t direction);
clist_node_t *
clist_iterator_next(clist_iterator_t *self);
clist_node_t *
clist_iterator_next(clist_iterator_t *self);
void
clist_iterator_destroy(clist_iterator_t *self);
void
clist_iterator_destroy(clist_iterator_t *self);
#ifdef __cplusplus
}