2013-03-25 15:23:56 +00:00
|
|
|
/*
|
|
|
|
* GLIB Compatibility Functions
|
|
|
|
*
|
|
|
|
* Copyright IBM, Corp. 2013
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Anthony Liguori <aliguori@us.ibm.com>
|
2014-05-08 08:30:46 +00:00
|
|
|
* Michael Tokarev <mjt@tls.msk.ru>
|
|
|
|
* Paolo Bonzini <pbonzini@redhat.com>
|
2013-03-25 15:23:56 +00:00
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
|
|
* See the COPYING file in the top-level directory.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef QEMU_GLIB_COMPAT_H
|
|
|
|
#define QEMU_GLIB_COMPAT_H
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
2017-01-03 19:19:33 +00:00
|
|
|
#if defined(_WIN32) && !GLIB_CHECK_VERSION(2, 50, 0)
|
glib: fix g_poll early timeout on windows
g_poll has a problem on Windows when using
timeouts < 10ms, in glib/gpoll.c:
/* If not, and we have a significant timeout, poll again with
* timeout then. Note that this will return indication for only
* one event, or only for messages. We ignore timeouts less than
* ten milliseconds as they are mostly pointless on Windows, the
* MsgWaitForMultipleObjectsEx() call will timeout right away
* anyway.
*/
if (retval == 0 && (timeout == INFINITE || timeout >= 10))
retval = poll_rest (poll_msgs, handles, nhandles, fds, nfds, timeout);
so whenever g_poll is called with timeout < 10ms it does
a quick poll instead of wait, this causes significant performance
degradation of QEMU, thus we should use WaitForMultipleObjectsEx
directly
Signed-off-by: Stanislav Vorobiov <s.vorobiov@samsung.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-05-08 08:47:10 +00:00
|
|
|
/*
|
|
|
|
* g_poll has a problem on Windows when using
|
|
|
|
* timeouts < 10ms, so use wrapper.
|
|
|
|
*/
|
|
|
|
#define g_poll(fds, nfds, timeout) g_poll_fixed(fds, nfds, timeout)
|
|
|
|
gint g_poll_fixed(GPollFD *fds, guint nfds, gint timeout);
|
2014-05-02 14:35:56 +00:00
|
|
|
#endif
|
|
|
|
|
2015-10-02 12:58:17 +00:00
|
|
|
|
|
|
|
#ifndef g_assert_cmpmem
|
|
|
|
#define g_assert_cmpmem(m1, l1, m2, l2) \
|
|
|
|
do { \
|
|
|
|
gconstpointer __m1 = m1, __m2 = m2; \
|
|
|
|
int __l1 = l1, __l2 = l2; \
|
|
|
|
if (__l1 != __l2) { \
|
|
|
|
g_assertion_message_cmpnum( \
|
|
|
|
G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
|
|
|
|
#l1 " (len(" #m1 ")) == " #l2 " (len(" #m2 "))", __l1, "==", \
|
|
|
|
__l2, 'i'); \
|
|
|
|
} else if (memcmp(__m1, __m2, __l1) != 0) { \
|
|
|
|
g_assertion_message(G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
|
|
|
|
"assertion failed (" #m1 " == " #m2 ")"); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
#endif
|
|
|
|
|
2013-03-25 15:23:56 +00:00
|
|
|
#endif
|