]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
sim: unify min/max macros
authorMike Frysinger <vapier@gentoo.org>
Tue, 5 Jan 2016 03:24:03 +0000 (22:24 -0500)
committerMike Frysinger <vapier@gentoo.org>
Tue, 5 Jan 2016 03:24:03 +0000 (22:24 -0500)
Import defines from gdb/defs.h to the sim core so we can delete the
various copies that already exist.

16 files changed:
sim/aarch64/ChangeLog
sim/aarch64/simulator.c
sim/bfin/ChangeLog
sim/bfin/bfin-sim.c
sim/bfin/dv-bfin_dma.c
sim/bfin/dv-bfin_ebiu_amc.c
sim/bfin/dv-bfin_emac.c
sim/bfin/dv-bfin_mmu.c
sim/bfin/dv-bfin_trace.c
sim/bfin/interp.c
sim/bfin/sim-main.h
sim/common/ChangeLog
sim/common/cgen-scache.c
sim/common/cgen-trace.c
sim/common/cgen-utils.c
sim/common/sim-basics.h

index f9b8673d941aa0eebbd98ef858bde5c20e62ef89..b88497960d4a5b15489c83874164e2860ac402c3 100644 (file)
@@ -1,3 +1,9 @@
+2016-01-04  Mike Frysinger  <vapier@gentoo.org>
+
+       * simulator.c (MAX, MIN): Delete.
+       (do_vec_maxv): Change MAX to max and MIN to min.
+       (do_vec_fminmaxV): Likewise.
+
 2016-01-04  Tristan Gingold  <gingold@adacore.com>
 
        * simulator.c: Remove syscall.h include.
index 84ce8e81cf0843e9db1bb2bee4b5ebd0a7965bd2..3315a2d5be76388d1eaa54d457aa1a9f6ab76b28 100644 (file)
@@ -4108,9 +4108,6 @@ do_vec_XTN (sim_cpu *cpu)
     }
 }
 
