From 2382ad551b3a6a15600e457b803a587933a55f38 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Wed, 12 Jun 2019 13:57:02 -0700 Subject: [PATCH] update msleep in deprecated-hid-flasher --- client/deprecated-hid-flasher/flasher/sleep.h | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/client/deprecated-hid-flasher/flasher/sleep.h b/client/deprecated-hid-flasher/flasher/sleep.h index 62d9f4d16..f3aac0c8f 100644 --- a/client/deprecated-hid-flasher/flasher/sleep.h +++ b/client/deprecated-hid-flasher/flasher/sleep.h @@ -1,10 +1,4 @@ //----------------------------------------------------------------------------- -// Copyright (C) 2010 iZsh -// -// This code is licensed to you under the terms of the GNU GPL, version 2 or, -// at your option, any later version. See the LICENSE.txt file for the text of -// the license. -//----------------------------------------------------------------------------- // platform-independant sleep macros //----------------------------------------------------------------------------- @@ -12,13 +6,18 @@ #define SLEEP_H__ #ifdef _WIN32 -#include -#define sleep(n) Sleep(1000 * n) -#define msleep(n) Sleep(n) + #include + #define msleep(n) Sleep(n) #else -#include -#define msleep(n) usleep(1000 * n) + #include + #include + static void nsleep(uint64_t n) { + struct timespec timeout; + timeout.tv_sec = n / 1000000000; + timeout.tv_nsec = n % 1000000000; + while (nanosleep(&timeout, &timeout) && errno == EINTR); + } + #define msleep(n) nsleep(1000000 * (uint64_t)n) #endif #endif -