@@ -275,6 +275,7 @@ rt_err_t rt_thread_startup(rt_thread_t thread)
275275 /* thread check */
276276 RT_ASSERT (thread != RT_NULL );
277277 RT_ASSERT ((thread -> stat & RT_THREAD_STAT_MASK ) == RT_THREAD_INIT );
278+ RT_ASSERT (rt_object_get_type ((rt_object_t )thread ) == RT_Object_Class_Thread );
278279
279280 /* set current priority to init priority */
280281 thread -> current_priority = thread -> init_priority ;
@@ -318,6 +319,8 @@ rt_err_t rt_thread_detach(rt_thread_t thread)
318319
319320 /* thread check */
320321 RT_ASSERT (thread != RT_NULL );
322+ RT_ASSERT (rt_object_get_type ((rt_object_t )thread ) == RT_Object_Class_Thread );
323+ RT_ASSERT (rt_object_is_systemobject ((rt_object_t )thread ));
321324
322325 if ((thread -> stat & RT_THREAD_STAT_MASK ) != RT_THREAD_INIT )
323326 {
@@ -416,6 +419,8 @@ rt_err_t rt_thread_delete(rt_thread_t thread)
416419
417420 /* thread check */
418421 RT_ASSERT (thread != RT_NULL );
422+ RT_ASSERT (rt_object_get_type ((rt_object_t )thread ) == RT_Object_Class_Thread );
423+ RT_ASSERT (rt_object_is_systemobject ((rt_object_t )thread ) == RT_FALSE );
419424
420425 if ((thread -> stat & RT_THREAD_STAT_MASK ) != RT_THREAD_INIT )
421426 {
@@ -504,6 +509,7 @@ rt_err_t rt_thread_sleep(rt_tick_t tick)
504509 /* set to current thread */
505510 thread = rt_current_thread ;
506511 RT_ASSERT (thread != RT_NULL );
512+ RT_ASSERT (rt_object_get_type ((rt_object_t )thread ) == RT_Object_Class_Thread );
507513
508514 /* suspend thread */
509515 rt_thread_suspend (thread );
@@ -572,6 +578,7 @@ rt_err_t rt_thread_control(rt_thread_t thread, int cmd, void *arg)
572578
573579 /* thread check */
574580 RT_ASSERT (thread != RT_NULL );
581+ RT_ASSERT (rt_object_get_type ((rt_object_t )thread ) == RT_Object_Class_Thread );
575582
576583 switch (cmd )
577584 {
@@ -650,6 +657,7 @@ rt_err_t rt_thread_suspend(rt_thread_t thread)
650657
651658 /* thread check */
652659 RT_ASSERT (thread != RT_NULL );
660+ RT_ASSERT (rt_object_get_type ((rt_object_t )thread ) == RT_Object_Class_Thread );
653661
654662 RT_DEBUG_LOG (RT_DEBUG_THREAD , ("thread suspend: %s\n" , thread -> name ));
655663
@@ -692,6 +700,7 @@ rt_err_t rt_thread_resume(rt_thread_t thread)
692700
693701 /* thread check */
694702 RT_ASSERT (thread != RT_NULL );
703+ RT_ASSERT (rt_object_get_type ((rt_object_t )thread ) == RT_Object_Class_Thread );
695704
696705 RT_DEBUG_LOG (RT_DEBUG_THREAD , ("thread resume: %s\n" , thread -> name ));
697706
@@ -737,6 +746,7 @@ void rt_thread_timeout(void *parameter)
737746 /* thread check */
738747 RT_ASSERT (thread != RT_NULL );
739748 RT_ASSERT ((thread -> stat & RT_THREAD_STAT_MASK ) == RT_THREAD_SUSPEND );
749+ RT_ASSERT (rt_object_get_type ((rt_object_t )thread ) == RT_Object_Class_Thread );
740750
741751 /* set error number */
742752 thread -> error = - RT_ETIMEOUT ;
0 commit comments