Small optimizations in stack filling code.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@14657 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
Giovanni Di Sirio 2021-08-16 08:39:03 +00:00
parent 40405ac29c
commit 6975e6673e
4 changed files with 13 additions and 26 deletions

View File

@ -291,7 +291,7 @@ extern "C" {
const char *name,
tprio_t prio);
#if CH_DBG_FILL_THREADS == TRUE
void __thd_memfill(uint8_t *startp, uint8_t *endp, uint8_t v);
void __thd_stackfill(uint8_t *startp, uint8_t *endp);
#endif
thread_t *chThdCreateSuspendedI(const thread_descriptor_t *tdp);
thread_t *chThdCreateSuspended(const thread_descriptor_t *tdp);

View File

@ -94,9 +94,7 @@ thread_t *chThdCreateFromHeap(memory_heap_t *heapp, size_t size,
thread_descriptor_t td = THD_DESCRIPTOR(name, wbase, wend, prio, pf, arg);
#if CH_DBG_FILL_THREADS == TRUE
__thd_memfill((uint8_t *)wbase,
(uint8_t *)wbase + size,
CH_DBG_STACK_FILL_VALUE);
__thd_stackfill((uint8_t *)wbase, (uint8_t *)wend);
#endif
chSysLock();
@ -152,9 +150,7 @@ thread_t *chThdCreateFromMemoryPool(memory_pool_t *mp, const char *name,
thread_descriptor_t td = THD_DESCRIPTOR(name, wbase, wend, prio, pf, arg);
#if CH_DBG_FILL_THREADS == TRUE
__thd_memfill((uint8_t *)wbase,
(uint8_t *)wbase + mp->object_size,
CH_DBG_STACK_FILL_VALUE);
__thd_stackfill((uint8_t *)wbase, (uint8_t *)wend);
#endif
chSysLock();

View File

@ -174,9 +174,8 @@ void chInstanceObjectInit(os_instance_t *oip,
};
#if CH_DBG_FILL_THREADS == TRUE
__thd_memfill((uint8_t *)idle_descriptor.wbase,
(uint8_t *)idle_descriptor.wend,
CH_DBG_STACK_FILL_VALUE);
__thd_stackfill((uint8_t *)idle_descriptor.wbase,
(uint8_t *)idle_descriptor.wend);
#endif
/* This thread has the lowest priority in the system, its role is just to

View File

@ -130,20 +130,18 @@ thread_t *__thd_object_init(os_instance_t *oip,
#if (CH_DBG_FILL_THREADS == TRUE) || defined(__DOXYGEN__)
/**
* @brief Memory fill utility.
* @todo Optimize using the stack align type instead of uint8_t.
* @brief Stack fill utility.
*
* @param[in] startp first address to fill
* @param[in] endp last address to fill +1
* @param[in] v filler value
*
* @notapi
*/
void __thd_memfill(uint8_t *startp, uint8_t *endp, uint8_t v) {
void __thd_stackfill(uint8_t *startp, uint8_t *endp) {
while (startp < endp) {
*startp++ = v;
}
do {
*startp++ = CH_DBG_STACK_FILL_VALUE;
} while (likely(startp < endp));
}
#endif /* CH_DBG_FILL_THREADS */
@ -234,9 +232,7 @@ thread_t *chThdCreateSuspended(const thread_descriptor_t *tdp) {
#endif
#if CH_DBG_FILL_THREADS == TRUE
__thd_memfill((uint8_t *)tdp->wbase,
(uint8_t *)tdp->wend,
CH_DBG_STACK_FILL_VALUE);
__thd_stackfill((uint8_t *)tdp->wbase, (uint8_t *)tdp->wend);
#endif
chSysLock();
@ -299,9 +295,7 @@ thread_t *chThdCreate(const thread_descriptor_t *tdp) {
#endif
#if CH_DBG_FILL_THREADS == TRUE
__thd_memfill((uint8_t *)tdp->wbase,
(uint8_t *)tdp->wend,
CH_DBG_STACK_FILL_VALUE);
__thd_stackfill((uint8_t *)tdp->wbase, (uint8_t *)tdp->wend);
#endif
chSysLock();
@ -349,9 +343,7 @@ thread_t *chThdCreateStatic(void *wsp, size_t size,
#endif
#if CH_DBG_FILL_THREADS == TRUE
__thd_memfill((uint8_t *)wsp,
(uint8_t *)wsp + size,
CH_DBG_STACK_FILL_VALUE);
__thd_stackfill((uint8_t *)wsp, (uint8_t *)wsp + size);
#endif
chSysLock();