Skip to content

Commit

Permalink
Windows build fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
ckolivas committed Jan 23, 2017
1 parent 14b22b6 commit ec1ac28
Show file tree
Hide file tree
Showing 17 changed files with 27 additions and 55 deletions.
6 changes: 1 addition & 5 deletions cgminer.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#ifndef WIN32
#include <sys/resource.h>
#else
#include <winsock2.h>
#include <windows.h>
#endif
#include <ccan/opt/opt.h>
Expand Down Expand Up @@ -4172,13 +4173,8 @@ static void kill_mining(void)
if (thr && PTH(thr) != 0L)
pth = &thr->pth;
thr_info_cancel(thr);
#ifndef WIN32
if (pth && *pth)
pthread_join(*pth, NULL);
#else
if (pth && pth->p)
pthread_join(*pth, NULL);
#endif
}
}

Expand Down
5 changes: 3 additions & 2 deletions compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "miner.h" // for timersub
#include "util.h"

#include <winsock2.h>
#include <windows.h>

#ifndef HAVE_LIBWINPTHREAD
Expand Down Expand Up @@ -46,7 +47,7 @@ static inline int nanosleep(const struct timespec *req, struct timespec *rem)
return 0;
}
#endif

#if 0
static inline int sleep(unsigned int secs)
{
struct timespec req, rem;
Expand All @@ -56,7 +57,7 @@ static inline int sleep(unsigned int secs)
return 0;
return rem.tv_sec + (rem.tv_nsec ? 1 : 0);
}

