Statistics
| Branch: | Revision:

root / include / sysemu / os-win32.h @ 3bd88451

History | View | Annotate | Download (3.4 kB)

1 39626c03 Jes Sorensen
/*
2 39626c03 Jes Sorensen
 * win32 specific declarations
3 39626c03 Jes Sorensen
 *
4 39626c03 Jes Sorensen
 * Copyright (c) 2003-2008 Fabrice Bellard
5 39626c03 Jes Sorensen
 * Copyright (c) 2010 Jes Sorensen <Jes.Sorensen@redhat.com>
6 39626c03 Jes Sorensen
 *
7 39626c03 Jes Sorensen
 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 39626c03 Jes Sorensen
 * of this software and associated documentation files (the "Software"), to deal
9 39626c03 Jes Sorensen
 * in the Software without restriction, including without limitation the rights
10 39626c03 Jes Sorensen
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 39626c03 Jes Sorensen
 * copies of the Software, and to permit persons to whom the Software is
12 39626c03 Jes Sorensen
 * furnished to do so, subject to the following conditions:
13 39626c03 Jes Sorensen
 *
14 39626c03 Jes Sorensen
 * The above copyright notice and this permission notice shall be included in
15 39626c03 Jes Sorensen
 * all copies or substantial portions of the Software.
16 39626c03 Jes Sorensen
 *
17 39626c03 Jes Sorensen
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 39626c03 Jes Sorensen
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 39626c03 Jes Sorensen
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 39626c03 Jes Sorensen
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 39626c03 Jes Sorensen
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 39626c03 Jes Sorensen
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 39626c03 Jes Sorensen
 * THE SOFTWARE.
24 39626c03 Jes Sorensen
 */
25 39626c03 Jes Sorensen
26 39626c03 Jes Sorensen
#ifndef QEMU_OS_WIN32_H
27 39626c03 Jes Sorensen
#define QEMU_OS_WIN32_H
28 39626c03 Jes Sorensen
29 082b5557 Blue Swirl
#include <windows.h>
30 082b5557 Blue Swirl
#include <winsock2.h>
31 082b5557 Blue Swirl
32 acf126ba Stefan Weil
/* Workaround for older versions of MinGW. */
33 acf126ba Stefan Weil
#ifndef ECONNREFUSED
34 acf126ba Stefan Weil
# define ECONNREFUSED WSAECONNREFUSED
35 acf126ba Stefan Weil
#endif
36 acf126ba Stefan Weil
#ifndef EINPROGRESS
37 acf126ba Stefan Weil
# define EINPROGRESS  WSAEINPROGRESS
38 acf126ba Stefan Weil
#endif
39 acf126ba Stefan Weil
#ifndef EHOSTUNREACH
40 acf126ba Stefan Weil
# define EHOSTUNREACH WSAEHOSTUNREACH
41 acf126ba Stefan Weil
#endif
42 acf126ba Stefan Weil
#ifndef EINTR
43 acf126ba Stefan Weil
# define EINTR        WSAEINTR
44 acf126ba Stefan Weil
#endif
45 acf126ba Stefan Weil
#ifndef EINPROGRESS
46 acf126ba Stefan Weil
# define EINPROGRESS  WSAEINPROGRESS
47 acf126ba Stefan Weil
#endif
48 acf126ba Stefan Weil
#ifndef ENETUNREACH
49 acf126ba Stefan Weil
# define ENETUNREACH  WSAENETUNREACH
50 acf126ba Stefan Weil
#endif
51 acf126ba Stefan Weil
#ifndef ENOTCONN
52 acf126ba Stefan Weil
# define ENOTCONN     WSAENOTCONN
53 acf126ba Stefan Weil
#endif
54 acf126ba Stefan Weil
#ifndef EWOULDBLOCK
55 acf126ba Stefan Weil
# define EWOULDBLOCK  WSAEWOULDBLOCK
56 acf126ba Stefan Weil
#endif
57 acf126ba Stefan Weil
58 5cf6dd51 Stefan Weil
#if defined(_WIN64)
59 5cf6dd51 Stefan Weil
/* On w64, setjmp is implemented by _setjmp which needs a second parameter.
60 5cf6dd51 Stefan Weil
 * If this parameter is NULL, longjump does no stack unwinding.
61 5cf6dd51 Stefan Weil
 * That is what we need for QEMU. Passing the value of register rsp (default)
62 5cf6dd51 Stefan Weil
 * lets longjmp try a stack unwinding which will crash with generated code. */
