mirror of
https://github.com/apache/nuttx.git
synced 2026-05-30 21:36:28 +08:00
Slightly improved nanosecond calculation
This commit is contained in:
@@ -129,14 +129,16 @@
|
|||||||
int usleep(useconds_t usec)
|
int usleep(useconds_t usec)
|
||||||
{
|
{
|
||||||
struct timespec rqtp;
|
struct timespec rqtp;
|
||||||
|
time_t sec;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (usec)
|
if (usec)
|
||||||
{
|
{
|
||||||
/* Let nanosleep() do all of the work. */
|
/* Let nanosleep() do all of the work. */
|
||||||
|
|
||||||
rqtp.tv_sec = usec / 1000000;
|
sec = usec / 1000000;
|
||||||
rqtp.tv_nsec = (usec % 1000000) * 1000;
|
rqtp.tv_sec = sec;
|
||||||
|
rqtp.tv_nsec = (usec - (sec * 1000000)) * 1000;
|
||||||
|
|
||||||
ret = nanosleep(&rqtp, NULL);
|
ret = nanosleep(&rqtp, NULL);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user