MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / timer_delete

Function timer_delete

components/libc/compilers/common/ctime.c:1052–1096  ·  view source on GitHub ↗

* @brief Delete a per-process timer. * * See IEEE 1003.1 */

Source from the content-addressed store, hash-verified

1050 * See IEEE 1003.1
1051 */
1052int timer_delete(timer_t timerid)
1053{
1054 struct timer_obj *timer;
1055 rt_ubase_t ktimerid;
1056
1057 ktimerid = (rt_ubase_t)timerid;
1058
1059 if (ktimerid < 0 || ktimerid >= TIMER_ID_MAX)
1060 {
1061 rt_set_errno(EINVAL);
1062 return -1;
1063 }
1064
1065 RT_DEBUG_NOT_IN_INTERRUPT;
1066 rt_spin_lock(&_timer_id_lock);
1067 timer = _g_timerid[ktimerid];
1068 if (timer != NULL)
1069 {
1070 _g_timerid[ktimerid] = RT_NULL;
1071 resource_id_put(&id_timer, ktimerid);
1072 }
1073 rt_spin_unlock(&_timer_id_lock);
1074
1075 if (timer == RT_NULL)
1076 {
1077 rt_set_errno(EINVAL);
1078 LOG_D("can not find timer %ld", ktimerid);
1079 return -1;
1080 }
1081
1082 if (timer->status == ACTIVE)
1083 {
1084 timer->status = NOT_ACTIVE;
1085 rt_ktime_hrtimer_stop(&timer->hrtimer);
1086 }
1087 rt_ktime_hrtimer_detach(&timer->hrtimer);
1088
1089#ifdef RT_USING_SMART
1090 if (timer->pid)
1091 rt_list_remove(&timer->lwp_node);
1092 rt_free(timer->work);
1093#endif
1094 rt_free(timer);
1095 return 0;
1096}
1097RTM_EXPORT(timer_delete);
1098
1099/**

Callers 3

lwp_signal_detachFunction · 0.85
sys_timer_deleteFunction · 0.85
timer_list_freeFunction · 0.85

Calls 8

rt_set_errnoFunction · 0.85
resource_id_putFunction · 0.85
rt_ktime_hrtimer_stopFunction · 0.85
rt_ktime_hrtimer_detachFunction · 0.85
rt_list_removeFunction · 0.85
rt_freeFunction · 0.85
rt_spin_lockFunction · 0.50
rt_spin_unlockFunction · 0.50

Tested by

no test coverage detected