void qemu_co_rwlock_unlock(CoRwlock *lock)

{

    assert(qemu_in_coroutine());

    if (lock->writer) {

        lock->writer = false;

        while (!qemu_co_queue_empty(&lock->queue)) {

            /*

             * Wakeup every body. This will include some

             * writers too.

             */

            qemu_co_queue_next(&lock->queue);

        }

    } else {

        lock->reader--;

        assert(lock->reader >= 0);

        /* Wakeup only one waiting writer */

        if (!lock->reader) {

            qemu_co_queue_next(&lock->queue);

        }

    }

}

void qemu_co_rwlock_unlock(CoRwlock *lock)

{

    assert(qemu_in_coroutine());

    if (lock->writer) {

        lock->writer = false;

        while (!qemu_co_queue_empty(&lock->queue)) {

            







            qemu_co_queue_next(&lock->queue);

        }

    } else {

        lock->reader--;

        assert(lock->reader >= 0);

        

        if (!lock->reader) {

            qemu_co_queue_next(&lock->queue);

        }

    }

}

void FUNC_0(CoRwlock *VAR_0)

{

    assert(qemu_in_coroutine());

    if (VAR_0->writer) {

        VAR_0->writer = false;

        while (!qemu_co_queue_empty(&VAR_0->queue)) {

            







            qemu_co_queue_next(&VAR_0->queue);

        }

    } else {

        VAR_0->reader--;

        assert(VAR_0->reader >= 0);

        

        if (!VAR_0->reader) {

            qemu_co_queue_next(&VAR_0->queue);

        }

    }

}

void FUNC_0(CoRwlock *VAR_0)
{ assert(qemu_in_coroutine()); if (VAR_0->writer) { VAR_0->writer = false; while (!qemu_co_queue_empty(&VAR_0->queue)) { qemu_co_queue_next(&VAR_0->queue); } } else { VAR_0->reader--; assert(VAR_0->reader >= 0); if (!VAR_0->reader) { qemu_co_queue_next(&VAR_0->queue); } } }