63 5cf6dd51 Stefan Weil
# undef setjmp
64 5cf6dd51 Stefan Weil
# define setjmp(env) _setjmp(env, NULL)
65 5cf6dd51 Stefan Weil
#endif
66 6ab7e546 Peter Maydell
/* QEMU uses sigsetjmp()/siglongjmp() as the portable way to specify
67 6ab7e546 Peter Maydell
 * "longjmp and don't touch the signal masks". Since we know that the
68 6ab7e546 Peter Maydell
 * savemask parameter will always be zero we can safely define these
69 6ab7e546 Peter Maydell
 * in terms of setjmp/longjmp on Win32.
70 6ab7e546 Peter Maydell
 */
71 6ab7e546 Peter Maydell
#define sigjmp_buf jmp_buf
72 6ab7e546 Peter Maydell
#define sigsetjmp(env, savemask) setjmp(env)
73 6ab7e546 Peter Maydell
#define siglongjmp(env, val) longjmp(env, val)
74 5cf6dd51 Stefan Weil
75 077030d1 Stefan Weil
/* Declaration of ffs() is missing in MinGW's strings.h. */
76 077030d1 Stefan Weil
int ffs(int i);
77 077030d1 Stefan Weil
78 d3e8f957 Stefan Weil
/* Missing POSIX functions. Don't use MinGW-w64 macros. */
79 d3e8f957 Stefan Weil
#undef gmtime_r
80 d3e8f957 Stefan Weil
struct tm *gmtime_r(const time_t *timep, struct tm *result);
81 d3e8f957 Stefan Weil
#undef localtime_r
82 d3e8f957 Stefan Weil
struct tm *localtime_r(const time_t *timep, struct tm *result);
83 d3e8f957 Stefan Weil
84 7b2d9779 Stefan Weil
char *strtok_r(char *str, const char *delim, char **saveptr);
85 7b2d9779 Stefan Weil
86 8d963e6a Jes Sorensen
static inline void os_setup_signal_handling(void) {}
87 eb505be1 Jes Sorensen
static inline void os_daemonize(void) {}
88 eb505be1 Jes Sorensen
static inline void os_setup_post(void) {}
89 6650b710 Stefan Weil
void os_set_line_buffering(void);
90 ce798cf2 Jes Sorensen
static inline void os_set_proc_name(const char *dummy) {}
91 8d963e6a Jes Sorensen
92 5635efc3 Stefan Weil
#if !defined(EPROTONOSUPPORT)
93 5635efc3 Stefan Weil
# define EPROTONOSUPPORT EINVAL
94 5635efc3 Stefan Weil
#endif
95 5635efc3 Stefan Weil
96 dc786bc9 Jes Sorensen
int setenv(const char *name, const char *value, int overwrite);
97 dc786bc9 Jes Sorensen
98 dc786bc9 Jes Sorensen
typedef struct {
99 dc786bc9 Jes Sorensen
    long tv_sec;
100 dc786bc9 Jes Sorensen
    long tv_usec;
101 dc786bc9 Jes Sorensen
} qemu_timeval;
102 dc786bc9 Jes Sorensen
int qemu_gettimeofday(qemu_timeval *tp);
103 dc786bc9 Jes Sorensen
104 995ee2bf Hitoshi Mitake
static inline bool is_daemonized(void)
105 995ee2bf Hitoshi Mitake
{
106 995ee2bf Hitoshi Mitake
    return false;
107 995ee2bf Hitoshi Mitake
}
108 995ee2bf Hitoshi Mitake
109 39626c03 Jes Sorensen
#endif