Commit 92c61cbd4ccccb73374791c4a755919b9826f1a4

Con Kolivas 2013-04-19T03:10:44

Merge pull request #426 from gzm55/master compile avalon driver on win32 and win64

diff --git a/driver-avalon.c b/driver-avalon.c
index 94502d9..28af4cd 100644
--- a/driver-avalon.c
+++ b/driver-avalon.c
@@ -17,10 +17,10 @@
 #include <stdio.h>
 #include <sys/time.h>
 #include <sys/types.h>
-#include <sys/select.h>
 #include <dirent.h>
 #include <unistd.h>
 #ifndef WIN32
+  #include <sys/select.h>
   #include <termios.h>
   #include <sys/stat.h>
   #include <fcntl.h>
@@ -28,6 +28,7 @@
     #define O_CLOEXEC 0
   #endif
 #else
+  #include "compat.h"
   #include <windows.h>
   #include <io.h>
 #endif
diff --git a/fpgautils.c b/fpgautils.c
index 61706a5..9330a21 100644
--- a/fpgautils.c
+++ b/fpgautils.c
@@ -592,4 +592,19 @@ int get_serial_cts(int fd)
 	ioctl(fd, TIOCMGET, &flags);
 	return (flags & TIOCM_CTS) ? 1 : 0;
 }
+#else
+int get_serial_cts(const int fd)
+{
+	if (!fd)
+		return -1;
+	const HANDLE fh = (HANDLE)_get_osfhandle(fd);
+	if (!fh)
+		return -1;
+
+	DWORD flags;
+	if (!GetCommModemStatus(fh, &flags))
+		return -1;
+
+	return (flags & MS_CTS_ON) ? 1 : 0;
+}
 #endif // ! WIN32
diff --git a/miner.h b/miner.h
index c992cce..6345d71 100644
--- a/miner.h
+++ b/miner.h
@@ -156,6 +156,7 @@ static inline int fsync (int fd)
 # if __BYTE_ORDER == __LITTLE_ENDIAN
 #  define htole16(x) (x)
 #  define htole32(x) (x)
+#  define le32toh(x) (x)
 #  define be32toh(x) bswap_32(x)
 #  define be64toh(x) bswap_64(x)
 #  define htobe32(x) bswap_32(x)
@@ -163,6 +164,7 @@ static inline int fsync (int fd)
 # elif __BYTE_ORDER == __BIG_ENDIAN
 #  define htole16(x) bswap_16(x)
 #  define htole32(x) bswap_32(x)
+#  define le32toh(x) bswap_32(x)
 #  define be32toh(x) (x)
 #  define be64toh(x) (x)
 #  define htobe32(x) (x)