Patchwork [1/2] Add be16_to_cpupu function

login
register
mail settings
Submitter Fabien Chouteau
Date July 10, 2013, 5:10 p.m.
Message ID <1373476202-11277-2-git-send-email-chouteau@adacore.com>
Download mbox | patch
Permalink /patch/258164/
State New
Headers show

Comments

Fabien Chouteau - July 10, 2013, 5:10 p.m.
Signed-off-by: Fabien Chouteau <chouteau@adacore.com>
---
 include/qemu/bswap.h |    5 +++++
 1 file changed, 5 insertions(+)
Peter Maydell - July 10, 2013, 5:25 p.m.
On 10 July 2013 18:10, Fabien Chouteau <chouteau@adacore.com> wrote:
> --- a/include/qemu/bswap.h
> +++ b/include/qemu/bswap.h
> @@ -432,6 +432,11 @@ static inline uint32_t le32_to_cpupu(const uint32_t *p)
>      return ldl_le_p(p);
>  }
>
> +static inline uint16_t be16_to_cpupu(const uint16_t *p)
> +{
> +    return lduw_be_p(p);
> +}
> +

So these functions are preceded by the comment:
/* Legacy unaligned versions.  Note that we never had a complete set.  */

which suggests that we shouldn't be adding new ones.
I think the correct answer is to use lduw_be_p() directly.
(If so it's tempting to get rid of the legacy functions
completely since the change would be pretty mechanical.)

thanks
-- PMM
Fabien Chouteau - July 12, 2013, 9:57 a.m.
On 07/10/2013 07:25 PM, Peter Maydell wrote:
> On 10 July 2013 18:10, Fabien Chouteau <chouteau@adacore.com> wrote:
>> --- a/include/qemu/bswap.h
>> +++ b/include/qemu/bswap.h
>> @@ -432,6 +432,11 @@ static inline uint32_t le32_to_cpupu(const uint32_t *p)
>>      return ldl_le_p(p);
>>  }
>>
>> +static inline uint16_t be16_to_cpupu(const uint16_t *p)
>> +{
>> +    return lduw_be_p(p);
>> +}
>> +
> 
> So these functions are preceded by the comment:
> /* Legacy unaligned versions.  Note that we never had a complete set.  */
> 
> which suggests that we shouldn't be adding new ones.
> I think the correct answer is to use lduw_be_p() directly.
> (If so it's tempting to get rid of the legacy functions
> completely since the change would be pretty mechanical.)
> 

OK noted.

Thanks,

Patch

diff --git a/include/qemu/bswap.h b/include/qemu/bswap.h
index 14a5f65..628f41f 100644
--- a/include/qemu/bswap.h
+++ b/include/qemu/bswap.h
@@ -432,6 +432,11 @@  static inline uint32_t le32_to_cpupu(const uint32_t *p)
     return ldl_le_p(p);
 }
 
+static inline uint16_t be16_to_cpupu(const uint16_t *p)
+{
+    return lduw_be_p(p);
+}
+
 static inline uint32_t be32_to_cpupu(const uint32_t *p)
 {
     return ldl_be_p(p);