diff --git a/include/rtthread.h b/include/rtthread.h index 00cfd42758..fecdd5eac2 100644 --- a/include/rtthread.h +++ b/include/rtthread.h @@ -133,7 +133,7 @@ void rt_enter_critical(void); void rt_exit_critical(void); #ifdef RT_USING_HOOK -void rt_schedule_sethook(void (*hook)(rt_thread_t from, rt_thread_t to)); +void rt_scheduler_sethook(void (*hook)(rt_thread_t from, rt_thread_t to)); #endif /*@}*/ @@ -157,8 +157,8 @@ void *rt_mp_alloc (rt_mp_t mp, rt_int32_t time); void rt_mp_free (void *block); #ifdef RT_USING_HOOK -void rt_mp_alloc_sethook(void (*hook)(void *block)); -void rt_mp_free_sethook(void (*hook)(void *block)); +void rt_mp_alloc_sethook(void (*hook)(struct rt_mempool* mp, void *block)); +void rt_mp_free_sethook(void (*hook)(struct rt_mempool* mp, void *block)); #endif #endif diff --git a/src/mempool.c b/src/mempool.c index ab90fdc465..4d28012b66 100644 --- a/src/mempool.c +++ b/src/mempool.c @@ -24,8 +24,8 @@ #ifdef RT_USING_MEMPOOL #ifdef RT_USING_HOOK -static void (*rt_mp_alloc_hook)(void *block); -static void (*rt_mp_free_hook)(void *block); +static void (*rt_mp_alloc_hook)(struct rt_mempool* mp, void *block); +static void (*rt_mp_free_hook)(struct rt_mempool* mp, void *block); /** * @addtogroup Hook @@ -38,7 +38,7 @@ static void (*rt_mp_free_hook)(void *block); * * @param hook the hook function */ -void rt_mp_alloc_sethook(void (*hook)(void *block)) +void rt_mp_alloc_sethook(void (*hook)(struct rt_mempool* mp, void *block)) { rt_mp_alloc_hook = hook; } @@ -49,7 +49,7 @@ void rt_mp_alloc_sethook(void (*hook)(void *block)) * * @param hook the hook function */ -void rt_mp_free_sethook(void (*hook)(void *block)) +void rt_mp_free_sethook(void (*hook)(struct rt_mempool* mp, void *block)) { rt_mp_free_hook = hook; } @@ -344,7 +344,7 @@ void *rt_mp_alloc (rt_mp_t mp, rt_int32_t time) rt_hw_interrupt_enable(level); #ifdef RT_USING_HOOK - if (rt_mp_alloc_hook != RT_NULL) rt_mp_alloc_hook((rt_uint8_t*)(block_ptr + sizeof(rt_uint8_t*))); + if (rt_mp_alloc_hook != RT_NULL) rt_mp_alloc_hook(mp, (rt_uint8_t*)(block_ptr + sizeof(rt_uint8_t*))); #endif return (rt_uint8_t*)(block_ptr + sizeof(rt_uint8_t*)); @@ -368,7 +368,7 @@ void rt_mp_free (void *block) mp = (struct rt_mempool*) *block_ptr; #ifdef RT_USING_HOOK - if (rt_mp_free_hook != RT_NULL) rt_mp_free_hook(block); + if (rt_mp_free_hook != RT_NULL) rt_mp_free_hook(mp, block); #endif /* disable interrupt */