-#define MAX(A,B) ((A) > (B) ? (A) : (B))
-#define MIN(A,B) ((A) < (B) ? (A) : (B))
-
 static void
 do_vec_maxv (sim_cpu *cpu)
 {
@@ -4147,17 +4144,17 @@ do_vec_maxv (sim_cpu *cpu)
          case 0:
            smax = aarch64_get_vec_s8 (cpu, vs, 0);
            for (i = 1; i < (full ? 16 : 8); i++)
-             smax = MAX (smax, aarch64_get_vec_s8 (cpu, vs, i));
+             smax = max (smax, aarch64_get_vec_s8 (cpu, vs, i));
            break;
          case 1:
            smax = aarch64_get_vec_s16 (cpu, vs, 0);
            for (i = 1; i < (full ? 8 : 4); i++)
-             smax = MAX (smax, aarch64_get_vec_s16 (cpu, vs, i));
+             smax = max (smax, aarch64_get_vec_s16 (cpu, vs, i));
            break;
          case 2:
            smax = aarch64_get_vec_s32 (cpu, vs, 0);
            for (i = 1; i < (full ? 4 : 2); i++)
-             smax = MAX (smax, aarch64_get_vec_s32 (cpu, vs, i));
+             smax = max (smax, aarch64_get_vec_s32 (cpu, vs, i));
            break;
          default:
          case 3:
@@ -4175,17 +4172,17 @@ do_vec_maxv (sim_cpu *cpu)
          case 0:
            smin = aarch64_get_vec_s8 (cpu, vs, 0);
            for (i = 1; i < (full ? 16 : 8); i++)
-             smin = MIN (smin, aarch64_get_vec_s8 (cpu, vs, i));
+             smin = min (smin, aarch64_get_vec_s8 (cpu, vs, i));
            break;
          case 1:
            smin = aarch64_get_vec_s16 (cpu, vs, 0);
            for (i = 1; i < (full ? 8 : 4); i++)
-             smin = MIN (smin, aarch64_get_vec_s16 (cpu, vs, i));
+             smin = min (smin, aarch64_get_vec_s16 (cpu, vs, i));
            break;
          case 2:
            smin = aarch64_get_vec_s32 (cpu, vs, 0);
            for (i = 1; i < (full ? 4 : 2); i++)
-             smin = MIN (smin, aarch64_get_vec_s32 (cpu, vs, i));
+             smin = min (smin, aarch64_get_vec_s32 (cpu, vs, i));
            break;
          default:
          case 3:
@@ -4203,17 +4200,17 @@ do_vec_maxv (sim_cpu *cpu)
          case 0:
            umax = aarch64_get_vec_u8 (cpu, vs, 0);
            for (i = 1; i < (full ? 16 : 8); i++)
-             umax = MAX (umax, aarch64_get_vec_u8 (cpu, vs, i));
+             umax = max (umax, aarch64_get_vec_u8 (cpu, vs, i));
            break;
          case 1:
            umax = aarch64_get_vec_u16 (cpu, vs, 0);
            for (i = 1; i < (full ? 8 : 4); i++)
-             umax = MAX (umax, aarch64_get_vec_u16 (cpu, vs, i));
+             umax = max (umax, aarch64_get_vec_u16 (cpu, vs, i));
            break;
          case 2:
            umax = aarch64_get_vec_u32 (cpu, vs, 0);
            for (i = 1; i < (full ? 4 : 2); i++)
-             umax = MAX (umax, aarch64_get_vec_u32 (cpu, vs, i));
+             umax = max (umax, aarch64_get_vec_u32 (cpu, vs, i));
            break;
          default:
          case 3:
@@ -4231,17 +4228,17 @@ do_vec_maxv (sim_cpu *cpu)
          case 0:
            umin = aarch64_get_vec_u8 (cpu, vs, 0);
            for (i = 1; i < (full ? 16 : 8); i++)
-             umin = MIN (umin, aarch64_get_vec_u8 (cpu, vs, i));
+             umin = min (umin, aarch64_get_vec_u8 (cpu, vs, i));
            break;
          case 1:
            umin = aarch64_get_vec_u16 (cpu, vs, 0);
            for (i = 1; i < (full ? 8 : 4); i++)
-             umin = MIN (umin, aarch64_get_vec_u16 (cpu, vs, i));
+             umin = min (umin, aarch64_get_vec_u16 (cpu, vs, i));
            break;
          case 2:
            umin = aarch64_get_vec_u32 (cpu, vs, 0);
            for (i = 1; i < (full ? 4 : 2); i++)
-             umin = MIN (umin, aarch64_get_vec_u32 (cpu, vs, i));
+             umin = min (umin, aarch64_get_vec_u32 (cpu, vs, i));
            break;
          default:
          case 3:
@@ -4287,7 +4284,7 @@ do_vec_fminmaxV (sim_cpu *cpu)
 
        case 3: /* FMINV.  */
          for (i = 1; i < 4; i++)
-           res = MIN (res, aarch64_get_vec_float (cpu, vs, i));
+           res = min (res, aarch64_get_vec_float (cpu, vs, i));
          break;
 
        default:
@@ -4305,7 +4302,7 @@ do_vec_fminmaxV (sim_cpu *cpu)
 
        case 3: /* FMAXV.  */
          for (i = 1; i < 4; i++)
-           res = MAX (res, aarch64_get_vec_float (cpu, vs, i));
+           res = max (res, aarch64_get_vec_float (cpu, vs, i));
          break;
 
        default:
index 7c16fde05f781db027e317815b8606f924cf5ad0..d4a4f2c1f2acde25a3858aff791f966216f7246b 100644 (file)
@@ -1,3 +1,16 @@
+2016-01-04  Mike Frysinger  <vapier@gentoo.org>
+
+       * 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  <vapier@gentoo.org>
 
        * configure: Regenerate.
index 98efcb487589b2594e683156701240607f9c1df3..000a00fcb42bc48f54e21c9d7b6263018f9654a2 100644 (file)
@@ -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);
 
index 6871782ee28e06fcca5fa413f5b5796de9941eb2..577ee30a34d6d44d8ee9df5ed38b273307c315cb 100644 (file)
@@ -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;
index c59154dacd82b1347be0c9b90d32c89556a22993..08dce04962ab37e6f3ed01ca0111a961927aba95 100644 (file)
@@ -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));
index ec40bc5dc811bfe4b575d91265f20b2c25d4b139..fd3fcd37351005424f8e6703b020c143b1891739 100644 (file)
@@ -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);
 
