From bc273e17510c7680bcffee75858d374aa93f7e4b Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 4 Jan 2016 22:24:03 -0500 Subject: sim: unify min/max macros Import defines from gdb/defs.h to the sim core so we can delete the various copies that already exist. --- sim/bfin/ChangeLog | 13 +++++++++++++ sim/bfin/bfin-sim.c | 2 +- sim/bfin/dv-bfin_dma.c | 2 +- sim/bfin/dv-bfin_ebiu_amc.c | 4 ++-- sim/bfin/dv-bfin_emac.c | 2 +- sim/bfin/dv-bfin_mmu.c | 2 +- sim/bfin/dv-bfin_trace.c | 2 +- sim/bfin/interp.c | 4 ++-- sim/bfin/sim-main.h | 6 +----- 9 files changed, 23 insertions(+), 14 deletions(-) (limited to 'sim/bfin') diff --git a/sim/bfin/ChangeLog b/sim/bfin/ChangeLog index 7c16fde..d4a4f2c 100644 --- a/sim/bfin/ChangeLog +++ b/sim/bfin/ChangeLog @@ -1,5 +1,18 @@ 2016-01-04 Mike Frysinger + * bfin-sim.c (decode_dsp32shift_0): Change MIN to min. + * dv-bfin_dma.c (bfin_dma_hw_event_callback): Likewise. + * dv-bfin_ebiu_amc.c (bfin_ebiu_amc_write_amgctl): Likewise. + * dv-bfin_emac.c (bfin_emac_dma_read_buffer): Change MAX to max. + * dv-bfin_mmu.c (_mmu_check_addr): Change MIN to min. + * dv-bfin_trace.c (bfin_trace_io_read_buffer): Likewise. + * interp.c (bfin_fdpic_load): Change MAX to max. + (bfin_fdpic_load): Likewise. + * sim-main.h (MIN, MAX): Delete. + (CLAMP): Change MIN to min and MAX to max. + +2016-01-04 Mike Frysinger + * configure: Regenerate. 2016-01-03 Mike Frysinger diff --git a/sim/bfin/bfin-sim.c b/sim/bfin/bfin-sim.c index 98efcb4..000a00f 100644 --- a/sim/bfin/bfin-sim.c +++ b/sim/bfin/bfin-sim.c @@ -5716,7 +5716,7 @@ decode_dsp32shift_0 (SIM_CPU *cpu, bu16 iw0, bu16 iw1) bu32 fg = DREG (src0); bu32 bg = DREG (src1); bu32 len = fg & 0x1f; - bu32 mask = (1 << MIN (16, len)) - 1; + bu32 mask = (1 << min (16, len)) - 1; bu32 fgnd = (fg >> 16) & mask; int shft = ((fg >> 8) & 0x1f); diff --git a/sim/bfin/dv-bfin_dma.c b/sim/bfin/dv-bfin_dma.c index 6871782..577ee30 100644 --- a/sim/bfin/dv-bfin_dma.c +++ b/sim/bfin/dv-bfin_dma.c @@ -255,7 +255,7 @@ bfin_dma_hw_event_callback (struct hw *me, void *data) /* XXX: This sucks performance wise. */ nr_bytes = dma->ele_size; else - nr_bytes = MIN (sizeof (buf), dma->curr_x_count * dma->ele_size); + nr_bytes = min (sizeof (buf), dma->curr_x_count * dma->ele_size); /* Pumping a chunk! */ bfin_peer->dma_master = me; diff --git a/sim/bfin/dv-bfin_ebiu_amc.c b/sim/bfin/dv-bfin_ebiu_amc.c index c59154d..08dce04 100644 --- a/sim/bfin/dv-bfin_ebiu_amc.c +++ b/sim/bfin/dv-bfin_ebiu_amc.c @@ -81,8 +81,8 @@ bfin_ebiu_amc_write_amgctl (struct hw *me, struct bfin_ebiu_amc *amc, { bu32 amben_old, amben, addr, i; - amben_old = MIN ((amc->amgctl >> 1) & 0x7, 4); - amben = MIN ((amgctl >> 1) & 0x7, 4); + amben_old = min ((amc->amgctl >> 1) & 0x7, 4); + amben = min ((amgctl >> 1) & 0x7, 4); HW_TRACE ((me, "reattaching banks: AMGCTL 0x%04x[%u] -> 0x%04x[%u]", amc->amgctl, amben_old, amgctl, amben)); diff --git a/sim/bfin/dv-bfin_emac.c b/sim/bfin/dv-bfin_emac.c index ec40bc5..fd3fcd3 100644 --- a/sim/bfin/dv-bfin_emac.c +++ b/sim/bfin/dv-bfin_emac.c @@ -413,7 +413,7 @@ bfin_emac_dma_read_buffer (struct hw *me, void *dest, int space, if (ret < 0) return 0; ret += 4; /* include crc */ - pad_ret = MAX (ret + 4, 64); + pad_ret = max (ret + 4, 64); len = pad_ret; memcpy (dest, &len, 2); diff --git a/sim/bfin/dv-bfin_mmu.c b/sim/bfin/dv-bfin_mmu.c index ceb0e36..b951e9a 100644 --- a/sim/bfin/dv-bfin_mmu.c +++ b/sim/bfin/dv-bfin_mmu.c @@ -532,7 +532,7 @@ _mmu_check_addr (SIM_CPU *cpu, bu32 addr, bool write, bool inst, int size) } else /* Normalize hit count so hits==2 is always multiple hit exception. */ - hits = MIN (2, hits); + hits = min (2, hits); _mmu_log_fault (cpu, mmu, addr, write, inst, hits == 0, supv, dag1, faults); diff --git a/sim/bfin/dv-bfin_trace.c b/sim/bfin/dv-bfin_trace.c index 2c44d1d..ebb2ada 100644 --- a/sim/bfin/dv-bfin_trace.c +++ b/sim/bfin/dv-bfin_trace.c @@ -131,7 +131,7 @@ bfin_trace_io_read_buffer (struct hw *me, void *dest, /* Hardware is limited to 16 entries, so to stay compatible with software, limit the value to 16. For software algorithms that keep reading while (TBUFSTAT != 0), they'll get all of it. */ - value = MIN (TBUF_LEN (trace), 16); + value = min (TBUF_LEN (trace), 16); break; case mmr_offset(tbuf): { diff --git a/sim/bfin/interp.c b/sim/bfin/interp.c index ad86500..accf5f3 100644 --- a/sim/bfin/interp.c +++ b/sim/bfin/interp.c @@ -915,7 +915,7 @@ bfin_fdpic_load (SIM_DESC sd, SIM_CPU *cpu, struct bfd *abfd, bu32 *sp, free (data); - max_load_addr = MAX (paddr + memsz, max_load_addr); + max_load_addr = max (paddr + memsz, max_load_addr); *sp -= 12; sim_write (sd, *sp+0, (void *)&paddr, 4); /* loadseg.addr */ @@ -946,7 +946,7 @@ bfin_fdpic_load (SIM_DESC sd, SIM_CPU *cpu, struct bfd *abfd, bu32 *sp, } /* Update the load offset with a few extra pages. */ - fdpic_load_offset = ALIGN (MAX (max_load_addr, fdpic_load_offset), 0x10000); + fdpic_load_offset = ALIGN (max (max_load_addr, fdpic_load_offset), 0x10000); fdpic_load_offset += 0x10000; /* Push the summary loadmap info onto the stack last. */ diff --git a/sim/bfin/sim-main.h b/sim/bfin/sim-main.h index 8804a71..51fb87e 100644 --- a/sim/bfin/sim-main.h +++ b/sim/bfin/sim-main.h @@ -56,13 +56,9 @@ struct sim_state { #include "sim-options.h" #include "dv-bfin_trace.h" -#undef MAX -#undef MIN #undef CLAMP #undef ALIGN -#define MAX(a, b) ((a) > (b) ? (a) : (b)) -#define MIN(a, b) ((a) < (b) ? (a) : (b)) -#define CLAMP(a, b, c) MIN (MAX (a, b), c) +#define CLAMP(a, b, c) min (max (a, b), c) #define ALIGN(addr, size) (((addr) + ((size)-1)) & ~((size)-1)) /* TODO: Move all this trace logic to the common code. */ -- cgit v1.1