static int os_host_main_loop_wait(int timeout)

{

    int ret, i;

    PollingEntry *pe;

    WaitObjects *w = &wait_objects;

    static struct timeval tv0;



    /* XXX: need to suppress polling by better using win32 events */

    ret = 0;

    for (pe = first_polling_entry; pe != NULL; pe = pe->next) {

        ret |= pe->func(pe->opaque);

    }

    if (ret != 0) {

        return ret;

    }



    if (nfds >= 0) {

        ret = select(nfds + 1, &rfds, &wfds, &xfds, &tv0);

        if (ret != 0) {

            timeout = 0;

        }

    }



    for (i = 0; i < w->num; i++) {

        poll_fds[i].fd = (DWORD) w->events[i];

        poll_fds[i].events = G_IO_IN;

    }



    qemu_mutex_unlock_iothread();

    ret = g_poll(poll_fds, w->num, timeout);

    qemu_mutex_lock_iothread();

    if (ret > 0) {

        for (i = 0; i < w->num; i++) {

            w->revents[i] = poll_fds[i].revents;

        }

        for (i = 0; i < w->num; i++) {

            if (w->revents[i] && w->func[i]) {

                w->func[i](w->opaque[i]);

            }

        }

    }



    /* If an edge-triggered socket event occurred, select will return a

     * positive result on the next iteration.  We do not need to do anything

     * here.

     */



    return ret;

}

static int os_host_main_loop_wait(int timeout)

{

    int ret, i;

    PollingEntry *pe;

    WaitObjects *w = &wait_objects;

    static struct timeval tv0;



    

    ret = 0;

    for (pe = first_polling_entry; pe != NULL; pe = pe->next) {

        ret |= pe->func(pe->opaque);

    }

    if (ret != 0) {

        return ret;

    }



    if (nfds >= 0) {

        ret = select(nfds + 1, &rfds, &wfds, &xfds, &tv0);

        if (ret != 0) {

            timeout = 0;

        }

    }



    for (i = 0; i < w->num; i++) {

        poll_fds[i].fd = (DWORD) w->events[i];

        poll_fds[i].events = G_IO_IN;

    }



    qemu_mutex_unlock_iothread();

    ret = g_poll(poll_fds, w->num, timeout);

    qemu_mutex_lock_iothread();

    if (ret > 0) {

        for (i = 0; i < w->num; i++) {

            w->revents[i] = poll_fds[i].revents;

        }

        for (i = 0; i < w->num; i++) {

            if (w->revents[i] && w->func[i]) {

                w->func[i](w->opaque[i]);

            }

        }

    }



    









    return ret;

}

static int FUNC_0(int VAR_0)

{

    int VAR_1, VAR_2;

    PollingEntry *pe;

    WaitObjects *w = &wait_objects;

    static struct timeval VAR_3;



    

    VAR_1 = 0;

    for (pe = first_polling_entry; pe != NULL; pe = pe->next) {

        VAR_1 |= pe->func(pe->opaque);

    }

    if (VAR_1 != 0) {

        return VAR_1;

    }



    if (nfds >= 0) {

        VAR_1 = select(nfds + 1, &rfds, &wfds, &xfds, &VAR_3);

        if (VAR_1 != 0) {

            VAR_0 = 0;

        }

    }



    for (VAR_2 = 0; VAR_2 < w->num; VAR_2++) {

        poll_fds[VAR_2].fd = (DWORD) w->events[VAR_2];

        poll_fds[VAR_2].events = G_IO_IN;

    }



    qemu_mutex_unlock_iothread();

    VAR_1 = g_poll(poll_fds, w->num, VAR_0);

    qemu_mutex_lock_iothread();

    if (VAR_1 > 0) {

        for (VAR_2 = 0; VAR_2 < w->num; VAR_2++) {

            w->revents[VAR_2] = poll_fds[VAR_2].revents;

        }

        for (VAR_2 = 0; VAR_2 < w->num; VAR_2++) {

            if (w->revents[VAR_2] && w->func[VAR_2]) {

                w->func[VAR_2](w->opaque[VAR_2]);

            }

        }

    }



    









    return VAR_1;

}

static int FUNC_0(int VAR_0)
{ int VAR_1, VAR_2; PollingEntry *pe; WaitObjects *w = &wait_objects; static struct timeval VAR_3; VAR_1 = 0; for (pe = first_polling_entry; pe != NULL; pe = pe->next) { VAR_1 |= pe->func(pe->opaque); } if (VAR_1 != 0) { return VAR_1; } if (nfds >= 0) { VAR_1 = select(nfds + 1, &rfds, &wfds, &xfds, &VAR_3); if (VAR_1 != 0) { VAR_0 = 0; } } for (VAR_2 = 0; VAR_2 < w->num; VAR_2++) { poll_fds[VAR_2].fd = (DWORD) w->events[VAR_2]; poll_fds[VAR_2].events = G_IO_IN; } qemu_mutex_unlock_iothread(); VAR_1 = g_poll(poll_fds, w->num, VAR_0); qemu_mutex_lock_iothread(); if (VAR_1 > 0) { for (VAR_2 = 0; VAR_2 < w->num; VAR_2++) { w->revents[VAR_2] = poll_fds[VAR_2].revents; } for (VAR_2 = 0; VAR_2 < w->num; VAR_2++) { if (w->revents[VAR_2] && w->func[VAR_2]) { w->func[VAR_2](w->opaque[VAR_2]); } } } return VAR_1; }