Skip to content

Commit b4836b9

Browse files
committed
mem pool size: Fix calculation of memory pool size for portability
Replace the hardcoded value calculation of the memory pool block size with the RTX preprocessor macro (via a shim layer). This is in preparation for the replacement of the direct access of RTX functionalities in Mbed OS with an access via CMSIS.
1 parent 9cc1caa commit b4836b9

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

rtos/MemoryPool.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,11 @@ class MemoryPool : private mbed::NonCopyable<MemoryPool<T, pool_sz> > {
184184
private:
185185
osMemoryPoolId_t _id;
186186
/* osMemoryPoolNew requires that pool block size is a multiple of 4 bytes. */
187-
char _pool_mem[((sizeof(T) + 3) & ~3) * pool_sz];
187+
char _pool_mem[MBED_RTOS_STORAGE_MEM_POOL_MEM_SIZE(pool_sz, sizeof(T))];
188188
mbed_rtos_storage_mem_pool_t _obj_mem;
189189
};
190190
/** @}*/
191191
/** @}*/
192192

193193
}
194194
#endif
195-
196-

rtos/TARGET_CORTEX/mbed_rtos_storage.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ typedef osRtxEventFlags_t mbed_rtos_storage_event_flags_t;
5252
typedef osRtxMessage_t mbed_rtos_storage_message_t;
5353
typedef osRtxTimer_t mbed_rtos_storage_timer_t;
5454

55+
#define MBED_RTOS_STORAGE_MEM_POOL_MEM_SIZE(block_count, block_size) \
56+
osRtxMemoryPoolMemSize(block_count, block_size)
57+
5558
#ifdef __cplusplus
5659
}
5760
#endif

0 commit comments

Comments
 (0)