aboutsummaryrefslogtreecommitdiffstats
path: root/src/include/mailboxes.h
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-05-16 14:49:41 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-05-16 14:49:41 +0000
commit53f1b747726d85020beca994f6fe67a5e9af7b8e (patch)
tree72bbc0235de15168314bc3b5c803464f2c16f667 /src/include/mailboxes.h
parentb20088a8cb72e3f3e694e309671cd7f96fb552dc (diff)
downloadChibiOS-53f1b747726d85020beca994f6fe67a5e9af7b8e.tar.gz
ChibiOS-53f1b747726d85020beca994f6fe67a5e9af7b8e.tar.bz2
ChibiOS-53f1b747726d85020beca994f6fe67a5e9af7b8e.zip
Added static initializers for mailboxes and memory pools.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@978 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'src/include/mailboxes.h')
-rw-r--r--src/include/mailboxes.h28
1 files changed, 28 insertions, 0 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_ */