diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2013-09-03 09:51:32 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2013-09-03 09:51:32 +0000 |
commit | 3368f57424db121a96207e9ee6f5e9f746d34ca6 (patch) | |
tree | dc023278c59177909c23ca1cc168d57097efbaba /os/rt/include/chthreads.h | |
parent | 9d0c6fb8bf7bf63c137d7c19fdefc7760d2f133a (diff) | |
download | ChibiOS-3368f57424db121a96207e9ee6f5e9f746d34ca6.tar.gz ChibiOS-3368f57424db121a96207e9ee6f5e9f746d34ca6.tar.bz2 ChibiOS-3368f57424db121a96207e9ee6f5e9f746d34ca6.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6251 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/rt/include/chthreads.h')
-rw-r--r-- | os/rt/include/chthreads.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/os/rt/include/chthreads.h b/os/rt/include/chthreads.h index d53a0cb47..6da6b6518 100644 --- a/os/rt/include/chthreads.h +++ b/os/rt/include/chthreads.h @@ -108,6 +108,46 @@ typedef msg_t (*tfunc_t)(void *); /*===========================================================================*/
/**
+ * @name Working Areas and Alignment
+ */
+/**
+ * @brief Enforces a correct alignment for a stack area size value.
+ *
+ * @param[in] n the stack size to be aligned to the next stack
+ * alignment boundary
+ * @return The aligned stack size.
+ *
+ * @api
+ */
+#define THD_ALIGN_STACK_SIZE(n) \
+ ((((n) - 1) | (sizeof(stkalign_t) - 1)) + 1)
+
+/**
+ * @brief Calculates the total Working Area size.
+ *
+ * @param[in] n the stack size to be assigned to the thread
+ * @return The total used memory in bytes.
+ *
+ * @api
+ */
+#define THD_WORKING_AREA_SIZE(n) \
+ THD_ALIGN_STACK_SIZE(sizeof(thread_t) + PORT_WA_SIZE(n))
+
+/**
+ * @brief Static working area allocation.
+ * @details This macro is used to allocate a static thread working area
+ * aligned as both position and size.
+ *
+ * @param[in] s the name to be assigned to the stack array
+ * @param[in] n the stack size to be assigned to the thread
+ *
+ * @api
+ */
+#define THD_WORKING_AREA(s, n) \
+ stkalign_t s[THD_WORKING_AREA_SIZE(n) / sizeof(stkalign_t)]
+/** @} */
+
+/**
* @name Macro Functions
* @{
*/
|