#endif
enum {
PRIO_PROCESS = 0,
};
Expand Down
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ case $target in
WS2_LIBS="-lws2_32"
MM_LIBS="-lwinmm"
RT_LIBS=""
AC_DEFINE([_WIN32_WINNT], [0x0501], "WinNT version for XP+ support")
#AC_DEFINE([_WIN32_WINNT], [0x0501], "WinNT version for XP+ support")
;;
powerpc-*-darwin*)
have_darwin=true
Expand Down Expand Up @@ -477,7 +477,7 @@ AC_ARG_WITH([curses],
if test "x$curses" = "xno"; then
cursesmsg='User specified --without-curses. TUI support DISABLED'
else
AC_SEARCH_LIBS(addstr, ncurses pdcurses, [
AC_SEARCH_LIBS(addstr, pdcurses ncurses pdcurses, [
curses=yes
cursesmsg="FOUND: ${ac_cv_search_addstr}"
AC_DEFINE([HAVE_CURSES], [1], [Defined to 1 if curses TUI support is wanted])
Expand Down
1 change: 0 additions & 1 deletion driver-avalon.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#endif
#else
#include "compat.h"
#include <windows.h>
#include <io.h>
#endif

Expand Down
1 change: 0 additions & 1 deletion driver-avalon2.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#define O_CLOEXEC 0
#endif
#else
#include <windows.h>
#include <io.h>
#endif

Expand Down
4 changes: 0 additions & 4 deletions driver-bflsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@
#include <sys/time.h>
#include <unistd.h>

#ifdef WIN32
#include <windows.h>
#endif

#include "compat.h"
#include "miner.h"
#include "usbutils.h"
Expand Down
4 changes: 0 additions & 4 deletions driver-bitforce.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@
#include "usbutils.h"
#include "util.h"

#ifdef WIN32
#include <windows.h>
#endif /* WIN32 */

#define BITFORCE_IDENTIFY "ZGX"
#define BITFORCE_IDENTIFY_LEN (sizeof(BITFORCE_IDENTIFY)-1)
#define BITFORCE_FLASH "ZMX"
Expand Down
1 change: 0 additions & 1 deletion driver-blockerupter.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#define O_CLOEXEC 0
#endif
#else
#include <windows.h>
#include <io.h>
#endif

Expand Down
1 change: 0 additions & 1 deletion driver-hashratio.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#define O_CLOEXEC 0
#endif
#else
#include <windows.h>
#include <io.h>
#endif

Expand Down
4 changes: 0 additions & 4 deletions driver-icarus.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@

#include "config.h"

#ifdef WIN32
#include <windows.h>
#endif

#include "compat.h"
#include "miner.h"
#include "usbutils.h"
Expand Down
4 changes: 0 additions & 4 deletions driver-klondike.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@

#include "config.h"

#ifdef WIN32
#include <windows.h>
#endif

#include "compat.h"
#include "miner.h"
#include "usbutils.h"
Expand Down
4 changes: 0 additions & 4 deletions driver-spondoolies-sp10.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@

#include "config.h"

#ifdef WIN32
#include <windows.h>
#endif

#include "compat.h"
#include "miner.h"
#include "driver-spondoolies-sp10-p.h"
Expand Down
4 changes: 0 additions & 4 deletions driver-spondoolies-sp30.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@

#include "config.h"

#ifdef WIN32
#include <windows.h>
#endif

#include "compat.h"
#include "miner.h"
#include "driver-spondoolies-sp30-p.h"
Expand Down
25 changes: 13 additions & 12 deletions miner.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,7 @@
#include <sys/time.h>
#include <pthread.h>
#include <jansson.h>
#ifdef HAVE_LIBCURL
#include <curl/curl.h>
#else
typedef char CURL;
extern char *curly;
#define curl_easy_init(curl) (curly)
#define curl_easy_cleanup(curl) {}
#define curl_global_cleanup() {}
#define CURL_GLOBAL_ALL 0
#define curl_global_init(X) (0)
#endif

#include <sched.h>

#include "elist.h"
Expand Down Expand Up @@ -68,13 +58,24 @@ void *alloca (size_t);
#endif

#ifdef __MINGW32__
#include <windows.h>
#include <io.h>
static inline int fsync (int fd)
{
return (FlushFileBuffers ((HANDLE) _get_osfhandle (fd))) ? 0 : -1;
}

#ifdef HAVE_LIBCURL
#include <curl/curl.h>
#else
typedef char CURL;
extern char *curly;
#define curl_easy_init(curl) (curly)
#define curl_easy_cleanup(curl) {}
#define curl_global_cleanup() {}
#define CURL_GLOBAL_ALL 0
#define curl_global_init(X) (0)
#endif

#ifndef EWOULDBLOCK
# define EWOULDBLOCK EAGAIN
#endif
Expand Down
3 changes: 2 additions & 1 deletion usbutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -3951,7 +3951,8 @@ union semun {
#else
static LPSECURITY_ATTRIBUTES unsec(LPSECURITY_ATTRIBUTES sec)
{
FreeSid(((PSECURITY_DESCRIPTOR)(sec->lpSecurityDescriptor))->Group);
SECURITY_DESCRIPTOR *sd = (PSECURITY_DESCRIPTOR)(sec->lpSecurityDescriptor);
FreeSid(sd->Group);
free(sec->lpSecurityDescriptor);
free(sec);
return NULL;
Expand Down
6 changes: 3 additions & 3 deletions util.c
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ json_t *json_rpc_call(CURL *curl, const char *url,
if (likely(global_hashrate)) {
char ghashrate[255];

sprintf(ghashrate, "X-Mining-Hashrate: %llu", global_hashrate);
sprintf(ghashrate, "X-Mining-Hashrate: %"PRIu64, global_hashrate);
headers = curl_slist_append(headers, ghashrate);
}

Expand Down Expand Up @@ -1444,7 +1444,7 @@ void cgtimer_sub(cgtimer_t *a, cgtimer_t *b, cgtimer_t *res)
}
#endif /* WIN32 */

#if defined(CLOCK_MONOTONIC) && !defined(__FreeBSD__) && !defined(__APPLE__) /* Essentially just linux */
#if defined(CLOCK_MONOTONIC) && !defined(__FreeBSD__) && !defined(__APPLE__) && !defined(WIN32) /* Essentially just linux */
//#ifdef CLOCK_MONOTONIC /* Essentially just linux */
void cgtimer_time(cgtimer_t *ts_start)
{
Expand Down Expand Up @@ -1834,7 +1834,7 @@ static void clear_sock(struct pool *pool)
}

/* Realloc memory to new size and zero any extra memory added */
void _recalloc(void **ptr, size_t old, size_t new, const char *file, const char *func, const int line)
void ckrecalloc(void **ptr, size_t old, size_t new, const char *file, const char *func, const int line)
{
if (new == old)
return;
Expand Down
5 changes: 3 additions & 2 deletions util.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
}
#elif defined WIN32
#include <winsock2.h>
#include <windows.h>
#include <ws2tcpip.h>

#define SOCKETTYPE SOCKET
Expand Down Expand Up @@ -147,8 +148,8 @@ int ms_tdiff(struct timeval *end, struct timeval *start);
double tdiff(struct timeval *end, struct timeval *start);
bool stratum_send(struct pool *pool, char *s, ssize_t len);
bool sock_full(struct pool *pool);
void _recalloc(void **ptr, size_t old, size_t new, const char *file, const char *func, const int line);
#define recalloc(ptr, old, new) _recalloc((void *)&(ptr), old, new, __FILE__, __func__, __LINE__)
void ckrecalloc(void **ptr, size_t old, size_t new, const char *file, const char *func, const int line);
#define recalloc(ptr, old, new) ckrecalloc((void *)&(ptr), old, new, __FILE__, __func__, __LINE__)
char *recv_line(struct pool *pool);
bool parse_method(struct pool *pool, char *s);
bool extract_sockaddr(char *url, char **sockaddr_url, char **sockaddr_port);
Expand Down

0 comments on commit ec1ac28

Please sign in to comment.