sim: use ARRAY_SIZE instead of ad-hoc sizeof calculations
[deliverable/binutils-gdb.git] / sim / m32c / srcdest.c
index 5e7beed0cdfe088b4b03490cdc5064b3661fae17..937779b442eee233fd395f35a21a6eb272582d26 100644 (file)
@@ -1,29 +1,28 @@
 /* srcdest.c --- decoding M32C addressing modes.
 
-Copyright (C) 2005 Free Software Foundation, Inc.
+Copyright (C) 2005-2017 Free Software Foundation, Inc.
 Contributed by Red Hat, Inc.
 
 This file is part of the GNU simulators.
 
-The GNU simulators are free software; you can redistribute them and/or
-modify them under the terms of the GNU General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3 of the License, or
+(at your option) any later version.
 
-The GNU simulators are distributed in the hope that they will be
-useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
-along with the GNU simulators; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301, USA  */
+along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
 #include <stdio.h>
 #include <stdlib.h>
 
+#include "libiberty.h"
 #include "cpu.h"
 #include "mem.h"
 
@@ -33,7 +32,7 @@ static int src_addend = 0;
 static int dest_addend = 0;
 
 static int
-disp8 ()
+disp8 (void)
 {
   int rv;
   int tsave = trace;
@@ -47,7 +46,7 @@ disp8 ()
 }
 
 static int
-disp16 ()
+disp16 (void)
 {
   int rv;
   int tsave = trace;
@@ -61,7 +60,7 @@ disp16 ()
 }
 
 static int
-disp24 ()
+disp24 (void)
 {
   int rv;
   int tsave = trace;
@@ -75,7 +74,7 @@ disp24 ()
 }
 
 static int
-disp20 ()
+disp20 (void)
 {
   return disp24 () & 0x000fffff;
 }
@@ -119,8 +118,6 @@ srcdest
 decode_srcdest4 (int destcode, int bw)
 {
   srcdest sd;
-  sd.bytes = bw ? 2 : 1;
-  sd.mem = (destcode >= 6) ? 1 : 0;
   static const char *dc_wnames[16] = { "r0", "r1", "r2", "r3",
     "a0", "a1", "[a0]", "[a1]",
     "disp8[a0]", "disp8[a1]", "disp8[sb]", "disp8[fb]",
@@ -128,6 +125,9 @@ decode_srcdest4 (int destcode, int bw)
   };
   static const char *dc_bnames[4] = { "r0l", "r0h", "r1l", "r1h" };;
 
+  sd.bytes = bw ? 2 : 1;
+  sd.mem = (destcode >= 6) ? 1 : 0;
+
   if (trace)
     {
       const char *n = dc_wnames[destcode];
@@ -201,8 +201,6 @@ srcdest
 decode_jumpdest (int destcode, int w)
 {
   srcdest sd;
-  sd.bytes = w ? 2 : 3;
-  sd.mem = (destcode >= 6) ? 1 : 0;
   static const char *dc_wnames[16] = { "r0", "r1", "r2", "r3",
     "a0", "a1", "[a0]", "[a1]",
     "disp8[a0]", "disp8[a1]", "disp8[sb]", "disp8[fb]",
@@ -210,6 +208,9 @@ decode_jumpdest (int destcode, int w)
   };
   static const char *dc_anames[4] = { "r0l", "r0h", "r1l", "r1h" };
 
+  sd.bytes = w ? 2 : 3;
+  sd.mem = (destcode >= 6) ? 1 : 0;
+
   if (trace)
     {
       const char *n = dc_wnames[destcode];
@@ -354,7 +355,7 @@ decode_sd23 (int bbb, int bb, int bytes, int ind, int add)
   srcdest sd;
   int code = (bbb << 2) | bb;
 
-  if (code >= sizeof (modes23) / sizeof (modes23[0]))
+  if (code >= ARRAY_SIZE (modes23))
     abort ();
 
   if (trace)
This page took 0.024799 seconds and 4 git commands to generate.