void *paio_init(void)

{

    struct sigaction act;

    PosixAioState *s;

    int fds[2];

    int ret;



    if (posix_aio_state)

        return posix_aio_state;



    s = qemu_malloc(sizeof(PosixAioState));



    sigfillset(&act.sa_mask);

    act.sa_flags = 0; /* do not restart syscalls to interrupt select() */

    act.sa_handler = aio_signal_handler;

    sigaction(SIGUSR2, &act, NULL);



    s->first_aio = NULL;

    if (pipe(fds) == -1) {

        fprintf(stderr, "failed to create pipe\n");

        return NULL;

    }



    s->rfd = fds[0];

    s->wfd = fds[1];



    fcntl(s->rfd, F_SETFL, O_NONBLOCK);

    fcntl(s->wfd, F_SETFL, O_NONBLOCK);



    qemu_aio_set_fd_handler(s->rfd, posix_aio_read, NULL, posix_aio_flush, s);



    ret = pthread_attr_init(&attr);

    if (ret)

        die2(ret, "pthread_attr_init");



    ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);

    if (ret)

        die2(ret, "pthread_attr_setdetachstate");



    TAILQ_INIT(&request_list);



    posix_aio_state = s;



    return posix_aio_state;

}

void *paio_init(void)

{

    struct sigaction act;

    PosixAioState *s;

    int fds[2];

    int ret;



    if (posix_aio_state)

        return posix_aio_state;



    s = qemu_malloc(sizeof(PosixAioState));



    sigfillset(&act.sa_mask);

    act.sa_flags = 0; 

    act.sa_handler = aio_signal_handler;

    sigaction(SIGUSR2, &act, NULL);



    s->first_aio = NULL;

    if (pipe(fds) == -1) {

        fprintf(stderr, "failed to create pipe\n");

        return NULL;

    }



    s->rfd = fds[0];

    s->wfd = fds[1];



    fcntl(s->rfd, F_SETFL, O_NONBLOCK);

    fcntl(s->wfd, F_SETFL, O_NONBLOCK);



    qemu_aio_set_fd_handler(s->rfd, posix_aio_read, NULL, posix_aio_flush, s);



    ret = pthread_attr_init(&attr);

    if (ret)

        die2(ret, "pthread_attr_init");



    ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);

    if (ret)

        die2(ret, "pthread_attr_setdetachstate");



    TAILQ_INIT(&request_list);



    posix_aio_state = s;



    return posix_aio_state;

}

void *FUNC_0(void)

{

    struct sigaction VAR_0;

    PosixAioState *s;

    int VAR_1[2];

    int VAR_2;



    if (posix_aio_state)

        return posix_aio_state;



    s = qemu_malloc(sizeof(PosixAioState));



    sigfillset(&VAR_0.sa_mask);

    VAR_0.sa_flags = 0; 

    VAR_0.sa_handler = aio_signal_handler;

    sigaction(SIGUSR2, &VAR_0, NULL);



    s->first_aio = NULL;

    if (pipe(VAR_1) == -1) {

        fprintf(stderr, "failed to create pipe\n");

        return NULL;

    }



    s->rfd = VAR_1[0];

    s->wfd = VAR_1[1];



    fcntl(s->rfd, F_SETFL, O_NONBLOCK);

    fcntl(s->wfd, F_SETFL, O_NONBLOCK);



    qemu_aio_set_fd_handler(s->rfd, posix_aio_read, NULL, posix_aio_flush, s);



    VAR_2 = pthread_attr_init(&attr);

    if (VAR_2)

        die2(VAR_2, "pthread_attr_init");



    VAR_2 = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);

    if (VAR_2)

        die2(VAR_2, "pthread_attr_setdetachstate");



    TAILQ_INIT(&request_list);



    posix_aio_state = s;



    return posix_aio_state;

}

void *FUNC_0(void)
{ struct sigaction VAR_0; PosixAioState *s; int VAR_1[2]; int VAR_2; if (posix_aio_state)
return posix_aio_state; s = qemu_malloc(sizeof(PosixAioState)); sigfillset(&VAR_0.sa_mask); VAR_0.sa_flags = 0; VAR_0.sa_handler = aio_signal_handler; sigaction(SIGUSR2, &VAR_0, NULL); s->first_aio = NULL; if (pipe(VAR_1) == -1) { fprintf(stderr, "failed to create pipe\n"); return NULL; } s->rfd = VAR_1[0]; s->wfd = VAR_1[1]; fcntl(s->rfd, F_SETFL, O_NONBLOCK); fcntl(s->wfd, F_SETFL, O_NONBLOCK); qemu_aio_set_fd_handler(s->rfd, posix_aio_read, NULL, posix_aio_flush, s); VAR_2 = pthread_attr_init(&attr); if (VAR_2)
die2(VAR_2, "pthread_attr_init"); VAR_2 = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); if (VAR_2)
die2(VAR_2, "pthread_attr_setdetachstate"); TAILQ_INIT(&request_list); posix_aio_state = s; return posix_aio_state; }