update msleep in deprecated-hid-flasher
This commit is contained in:
@@ -1,10 +1,4 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
|
||||
//
|
||||
// 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 <windows.h>
|
||||
#define sleep(n) Sleep(1000 * n)
|
||||
#define msleep(n) Sleep(n)
|
||||
#include <windows.h>
|
||||
#define msleep(n) Sleep(n)
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#define msleep(n) usleep(1000 * n)
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user