File tree 1 file changed +16
-8
lines changed
components/libc/compilers/common
1 file changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -37,19 +37,26 @@ RTM_EXPORT(isatty);
37
37
38
38
char * ttyname (int fd )
39
39
{
40
- return "/dev/tty" ; /*TODO: need to add more specific*/
40
+ return "/dev/tty" ; /* TODO: need to add more specific */
41
41
}
42
42
RTM_EXPORT (ttyname );
43
43
44
44
unsigned int sleep (unsigned int seconds )
45
45
{
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
+ }
51
58
52
- return seconds - delta_tick / RT_TICK_PER_SECOND ;
59
+ return 0 ;
53
60
}
54
61
RTM_EXPORT (sleep );
55
62
@@ -59,11 +66,12 @@ int usleep(useconds_t usec)
59
66
{
60
67
rt_thread_mdelay (usec / 1000u );
61
68
}
62
- else
69
+ else /* scheduler has not run yet */
63
70
{
64
71
rt_hw_us_delay (usec / 1000u );
65
72
}
66
73
rt_hw_us_delay (usec % 1000u );
74
+
67
75
return 0 ;
68
76
}
69
77
RTM_EXPORT (usleep );
You can’t perform that action at this time.
0 commit comments