1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-26 22:52:34 +02:00

Use nanosleep() instead of usleep() where available

Usleep() has been obsolete for quite a while.
The only target that uses it without alternative is DOS.

Corresponding to flashrom svn r1899.

Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
This commit is contained in:
Stefan Tauner 2015-11-14 02:55:22 +00:00
parent 8cd0c73fb5
commit 839db6dccd

View File

@ -22,6 +22,7 @@
#ifndef __LIBPAYLOAD__ #ifndef __LIBPAYLOAD__
#include <unistd.h> #include <unistd.h>
#include <time.h>
#include <sys/time.h> #include <sys/time.h>
#include <stdlib.h> #include <stdlib.h>
#include <limits.h> #include <limits.h>
@ -174,9 +175,11 @@ void internal_sleep(unsigned int usecs)
{ {
#if IS_WINDOWS #if IS_WINDOWS
Sleep((usecs + 999) / 1000); Sleep((usecs + 999) / 1000);
#else #elif defined(__DJGPP__)
sleep(usecs / 1000000); sleep(usecs / 1000000);
usleep(usecs % 1000000); usleep(usecs % 1000000);
#else
nanosleep(&(struct timespec){usecs / 1000000, (usecs * 1000) % 1000000000UL}, NULL);
#endif #endif
} }