]>
Commit | Line | Data |
---|---|---|
39626c03 JS |
1 | /* |
2 | * win32 specific declarations | |
3 | * | |
4 | * Copyright (c) 2003-2008 Fabrice Bellard | |
5 | * Copyright (c) 2010 Jes Sorensen <Jes.Sorensen@redhat.com> | |
6 | * | |
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
8 | * of this software and associated documentation files (the "Software"), to deal | |
9 | * in the Software without restriction, including without limitation the rights | |
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
11 | * copies of the Software, and to permit persons to whom the Software is | |
12 | * furnished to do so, subject to the following conditions: | |
13 | * | |
14 | * The above copyright notice and this permission notice shall be included in | |
15 | * all copies or substantial portions of the Software. | |
16 | * | |
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
20 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
23 | * THE SOFTWARE. | |
24 | */ | |
25 | ||
26 | #ifndef QEMU_OS_WIN32_H | |
27 | #define QEMU_OS_WIN32_H | |
28 | ||
082b5557 | 29 | #include <winsock2.h> |
1834ed3a | 30 | #include <windows.h> |
a2d96af4 | 31 | #include <ws2tcpip.h> |
082b5557 | 32 | |
5cf6dd51 SW |
33 | #if defined(_WIN64) |
34 | /* On w64, setjmp is implemented by _setjmp which needs a second parameter. | |
35 | * If this parameter is NULL, longjump does no stack unwinding. | |
36 | * That is what we need for QEMU. Passing the value of register rsp (default) | |
37 | * lets longjmp try a stack unwinding which will crash with generated code. */ | |
38 | # undef setjmp | |
39 | # define setjmp(env) _setjmp(env, NULL) | |
40 | #endif | |
6ab7e546 PM |
41 | /* QEMU uses sigsetjmp()/siglongjmp() as the portable way to specify |
42 | * "longjmp and don't touch the signal masks". Since we know that the | |
43 | * savemask parameter will always be zero we can safely define these | |
44 | * in terms of setjmp/longjmp on Win32. | |
45 | */ | |
46 | #define sigjmp_buf jmp_buf | |
47 | #define sigsetjmp(env, savemask) setjmp(env) | |
48 | #define siglongjmp(env, val) longjmp(env, val) | |
5cf6dd51 | 49 | |
d3e8f957 | 50 | /* Missing POSIX functions. Don't use MinGW-w64 macros. */ |
4d9310f4 | 51 | #ifndef CONFIG_LOCALTIME_R |
d3e8f957 SW |
52 | #undef gmtime_r |
53 | struct tm *gmtime_r(const time_t *timep, struct tm *result); | |
54 | #undef localtime_r | |
55 | struct tm *localtime_r(const time_t *timep, struct tm *result); | |
4d9310f4 | 56 | #endif /* CONFIG_LOCALTIME_R */ |
d3e8f957 | 57 | |
8d963e6a | 58 | static inline void os_setup_signal_handling(void) {} |
eb505be1 JS |
59 | static inline void os_daemonize(void) {} |
60 | static inline void os_setup_post(void) {} | |
6650b710 | 61 | void os_set_line_buffering(void); |
ce798cf2 | 62 | static inline void os_set_proc_name(const char *dummy) {} |
8d963e6a | 63 | |
a28c2f2d | 64 | int getpagesize(void); |
38183310 | 65 | |
5635efc3 SW |
66 | #if !defined(EPROTONOSUPPORT) |
67 | # define EPROTONOSUPPORT EINVAL | |
68 | #endif | |
69 | ||
dc786bc9 JS |
70 | int setenv(const char *name, const char *value, int overwrite); |
71 | ||
72 | typedef struct { | |
73 | long tv_sec; | |
74 | long tv_usec; | |
75 | } qemu_timeval; | |
76 | int qemu_gettimeofday(qemu_timeval *tp); | |
77 | ||
995ee2bf HM |
78 | static inline bool is_daemonized(void) |
79 | { | |
80 | return false; | |
81 | } | |
82 | ||
888a6bc6 SM |
83 | static inline int os_mlock(void) |
84 | { | |
85 | return -ENOSYS; | |
86 | } | |
87 | ||
1aad8104 PM |
88 | #define fsync _commit |
89 | ||
90 | #if !defined(lseek) | |
91 | # define lseek _lseeki64 | |
92 | #endif | |
93 | ||
94 | int qemu_ftruncate64(int, int64_t); | |
95 | ||
96 | #if !defined(ftruncate) | |
97 | # define ftruncate qemu_ftruncate64 | |
98 | #endif | |
99 | ||
100 | static inline char *realpath(const char *path, char *resolved_path) | |
101 | { | |
102 | _fullpath(resolved_path, path, _MAX_PATH); | |
103 | return resolved_path; | |
104 | } | |
105 | ||
a2d96af4 DB |
106 | |
107 | /* We wrap all the sockets functions so that we can | |
108 | * set errno based on WSAGetLastError() | |
109 | */ | |
110 | ||
111 | #undef connect | |
112 | #define connect qemu_connect_wrap | |
113 | int qemu_connect_wrap(int sockfd, const struct sockaddr *addr, | |
114 | socklen_t addrlen); | |
115 | ||
116 | #undef listen | |
117 | #define listen qemu_listen_wrap | |
118 | int qemu_listen_wrap(int sockfd, int backlog); | |
119 | ||
120 | #undef bind | |
121 | #define bind qemu_bind_wrap | |
122 | int qemu_bind_wrap(int sockfd, const struct sockaddr *addr, | |
123 | socklen_t addrlen); | |
124 | ||
125 | #undef socket | |
126 | #define socket qemu_socket_wrap | |
127 | int qemu_socket_wrap(int domain, int type, int protocol); | |
128 | ||
129 | #undef accept | |
130 | #define accept qemu_accept_wrap | |
131 | int qemu_accept_wrap(int sockfd, struct sockaddr *addr, | |
132 | socklen_t *addrlen); | |
133 | ||
134 | #undef shutdown | |
135 | #define shutdown qemu_shutdown_wrap | |
136 | int qemu_shutdown_wrap(int sockfd, int how); | |
137 | ||
138 | #undef ioctlsocket | |
139 | #define ioctlsocket qemu_ioctlsocket_wrap | |
140 | int qemu_ioctlsocket_wrap(int fd, int req, void *val); | |
141 | ||
142 | #undef closesocket | |
143 | #define closesocket qemu_closesocket_wrap | |
144 | int qemu_closesocket_wrap(int fd); | |
145 | ||
146 | #undef getsockopt | |
147 | #define getsockopt qemu_getsockopt_wrap | |
148 | int qemu_getsockopt_wrap(int sockfd, int level, int optname, | |
149 | void *optval, socklen_t *optlen); | |
150 | ||
151 | #undef setsockopt | |
152 | #define setsockopt qemu_setsockopt_wrap | |
153 | int qemu_setsockopt_wrap(int sockfd, int level, int optname, | |
154 | const void *optval, socklen_t optlen); | |
155 | ||
156 | #undef getpeername | |
157 | #define getpeername qemu_getpeername_wrap | |
158 | int qemu_getpeername_wrap(int sockfd, struct sockaddr *addr, | |
159 | socklen_t *addrlen); | |
160 | ||
161 | #undef getsockname | |
162 | #define getsockname qemu_getsockname_wrap | |
163 | int qemu_getsockname_wrap(int sockfd, struct sockaddr *addr, | |
164 | socklen_t *addrlen); | |
165 | ||
166 | #undef send | |
167 | #define send qemu_send_wrap | |
168 | ssize_t qemu_send_wrap(int sockfd, const void *buf, size_t len, int flags); | |
169 | ||
170 | #undef sendto | |
171 | #define sendto qemu_sendto_wrap | |
172 | ssize_t qemu_sendto_wrap(int sockfd, const void *buf, size_t len, int flags, | |
173 | const struct sockaddr *addr, socklen_t addrlen); | |
174 | ||
175 | #undef recv | |
176 | #define recv qemu_recv_wrap | |
177 | ssize_t qemu_recv_wrap(int sockfd, void *buf, size_t len, int flags); | |
178 | ||
179 | #undef recvfrom | |
180 | #define recvfrom qemu_recvfrom_wrap | |
181 | ssize_t qemu_recvfrom_wrap(int sockfd, void *buf, size_t len, int flags, | |
182 | struct sockaddr *addr, socklen_t *addrlen); | |
183 | ||
39626c03 | 184 | #endif |