int cpu_watchpoint_insert(CPUState *env, target_ulong addr, target_ulong len,

                          int flags, CPUWatchpoint **watchpoint)

{

    target_ulong len_mask = ~(len - 1);

    CPUWatchpoint *wp;



    /* sanity checks: allow power-of-2 lengths, deny unaligned watchpoints */

    if ((len != 1 && len != 2 && len != 4 && len != 8) || (addr & ~len_mask)) {

        fprintf(stderr, "qemu: tried to set invalid watchpoint at "

                TARGET_FMT_lx ", len=" TARGET_FMT_lu "\n", addr, len);

        return -EINVAL;

    }

    wp = qemu_malloc(sizeof(*wp));



    wp->vaddr = addr;

    wp->len_mask = len_mask;

    wp->flags = flags;



    /* keep all GDB-injected watchpoints in front */

    if (flags & BP_GDB)

        TAILQ_INSERT_HEAD(&env->watchpoints, wp, entry);

    else

        TAILQ_INSERT_TAIL(&env->watchpoints, wp, entry);



    tlb_flush_page(env, addr);



    if (watchpoint)

        *watchpoint = wp;

    return 0;

}

int cpu_watchpoint_insert(CPUState *env, target_ulong addr, target_ulong len,

                          int flags, CPUWatchpoint **watchpoint)

{

    target_ulong len_mask = ~(len - 1);

    CPUWatchpoint *wp;



    

    if ((len != 1 && len != 2 && len != 4 && len != 8) || (addr & ~len_mask)) {

        fprintf(stderr, "qemu: tried to set invalid watchpoint at "

                TARGET_FMT_lx ", len=" TARGET_FMT_lu "\n", addr, len);

        return -EINVAL;

    }

    wp = qemu_malloc(sizeof(*wp));



    wp->vaddr = addr;

    wp->len_mask = len_mask;

    wp->flags = flags;



    

    if (flags & BP_GDB)

        TAILQ_INSERT_HEAD(&env->watchpoints, wp, entry);

    else

        TAILQ_INSERT_TAIL(&env->watchpoints, wp, entry);



    tlb_flush_page(env, addr);



    if (watchpoint)

        *watchpoint = wp;

    return 0;

}

int FUNC_0(CPUState *VAR_0, target_ulong VAR_1, target_ulong VAR_2,

                          int VAR_3, CPUWatchpoint **VAR_4)

{

    target_ulong len_mask = ~(VAR_2 - 1);

    CPUWatchpoint *wp;



    

    if ((VAR_2 != 1 && VAR_2 != 2 && VAR_2 != 4 && VAR_2 != 8) || (VAR_1 & ~len_mask)) {

        fprintf(stderr, "qemu: tried to set invalid VAR_4 at "

                TARGET_FMT_lx ", VAR_2=" TARGET_FMT_lu "\n", VAR_1, VAR_2);

        return -EINVAL;

    }

    wp = qemu_malloc(sizeof(*wp));



    wp->vaddr = VAR_1;

    wp->len_mask = len_mask;

    wp->VAR_3 = VAR_3;



    

    if (VAR_3 & BP_GDB)

        TAILQ_INSERT_HEAD(&VAR_0->watchpoints, wp, entry);

    else

        TAILQ_INSERT_TAIL(&VAR_0->watchpoints, wp, entry);



    tlb_flush_page(VAR_0, VAR_1);



    if (VAR_4)

        *VAR_4 = wp;

    return 0;

}

int FUNC_0(CPUState *VAR_0, target_ulong VAR_1, target_ulong VAR_2,
int VAR_3, CPUWatchpoint **VAR_4)
{ target_ulong len_mask = ~(VAR_2 - 1); CPUWatchpoint *wp; if ((VAR_2 != 1 && VAR_2 != 2 && VAR_2 != 4 && VAR_2 != 8) || (VAR_1 & ~len_mask)) { fprintf(stderr, "qemu: tried to set invalid VAR_4 at "
TARGET_FMT_lx ", VAR_2=" TARGET_FMT_lu "\n", VAR_1, VAR_2); return -EINVAL; } wp = qemu_malloc(sizeof(*wp)); wp->vaddr = VAR_1; wp->len_mask = len_mask; wp->VAR_3 = VAR_3; if (VAR_3 & BP_GDB)
TAILQ_INSERT_HEAD(&VAR_0->watchpoints, wp, entry); else
TAILQ_INSERT_TAIL(&VAR_0->watchpoints, wp, entry); tlb_flush_page(VAR_0, VAR_1); if (VAR_4)
*VAR_4 = wp; return 0; }