From: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
To: Richard Henderson <rth@twiddle.net>, qemu-devel@nongnu.org
Cc: qemu-ppc@nongnu.org
Subject: Re: [Qemu-devel] [Qemu-ppc] [PATCH v4] target-ppc: gdbstub allow byte swapping for reading/writing registers
Date: Fri, 28 Feb 2014 13:28:03 -0600 [thread overview]
Message-ID: <5310E343.1050005@linux.vnet.ibm.com> (raw)
In-Reply-To: <5310C96E.8040002@twiddle.net>
On 02/28/2014 11:37 AM, Richard Henderson wrote:
> On 02/26/2014 02:51 PM, Thomas Falcon wrote:
>> +void ppc_cpu_gdb_swap_register(uint8_t *mem_buf, int n)
>> +{
>> + int len = ppc_cpu_gdb_register_len(n);
>> + int i = 0;
>> + uint8_t tmp;
>> + for (i = 0; i < len/2; i++) {
>> + tmp = *(mem_buf + i);
>> + *(mem_buf+i) = *(mem_buf + len - 1 - i);
>> + *(mem_buf + len - 1 - i) = tmp;
>> + }
>> +}
> Ew.
>
> The number of register sizes you need to handle is extremely limited. One can
> easily use bswap32 and bswap64 for this.
>
>
> r~
>
Thanks for your feedback. Did not realize there were built-in bswap
functions for pointers. How about this instead?
int len = ppc_cpu_gdb_register_len(n);
if (len==4) {
bswap32s((uint32_t *)mem_buf);
} else {
bswap64s((uint64_t *)mem_buf);
}
next prev parent reply other threads:[~2014-02-28 19:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-26 22:51 [Qemu-devel] [PATCH v4] target-ppc: gdbstub allow byte swapping for reading/writing registers Thomas Falcon
2014-02-28 17:37 ` Richard Henderson
2014-02-28 19:28 ` Thomas Falcon [this message]
2014-02-28 20:08 ` [Qemu-devel] [Qemu-ppc] " Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5310E343.1050005@linux.vnet.ibm.com \
--to=tlfalcon@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=rth@twiddle.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).