summaryrefslogtreecommitdiff
path: root/src/thread.c
diff options
context:
space:
mode:
authorShell <[email protected]>2023-12-23 17:59:18 +0800
committerMeco Man <[email protected]>2024-01-02 19:42:46 +0800
commite7880a9713ef3efed9ad133231981761bcc3e4eb (patch)
tree14909d6f79c1c39c89aa462a58779542e6f415d2 /src/thread.c
parent3a7903b799c9f379048368df029cac3e42c28be4 (diff)
[kernel] support for hook list
Signed-off-by: Shell <[email protected]>
Diffstat (limited to 'src/thread.c')
-rw-r--r--src/thread.c23
1 files changed, 2 insertions, 21 deletions
diff --git a/src/thread.c b/src/thread.c
index 9f2a89ee4f..9f1a9f3cfb 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -45,20 +45,9 @@
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
-#ifndef __on_rt_thread_inited_hook
- #define __on_rt_thread_inited_hook(thread) __ON_HOOK_ARGS(rt_thread_inited_hook, (thread))
-#endif
-#ifndef __on_rt_thread_suspend_hook
- #define __on_rt_thread_suspend_hook(thread) __ON_HOOK_ARGS(rt_thread_suspend_hook, (thread))
-#endif
-#ifndef __on_rt_thread_resume_hook
- #define __on_rt_thread_resume_hook(thread) __ON_HOOK_ARGS(rt_thread_resume_hook, (thread))
-#endif
-
#if defined(RT_USING_HOOK) && defined(RT_HOOK_USING_FUNC_PTR)
static void (*rt_thread_suspend_hook)(rt_thread_t thread);
static void (*rt_thread_resume_hook) (rt_thread_t thread);
-static void (*rt_thread_inited_hook) (rt_thread_t thread);
/**
* @brief This function sets a hook function when the system suspend a thread.
@@ -84,15 +73,7 @@ void rt_thread_resume_sethook(void (*hook)(rt_thread_t thread))
rt_thread_resume_hook = hook;
}
-/**
- * @brief This function sets a hook function when a thread is initialized.
- *
- * @param hook is the specified hook function.
- */
-void rt_thread_inited_sethook(void (*hook)(rt_thread_t thread))
-{
- rt_thread_inited_hook = hook;
-}
+RT_OBJECT_HOOKLIST_DEFINE(rt_thread_inited);
#endif /* defined(RT_USING_HOOK) && defined(RT_HOOK_USING_FUNC_PTR) */
static void _thread_exit(void)
@@ -313,7 +294,7 @@ static rt_err_t _thread_init(struct rt_thread *thread,
rt_atomic_store(&thread->ref_count, 0);
rt_spin_lock_init(&thread->spinlock);
- RT_OBJECT_HOOK_CALL(rt_thread_inited_hook, (thread));
+ RT_OBJECT_HOOKLIST_CALL(rt_thread_inited, (thread));
return RT_EOK;
}