From a7844ca2221d188b449e6c78d7d8a3e2566e1676 Mon Sep 17 00:00:00 2001 From: dennis Date: Wed, 29 Oct 2014 01:33:39 +0000 Subject: [PATCH] Correct 32 and 64 bit byte swap inlines --- sys/arch/aarch64/include/byte_swap.h | 10 +++++----- sys/arch/or1k/include/byte_swap.h | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/sys/arch/aarch64/include/byte_swap.h b/sys/arch/aarch64/include/byte_swap.h index bef9ea9803e6..5deb524b87c5 100644 --- a/sys/arch/aarch64/include/byte_swap.h +++ b/sys/arch/aarch64/include/byte_swap.h @@ -1,4 +1,4 @@ -/* $NetBSD: byte_swap.h,v 1.2 2014/08/11 04:03:59 matt Exp $ */ +/* $NetBSD: byte_swap.h,v 1.3 2014/10/29 01:33:39 dennis Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -59,9 +59,9 @@ __byte_swap_u64_variable(uint64_t v) } v = ((v & 0x000000ff) << (56 - 0)) | ((v >> (56 - 0)) & 0x000000ff) - | ((v & 0x0000ff00) << (48 - 8)) | ((v << (48 - 8)) & 0x0000ff00) - | ((v & 0x00ff0000) << (40 - 16)) | ((v << (40 - 16)) & 0x00ff0000) - | ((v & 0xff000000) << (32 - 24)) | ((v << (32 - 24)) & 0xff000000); + | ((v & 0x0000ff00) << (48 - 8)) | ((v >> (48 - 8)) & 0x0000ff00) + | ((v & 0x00ff0000) << (40 - 16)) | ((v >> (40 - 16)) & 0x00ff0000) + | ((v & 0xff000000) << (32 - 24)) | ((v >> (32 - 24)) & 0xff000000); return v; } @@ -76,7 +76,7 @@ __byte_swap_u32_variable(uint32_t v) } v = ((v & 0x00ff) << (24 - 0)) | ((v >> (24 - 0)) & 0x00ff) - | ((v & 0xff00) << (16 - 8)) | ((v << (16 - 8)) & 0xff00); + | ((v & 0xff00) << (16 - 8)) | ((v >> (16 - 8)) & 0xff00); return v; } diff --git a/sys/arch/or1k/include/byte_swap.h b/sys/arch/or1k/include/byte_swap.h index 78922755f6b1..a79ab0830857 100644 --- a/sys/arch/or1k/include/byte_swap.h +++ b/sys/arch/or1k/include/byte_swap.h @@ -1,4 +1,4 @@ -/* $NetBSD: byte_swap.h,v 1.1 2014/09/03 19:34:26 matt Exp $ */ +/* $NetBSD: byte_swap.h,v 1.2 2014/10/29 01:33:39 dennis Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -61,9 +61,9 @@ static __inline uint64_t __byte_swap_u64_variable(uint64_t v) { v = ((v & 0x000000ff) << (56 - 0)) | ((v >> (56 - 0)) & 0x000000ff) - | ((v & 0x0000ff00) << (48 - 8)) | ((v << (48 - 8)) & 0x0000ff00) - | ((v & 0x00ff0000) << (40 - 16)) | ((v << (40 - 16)) & 0x00ff0000) - | ((v & 0xff000000) << (32 - 24)) | ((v << (32 - 24)) & 0xff000000); + | ((v & 0x0000ff00) << (48 - 8)) | ((v >> (48 - 8)) & 0x0000ff00) + | ((v & 0x00ff0000) << (40 - 16)) | ((v >> (40 - 16)) & 0x00ff0000) + | ((v & 0xff000000) << (32 - 24)) | ((v >> (32 - 24)) & 0xff000000); return v; } @@ -73,7 +73,7 @@ static __inline uint32_t __byte_swap_u32_variable(uint32_t v) { v = ((v & 0x00ff) << (24 - 0)) | ((v >> (24 - 0)) & 0x00ff) - | ((v & 0xff00) << (16 - 8)) | ((v << (16 - 8)) & 0xff00); + | ((v & 0xff00) << (16 - 8)) | ((v >> (16 - 8)) & 0xff00); return v; }