From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51420) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSQKb-0007TI-1B for qemu-devel@nongnu.org; Mon, 11 Jun 2018 13:10:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fSQKa-0000Tz-3s for qemu-devel@nongnu.org; Mon, 11 Jun 2018 13:10:12 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:42678) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fSQKZ-0000TG-SN for qemu-devel@nongnu.org; Mon, 11 Jun 2018 13:10:12 -0400 From: Peter Maydell Date: Mon, 11 Jun 2018 18:10:04 +0100 Message-Id: <20180611171007.4165-1-peter.maydell@linaro.org> Subject: [Qemu-devel] [PATCH 0/3] Add ldn_*_p() and stn_*_p() and use them in exec.c List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: patches@linaro.org, Richard Henderson , Paolo Bonzini There's a common pattern in QEMU where a function needs to perform a data load or store of an N byte integer in a particular endianness. At the moment this is handled by doing a switch() on the size and calling the appropriate ld*_p or st*_p function for each size. This patchset provides a new family of functions ldn_*_p() and stn_*_p() which take the size as an argument and do the switch() themselves, and uses them in 5 callsites in exec.c. If people like the idea, naming convention, etc, we can look for and convert other callsites, extend this to eg an address_space_ldn() and address_space_stn() (sample use cases in watch_mem_read(), watch_mem_write(), dino_chip_write_with_attrs(), tx_ppc_read(), tx_ppc_write()...) Patch 2 here fixes an apparently unintentional sign-extension in subpage_read(), so that patch 3 is a no-behaviour-change patch. thanks -- PMM Peter Maydell (3): bswap: Add new stn_*_p() and ldn_*_p() memory access functions exec.c: Don't accidentally sign-extend 4-byte loads in subpage_read() exec.c: Use stn_p() and ldn_p() instead of explicit switches include/exec/cpu-all.h | 4 ++ include/qemu/bswap.h | 52 +++++++++++++++++ exec.c | 112 +++--------------------------------- docs/devel/loads-stores.rst | 15 +++++ 4 files changed, 79 insertions(+), 104 deletions(-) -- 2.17.1