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

Function rtthread_timer_wrapper

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

Source from the content-addressed store, hash-verified

885#endif /* RT_USING_SMART */
886
887static void rtthread_timer_wrapper(void *timerobj)
888{
889 struct timer_obj *timer;
890
891 timer = (struct timer_obj *)timerobj;
892
893 if (timer->reload == 0U)
894 {
895 timer->status = NOT_ACTIVE;
896 }
897
898 timer->reload = ((timer->interval.tv_sec * NANOSECOND_PER_SECOND + timer->interval.tv_nsec) * RT_KTIME_RESMUL) /
899 rt_ktime_cputimer_getres();
900 if (timer->reload)
901 {
902 rt_ktime_hrtimer_start(&timer->hrtimer, timer->reload);
903 }
904#ifdef RT_USING_SMART
905 /* this field is named as tid in musl */
906 void *ptid = &timer->sigev_notify_func;
907 int tid = *(int *)ptid;
908 struct lwp_timer_event_param *data = rt_container_of(timer->work, struct lwp_timer_event_param, work);
909 data->signo = timer->sigev_signo;
910
911 if (!tid)
912 {
913 data->pid = timer->pid;
914 rt_work_init(timer->work, _lwp_timer_event_from_pid, 0);
915 }
916 else
917 {
918 data->tid = tid;
919 rt_work_init(timer->work, _lwp_timer_event_from_tid, 0);
920 }
921
922 if (rt_work_submit(timer->work, 0))
923 RT_ASSERT(0);
924#else
925 if(timer->sigev_notify_func != RT_NULL)
926 {
927 (timer->sigev_notify_func)(timer->val);
928 }
929#endif /* RT_USING_SMART */
930}
931
932#define TIMER_ID_MAX 50
933static struct rt_spinlock _timer_id_lock = RT_SPINLOCK_INIT;

Callers

nothing calls this directly

Calls 4

rt_ktime_hrtimer_startFunction · 0.85
rt_work_initFunction · 0.85
rt_work_submitFunction · 0.85
rt_ktime_cputimer_getresFunction · 0.50

Tested by

no test coverage detected