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>
diff --git a/udelay.c b/udelay.c
index c03bcc4..7c6961d 100644
--- a/udelay.c
+++ b/udelay.c
@@ -22,6 +22,7 @@
#ifndef __LIBPAYLOAD__
#include <unistd.h>
+#include <time.h>
#include <sys/time.h>
#include <stdlib.h>
#include <limits.h>
@@ -174,9 +175,11 @@
{
#if IS_WINDOWS
Sleep((usecs + 999) / 1000);
-#else
+#elif defined(__DJGPP__)
sleep(usecs / 1000000);
usleep(usecs % 1000000);
+#else
+ nanosleep(&(struct timespec){usecs / 1000000, (usecs * 1000) % 1000000000UL}, NULL);
#endif
}