mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-11 07:17:58 +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_LDFLAGS = $(PTHREAD_FLAGS)
|
||||||
cgminer_LDADD = $(DLOPEN_FLAGS) @LIBCURL_LIBS@ @JANSSON_LIBS@ @PTHREAD_LIBS@ \
|
cgminer_LDADD = $(DLOPEN_FLAGS) @LIBCURL_LIBS@ @JANSSON_LIBS@ @PTHREAD_LIBS@ \
|
||||||
@OPENCL_LIBS@ @NCURSES_LIBS@ @PDCURSES_LIBS@ @WS2_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
|
@MATH_LIBS@ lib/libgnu.a ccan/libccan.a
|
||||||
|
|
||||||
if HAVE_WINDOWS
|
if HAVE_WINDOWS
|
||||||
|
@ -65,6 +65,7 @@ PTHREAD_FLAGS="-lpthread"
|
|||||||
DLOPEN_FLAGS="-ldl"
|
DLOPEN_FLAGS="-ldl"
|
||||||
OPENCL_LIBS="-lOpenCL"
|
OPENCL_LIBS="-lOpenCL"
|
||||||
WS2_LIBS=""
|
WS2_LIBS=""
|
||||||
|
MM_LIBS=""
|
||||||
MATH_LIBS="-lm"
|
MATH_LIBS="-lm"
|
||||||
|
|
||||||
case $target in
|
case $target in
|
||||||
@ -85,6 +86,7 @@ case $target in
|
|||||||
PTHREAD_FLAGS=""
|
PTHREAD_FLAGS=""
|
||||||
DLOPEN_FLAGS=""
|
DLOPEN_FLAGS=""
|
||||||
WS2_LIBS="-lws2_32"
|
WS2_LIBS="-lws2_32"
|
||||||
|
MM_LIBS="-lwinmm"
|
||||||
AC_DEFINE([_WIN32_WINNT], [0x0501], "WinNT version for XP+ support")
|
AC_DEFINE([_WIN32_WINNT], [0x0501], "WinNT version for XP+ support")
|
||||||
;;
|
;;
|
||||||
powerpc-*-darwin*)
|
powerpc-*-darwin*)
|
||||||
@ -493,6 +495,7 @@ AC_SUBST(PTHREAD_LIBS)
|
|||||||
AC_SUBST(NCURSES_LIBS)
|
AC_SUBST(NCURSES_LIBS)
|
||||||
AC_SUBST(PDCURSES_LIBS)
|
AC_SUBST(PDCURSES_LIBS)
|
||||||
AC_SUBST(WS2_LIBS)
|
AC_SUBST(WS2_LIBS)
|
||||||
|
AC_SUBST(MM_LIBS)
|
||||||
AC_SUBST(MATH_LIBS)
|
AC_SUBST(MATH_LIBS)
|
||||||
AC_SUBST(UDEV_LIBS)
|
AC_SUBST(UDEV_LIBS)
|
||||||
AC_SUBST(YASM_FMT)
|
AC_SUBST(YASM_FMT)
|
||||||
|
7
util.c
7
util.c
@ -30,6 +30,7 @@
|
|||||||
# include <netinet/tcp.h>
|
# include <netinet/tcp.h>
|
||||||
# include <netdb.h>
|
# include <netdb.h>
|
||||||
#else
|
#else
|
||||||
|
# include <windows.h>
|
||||||
# include <winsock2.h>
|
# include <winsock2.h>
|
||||||
# include <ws2tcpip.h>
|
# include <ws2tcpip.h>
|
||||||
#endif
|
#endif
|
||||||
@ -825,6 +826,9 @@ void nmsleep(unsigned int msecs)
|
|||||||
int ret;
|
int ret;
|
||||||
ldiv_t d;
|
ldiv_t d;
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
timeBeginPeriod(1);
|
||||||
|
#endif
|
||||||
d = ldiv(msecs, 1000);
|
d = ldiv(msecs, 1000);
|
||||||
tleft.tv_sec = d.quot;
|
tleft.tv_sec = d.quot;
|
||||||
tleft.tv_nsec = d.rem * 1000000;
|
tleft.tv_nsec = d.rem * 1000000;
|
||||||
@ -833,6 +837,9 @@ void nmsleep(unsigned int msecs)
|
|||||||
twait.tv_nsec = tleft.tv_nsec;
|
twait.tv_nsec = tleft.tv_nsec;
|
||||||
ret = nanosleep(&twait, &tleft);
|
ret = nanosleep(&twait, &tleft);
|
||||||
} while (ret == -1 && errno == EINTR);
|
} while (ret == -1 && errno == EINTR);
|
||||||
|
#ifdef WIN32
|
||||||
|
timeEndPeriod(1);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns the microseconds difference between end and start times as a double */
|
/* Returns the microseconds difference between end and start times as a double */
|
||||||
|
Loading…
Reference in New Issue
Block a user