File tree Expand file tree Collapse file tree 1 file changed +16
-8
lines changed
components/libc/compilers/common Expand file tree Collapse file tree 1 file changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -37,19 +37,26 @@ RTM_EXPORT(isatty);
3737
3838char * ttyname (int fd )
3939{
40- return "/dev/tty" ; /*TODO: need to add more specific*/
40+ return "/dev/tty" ; /* TODO: need to add more specific */
4141}
4242RTM_EXPORT (ttyname );
4343
4444unsigned int sleep (unsigned int seconds )
4545{
46- rt_tick_t delta_tick ;
47-
48- delta_tick = rt_tick_get ();
49- rt_thread_delay (seconds * RT_TICK_PER_SECOND );
50- delta_tick = rt_tick_get () - delta_tick ;
46+ if (rt_thread_self () != RT_NULL )
47+ {
48+ rt_thread_delay (seconds * RT_TICK_PER_SECOND );
49+ }
50+ else /* scheduler has not run yet */
51+ {
52+ while (seconds > 0 )
53+ {
54+ rt_hw_us_delay (1000000u );
55+ seconds -- ;
56+ }
57+ }
5158
52- return seconds - delta_tick / RT_TICK_PER_SECOND ;
59+ return 0 ;
5360}
5461RTM_EXPORT (sleep );
5562
@@ -59,11 +66,12 @@ int usleep(useconds_t usec)
5966 {
6067 rt_thread_mdelay (usec / 1000u );
6168 }
62- else
69+ else /* scheduler has not run yet */
6370 {
6471 rt_hw_us_delay (usec / 1000u );
6572 }
6673 rt_hw_us_delay (usec % 1000u );
74+
6775 return 0 ;
6876}
6977RTM_EXPORT (usleep );
You can’t perform that action at this time.
0 commit comments