Alignment reuirement for memory pools Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
yusuf.husainy
Posts: 9
Joined: Sat Jan 27, 2018 1:33 am
Has thanked: 4 times
Been thanked: 5 times

Alignment reuirement for memory pools  Topic is solved

Postby yusuf.husainy » Fri Jul 06, 2018 11:52 pm

Hi All,

I have a memory pool object and associated object memory aligned to stkalign_t as well as another pool and associated object memory without any alignment.

On looking at the source code of ChibiOS, I see chPoolAdd() is called by chPoolLoadArray() on loading both above pools after their initialization. The function description for chPoolAdd() says:

Code: Select all

/**
 * @brief   Adds an object to a memory pool.
 * @pre     The memory pool must be already been initialized.
 * @pre     The added object must be of the right size for the specified
 *          memory pool.
 [glow=red]* @pre     The added object must be memory aligned to the size of
 *          @p stkalign_t type.
[/glow] * @note    This function is just an alias for @p chPoolFree() and has been
 *          added for clarity.
 *
 * @param[in] mp        pointer to a @p memory_pool_t structure
 * @param[in] objp      the pointer to the object to be added
 *
 * @api
 */
static inline void chPoolAdd(memory_pool_t *mp, void *objp) {

  chPoolFree(mp, objp);
}


Why is there a requirement that the alignment should be stkalign_t and not the PORT_NATURAL_ALIGN.

My code works with both the pools mentioned above, with and without the objects being aligne to stkalign_t.

My setup:
version: ChibiOS 18.2.0.
platform: simulator posix.

Regards,
Yusuf Husainy,

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: Alignment reuirement for memory pools

Postby Giovanni » Sun Jul 08, 2018 2:47 pm

Hi,

It is a documentation error, PORT_NATURAL_ALIGN is fine.

Moved in bug reports.

Giovanni

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: Alignment reuirement for memory pools

Postby Giovanni » Sun Jul 15, 2018 12:53 pm

Hi,

Fixed in repository.

Giovanni


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 24 guests