- Cable driver helper API courtesy of Dick Hollenbeck <dick@softplc.com>
[fw/openocd] / src / helper / replacements.h
index a1500d798fccb0422e7a76b7c9b5969e63d3e074..c3a2bf77d94e5bc3dbc3d8bfe607457e08b1dc0f 100644 (file)
@@ -84,7 +84,6 @@ struct timeval {
 /* gettimeofday() */
 #ifndef HAVE_GETTIMEOFDAY
 
-
 #ifdef _WIN32
 struct timezone {
        int tz_minuteswest;
@@ -161,6 +160,12 @@ void usleep(int us);
 #include <windows.h>
 #include <time.h>
 
+/* win32 systems do not support ETIMEDOUT */
+
+#ifndef ETIMEDOUT
+#define ETIMEDOUT WSAETIMEDOUT
+#endif
+
 #if IS_MINGW == 1
 static __inline unsigned char inb(unsigned short int port)
 {
@@ -175,6 +180,9 @@ static __inline void outb(unsigned char value, unsigned short int port)
 }
 
 #endif /* IS_MINGW */
+
+int win_select(int max_fd, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *tv);
+
 #endif  /* _WIN32 */
 
 /* generic socket functions for Windows and Posix */
@@ -216,6 +224,15 @@ static __inline void socket_nonblock(int fd)
 #endif
 }
 
+static __inline int socket_select(int max_fd, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *tv)
+{
+#ifdef _WIN32
+       return win_select(max_fd, rfds, wfds, efds, tv);
+#else
+       return select(max_fd, rfds, wfds, efds, tv);
+#endif
+}
+
 #ifndef HAVE_ELF_H
 
 typedef struct