Revision 0d93ca7c
b/os-win32.c | ||
---|---|---|
109 | 109 |
if (found) |
110 | 110 |
w->num--; |
111 | 111 |
} |
112 |
|
|
113 |
void os_host_main_loop_wait(int *timeout) |
|
114 |
{ |
|
115 |
int ret, ret2, i; |
|
116 |
PollingEntry *pe; |
|
117 |
|
|
118 |
/* XXX: need to suppress polling by better using win32 events */ |
|
119 |
ret = 0; |
|
120 |
for(pe = first_polling_entry; pe != NULL; pe = pe->next) { |
|
121 |
ret |= pe->func(pe->opaque); |
|
122 |
} |
|
123 |
if (ret == 0) { |
|
124 |
int err; |
|
125 |
WaitObjects *w = &wait_objects; |
|
126 |
|
|
127 |
ret = WaitForMultipleObjects(w->num, w->events, FALSE, *timeout); |
|
128 |
if (WAIT_OBJECT_0 + 0 <= ret && ret <= WAIT_OBJECT_0 + w->num - 1) { |
|
129 |
if (w->func[ret - WAIT_OBJECT_0]) |
|
130 |
w->func[ret - WAIT_OBJECT_0](w->opaque[ret - WAIT_OBJECT_0]); |
|
131 |
|
|
132 |
/* Check for additional signaled events */ |
|
133 |
for(i = (ret - WAIT_OBJECT_0 + 1); i < w->num; i++) { |
|
134 |
|
|
135 |
/* Check if event is signaled */ |
|
136 |
ret2 = WaitForSingleObject(w->events[i], 0); |
|
137 |
if(ret2 == WAIT_OBJECT_0) { |
|
138 |
if (w->func[i]) |
|
139 |
w->func[i](w->opaque[i]); |
|
140 |
} else if (ret2 == WAIT_TIMEOUT) { |
|
141 |
} else { |
|
142 |
err = GetLastError(); |
|
143 |
fprintf(stderr, "WaitForSingleObject error %d %d\n", i, err); |
|
144 |
} |
|
145 |
} |
|
146 |
} else if (ret == WAIT_TIMEOUT) { |
|
147 |
} else { |
|
148 |
err = GetLastError(); |
|
149 |
fprintf(stderr, "WaitForMultipleObjects error %d %d\n", ret, err); |
|
150 |
} |
|
151 |
} |
|
152 |
|
|
153 |
*timeout = 0; |
|
154 |
} |
b/qemu-os-posix.h | ||
---|---|---|
1 |
/* |
|
2 |
* posix 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_POSIX_H |
|
27 |
#define QEMU_OS_POSIX_H |
|
28 |
|
|
29 |
static inline void os_host_main_loop_wait(int *timeout) |
|
30 |
{ |
|
31 |
} |
|
32 |
|
|
33 |
#endif |
b/qemu-os-win32.h | ||
---|---|---|
40 | 40 |
int qemu_add_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque); |
41 | 41 |
void qemu_del_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque); |
42 | 42 |
|
43 |
void os_host_main_loop_wait(int *timeout); |
|
43 | 44 |
#endif |
b/sysemu.h | ||
---|---|---|
12 | 12 |
#include "qemu-os-win32.h" |
13 | 13 |
#endif |
14 | 14 |
|
15 |
#ifdef CONFIG_POSIX |
|
16 |
#include "qemu-os-posix.h" |
|
17 |
#endif |
|
18 |
|
|
15 | 19 |
/* vl.c */ |
16 | 20 |
extern const char *bios_name; |
17 | 21 |
|
b/vl.c | ||
---|---|---|
1722 | 1722 |
qemu_notify_event(); |
1723 | 1723 |
} |
1724 | 1724 |
|
1725 |
#ifdef _WIN32 |
|
1726 |
static void host_main_loop_wait(int *timeout) |
|
1727 |
{ |
|
1728 |
int ret, ret2, i; |
|
1729 |
PollingEntry *pe; |
|
1730 |
|
|
1731 |
|
|
1732 |
/* XXX: need to suppress polling by better using win32 events */ |
|
1733 |
ret = 0; |
|
1734 |
for(pe = first_polling_entry; pe != NULL; pe = pe->next) { |
|
1735 |
ret |= pe->func(pe->opaque); |
|
1736 |
} |
|
1737 |
if (ret == 0) { |
|
1738 |
int err; |
|
1739 |
WaitObjects *w = &wait_objects; |
|
1740 |
|
|
1741 |
ret = WaitForMultipleObjects(w->num, w->events, FALSE, *timeout); |
|
1742 |
if (WAIT_OBJECT_0 + 0 <= ret && ret <= WAIT_OBJECT_0 + w->num - 1) { |
|
1743 |
if (w->func[ret - WAIT_OBJECT_0]) |
|
1744 |
w->func[ret - WAIT_OBJECT_0](w->opaque[ret - WAIT_OBJECT_0]); |
|
1745 |
|
|
1746 |
/* Check for additional signaled events */ |
|
1747 |
for(i = (ret - WAIT_OBJECT_0 + 1); i < w->num; i++) { |
|
1748 |
|
|
1749 |
/* Check if event is signaled */ |
|
1750 |
ret2 = WaitForSingleObject(w->events[i], 0); |
|
1751 |
if(ret2 == WAIT_OBJECT_0) { |
|
1752 |
if (w->func[i]) |
|
1753 |
w->func[i](w->opaque[i]); |
|
1754 |
} else if (ret2 == WAIT_TIMEOUT) { |
|
1755 |
} else { |
|
1756 |
err = GetLastError(); |
|
1757 |
fprintf(stderr, "WaitForSingleObject error %d %d\n", i, err); |
|
1758 |
} |
|
1759 |
} |
|
1760 |
} else if (ret == WAIT_TIMEOUT) { |
|
1761 |
} else { |
|
1762 |
err = GetLastError(); |
|
1763 |
fprintf(stderr, "WaitForMultipleObjects error %d %d\n", ret, err); |
|
1764 |
} |
|
1765 |
} |
|
1766 |
|
|
1767 |
*timeout = 0; |
|
1768 |
} |
|
1769 |
#else |
|
1770 |
static void host_main_loop_wait(int *timeout) |
|
1771 |
{ |
|
1772 |
} |
|
1773 |
#endif |
|
1774 |
|
|
1775 | 1725 |
void main_loop_wait(int nonblocking) |
1776 | 1726 |
{ |
1777 | 1727 |
IOHandlerRecord *ioh; |
... | ... | |
1787 | 1737 |
qemu_bh_update_timeout(&timeout); |
1788 | 1738 |
} |
1789 | 1739 |
|
1790 |
host_main_loop_wait(&timeout); |
|
1740 |
os_host_main_loop_wait(&timeout);
|
|
1791 | 1741 |
|
1792 | 1742 |
/* poll any events */ |
1793 | 1743 |
/* XXX: separate device handlers from system ones */ |
Also available in: Unified diff