14 #ifndef OPENOCD_HELPER_REPLACEMENTS_H
15 #define OPENOCD_HELPER_REPLACEMENTS_H
22 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
25 #define MAX(a, b) (((a) > (b)) ? (a) : (b))
40 #ifndef HAVE_SYS_TIME_H
42 #ifndef _TIMEVAL_DEFINED
43 #define _TIMEVAL_DEFINED
55 #ifndef HAVE_GETTIMEOFDAY
69 #ifndef IN_REPLACEMENTS_C
106 char *
strndup(
const char *s,
size_t n);
110 size_t strnlen(
const char *s,
size_t maxlen);
115 static inline unsigned usleep(
unsigned int usecs)
121 #error no usleep defined for your platform
132 #define UNIX_PATH_LEN 108
135 char sun_path[UNIX_PATH_LEN];
141 #define ETIMEDOUT WSAETIMEDOUT
145 static inline unsigned char inb(
unsigned short int port)
148 __asm__ __volatile__ (
"inb %w1,%0" :
"=a" (_v) :
"Nd" (port));
152 static inline void outb(
unsigned char value,
unsigned short int port)
154 __asm__ __volatile__ (
"outb %b0,%w1" : :
"a" (value),
"Nd" (port));
158 #define ffs __builtin_ffs
162 int win_select(
int max_fd, fd_set *rfds, fd_set *wfds, fd_set *efds,
struct timeval *tv);
188 return closesocket(sock);
197 unsigned long nonblock = 0;
198 ioctlsocket(fd, FIONBIO, &nonblock);
200 int oldopts = fcntl(fd, F_GETFL, 0);
201 fcntl(fd, F_SETFL, oldopts & ~O_NONBLOCK);
208 unsigned long nonblock = 1;
209 ioctlsocket(fd, FIONBIO, &nonblock);
211 int oldopts = fcntl(fd, F_GETFL, 0);
212 fcntl(fd, F_SETFL, oldopts | O_NONBLOCK);
223 return win_select(max_fd, rfds, wfds, efds, tv);
225 return select(max_fd, rfds, wfds, efds, tv);
256 #define ELFMAG "\177ELF"
264 #define ELFDATA2LSB 1
265 #define ELFDATA2MSB 2
static int socket_select(int max_fd, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *tv)
static void socket_block(int fd)
static int read_socket(int handle, void *buffer, unsigned int count)
static int close_socket(int sock)
char * strndup(const char *s, size_t n)
static int write_socket(int handle, const void *buffer, unsigned int count)
void * clear_malloc(size_t size)
int gettimeofday(struct timeval *tv, struct timezone *tz)
static void socket_nonblock(int fd)
void * fill_malloc(size_t size)
size_t strnlen(const char *s, size_t maxlen)
size_t size
Size of the control block search area.