Skip to content

Commit

Permalink
x86: modernize swab64()
Browse files Browse the repository at this point in the history
For quite a while we didn't need to be concerned of 32-bit code
generation anymore: Simply use the 64-bit form of BSWAP here.

Signed-off-by: Jan Beulich <[email protected]>
Reviewed-by: Frediano Ziglio <[email protected]>
  • Loading branch information
jbeulich committed Oct 31, 2024
1 parent 60db1b1 commit 0d87ca0
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions xen/arch/x86/include/asm/byteorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,10 @@ static inline attr_const __u32 ___arch__swab32(__u32 x)
return x;
}

static inline attr_const __u64 ___arch__swab64(__u64 val)
static inline attr_const uint64_t ___arch__swab64(uint64_t x)
{
union {
struct { __u32 a,b; } s;
__u64 u;
} v;
v.u = val;
asm("bswapl %0 ; bswapl %1 ; xchgl %0,%1"
: "=r" (v.s.a), "=r" (v.s.b)
: "0" (v.s.a), "1" (v.s.b));
return v.u;
asm ( "bswap %0" : "+r" (x) );
return x;
}

/* Do not define swab16. Gcc is smart enough to recognize "C" version and
Expand Down

0 comments on commit 0d87ca0

Please sign in to comment.