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
72 #ifndef IN_REPLACEMENTS_C
105 char *
strndup(
const char *s,
size_t n);
109 size_t strnlen(
const char *s,
size_t maxlen);
114 static inline unsigned int usleep(
unsigned int usecs)
120 #error no usleep defined for your platform
131 #define UNIX_PATH_LEN 108
134 char sun_path[UNIX_PATH_LEN];
140 #define ETIMEDOUT WSAETIMEDOUT
144 static inline unsigned char inb(
unsigned short int port)
147 __asm__ __volatile__ (
"inb %w1,%0" :
"=a" (_v) :
"Nd" (port));
151 static inline void outb(
unsigned char value,
unsigned short int port)
153 __asm__ __volatile__ (
"outb %b0,%w1" : :
"a" (value),
"Nd" (port));
157 #define ffs __builtin_ffs
161 int win_select(
int max_fd, fd_set *rfds, fd_set *wfds, fd_set *efds,
struct timeval *tv);
187 return closesocket(sock);
196 unsigned long nonblock = 0;
197 ioctlsocket(fd, FIONBIO, &nonblock);
199 int oldopts = fcntl(fd, F_GETFL, 0);
200 fcntl(fd, F_SETFL, oldopts & ~O_NONBLOCK);
207 unsigned long nonblock = 1;
208 ioctlsocket(fd, FIONBIO, &nonblock);
210 int oldopts = fcntl(fd, F_GETFL, 0);
211 fcntl(fd, F_SETFL, oldopts | O_NONBLOCK);
222 return win_select(max_fd, rfds, wfds, efds, tv);
224 return select(max_fd, rfds, wfds, efds, tv);
255 #define ELFMAG "\177ELF"
263 #define ELFDATA2LSB 1
264 #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.