index ceb0e3677aad415ae4fbceada542afa3d46edec0..b951e9a316230b076ff953313b5a3260b139bd9d 100644 (file)
@@ -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);
 
index 2c44d1d23d093d071fc4970066432ec4e5a80f2e..ebb2ada4887afb030b19d485d2a921fa24b2a3d2 100644 (file)
@@ -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):
       {
index ad865005ea4d3b129f8f2c9fe57d513b24b4cbc4..accf5f33fc63f5a5125f2cc19535b7e6270de816 100644 (file)
@@ -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.  */
index 8804a7174ad3ffcf564a3cfd586399ba64511104..51fb87e4fafde0d76c61bc97baec71916cd0c93c 100644 (file)
@@ -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.  */
index e0eebb2214e270c1bef18b6aa82a8a807e3397ac..f8cdbf4d1b20826d6b552412e53029e7488a59f3 100644 (file)
@@ -1,3 +1,12 @@
+2016-01-04  Mike Frysinger  <vapier@gentoo.org>
+
+       * cgen-scache.c (MAX): Delete.
+       (scache_init): Change MAX to max.
+       * cgen-trace.c (min): Delete.
+       * cgen-utils.c (min): Delete.
+       * sim-basics.h [!min] (min): Define.
+       [!max] (max): Define.
+
 2016-01-04  Mike Frysinger  <vapier@gentoo.org>
 
        * sim-options.c (sim_parse_args): Tweak getopt error message.
index e0c3570403665384c7853d19a912bc5a5422251f..3a795140e4009359b218fcb2327470fe29e99cdd 100644 (file)
@@ -27,8 +27,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "sim-options.h"
 #include "sim-io.h"
 
-#define MAX(a,b) ((a) > (b) ? (a) : (b))
-
 /* Unused address.  */
 #define UNUSED_ADDR 0xffffffff
 
@@ -212,7 +210,7 @@ scache_init (SIM_DESC sd)
 #if WITH_SCACHE_PBB
          CPU_SCACHE_MAX_CHAIN_LENGTH (cpu) = MAX_CHAIN_LENGTH;
          CPU_SCACHE_NUM_HASH_CHAIN_ENTRIES (cpu) = MAX_HASH_CHAIN_LENGTH;
-         CPU_SCACHE_NUM_HASH_CHAINS (cpu) = MAX (MIN_HASH_CHAINS,
+         CPU_SCACHE_NUM_HASH_CHAINS (cpu) = max (MIN_HASH_CHAINS,
                                                  CPU_SCACHE_SIZE (cpu)
                                                  / SCACHE_HASH_RATIO);
          CPU_SCACHE_HASH_TABLE (cpu) =
index 5adc552a0e66050a4b3180ebbcc7073826765052..2332df4f3d98f75b2f011de0b0e15b312a037b72 100644 (file)
@@ -24,9 +24,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "sim-main.h"
 #include "sim-fpu.h"
 
-#undef min
-#define min(a,b) ((a) < (b) ? (a) : (b))
-
 #ifndef SIZE_INSTRUCTION
 #define SIZE_INSTRUCTION 16
 #endif
index b16a608063e18975f3b00c9804aa9143769c0606..d17fb42ce1c84d88541e48b143a8a50144bd4a61 100644 (file)
@@ -28,9 +28,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 #define SEMOPS_DEFINE_INLINE
 #include "cgen-ops.h"
 
-#undef min
-#define min(a,b) ((a) < (b) ? (a) : (b))
-
 const char *mode_names[] = {
   "VOID",
   "BI",
index e0cb6d17c91dfafce19b173e8c1a23d7f6fa95ce..16c7eb5c4fcdaa5b4280562a0de50429ab14e61a 100644 (file)
@@ -48,6 +48,13 @@ extern int asprintf (char **result, const char *format, ...);
 #endif
 
 
+#ifndef min
+#define min(a, b) ((a) < (b) ? (a) : (b))
+#endif
+#ifndef max
+#define max(a, b) ((a) > (b) ? (a) : (b))
+#endif
+
 
 /* Some versions of GCC include an attribute operator, define it */