slirp: Add windows build support for MinGW
This commit is contained in:
parent
442e70328e
commit
3be5125d00
9 changed files with 65 additions and 32 deletions
4
makefile
4
makefile
|
@ -801,6 +801,10 @@ else
|
|||
OS_LDFLAGS += -lpcreposix -lpcre -L../windows-build/PCRE/lib/
|
||||
$(info using libpcreposix: $(abspath ../windows-build/PCRE/lib/pcreposix.a) $(abspath ../windows-build/PCRE/include/pcreposix.h))
|
||||
endif
|
||||
ifeq (slirp,slirp)
|
||||
NETWORK_OPT += -Islirp -Islirp/simh -Islirp/simh/qemu -DHAVE_SLIRP_NETWORK slirp/*.c slirp/simh/*.c -lIphlpapi
|
||||
NETWORK_LAN_FEATURES += NAT(SLiRP)
|
||||
endif
|
||||
endif
|
||||
endif # Win32 (via MinGW)
|
||||
ifneq (,$(GIT_COMMIT_ID))
|
||||
|
|
16
slirp/simh/README
Normal file
16
slirp/simh/README
Normal file
|
@ -0,0 +1,16 @@
|
|||
The files in and below this directory are the necessary glue and stubs
|
||||
to allow the effectively unmodified qemu slirp code to be used in simh
|
||||
as a network connection mechanism.
|
||||
|
||||
Most of the include files here started from related files in the qemu
|
||||
include directories and have been chopped up and tweaked as necessary
|
||||
so that the slirp code can be used outside of qemu.
|
||||
|
||||
Slirp depends on a small set of capabilities from glib (GArrays mostly).
|
||||
|
||||
All of the other include files exist so that the references in the
|
||||
slirp code don't have to be modified.
|
||||
|
||||
- Mark Pizzolato
|
||||
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#ifdef _MSC_VER
|
||||
#ifdef _WIN32
|
||||
#include <winsock2.h>
|
||||
#else
|
||||
typedef int SOCKET;
|
||||
|
@ -24,8 +24,10 @@ int qemu_recv (int s, void *buf, size_t len, int flags);
|
|||
#define snprintf _snprintf
|
||||
#define strcasecmp stricmp
|
||||
#else
|
||||
#ifndef _WIN32
|
||||
#define CONFIG_IOVEC 1
|
||||
#endif
|
||||
#endif
|
||||
#define register_savevm(p1, p2, p3, p4, p5, p6, p7)
|
||||
#define unregister_savevm(p1, p2, p3)
|
||||
#define qemu_put_be16(p1, p2)
|
||||
|
|
|
@ -254,7 +254,9 @@ slirp_remque(void *a)
|
|||
((struct quehead *)(element->qh_rlink))->qh_link = element->qh_link;
|
||||
element->qh_rlink = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
int
|
||||
inet_aton(const char *arg, struct in_addr *addr)
|
||||
{
|
||||
|
|
|
@ -109,32 +109,4 @@ typedef struct {
|
|||
} qemu_timeval;
|
||||
int qemu_gettimeofday(qemu_timeval *tp);
|
||||
|
||||
static inline bool is_daemonized(void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline int os_mlock(void)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
#define fsync _commit
|
||||
|
||||
#if !defined(lseek)
|
||||
# define lseek _lseeki64
|
||||
#endif
|
||||
|
||||
int qemu_ftruncate64(int, int64_t);
|
||||
|
||||
#if !defined(ftruncate)
|
||||
# define ftruncate qemu_ftruncate64
|
||||
#endif
|
||||
|
||||
static inline char *realpath(const char *path, char *resolved_path)
|
||||
{
|
||||
_fullpath(resolved_path, path, _MAX_PATH);
|
||||
return resolved_path;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
34
slirp/simh/qemu/thread-win32.h
Normal file
34
slirp/simh/qemu/thread-win32.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
#ifndef __QEMU_THREAD_WIN32_H
|
||||
#define __QEMU_THREAD_WIN32_H 1
|
||||
#include "windows.h"
|
||||
|
||||
struct QemuMutex {
|
||||
CRITICAL_SECTION lock;
|
||||
LONG owner;
|
||||
};
|
||||
|
||||
struct QemuCond {
|
||||
LONG waiters, target;
|
||||
HANDLE sema;
|
||||
HANDLE continue_event;
|
||||
};
|
||||
|
||||
struct QemuSemaphore {
|
||||
HANDLE sema;
|
||||
};
|
||||
|
||||
struct QemuEvent {
|
||||
int value;
|
||||
HANDLE event;
|
||||
};
|
||||
|
||||
typedef struct QemuThreadData QemuThreadData;
|
||||
struct QemuThread {
|
||||
QemuThreadData *data;
|
||||
unsigned tid;
|
||||
};
|
||||
|
||||
/* Only valid for joinable threads. */
|
||||
HANDLE qemu_thread_get_handle(QemuThread *thread);
|
||||
|
||||
#endif
|
|
@ -60,7 +60,7 @@ struct redir_tcp_udp {
|
|||
static int
|
||||
_parse_redirect_port (struct redir_tcp_udp **head, char *buff, int is_udp)
|
||||
{
|
||||
u_int32_t inaddr = 0;
|
||||
uint32 inaddr = 0;
|
||||
int port = 0;
|
||||
int lport = 0;
|
||||
char *ipaddrstr = NULL;
|
||||
|
@ -550,7 +550,7 @@ for (i = 0; i < pollfds->len; i++) {
|
|||
int sim_slirp_select (SLIRP *slirp, int ms_timeout)
|
||||
{
|
||||
int select_ret = 0;
|
||||
uint32_t slirp_timeout = ms_timeout;
|
||||
uint32 slirp_timeout = ms_timeout;
|
||||
struct timeval timeout;
|
||||
fd_set rfds, wfds, xfds;
|
||||
fd_set save_rfds, save_wfds, save_xfds;
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
#include "slirp_config.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifndef _MSC_VER
|
||||
# include <inttypes.h>
|
||||
#endif
|
||||
|
||||
typedef char *caddr_t;
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
#undef DUMMY_PPP
|
||||
|
||||
/* Define if you have unistd.h */
|
||||
#ifndef _WIN32
|
||||
#ifndef _MSC_VER
|
||||
#define HAVE_UNISTD_H
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue