1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26#ifndef QEMU_OS_WIN32_H
27#define QEMU_OS_WIN32_H
28
29#include <winsock2.h>
30#include <windows.h>
31#include <ws2tcpip.h>
32
33#ifdef HAVE_AFUNIX_H
34#include <afunix.h>
35#else
36
37
38
39
40#define UNIX_PATH_MAX 108
41
42typedef struct sockaddr_un {
43 ADDRESS_FAMILY sun_family;
44 char sun_path[UNIX_PATH_MAX];
45} SOCKADDR_UN, *PSOCKADDR_UN;
46
47#define SIO_AF_UNIX_GETPEERPID _WSAIOR(IOC_VENDOR, 256)
48#endif
49
50#ifdef __cplusplus
51extern "C" {
52#endif
53
54#if defined(_WIN64)
55
56
57
58
59# undef setjmp
60# define setjmp(env) _setjmp(env, NULL)
61#endif
62
63
64
65
66
67#define sigjmp_buf jmp_buf
68#define sigsetjmp(env, savemask) setjmp(env)
69#define siglongjmp(env, val) longjmp(env, val)
70
71
72#ifndef _POSIX_THREAD_SAFE_FUNCTIONS
73#undef gmtime_r
74struct tm *gmtime_r(const time_t *timep, struct tm *result);
75#undef localtime_r
76struct tm *localtime_r(const time_t *timep, struct tm *result);
77#endif
78
79static inline void os_setup_signal_handling(void) {}
80static inline void os_daemonize(void) {}
81static inline void os_setup_post(void) {}
82static inline void os_set_proc_name(const char *dummy) {}
83static inline int os_parse_cmd_args(int index, const char *optarg) { return -1; }
84void os_set_line_buffering(void);
85void os_setup_early_signal_handling(void);
86
87int getpagesize(void);
88
89#if !defined(EPROTONOSUPPORT)
90# define EPROTONOSUPPORT EINVAL
91#endif
92
93static inline int os_set_daemonize(bool d)
94{
95 if (d) {
96 return -ENOTSUP;
97 }
98 return 0;
99}
100
101static inline bool is_daemonized(void)
102{
103 return false;
104}
105
106static inline int os_mlock(void)
107{
108 return -ENOSYS;
109}
110
111#define fsync _commit
112
113#if !defined(lseek)
114# define lseek _lseeki64
115#endif
116
117int qemu_ftruncate64(int, int64_t);
118
119#if !defined(ftruncate)
120# define ftruncate qemu_ftruncate64
121#endif
122
123static inline char *realpath(const char *path, char *resolved_path)
124{
125 _fullpath(resolved_path, path, _MAX_PATH);
126 return resolved_path;
127}
128
129
130
131
132
133static inline void qemu_flockfile(FILE *f)
134{
135#ifdef HAVE__LOCK_FILE
136 _lock_file(f);
137#endif
138}
139
140static inline void qemu_funlockfile(FILE *f)
141{
142#ifdef HAVE__LOCK_FILE
143 _unlock_file(f);
144#endif
145}
146
147
148
149
150
151#undef connect
152#define connect qemu_connect_wrap
153int qemu_connect_wrap(int sockfd, const struct sockaddr *addr,
154 socklen_t addrlen);
155
156#undef listen
157#define listen qemu_listen_wrap
158int qemu_listen_wrap(int sockfd, int backlog);
159
160#undef bind
161#define bind qemu_bind_wrap
162int qemu_bind_wrap(int sockfd, const struct sockaddr *addr,
163 socklen_t addrlen);
164
165#undef socket
166#define socket qemu_socket_wrap
167int qemu_socket_wrap(int domain, int type, int protocol);
168
169#undef accept
170#define accept qemu_accept_wrap
171int qemu_accept_wrap(int sockfd, struct sockaddr *addr,
172 socklen_t *addrlen);
173
174#undef shutdown
175#define shutdown qemu_shutdown_wrap
176int qemu_shutdown_wrap(int sockfd, int how);
177
178#undef ioctlsocket
179#define ioctlsocket qemu_ioctlsocket_wrap
180int qemu_ioctlsocket_wrap(int fd, int req, void *val);
181
182#undef closesocket
183#define closesocket qemu_closesocket_wrap
184int qemu_closesocket_wrap(int fd);
185
186#undef getsockopt
187#define getsockopt qemu_getsockopt_wrap
188int qemu_getsockopt_wrap(int sockfd, int level, int optname,
189 void *optval, socklen_t *optlen);
190
191#undef setsockopt
192#define setsockopt qemu_setsockopt_wrap
193int qemu_setsockopt_wrap(int sockfd, int level, int optname,
194 const void *optval, socklen_t optlen);
195
196#undef getpeername
197#define getpeername qemu_getpeername_wrap
198int qemu_getpeername_wrap(int sockfd, struct sockaddr *addr,
199 socklen_t *addrlen);
200
201#undef getsockname
202#define getsockname qemu_getsockname_wrap
203int qemu_getsockname_wrap(int sockfd, struct sockaddr *addr,
204 socklen_t *addrlen);
205
206#undef send
207#define send qemu_send_wrap
208ssize_t qemu_send_wrap(int sockfd, const void *buf, size_t len, int flags);
209
210#undef sendto
211#define sendto qemu_sendto_wrap
212ssize_t qemu_sendto_wrap(int sockfd, const void *buf, size_t len, int flags,
213 const struct sockaddr *addr, socklen_t addrlen);
214
215#undef recv
216#define recv qemu_recv_wrap
217ssize_t qemu_recv_wrap(int sockfd, void *buf, size_t len, int flags);
218
219#undef recvfrom
220#define recvfrom qemu_recvfrom_wrap
221ssize_t qemu_recvfrom_wrap(int sockfd, void *buf, size_t len, int flags,
222 struct sockaddr *addr, socklen_t *addrlen);
223
224#ifdef __cplusplus
225}
226#endif
227
228#endif
229