mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-10 23:08:07 +00:00
Add high resolution to nmsleep wrapper on windows.
This commit is contained in:
parent
57e5bfbb25
commit
3b5ef34371
@ -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
|
||||
|
@ -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)
|
||||
|
7
util.c
7
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 */
|
||||
|
Loading…
Reference in New Issue
Block a user