static void kvm_pit_put(PITCommonState *pit)

{

    KVMPITState *s = KVM_PIT(pit);

    struct kvm_pit_state2 kpit;

    struct kvm_pit_channel_state *kchan;

    struct PITChannelState *sc;

    int i, ret;



    /* The offset keeps changing as long as the VM is stopped. */

    if (s->vm_stopped) {

        kvm_pit_update_clock_offset(s);

    }



    kpit.flags = pit->channels[0].irq_disabled ? KVM_PIT_FLAGS_HPET_LEGACY : 0;

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

        kchan = &kpit.channels[i];

        sc = &pit->channels[i];

        kchan->count = sc->count;

        kchan->latched_count = sc->latched_count;

        kchan->count_latched = sc->count_latched;

        kchan->status_latched = sc->status_latched;

        kchan->status = sc->status;

        kchan->read_state = sc->read_state;

        kchan->write_state = sc->write_state;

        kchan->write_latch = sc->write_latch;

        kchan->rw_mode = sc->rw_mode;

        kchan->mode = sc->mode;

        kchan->bcd = sc->bcd;

        kchan->gate = sc->gate;

        kchan->count_load_time = sc->count_load_time - s->kernel_clock_offset;

    }



    ret = kvm_vm_ioctl(kvm_state,

                       kvm_has_pit_state2() ? KVM_SET_PIT2 : KVM_SET_PIT,

                       &kpit);

    if (ret < 0) {

        fprintf(stderr, "%s failed: %s\n",

                kvm_has_pit_state2() ? "KVM_SET_PIT2" : "KVM_SET_PIT",

                strerror(ret));

        abort();

    }

}

static void kvm_pit_put(PITCommonState *pit)

{

    KVMPITState *s = KVM_PIT(pit);

    struct kvm_pit_state2 kpit;

    struct kvm_pit_channel_state *kchan;

    struct PITChannelState *sc;

    int i, ret;



    

    if (s->vm_stopped) {

        kvm_pit_update_clock_offset(s);

    }



    kpit.flags = pit->channels[0].irq_disabled ? KVM_PIT_FLAGS_HPET_LEGACY : 0;

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

        kchan = &kpit.channels[i];

        sc = &pit->channels[i];

        kchan->count = sc->count;

        kchan->latched_count = sc->latched_count;

        kchan->count_latched = sc->count_latched;

        kchan->status_latched = sc->status_latched;

        kchan->status = sc->status;

        kchan->read_state = sc->read_state;

        kchan->write_state = sc->write_state;

        kchan->write_latch = sc->write_latch;

        kchan->rw_mode = sc->rw_mode;

        kchan->mode = sc->mode;

        kchan->bcd = sc->bcd;

        kchan->gate = sc->gate;

        kchan->count_load_time = sc->count_load_time - s->kernel_clock_offset;

    }



    ret = kvm_vm_ioctl(kvm_state,

                       kvm_has_pit_state2() ? KVM_SET_PIT2 : KVM_SET_PIT,

                       &kpit);

    if (ret < 0) {

        fprintf(stderr, "%s failed: %s\n",

                kvm_has_pit_state2() ? "KVM_SET_PIT2" : "KVM_SET_PIT",

                strerror(ret));

        abort();

    }

}

static void FUNC_0(PITCommonState *VAR_0)

{

    KVMPITState *s = KVM_PIT(VAR_0);

    struct kvm_pit_state2 VAR_1;

    struct kvm_pit_channel_state *VAR_2;

    struct PITChannelState *VAR_3;

    int VAR_4, VAR_5;



    

    if (s->vm_stopped) {

        kvm_pit_update_clock_offset(s);

    }



    VAR_1.flags = VAR_0->channels[0].irq_disabled ? KVM_PIT_FLAGS_HPET_LEGACY : 0;

    for (VAR_4 = 0; VAR_4 < 3; VAR_4++) {

        VAR_2 = &VAR_1.channels[VAR_4];

        VAR_3 = &VAR_0->channels[VAR_4];

        VAR_2->count = VAR_3->count;

        VAR_2->latched_count = VAR_3->latched_count;

        VAR_2->count_latched = VAR_3->count_latched;

        VAR_2->status_latched = VAR_3->status_latched;

        VAR_2->status = VAR_3->status;

        VAR_2->read_state = VAR_3->read_state;

        VAR_2->write_state = VAR_3->write_state;

        VAR_2->write_latch = VAR_3->write_latch;

        VAR_2->rw_mode = VAR_3->rw_mode;

        VAR_2->mode = VAR_3->mode;

        VAR_2->bcd = VAR_3->bcd;

        VAR_2->gate = VAR_3->gate;

        VAR_2->count_load_time = VAR_3->count_load_time - s->kernel_clock_offset;

    }



    VAR_5 = kvm_vm_ioctl(kvm_state,

                       kvm_has_pit_state2() ? KVM_SET_PIT2 : KVM_SET_PIT,

                       &VAR_1);

    if (VAR_5 < 0) {

        fprintf(stderr, "%s failed: %s\n",

                kvm_has_pit_state2() ? "KVM_SET_PIT2" : "KVM_SET_PIT",

                strerror(VAR_5));

        abort();

    }

}

static void FUNC_0(PITCommonState *VAR_0)
{ KVMPITState *s = KVM_PIT(VAR_0); struct kvm_pit_state2 VAR_1; struct kvm_pit_channel_state *VAR_2; struct PITChannelState *VAR_3; int VAR_4, VAR_5; if (s->vm_stopped) { kvm_pit_update_clock_offset(s); } VAR_1.flags = VAR_0->channels[0].irq_disabled ? KVM_PIT_FLAGS_HPET_LEGACY : 0; for (VAR_4 = 0; VAR_4 < 3; VAR_4++) { VAR_2 = &VAR_1.channels[VAR_4]; VAR_3 = &VAR_0->channels[VAR_4]; VAR_2->count = VAR_3->count; VAR_2->latched_count = VAR_3->latched_count; VAR_2->count_latched = VAR_3->count_latched; VAR_2->status_latched = VAR_3->status_latched; VAR_2->status = VAR_3->status; VAR_2->read_state = VAR_3->read_state; VAR_2->write_state = VAR_3->write_state; VAR_2->write_latch = VAR_3->write_latch; VAR_2->rw_mode = VAR_3->rw_mode; VAR_2->mode = VAR_3->mode; VAR_2->bcd = VAR_3->bcd; VAR_2->gate = VAR_3->gate; VAR_2->count_load_time = VAR_3->count_load_time - s->kernel_clock_offset; } VAR_5 = kvm_vm_ioctl(kvm_state,
kvm_has_pit_state2() ? KVM_SET_PIT2 : KVM_SET_PIT,
&VAR_1); if (VAR_5 < 0) { fprintf(stderr, "%s failed: %s\n",
kvm_has_pit_state2() ? "KVM_SET_PIT2" : "KVM_SET_PIT",
strerror(VAR_5)); abort(); } }