]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
sim: constify various integer readers
authorMike Frysinger <vapier@gentoo.org>
Wed, 26 Oct 2022 16:57:10 +0000 (22:42 +0545)
committerMike Frysinger <vapier@gentoo.org>
Mon, 31 Oct 2022 15:39:39 +0000 (21:24 +0545)
These functions only read from memory, so mark the pointer as const.

16 files changed:
sim/aarch64/interp.c
sim/arm/iwmmxt.c
sim/arm/iwmmxt.h
sim/arm/wrapper.c
sim/bfin/machs.c
sim/cr16/interp.c
sim/d10v/d10v_sim.h
sim/d10v/endian.c
sim/ft32/interp.c
sim/m32c/gdb-if.c
sim/mcore/interp.c
sim/microblaze/interp.c
sim/moxie/interp.c
sim/pru/interp.c
sim/rl78/gdb-if.c
sim/rx/gdb-if.c

index a04f1dcc389c2ef4576e8cef5ece0894581c1f41..ac95c7dfaac7dbd458f1118d7f00da3bc371f7be 100644 (file)
@@ -171,7 +171,7 @@ sim_create_inferior (SIM_DESC sd, struct bfd *abfd,
 /* Read the LENGTH bytes at BUF as a little-endian value.  */
 
 static bfd_vma
-get_le (unsigned char *buf, unsigned int length)
+get_le (const unsigned char *buf, unsigned int length)
 {
   bfd_vma acc = 0;
 
index 5f91012bc2a9038b00dcb8b780f34ba0e020d9d1..ad065317b410424ae25cb1ff34b873a1610fb2cb 100644 (file)
@@ -3723,7 +3723,7 @@ Fetch_Iwmmxt_Register (unsigned int regnum, unsigned char * memory)
 }
 
 int
-Store_Iwmmxt_Register (unsigned int regnum, unsigned char * memory)
+Store_Iwmmxt_Register (unsigned int regnum, const unsigned char * memory)
 {
   if (regnum >= 16)
     {
index e49a8d78d09bb6219fba19af3ee1146a2565a512..2f677affa318d7b190be1a7f85e0e54e6f714a63 100644 (file)
@@ -24,4 +24,4 @@ extern unsigned IwmmxtCDP (ARMul_State *, unsigned, ARMword);
 extern int ARMul_HandleIwmmxt (ARMul_State *, ARMword);
 
 extern int Fetch_Iwmmxt_Register (unsigned int, unsigned char *);
-extern int Store_Iwmmxt_Register (unsigned int, unsigned char *);
+extern int Store_Iwmmxt_Register (unsigned int, const unsigned char *);
index 38a1f27a3b01bf7e51e9f5756f7789be99edf3a9..72a65242b9dd4a8fd23467d52278348a18f87a8d 100644 (file)
@@ -397,7 +397,7 @@ sim_create_inferior (SIM_DESC sd ATTRIBUTE_UNUSED,
 }
 
 static int
-frommem (struct ARMul_State *state, unsigned char *memory)
+frommem (struct ARMul_State *state, const unsigned char *memory)
 {
   if (state->bigendSig == HIGH)
     return (memory[0] << 24) | (memory[1] << 16)
index 2d3a019b9babb31e5ab4696f2e3f633d8b23acfb..f322b183b2e269ffe532725873ff8573f7d78694 100644 (file)
@@ -1758,7 +1758,7 @@ bfin_model_init (SIM_CPU *cpu)
 }
 
 static bu32
-bfin_extract_unsigned_integer (unsigned char *addr, int len)
+bfin_extract_unsigned_integer (const unsigned char *addr, int len)
 {
   bu32 retval;
   unsigned char * p;
index b375dadff5d6d3278b92b28cb6f3a22dfe8eeed6..cbdcdc6e7932ef020da286cb266855fd101e4543 100644 (file)
@@ -690,7 +690,7 @@ sim_create_inferior (SIM_DESC sd, struct bfd *abfd,
 }
 
 static uint32_t
-cr16_extract_unsigned_integer (unsigned char *addr, int len)
+cr16_extract_unsigned_integer (const unsigned char *addr, int len)
 {
   uint32_t retval;
   unsigned char * p;
index 7b354fd48414bb126337be6b1bcfde7e8f0fbd14..e78ea2fe9df873c867e5aa51c3c53d402bd63021 100644 (file)
@@ -445,9 +445,9 @@ extern uint8_t *imem_addr (SIM_DESC, SIM_CPU *, uint32_t);
 #undef ENDIAN_INLINE
 
 #else
-extern uint32_t get_longword (uint8_t *);
-extern uint16_t get_word (uint8_t *);
-extern int64_t get_longlong (uint8_t *);
+extern uint32_t get_longword (const uint8_t *);
+extern uint16_t get_word (const uint8_t *);
+extern int64_t get_longlong (const uint8_t *);
 extern void write_word (uint8_t *addr, uint16_t data);
 extern void write_longword (uint8_t *addr, uint32_t data);
 extern void write_longlong (uint8_t *addr, int64_t data);
index f3e1e46214f74b6d89c22df48f1fa991e485c035..44e80e6d65301f6556b570ca979f9dc680b7b495 100644 (file)
 #endif
 
 ENDIAN_INLINE uint16_t
-get_word (uint8_t *x)
+get_word (const uint8_t *x)
 {
   return ((uint16_t)x[0]<<8) + x[1];
 }
 
 ENDIAN_INLINE uint32_t
-get_longword (uint8_t *x)
+get_longword (const uint8_t *x)
 {
   return ((uint32_t)x[0]<<24) + ((uint32_t)x[1]<<16) + ((uint32_t)x[2]<<8) + ((uint32_t)x[3]);
 }
 
 ENDIAN_INLINE int64_t
-get_longlong (uint8_t *x)
+get_longlong (const uint8_t *x)
 {
   uint32_t top = get_longword (x);
   uint32_t bottom = get_longword (x+4);
index 8e828e68effb1b9086b5d99ad6f1ed8784991710..70212f45cca339a02a9fd68ed2f505c1a0d1781c 100644 (file)
@@ -56,7 +56,7 @@
 #define RAM_BIAS  0x800000  /* Bias added to RAM addresses.  */
 
 static unsigned long
-ft32_extract_unsigned_integer (unsigned char *addr, int len)
+ft32_extract_unsigned_integer (const unsigned char *addr, int len)
 {
   unsigned long retval;
   unsigned char *p;
index 8bb8e9bb56362d9a07b668361a089ae5d9052573..802eae97851841d822d27329249087facd507d83 100644 (file)
@@ -184,7 +184,7 @@ sim_write (SIM_DESC sd, SIM_ADDR mem, const void *buf, int length)
 
 /* Read the LENGTH bytes at BUF as an little-endian value.  */
 static DI
-get_le (unsigned char *buf, int length)
+get_le (const unsigned char *buf, int length)
 {
   DI acc = 0;
   while (--length >= 0)
index dbac1567ffb053c48fdfef59059a620d34616b35..082bc4e07677e79adc0b2a8f096f5c1713994b9d 100644 (file)
@@ -42,7 +42,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
 static unsigned long
-mcore_extract_unsigned_integer (unsigned char *addr, int len)
+mcore_extract_unsigned_integer (const unsigned char *addr, int len)
 {
   unsigned long retval;
   unsigned char * p;
index 2ec223868a74374bcf616ed040bbce5c412a06aa..6aa02632093ae19a9a6f46b5383cd307a58a752f 100644 (file)
@@ -38,7 +38,7 @@
 #define target_big_endian (CURRENT_TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
 
 static unsigned long
-microblaze_extract_unsigned_integer (unsigned char *addr, int len)
+microblaze_extract_unsigned_integer (const unsigned char *addr, int len)
 {
   unsigned long retval;
   unsigned char *p;
index a08dc694553ae5055dd1acd254a85e46375762cb..d5d14bfe49d90ecaf4aebf12a2ec23970c738fdd 100644 (file)
@@ -57,7 +57,7 @@ typedef unsigned int uword;
      + (sim_core_read_aligned_1 (scpu, cia, read_map, addr+1))) << 16) >> 16)
 
 static unsigned long
-moxie_extract_unsigned_integer (unsigned char *addr, int len)
+moxie_extract_unsigned_integer (const unsigned char *addr, int len)
 {
   unsigned long retval;
   unsigned char * p;
index a62b5a2c8fe25fe65a5c795ccaa1e66fbf2bd7e9..fabedc99f6e2f9792f34244b3b8354243c0aa69c 100644 (file)
@@ -45,12 +45,12 @@ enum {
 
 /* Extract (from PRU endianess) and return an integer in HOST's endianness.  */
 static uint32_t
-pru_extract_unsigned_integer (uint8_t *addr, size_t len)
+pru_extract_unsigned_integer (const uint8_t *addr, size_t len)
 {
   uint32_t retval;
-  uint8_t *p;
-  uint8_t *startaddr = addr;
-  uint8_t *endaddr = startaddr + len;
+  const uint8_t *p;
+  const uint8_t *startaddr = addr;
+  const uint8_t *endaddr = startaddr + len;
 
   /* Start at the most significant end of the integer, and work towards
      the least significant.  */
index 8129c0924dc923114e0cb79d37480136ae4ffbb4..98bb0a4044b28fa6ef38be9976a75274fa2fc803 100644 (file)
@@ -237,7 +237,7 @@ sim_write (SIM_DESC sd, SIM_ADDR mem, const void *buf, int length)
 /* Read the LENGTH bytes at BUF as an little-endian value.  */
 
 static SI
-get_le (unsigned char *buf, int length)
+get_le (const unsigned char *buf, int length)
 {
   SI acc = 0;
 
index c116bdcf608ba2bdac9f453e2cfb3fa794aac671..7af37b94fcf1d7520d7bc52ec73d0a543438afed 100644 (file)
@@ -276,7 +276,7 @@ sim_write (SIM_DESC sd, SIM_ADDR mem, const void *buffer, int length)
 
 /* Read the LENGTH bytes at BUF as an little-endian value.  */
 static DI
-get_le (unsigned char *buf, int length)
+get_le (const unsigned char *buf, int length)
 {
   DI acc = 0;
   while (--length >= 0)
@@ -287,7 +287,7 @@ get_le (unsigned char *buf, int length)
 
 /* Read the LENGTH bytes at BUF as a big-endian value.  */
 static DI
-get_be (unsigned char *buf, int length)
+get_be (const unsigned char *buf, int length)
 {
   DI acc = 0;
   while (length-- > 0)