summaryrefslogtreecommitdiffstats
path: root/udelay.c
diff options
context:
space:
mode:
authorMaksim Kuleshov <mmcx@mail.ru>2013-04-05 08:06:10 +0000
committerCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2013-04-05 08:06:10 +0000
commit4887c7364844f139b2af769711a8d770c419b2d4 (patch)
tree752c2840a2c207360bcabaebfdbd66ceabc26c87 /udelay.c
parent562cf9ff621a6dc657a327a47c4cc23349851043 (diff)
downloadflashrom-4887c7364844f139b2af769711a8d770c419b2d4.zip
flashrom-4887c7364844f139b2af769711a8d770c419b2d4.tar.gz
Usleep() is not found in all versions of MinGW, use Sleep() on Windows
Handle long sleeps on non-Windows correctly. Corresponding to flashrom svn r1667. Signed-off-by: Maksim Kuleshov <mmcx@mail.ru> Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Diffstat (limited to 'udelay.c')
-rw-r--r--udelay.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/udelay.c b/udelay.c
index 9f5e562..e3cf3e3 100644
--- a/udelay.c
+++ b/udelay.c
@@ -169,13 +169,23 @@ recalibrate:
msg_pinfo("OK.\n");
}
+/* Not very precise sleep. */
+void internal_sleep(int usecs)
+{
+#ifdef _WIN32
+ Sleep((usecs + 999) / 1000);
+#else
+ sleep(usecs / 1000000);
+ usleep(usecs % 1000000);
+#endif
+}
+
+/* Precise delay. */
void internal_delay(int usecs)
{
- /* If the delay is >1 s, use usleep because timing does not need to
- * be so precise.
- */
+ /* If the delay is >1 s, use internal_sleep because timing does not need to be so precise. */
if (usecs > 1000000) {
- usleep(usecs);
+ internal_sleep(usecs);
} else {
myusec_delay(usecs);
}
OpenPOWER on IntegriCloud