#ifndef REPLACEMENTS_H
#define REPLACEMENTS_H
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
#include "types.h"
-
-#if BUILD_ECOSBOARD
-#include <pkgconf/system.h>
-#include <stdlib.h>
-#include <sys/select.h>
-#endif
-
-/* include necessary headers for socket functionality */
-#ifdef _WIN32
-#include <winsock2.h>
-#else
-#include <sys/socket.h>
-#include <sys/poll.h>
-#include <netinet/in.h>
-#include <unistd.h>
-#include <fcntl.h>
-#endif
-
-#ifdef HAVE_SYS_PARAM_H
-#include <sys/param.h> /* for MIN/MAX macros */
-#endif
+#include "system.h"
/* MIN,MAX macros */
#ifndef MIN
/* gettimeofday() */
#ifndef HAVE_GETTIMEOFDAY
+
+#ifdef _WIN32
struct timezone {
- int tz_minuteswest;
+ int tz_minuteswest;
int tz_dsttime;
};
+#endif
+struct timezone;
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);
+#endif
/*
* Now you have 3 ways for the malloc function:
#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)
{
}
#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 */
static __inline int write_socket( int handle, const void *buffer, unsigned int count )
{
#ifdef _WIN32
- return send(handle, buffer, count, 0);
+ return send(handle, buffer, count, 0);
#else
- return write(handle, buffer, count);
+ return write(handle, buffer, count);
#endif
}
static __inline int read_socket( int handle, void *buffer, unsigned int count )
{
#ifdef _WIN32
- return recv(handle, buffer, count, 0);
+ return recv(handle, buffer, count, 0);
#else
- return read(handle, buffer, count);
+ return read(handle, buffer, count);
#endif
}
static __inline int close_socket(int sock)
{
#ifdef _WIN32
- return closesocket(sock);
+ return closesocket(sock);
#else
- return close(sock);
+ return close(sock);
#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
u32 e_shoff; /* Section header table file offset */
u32 e_flags; /* Processor-specific flags */
u16 e_ehsize; /* ELF header size in bytes */
- u16 e_phentsize; /* Program header table entry size */
+ u16 e_phentsize; /* Program header table entry size */
u16 e_phnum; /* Program header table entry count */
- u16 e_shentsize; /* Section header table entry size */
+ u16 e_shentsize; /* Section header table entry size */
u16 e_shnum; /* Section header table entry count */
u16 e_shstrndx; /* Section header string table index */
} Elf32_Ehdr;