From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1521) id 52BF93851C1F; Mon, 31 Oct 2022 16:54:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 52BF93851C1F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1667235288; bh=ge8xSPiiDvja3iIYEYa3jykbdthK/2GcTUyBeDlbJyA=; h=From:To:Subject:Date:From; b=enf0ZpEjb/UAIxMMpFj+Omh9ubuqwiOZU0MHTK+Nl8Kkv4o4OKZoieodSSp9ovu+J Dubajoc55x9DY/wHWdDTegrNeh2Vf8SCYLGF60+OpgU4yQPw/bOVh69VTBD6+EKMjY EBviXwi/6U7fJbjTe0zewckqY8V9s0lv6wPJ8T9c= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Michael Frysinger To: gdb-cvs@sourceware.org Subject: [binutils-gdb] sim: constify various integer readers X-Act-Checkin: binutils-gdb X-Git-Author: Mike Frysinger X-Git-Refname: refs/heads/master X-Git-Oldrev: ead2618501e8ba696bf29de635a9a5f6a1ba1b0e X-Git-Newrev: ed60d3edd51f6c33fb0f3f09400094a1b1c2ceb2 Message-Id: <20221031165448.52BF93851C1F@sourceware.org> Date: Mon, 31 Oct 2022 16:54:48 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Ded60d3edd51f= 6c33fb0f3f09400094a1b1c2ceb2 commit ed60d3edd51f6c33fb0f3f09400094a1b1c2ceb2 Author: Mike Frysinger Date: Wed Oct 26 22:42:10 2022 +0545 sim: constify various integer readers =20 These functions only read from memory, so mark the pointer as const. Diff: --- sim/aarch64/interp.c | 2 +- sim/arm/iwmmxt.c | 2 +- sim/arm/iwmmxt.h | 2 +- sim/arm/wrapper.c | 2 +- sim/bfin/machs.c | 2 +- sim/cr16/interp.c | 2 +- sim/d10v/d10v_sim.h | 6 +++--- sim/d10v/endian.c | 6 +++--- sim/ft32/interp.c | 2 +- sim/m32c/gdb-if.c | 2 +- sim/mcore/interp.c | 2 +- sim/microblaze/interp.c | 2 +- sim/moxie/interp.c | 2 +- sim/pru/interp.c | 8 ++++---- sim/rl78/gdb-if.c | 2 +- sim/rx/gdb-if.c | 4 ++-- 16 files changed, 24 insertions(+), 24 deletions(-) diff --git a/sim/aarch64/interp.c b/sim/aarch64/interp.c index a04f1dcc389..ac95c7dfaac 100644 --- a/sim/aarch64/interp.c +++ b/sim/aarch64/interp.c @@ -171,7 +171,7 @@ sim_create_inferior (SIM_DESC sd, struct bfd *abfd, /* Read the LENGTH bytes at BUF as a little-endian value. */ =20 static bfd_vma -get_le (unsigned char *buf, unsigned int length) +get_le (const unsigned char *buf, unsigned int length) { bfd_vma acc =3D 0; =20 diff --git a/sim/arm/iwmmxt.c b/sim/arm/iwmmxt.c index 5f91012bc2a..ad065317b41 100644 --- a/sim/arm/iwmmxt.c +++ b/sim/arm/iwmmxt.c @@ -3723,7 +3723,7 @@ Fetch_Iwmmxt_Register (unsigned int regnum, unsigned = char * memory) } =20 int -Store_Iwmmxt_Register (unsigned int regnum, unsigned char * memory) +Store_Iwmmxt_Register (unsigned int regnum, const unsigned char * memory) { if (regnum >=3D 16) { diff --git a/sim/arm/iwmmxt.h b/sim/arm/iwmmxt.h index e49a8d78d09..2f677affa31 100644 --- a/sim/arm/iwmmxt.h +++ b/sim/arm/iwmmxt.h @@ -24,4 +24,4 @@ extern unsigned IwmmxtCDP (ARMul_State *, unsigned, ARMwo= rd); extern int ARMul_HandleIwmmxt (ARMul_State *, ARMword); =20 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 *); diff --git a/sim/arm/wrapper.c b/sim/arm/wrapper.c index 38a1f27a3b0..72a65242b9d 100644 --- a/sim/arm/wrapper.c +++ b/sim/arm/wrapper.c @@ -397,7 +397,7 @@ sim_create_inferior (SIM_DESC sd ATTRIBUTE_UNUSED, } =20 static int -frommem (struct ARMul_State *state, unsigned char *memory) +frommem (struct ARMul_State *state, const unsigned char *memory) { if (state->bigendSig =3D=3D HIGH) return (memory[0] << 24) | (memory[1] << 16) diff --git a/sim/bfin/machs.c b/sim/bfin/machs.c index 2d3a019b9ba..f322b183b2e 100644 --- a/sim/bfin/machs.c +++ b/sim/bfin/machs.c @@ -1758,7 +1758,7 @@ bfin_model_init (SIM_CPU *cpu) } =20 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; diff --git a/sim/cr16/interp.c b/sim/cr16/interp.c index b375dadff5d..cbdcdc6e793 100644 --- a/sim/cr16/interp.c +++ b/sim/cr16/interp.c @@ -690,7 +690,7 @@ sim_create_inferior (SIM_DESC sd, struct bfd *abfd, } =20 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; diff --git a/sim/d10v/d10v_sim.h b/sim/d10v/d10v_sim.h index 7b354fd4841..e78ea2fe9df 100644 --- a/sim/d10v/d10v_sim.h +++ b/sim/d10v/d10v_sim.h @@ -445,9 +445,9 @@ extern uint8_t *imem_addr (SIM_DESC, SIM_CPU *, uint32_= t); #undef ENDIAN_INLINE =20 #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); diff --git a/sim/d10v/endian.c b/sim/d10v/endian.c index f3e1e46214f..44e80e6d653 100644 --- a/sim/d10v/endian.c +++ b/sim/d10v/endian.c @@ -11,19 +11,19 @@ #endif =20 ENDIAN_INLINE uint16_t -get_word (uint8_t *x) +get_word (const uint8_t *x) { return ((uint16_t)x[0]<<8) + x[1]; } =20 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]); } =20 ENDIAN_INLINE int64_t -get_longlong (uint8_t *x) +get_longlong (const uint8_t *x) { uint32_t top =3D get_longword (x); uint32_t bottom =3D get_longword (x+4); diff --git a/sim/ft32/interp.c b/sim/ft32/interp.c index 8e828e68eff..70212f45cca 100644 --- a/sim/ft32/interp.c +++ b/sim/ft32/interp.c @@ -56,7 +56,7 @@ #define RAM_BIAS 0x800000 /* Bias added to RAM addresses. */ =20 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; diff --git a/sim/m32c/gdb-if.c b/sim/m32c/gdb-if.c index 8bb8e9bb563..802eae97851 100644 --- a/sim/m32c/gdb-if.c +++ b/sim/m32c/gdb-if.c @@ -184,7 +184,7 @@ sim_write (SIM_DESC sd, SIM_ADDR mem, const void *buf, = int length) =20 /* 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 =3D 0; while (--length >=3D 0) diff --git a/sim/mcore/interp.c b/sim/mcore/interp.c index dbac1567ffb..082bc4e0767 100644 --- a/sim/mcore/interp.c +++ b/sim/mcore/interp.c @@ -42,7 +42,7 @@ along with this program. If not, see . */ =20 =20 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; diff --git a/sim/microblaze/interp.c b/sim/microblaze/interp.c index 2ec223868a7..6aa02632093 100644 --- a/sim/microblaze/interp.c +++ b/sim/microblaze/interp.c @@ -38,7 +38,7 @@ #define target_big_endian (CURRENT_TARGET_BYTE_ORDER =3D=3D BFD_ENDIAN_BIG) =20 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; diff --git a/sim/moxie/interp.c b/sim/moxie/interp.c index a08dc694553..d5d14bfe49d 100644 --- a/sim/moxie/interp.c +++ b/sim/moxie/interp.c @@ -57,7 +57,7 @@ typedef unsigned int uword; + (sim_core_read_aligned_1 (scpu, cia, read_map, addr+1))) << 16) >> = 16) =20 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; diff --git a/sim/pru/interp.c b/sim/pru/interp.c index a62b5a2c8fe..fabedc99f6e 100644 --- a/sim/pru/interp.c +++ b/sim/pru/interp.c @@ -45,12 +45,12 @@ enum { =20 /* 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 =3D addr; - uint8_t *endaddr =3D startaddr + len; + const uint8_t *p; + const uint8_t *startaddr =3D addr; + const uint8_t *endaddr =3D startaddr + len; =20 /* Start at the most significant end of the integer, and work towards the least significant. */ diff --git a/sim/rl78/gdb-if.c b/sim/rl78/gdb-if.c index 8129c0924dc..98bb0a4044b 100644 --- a/sim/rl78/gdb-if.c +++ b/sim/rl78/gdb-if.c @@ -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. */ =20 static SI -get_le (unsigned char *buf, int length) +get_le (const unsigned char *buf, int length) { SI acc =3D 0; =20 diff --git a/sim/rx/gdb-if.c b/sim/rx/gdb-if.c index c116bdcf608..7af37b94fcf 100644 --- a/sim/rx/gdb-if.c +++ b/sim/rx/gdb-if.c @@ -276,7 +276,7 @@ sim_write (SIM_DESC sd, SIM_ADDR mem, const void *buffe= r, int length) =20 /* 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 =3D 0; while (--length >=3D 0) @@ -287,7 +287,7 @@ get_le (unsigned char *buf, int length) =20 /* 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 =3D 0; while (length-- > 0)