2014-03-02 11:42:24 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
// $Id$
|
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2015-05-01 22:41:08 +03:00
|
|
|
/*
|
|
|
|
* Qemu compatibility defines
|
|
|
|
*
|
|
|
|
* Copyright (c) 2003-2008 Fabrice Bellard
|
2017-04-22 00:07:52 +03:00
|
|
|
* Copyright (C) 2014-2017 The Bochs Project
|
2015-05-01 22:41:08 +03:00
|
|
|
*/
|
|
|
|
|
2014-02-16 17:31:53 +04:00
|
|
|
#ifndef SLIRP_COMPAT_H
|
|
|
|
#define SLIRP_COMPAT_H 1
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
|
2016-01-08 21:58:27 +03:00
|
|
|
#include "qemu-queue.h"
|
|
|
|
|
2014-02-16 17:31:53 +04:00
|
|
|
#if defined(_MSC_VER)
|
|
|
|
#include <io.h>
|
|
|
|
typedef Bit8s int8_t;
|
|
|
|
typedef Bit16s int16_t;
|
|
|
|
typedef Bit8u uint8_t;
|
|
|
|
typedef Bit16u uint16_t;
|
|
|
|
typedef Bit32u uint32_t;
|
|
|
|
typedef Bit64u uint64_t;
|
|
|
|
typedef Bit64s ssize_t;
|
2014-03-29 19:23:49 +04:00
|
|
|
#ifndef BX_OSDEP_H
|
2014-02-16 17:31:53 +04:00
|
|
|
#define snprintf _snprintf
|
|
|
|
#define strdup _strdup
|
|
|
|
#define open _open
|
|
|
|
#define close _close
|
2017-08-06 21:35:37 +03:00
|
|
|
#define lseek _lseeki64
|
2014-02-16 17:31:53 +04:00
|
|
|
#define read _read
|
2014-03-29 19:23:49 +04:00
|
|
|
#define write _write
|
|
|
|
#endif
|
2014-02-16 17:31:53 +04:00
|
|
|
#define strcasecmp _stricmp
|
|
|
|
#endif
|
|
|
|
|
2014-02-19 00:34:14 +04:00
|
|
|
#ifndef ARRAY_SIZE
|
|
|
|
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
|
|
|
#endif
|
|
|
|
|
2014-02-16 17:31:53 +04:00
|
|
|
#ifndef MIN
|
|
|
|
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Workaround for older versions of MinGW. */
|
|
|
|
#ifndef ECONNREFUSED
|
|
|
|
# define ECONNREFUSED WSAECONNREFUSED
|
|
|
|
#endif
|
|
|
|
#ifndef EINPROGRESS
|
|
|
|
# define EINPROGRESS WSAEINPROGRESS
|
|
|
|
#endif
|
|
|
|
#ifndef EHOSTUNREACH
|
|
|
|
# define EHOSTUNREACH WSAEHOSTUNREACH
|
|
|
|
#endif
|
|
|
|
#ifndef EINTR
|
|
|
|
# define EINTR WSAEINTR
|
|
|
|
#endif
|
|
|
|
#ifndef EINPROGRESS
|
|
|
|
# define EINPROGRESS WSAEINPROGRESS
|
|
|
|
#endif
|
|
|
|
#ifndef ENETUNREACH
|
|
|
|
# define ENETUNREACH WSAENETUNREACH
|
|
|
|
#endif
|
|
|
|
#ifndef ENOTCONN
|
|
|
|
# define ENOTCONN WSAENOTCONN
|
|
|
|
#endif
|
2017-04-23 11:38:16 +03:00
|
|
|
#if defined(__CYGWIN__) && defined(EWOULDBLOCK)
|
|
|
|
# undef EWOULDBLOCK
|
|
|
|
# define EWOULDBLOCK WSAEWOULDBLOCK
|
|
|
|
#endif
|
2014-02-16 17:31:53 +04:00
|
|
|
#ifndef EWOULDBLOCK
|
|
|
|
# define EWOULDBLOCK WSAEWOULDBLOCK
|
|
|
|
#endif
|
|
|
|
|
2017-04-22 00:07:52 +03:00
|
|
|
#ifdef _WIN32
|
2014-02-16 17:31:53 +04:00
|
|
|
struct iovec {
|
|
|
|
void *iov_base;
|
|
|
|
size_t iov_len;
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// missing functions
|
|
|
|
void pstrcpy(char *buf, int buf_size, const char *str);
|
|
|
|
int qemu_socket(int domain, int type, int protocol);
|
2017-04-22 00:07:52 +03:00
|
|
|
#ifndef HAVE_INET_ATON
|
|
|
|
int inet_aton(const char *cp, struct in_addr *ia);
|
|
|
|
#endif
|
|
|
|
#ifdef _WIN32
|
2014-02-28 01:15:31 +04:00
|
|
|
#define qemu_setsockopt(sockfd, level, optname, optval, optlen) \
|
|
|
|
setsockopt(sockfd, level, optname, (const char *)optval, optlen)
|
2014-02-17 00:35:28 +04:00
|
|
|
#define qemu_recv(a,b,c,d) recv(a,(char*)b,c,d)
|
|
|
|
#else
|
2014-02-28 01:15:31 +04:00
|
|
|
#define qemu_setsockopt(sockfd, level, optname, optval, optlen) \
|
|
|
|
setsockopt(sockfd, level, optname, (const void *)optval, optlen)
|
2014-02-17 00:35:28 +04:00
|
|
|
#define qemu_recv(a,b,c,d) recv(a,b,c,d)
|
2014-02-16 17:31:53 +04:00
|
|
|
#endif
|
2014-02-28 01:15:31 +04:00
|
|
|
int socket_set_fast_reuse(int fd);
|
|
|
|
int socket_set_nodelay(int fd);
|
2014-02-17 00:35:28 +04:00
|
|
|
void qemu_set_nonblock(int fd);
|
2014-02-16 17:31:53 +04:00
|
|
|
|
|
|
|
#endif
|