static void glib_select_fill(int *max_fd, fd_set *rfds, fd_set *wfds,

                             fd_set *xfds, uint32_t *cur_timeout)

{

    GMainContext *context = g_main_context_default();

    int i;

    int timeout = 0;



    g_main_context_prepare(context, &max_priority);



    n_poll_fds = g_main_context_query(context, max_priority, &timeout,

                                      poll_fds, ARRAY_SIZE(poll_fds));

    g_assert(n_poll_fds <= ARRAY_SIZE(poll_fds));



    for (i = 0; i < n_poll_fds; i++) {

        GPollFD *p = &poll_fds[i];



        if ((p->events & G_IO_IN)) {

            FD_SET(p->fd, rfds);

            *max_fd = MAX(*max_fd, p->fd);

        }

        if ((p->events & G_IO_OUT)) {

            FD_SET(p->fd, wfds);

            *max_fd = MAX(*max_fd, p->fd);

        }

        if ((p->events & G_IO_ERR)) {

            FD_SET(p->fd, xfds);

            *max_fd = MAX(*max_fd, p->fd);

        }

    }



    if (timeout >= 0 && timeout < *cur_timeout) {

        *cur_timeout = timeout;

    }

}

static void glib_select_fill(int *max_fd, fd_set *rfds, fd_set *wfds,

                             fd_set *xfds, uint32_t *cur_timeout)

{

    GMainContext *context = g_main_context_default();

    int i;

    int timeout = 0;



    g_main_context_prepare(context, &max_priority);



    n_poll_fds = g_main_context_query(context, max_priority, &timeout,

                                      poll_fds, ARRAY_SIZE(poll_fds));

    g_assert(n_poll_fds <= ARRAY_SIZE(poll_fds));



    for (i = 0; i < n_poll_fds; i++) {

        GPollFD *p = &poll_fds[i];



        if ((p->events & G_IO_IN)) {

            FD_SET(p->fd, rfds);

            *max_fd = MAX(*max_fd, p->fd);

        }

        if ((p->events & G_IO_OUT)) {

            FD_SET(p->fd, wfds);

            *max_fd = MAX(*max_fd, p->fd);

        }

        if ((p->events & G_IO_ERR)) {

            FD_SET(p->fd, xfds);

            *max_fd = MAX(*max_fd, p->fd);

        }

    }



    if (timeout >= 0 && timeout < *cur_timeout) {

        *cur_timeout = timeout;

    }

}

static void FUNC_0(int *VAR_0, fd_set *VAR_1, fd_set *VAR_2,

                             fd_set *VAR_3, uint32_t *VAR_4)

{

    GMainContext *context = g_main_context_default();

    int VAR_5;

    int VAR_6 = 0;



    g_main_context_prepare(context, &max_priority);



    n_poll_fds = g_main_context_query(context, max_priority, &VAR_6,

                                      poll_fds, ARRAY_SIZE(poll_fds));

    g_assert(n_poll_fds <= ARRAY_SIZE(poll_fds));



    for (VAR_5 = 0; VAR_5 < n_poll_fds; VAR_5++) {

        GPollFD *p = &poll_fds[VAR_5];



        if ((p->events & G_IO_IN)) {

            FD_SET(p->fd, VAR_1);

            *VAR_0 = MAX(*VAR_0, p->fd);

        }

        if ((p->events & G_IO_OUT)) {

            FD_SET(p->fd, VAR_2);

            *VAR_0 = MAX(*VAR_0, p->fd);

        }

        if ((p->events & G_IO_ERR)) {

            FD_SET(p->fd, VAR_3);

            *VAR_0 = MAX(*VAR_0, p->fd);

        }

    }



    if (VAR_6 >= 0 && VAR_6 < *VAR_4) {

        *VAR_4 = VAR_6;

    }

}

static void FUNC_0(int *VAR_0, fd_set *VAR_1, fd_set *VAR_2,
fd_set *VAR_3, uint32_t *VAR_4)
{ GMainContext *context = g_main_context_default(); int VAR_5; int VAR_6 = 0; g_main_context_prepare(context, &max_priority); n_poll_fds = g_main_context_query(context, max_priority, &VAR_6,
poll_fds, ARRAY_SIZE(poll_fds)); g_assert(n_poll_fds <= ARRAY_SIZE(poll_fds)); for (VAR_5 = 0; VAR_5 < n_poll_fds; VAR_5++) { GPollFD *p = &poll_fds[VAR_5]; if ((p->events & G_IO_IN)) { FD_SET(p->fd, VAR_1); *VAR_0 = MAX(*VAR_0, p->fd); } if ((p->events & G_IO_OUT)) { FD_SET(p->fd, VAR_2); *VAR_0 = MAX(*VAR_0, p->fd); } if ((p->events & G_IO_ERR)) { FD_SET(p->fd, VAR_3); *VAR_0 = MAX(*VAR_0, p->fd); } } if (VAR_6 >= 0 && VAR_6 < *VAR_4) { *VAR_4 = VAR_6; } }