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 __cplusplus
34extern "C" {
35#endif
36
37#if defined(_WIN64)
38
39
40
41
42# undef setjmp
43# define setjmp(env) _setjmp(env, NULL)
44#endif
45
46
47
48
49
50#define sigjmp_buf jmp_buf
51#define sigsetjmp(env, savemask) setjmp(env)
52#define siglongjmp(env, val) longjmp(env, val)
53
54
55#ifndef _POSIX_THREAD_SAFE_FUNCTIONS
56#undef gmtime_r
57struct tm *gmtime_r(const time_t *timep, struct tm *result);
58#undef localtime_r
59struct tm *localtime_r(const time_t *timep, struct tm *result);
60#endif
61
62static inline void os_setup_signal_handling(void) {}
63static inline void os_daemonize(void) {}
64static inline void os_setup_post(void) {}
65void os_set_line_buffering(void);
66static inline void os_set_proc_name(const char *dummy) {}
67
68int getpagesize(void);
69
70#if !defined(EPROTONOSUPPORT)
71# define EPROTONOSUPPORT EINVAL
72#endif
73
74typedef struct {
75 long tv_sec;
76 long tv_usec;
77} qemu_timeval;
78int qemu_gettimeofday(qemu_timeval *tp);
79
80static inline bool is_daemonized(void)
81{
82 return false;
83}
84
85static inline int os_mlock(void)
86{
87 return -ENOSYS;
88}
89
90#define fsync _commit
91
92#if !defined(lseek)
93# define lseek _lseeki64
94#endif
95
96int qemu_ftruncate64(int, int64_t);
97
98#if !defined(ftruncate)
99# define ftruncate qemu_ftruncate64
100#endif
101
102static inline char *realpath(const char *path, char *resolved_path)
103{
104 _fullpath(resolved_path, path, _MAX_PATH);
105 return resolved_path;
106}
107
108
109
110
111
112
113
114
115
116static inline void qemu_flockfile(FILE *f)
117{
118}
119
120static inline void qemu_funlockfile(FILE *f)
121{
122}
123
124
125
126
127
128#undef connect
129#define connect qemu_connect_wrap
130int qemu_connect_wrap(int sockfd, const struct sockaddr *addr,
131 socklen_t addrlen);
132
133#undef listen
134#define listen qemu_listen_wrap
135int qemu_listen_wrap(int sockfd, int backlog);
136
137#undef bind
138#define bind qemu_bind_wrap
139int qemu_bind_wrap(int sockfd, const struct sockaddr *addr,
140 socklen_t addrlen);
141
142#undef socket
143#define socket qemu_socket_wrap
144int qemu_socket_wrap(int domain, int type, int protocol);
145
146#undef accept
147#define accept qemu_accept_wrap
148int qemu_accept_wrap(int sockfd, struct sockaddr *addr,
149 socklen_t *addrlen);
150
151#undef shutdown
152#define shutdown qemu_shutdown_wrap
153int qemu_shutdown_wrap(int sockfd, int how);
154
155#undef ioctlsocket
156#define ioctlsocket qemu_ioctlsocket_wrap
157int qemu_ioctlsocket_wrap(int fd, int req, void *val);
158
159#undef closesocket
160#define closesocket qemu_closesocket_wrap
161int qemu_closesocket_wrap(int fd);
162
163#undef getsockopt
164#define getsockopt qemu_getsockopt_wrap
165int qemu_getsockopt_wrap(int sockfd, int level, int optname,
166 void *optval, socklen_t *optlen);
167
168#undef setsockopt
169#define setsockopt qemu_setsockopt_wrap
170int qemu_setsockopt_wrap(int sockfd, int level, int optname,
171 const void *optval, socklen_t optlen);
172
173#undef getpeername
174#define getpeername qemu_getpeername_wrap
175int qemu_getpeername_wrap(int sockfd, struct sockaddr *addr,
176 socklen_t *addrlen);
177
178#undef getsockname
179#define getsockname qemu_getsockname_wrap
180int qemu_getsockname_wrap(int sockfd, struct sockaddr *addr,
181 socklen_t *addrlen);
182
183#undef send
184#define send qemu_send_wrap
185ssize_t qemu_send_wrap(int sockfd, const void *buf, size_t len, int flags);
186
187#undef sendto
188#define sendto qemu_sendto_wrap
189ssize_t qemu_sendto_wrap(int sockfd, const void *buf, size_t len, int flags,
190 const struct sockaddr *addr, socklen_t addrlen);
191
192#undef recv
193#define recv qemu_recv_wrap
194ssize_t qemu_recv_wrap(int sockfd, void *buf, size_t len, int flags);
195
196#undef recvfrom
197#define recvfrom qemu_recvfrom_wrap
198ssize_t qemu_recvfrom_wrap(int sockfd, void *buf, size_t len, int flags,
199 struct sockaddr *addr, socklen_t *addrlen);
200
201#ifdef __cplusplus
202}
203#endif
204
205#endif
206