aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/include/mailboxes.h28
-rw-r--r--src/include/mempools.h19
-rw-r--r--src/include/queues.h16
3 files changed, 55 insertions, 8 deletions
diff --git a/src/include/mailboxes.h b/src/include/mailboxes.h
index 734a71bac..075806da8 100644
--- a/src/include/mailboxes.h
+++ b/src/include/mailboxes.h
@@ -91,6 +91,34 @@ extern "C" {
*/
#define chMBPeek(mbp) (*(mbp)->mb_rdptr)
+/**
+ * @brief Data part of a static mailbox initializer.
+ * @details This macro should be used when statically initializing a
+ * mailbox that is part of a bigger structure.
+ * @param name the name of the mailbox variable
+ * @param buffer pointer to the mailbox buffer area
+ * @param size size of the mailbox buffer area
+ */
+#define _MAILBOX_DATA(name, buffer, size) { \
+ (msg_t *)(buffer), \
+ (msg_t *)(buffer) + size, \
+ (msg_t *)(buffer), \
+ (msg_t *)(buffer), \
+ _SEMAPHORE_DATA(name.mb_fullsem, 0), \
+ _SEMAPHORE_DATA(name.mb_emptysem, size), \
+}
+
+/**
+ * @brief Static mailbox initializer.
+ * @details Statically initialized mailboxes require no explicit
+ * initialization using @p chMBInit().
+ * @param name the name of the mailbox variable
+ * @param buffer pointer to the mailbox buffer area
+ * @param size size of the mailbox buffer area
+ */
+#define MAILBOX_DECL(name, buffer, size) \
+ Mailbox name = _MAILBOX_DATA(name, buffer, size)
+
#endif /* CH_USE_MAILBOXES */
#endif /* _MAILBOXES_H_ */
diff --git a/src/include/mempools.h b/src/include/mempools.h
index 537ca3425..38e54b3d8 100644
--- a/src/include/mempools.h
+++ b/src/include/mempools.h
@@ -44,6 +44,25 @@ typedef struct {
size_t mp_object_size; /**< Memory pool objects size.*/
} MemoryPool;
+/**
+ * @brief Data part of a static memory pool initializer.
+ * @details This macro should be used when statically initializing a
+ * memory pool that is part of a bigger structure.
+ * @param name the name of the memory pool variable
+ * @param size size of the memory pool contained objects
+ */
+#define _MEMORYPOOL_DATA(name, size) {NULL, size}
+
+/**
+ * @brief Static memory pool initializer.
+ * @details Statically initialized memory pools require no explicit
+ * initialization using @p chPoolInit().
+ * @param name the name of the memory pool variable
+ * @param size size of the memory pool contained objects
+ */
+#define MEMORYPOOL_DECL(name, size) \
+ MemoryPool name = _MEMORYPOOL_DATA(name, size)
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/src/include/queues.h b/src/include/queues.h
index d6c7d46fc..6bd98b4f1 100644
--- a/src/include/queues.h
+++ b/src/include/queues.h
@@ -112,10 +112,10 @@ typedef GenericQueue InputQueue;
* @param inotify input notification callback pointer
*/
#define _INPUTQUEUE_DATA(name, buffer, size, inotify) { \
- buffer, \
- buffer + size, \
- buffer, \
- buffer, \
+ (uint8_t *)(buffer), \
+ (uint8_t *)(buffer) + size, \
+ (uint8_t *)(buffer), \
+ (uint8_t *)(buffer), \
_SEMAPHORE_DATA(name.q_sem, 0), \
inotify \
}
@@ -174,10 +174,10 @@ typedef GenericQueue OutputQueue;
* @param onotify output notification callback pointer
*/
#define _OUTPUTQUEUE_DATA(name, buffer, size, onotify) { \
- buffer, \
- buffer + size, \
- buffer, \
- buffer, \
+ (uint8_t *)(buffer), \
+ (uint8_t *)(buffer) + size, \
+ (uint8_t *)(buffer), \
+ (uint8_t *)(buffer), \
_SEMAPHORE_DATA(name.q_sem, size), \
onotify \
}