diff options
| author | zhaohengbo <[email protected]> | 2018-12-15 11:20:24 +0800 |
|---|---|---|
| committer | zhaohengbo <[email protected]> | 2018-12-15 11:20:24 +0800 |
| commit | afcd8b452114d3ba3ed72d6d143942da7d8a30f4 (patch) | |
| tree | 6d13a2ba3887dd20e3a2fd50ba7b714b12edc1ab /src | |
| parent | 61b8db8ee9d3d649ee9b39d4e7e25516fa54117f (diff) | |
fix some bug when stack grows upward
Diffstat (limited to 'src')
| -rw-r--r-- | src/scheduler.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/scheduler.c b/src/scheduler.c index 14f7510e66..697df63ee1 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -82,10 +82,17 @@ static void _rt_scheduler_stack_check(struct rt_thread *thread) { RT_ASSERT(thread != RT_NULL); +#if defined(ARCH_CPU_STACK_GROWS_UPWARD) + if (*((rt_uint8_t *)((rt_ubase_t)thread->stack_addr + thread->stack_size - 1)) != '#' || + (rt_ubase_t)thread->sp <= (rt_ubase_t)thread->stack_addr || + (rt_ubase_t)thread->sp > + (rt_ubase_t)thread->stack_addr + (rt_ubase_t)thread->stack_size) +#else if (*((rt_uint8_t *)thread->stack_addr) != '#' || (rt_ubase_t)thread->sp <= (rt_ubase_t)thread->stack_addr || (rt_ubase_t)thread->sp > (rt_ubase_t)thread->stack_addr + (rt_ubase_t)thread->stack_size) +#endif { rt_ubase_t level; |
