diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2014-08-10 13:11:52 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2014-08-10 13:11:52 -0600 |
commit | 76b2427b15f1f4f968aa4b7850581d3c679290a9 (patch) | |
tree | f088d51af1c435376d6278c957ead62a6a3189b0 | |
parent | f73988dd9b1e4c6ae096871b1f98024827b2f82b (diff) | |
download | nuttx-76b2427b15f1f4f968aa4b7850581d3c679290a9.tar.gz nuttx-76b2427b15f1f4f968aa4b7850581d3c679290a9.tar.bz2 nuttx-76b2427b15f1f4f968aa4b7850581d3c679290a9.zip |
Slightly improved nanosecond calculation
-rw-r--r-- | nuttx/libc/unistd/lib_usleep.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/nuttx/libc/unistd/lib_usleep.c b/nuttx/libc/unistd/lib_usleep.c index e48ae4267..3088c7737 100644 --- a/nuttx/libc/unistd/lib_usleep.c +++ b/nuttx/libc/unistd/lib_usleep.c @@ -129,14 +129,16 @@ int usleep(useconds_t usec) { struct timespec rqtp; + time_t sec; int ret = 0; if (usec) { /* Let nanosleep() do all of the work. */ - rqtp.tv_sec = usec / 1000000; - rqtp.tv_nsec = (usec % 1000000) * 1000; + sec = usec / 1000000; + rqtp.tv_sec = sec; + rqtp.tv_nsec = (usec - (sec * 1000000)) * 1000; ret = nanosleep(&rqtp, NULL); } |