aboutsummaryrefslogtreecommitdiffstats
path: root/src/include/lists.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/lists.h')
-rw-r--r--src/include/lists.h50
1 files changed, 28 insertions, 22 deletions
diff --git a/src/include/lists.h b/src/include/lists.h
index 89fdb84a7..3783f8749 100644
--- a/src/include/lists.h
+++ b/src/include/lists.h
@@ -29,39 +29,47 @@
typedef struct Thread Thread;
-/* Macros good with both ThreadsQueue and ThreadsList.*/
+/**
+ * Threads queue initialization.
+ */
+#define queue_init(tqp) ((tqp)->p_next = (tqp)->p_prev = (Thread *)(tqp));
+
+/**
+ * Macro evaluating to @p TRUE if the specified threads queue is empty.
+ */
#define isempty(p) ((p)->p_next == (Thread *)(p))
-#define notempty(p) ((p)->p_next != (Thread *)(p))
/**
- * @brief Generic threads bidirectional linked list header and element.
- * @extends ThreadsList
+ * Macro evaluating to @p TRUE if the specified threads queue is not empty.
*/
-typedef struct {
- Thread *p_next; /**< First @p Thread in the queue, or
- @p ThreadQueue when empty.*/
- Thread *p_prev; /**< Last @p Thread in the queue, or
- @p ThreadQueue when empty.*/
-} ThreadsQueue;
+#define notempty(p) ((p)->p_next != (Thread *)(p))
/**
- * @brief Generic threads single linked list.
- * @details This list behaves like a stack.
+ * @brief Data part of a static threads queue initializer.
+ * @details This macro should be used when statically initializing a threads
+ * queue that is part of a bigger structure.
+ * @param name the name of the threads queue variable
*/
-typedef struct {
- Thread *p_next; /**< Last pushed @p Thread on the stack,
- or @p ThreadList when empty.*/
-} ThreadsList;
+#define _THREADSQUEUE_DATA(name) {(Thread *)&name, (Thread *)&name}
/**
- * Queue initialization.
+ * @brief Static threads queue initializer.
+ * @details Statically initialized threads queues require no explicit
+ * initialization using @p queue_init().
+ * @param name the name of the threads queue variable
*/
-#define queue_init(tqp) ((tqp)->p_next = (tqp)->p_prev = (Thread *)(tqp));
+#define THREADSQUEUE_DECL(name) ThreadsQueue name = _THREADSQUEUE_DATA(name)
/**
- * List initialization.
+ * @brief Generic threads bidirectional linked list header and element.
+ * @extends ThreadsList
*/
-#define list_init(tlp) ((tlp)->p_next = (Thread *)(tlp))
+typedef struct {
+ Thread *p_next; /**< First @p Thread in the queue, or
+ @p ThreadQueue when empty.*/
+ Thread *p_prev; /**< Last @p Thread in the queue, or
+ @p ThreadQueue when empty.*/
+} ThreadsQueue;
#if !CH_OPTIMIZE_SPEED
@@ -73,8 +81,6 @@ extern "C" {
Thread *fifo_remove(ThreadsQueue *tqp);
Thread *lifo_remove(ThreadsQueue *tqp);
Thread *dequeue(Thread *tp);
- void list_insert(Thread *tp, ThreadsList *tlp);
- Thread *list_remove(ThreadsList *tlp);
#ifdef __cplusplus
}
#endif