Add high resolution to nmsleep wrapper on windows.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
diff --git a/Makefile.am b/Makefile.am
index 2417fbe..3079f6d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -24,7 +24,7 @@ bin_SCRIPTS = $(top_srcdir)/*.cl
cgminer_LDFLAGS = $(PTHREAD_FLAGS)
cgminer_LDADD = $(DLOPEN_FLAGS) @LIBCURL_LIBS@ @JANSSON_LIBS@ @PTHREAD_LIBS@ \
@OPENCL_LIBS@ @NCURSES_LIBS@ @PDCURSES_LIBS@ @WS2_LIBS@ \
- @UDEV_LIBS@ @LIBUSB_LIBS@ \
+ @UDEV_LIBS@ @LIBUSB_LIBS@ @MM_LIBS@ \
@MATH_LIBS@ lib/libgnu.a ccan/libccan.a
if HAVE_WINDOWS
diff --git a/configure.ac b/configure.ac
index 6c2b3c4..4fb74a1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -65,6 +65,7 @@ PTHREAD_FLAGS="-lpthread"
DLOPEN_FLAGS="-ldl"
OPENCL_LIBS="-lOpenCL"
WS2_LIBS=""
+MM_LIBS=""
MATH_LIBS="-lm"
case $target in
@@ -85,6 +86,7 @@ case $target in
PTHREAD_FLAGS=""
DLOPEN_FLAGS=""
WS2_LIBS="-lws2_32"
+ MM_LIBS="-lwinmm"
AC_DEFINE([_WIN32_WINNT], [0x0501], "WinNT version for XP+ support")
;;
powerpc-*-darwin*)
@@ -493,6 +495,7 @@ AC_SUBST(PTHREAD_LIBS)
AC_SUBST(NCURSES_LIBS)
AC_SUBST(PDCURSES_LIBS)
AC_SUBST(WS2_LIBS)
+AC_SUBST(MM_LIBS)
AC_SUBST(MATH_LIBS)
AC_SUBST(UDEV_LIBS)
AC_SUBST(YASM_FMT)
diff --git a/util.c b/util.c
index ffe4b94..0433d0b 100644
--- a/util.c
+++ b/util.c
@@ -30,6 +30,7 @@
# include <netinet/tcp.h>
# include <netdb.h>
#else
+# include <windows.h>
# include <winsock2.h>
# include <ws2tcpip.h>
#endif
@@ -825,6 +826,9 @@ void nmsleep(unsigned int msecs)
int ret;
ldiv_t d;
+#ifdef WIN32
+ timeBeginPeriod(1);
+#endif
d = ldiv(msecs, 1000);
tleft.tv_sec = d.quot;
tleft.tv_nsec = d.rem * 1000000;
@@ -833,6 +837,9 @@ void nmsleep(unsigned int msecs)
twait.tv_nsec = tleft.tv_nsec;
ret = nanosleep(&twait, &tleft);
} while (ret == -1 && errno == EINTR);
+#ifdef WIN32
+ timeEndPeriod(1);
+#endif
}
/* Returns the microseconds difference between end and start times as a double */