summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Tauner <stefan.tauner@alumni.tuwien.ac.at>2015-11-14 02:55:22 +0000
committerStefan Tauner <stefan.tauner@alumni.tuwien.ac.at>2015-11-14 02:55:22 +0000
commit839db6dccd416417f15771beef234b54cd058627 (patch)
tree78ecc458c60ef8849dd9ecfc51aefdfa68501d9f
parent8cd0c73fb54658e9176c4b78a57bc9e99eab4faf (diff)
downloadast2050-flashrom-839db6dccd416417f15771beef234b54cd058627.zip
ast2050-flashrom-839db6dccd416417f15771beef234b54cd058627.tar.gz
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>
-rw-r--r--udelay.c5
1 files changed, 4 insertions, 1 deletions
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 @@ void internal_sleep(unsigned int usecs)
{
#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
}
OpenPOWER on IntegriCloud