Skip to content

mem pool size: Fix calculation of memory pool size for portability #10706

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions rtos/MemoryPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,11 @@ class MemoryPool : private mbed::NonCopyable<MemoryPool<T, pool_sz> > {

private:
osMemoryPoolId_t _id;
/* osMemoryPoolNew requires that pool block size is a multiple of 4 bytes. */
char _pool_mem[((sizeof(T) + 3) & ~3) * pool_sz];
char _pool_mem[MBED_RTOS_STORAGE_MEM_POOL_MEM_SIZE(pool_sz, sizeof(T))];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change leaves the comment above unnecessary.

I do worry a bit about alignment, but maybe some C++11 alignas qualifier(s) could be added later.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mbed_rtos_storage_mem_pool_t _obj_mem;
};
/** @}*/
/** @}*/

}
#endif


3 changes: 3 additions & 0 deletions rtos/TARGET_CORTEX/mbed_rtos_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ typedef osRtxEventFlags_t mbed_rtos_storage_event_flags_t;
typedef osRtxMessage_t mbed_rtos_storage_message_t;
typedef osRtxTimer_t mbed_rtos_storage_timer_t;

#define MBED_RTOS_STORAGE_MEM_POOL_MEM_SIZE(block_count, block_size) \
osRtxMemoryPoolMemSize(block_count, block_size)

#ifdef __cplusplus
}
#endif
Expand Down