aboutsummaryrefslogtreecommitdiffstats
path: root/os/lib/include
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2019-01-06 15:45:01 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2019-01-06 15:45:01 +0000
commit2e2a38cd10e11d3e085c62149440dddb474ea7bf (patch)
tree6dced32c2c9c8f0fac8b51d386a377d5c5dbec76 /os/lib/include
parent6421004d21f26d809d6b7dcd18d5b0d6ee02eb8c (diff)
downloadChibiOS-2e2a38cd10e11d3e085c62149440dddb474ea7bf.tar.gz
ChibiOS-2e2a38cd10e11d3e085c62149440dddb474ea7bf.tar.bz2
ChibiOS-2e2a38cd10e11d3e085c62149440dddb474ea7bf.zip
chFifoObjectInit() renamed to chFifoObjectInitAligned(). Added a new chFifoObjectInit() without the alignment parameter. Stricter alignment checks in memory pools.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@12535 110e8d01-0319-4d1e-a829-52ad28d1bb01
Diffstat (limited to 'os/lib/include')
-rw-r--r--os/lib/include/chobjfifos.h33
1 files changed, 30 insertions, 3 deletions
diff --git a/os/lib/include/chobjfifos.h b/os/lib/include/chobjfifos.h
index a422bf81d..c75937eb7 100644
--- a/os/lib/include/chobjfifos.h
+++ b/os/lib/include/chobjfifos.h
@@ -125,9 +125,11 @@ extern "C" {
*
* @init
*/
-static inline void chFifoObjectInit(objects_fifo_t *ofp, size_t objsize,
- size_t objn, unsigned objalign,
- void *objbuf, msg_t *msgbuf) {
+static inline void chFifoObjectInitAligned(objects_fifo_t *ofp, size_t objsize,
+ size_t objn, unsigned objalign,
+ void *objbuf, msg_t *msgbuf) {
+
+ chDbgCheck((objsize >= objalign) && (objsize % objalign == 0U));
chGuardedPoolObjectInitAligned(&ofp->free, objsize, objalign);
chGuardedPoolLoadArray(&ofp->free, objbuf, objn);
@@ -135,6 +137,31 @@ static inline void chFifoObjectInit(objects_fifo_t *ofp, size_t objsize,
}
/**
+ * @brief Initializes a FIFO object.
+ * @pre The messages size must be a multiple of the alignment
+ * requirement.
+ *
+ * @param[out] ofp pointer to a @p objects_fifo_t structure
+ * @param[in] objsize size of objects
+ * @param[in] objn number of objects available
+ * @param[in] objbuf pointer to the buffer of objects, it must be able
+ * to hold @p objn objects of @p objsize size with
+ * @p objealign alignment
+ * @param[in] msgbuf pointer to the buffer of messages, it must be able
+ * to hold @p objn messages
+ *
+ * @init
+ */
+static inline void chFifoObjectInit(objects_fifo_t *ofp, size_t objsize,
+ size_t objn, void *objbuf,
+ msg_t *msgbuf) {
+
+ chFifoObjectInitAligned(ofp, objsize, objn,
+ PORT_NATURAL_ALIGN,
+ objbuf, msgbuf);
+}
+
+/**
* @brief Allocates a free object.
*
* @param[in] ofp pointer to a @p objects_fifo_t structure