binutils: support for the SPARC M8 processor
[deliverable/binutils-gdb.git] / sim / common / cgen-scache.c
index a06376681dd22a435916dfae9c5f4aad3c67263e..d2cbc069655dcddab77ca663656a17c195f92a8b 100644 (file)
@@ -1,5 +1,5 @@
 /* Simulator cache routines for CGEN simulators (and maybe others).
-   Copyright (C) 1996-2015 Free Software Foundation, Inc.
+   Copyright (C) 1996-2017 Free Software Foundation, Inc.
    Contributed by Cygnus Support.
 
 This file is part of GDB, the GNU debugger.
@@ -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
 
@@ -123,24 +121,26 @@ scache_option_handler (SIM_DESC sd, sim_cpu *cpu, int opt,
        {
          if (arg != NULL)
            {
-             int n = strtol (arg, NULL, 0);
+             unsigned int n = (unsigned int) strtoul (arg, NULL, 0);
              if (n < MIN_SCACHE_SIZE)
                {
-                 sim_io_eprintf (sd, "invalid scache size `%d', must be at least 4", n);
+                 sim_io_eprintf (sd, "invalid scache size `%u', must be at least %u",
+                                 n, MIN_SCACHE_SIZE);
                  return SIM_RC_FAIL;
                }
              /* Ensure it's a multiple of 2.  */
              if ((n & (n - 1)) != 0)
                {
-                 sim_io_eprintf (sd, "scache size `%d' not a multiple of 2\n", n);
-                 {
-                   /* round up to nearest multiple of 2 */
-                   int i;
-                   for (i = 1; i < n; i <<= 1)
-                     continue;
-                   n = i;
-                 }
-                 sim_io_eprintf (sd, "rounding scache size up to %d\n", n);
+                 unsigned int i;
+                 sim_io_eprintf (sd, "scache size `%u' not a multiple of 2\n", n);
+                 /* Round up to nearest multiple of 2.  */
+                 for (i = 1; i && i < n; i <<= 1)
+                   continue;
+                 if (i)
+                   {
+                     n = i;
+                     sim_io_eprintf (sd, "rounding scache size up to %u\n", n);
+                   }
                }
              if (cpu == NULL)
                STATE_SCACHE_SIZE (sd) = n;
@@ -212,7 +212,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) =
This page took 0.026717 seconds and 4 git commands to generate.