projects
/
fw
/
openocd
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Michael Bruck <mbruck@digenius.de>: use HAVE_UNISTD_H for environ decl.
[fw/openocd]
/
src
/
helper
/
replacements.h
diff --git
a/src/helper/replacements.h
b/src/helper/replacements.h
index a1500d798fccb0422e7a76b7c9b5969e63d3e074..18c96701dd0e072c760453b1f10b81b6e8c5be69 100644
(file)
--- a/
src/helper/replacements.h
+++ b/
src/helper/replacements.h
@@
-35,12
+35,20
@@
#if BUILD_ECOSBOARD
#include <pkgconf/system.h>
#include <stdlib.h>
#if BUILD_ECOSBOARD
#include <pkgconf/system.h>
#include <stdlib.h>
-#include <sys/select.h>
+#endif
+
+#ifdef HAVE_SYS_SELECT_H
+#include <sys/select.h> /* select, FD_SET and friends (POSIX.1-2001) */
+#endif
+
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h> /* FD_SET and friends (pre-POSIX.1-2001) */
#endif
/* include necessary headers for socket functionality */
#ifdef _WIN32
#include <winsock2.h>
#endif
/* include necessary headers for socket functionality */
#ifdef _WIN32
#include <winsock2.h>
+#include <ws2tcpip.h>
#else
#include <sys/socket.h>
#include <sys/poll.h>
#else
#include <sys/socket.h>
#include <sys/poll.h>
@@
-84,7
+92,6
@@
struct timeval {
/* gettimeofday() */
#ifndef HAVE_GETTIMEOFDAY
/* gettimeofday() */
#ifndef HAVE_GETTIMEOFDAY
-
#ifdef _WIN32
struct timezone {
int tz_minuteswest;
#ifdef _WIN32
struct timezone {
int tz_minuteswest;
@@
-96,9
+103,11
@@
struct timezone;
extern int gettimeofday(struct timeval *tv, struct timezone *tz);
#endif
extern int gettimeofday(struct timeval *tv, struct timezone *tz);
#endif
+#ifndef IN_REPLACEMENTS_C
/**** clear_malloc & fill_malloc ****/
void *clear_malloc(size_t size);
void *fill_malloc(size_t size);
/**** clear_malloc & fill_malloc ****/
void *clear_malloc(size_t size);
void *fill_malloc(size_t size);
+#endif
/*
* Now you have 3 ways for the malloc function:
/*
* Now you have 3 ways for the malloc function:
@@
-161,6
+170,12
@@
void usleep(int us);
#include <windows.h>
#include <time.h>
#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)
{
#if IS_MINGW == 1
static __inline unsigned char inb(unsigned short int port)
{
@@
-175,6
+190,9
@@
static __inline void outb(unsigned char value, unsigned short int port)
}
#endif /* IS_MINGW */
}
#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 */
#endif /* _WIN32 */
/* generic socket functions for Windows and Posix */
@@
-216,6
+234,15
@@
static __inline void socket_nonblock(int fd)
#endif
}
#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
#ifndef HAVE_ELF_H
typedef struct