mirror of
https://github.com/utmapp/qemu.git
synced 2026-12-05 13:52:02 -10:00
qemu/bswap: Add const_le64()
Gcc requires constant versions of cpu_to_le* calls. Add a 64 bit version. Reviewed-by: Peter Maydell <[email protected]> Reviewed-by: Philippe Mathieu-Daudé <[email protected]> Reviewed-by: Gregory Price <[email protected]> Tested-by: Gregory Price <[email protected]> Signed-off-by: Ira Weiny <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]> Message-Id: <[email protected]> Reviewed-by: Fan Ni <[email protected]> Reviewed-by: Michael S. Tsirkin <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]>
This commit is contained in:
1 parent
21063bcee8
commit
845d80a8c7
1 file changed
+11
-1
+11
-1
@@ -125,11 +125,20 @@ CPU_CONVERT(le, 32, uint32_t)
|
||||
CPU_CONVERT(le, 64, uint64_t)
|
||||
|
||||
/*
|
||||
* Same as cpu_to_le{16,32}, except that gcc will figure the result is
|
||||
* Same as cpu_to_le{16,32,64}, except that gcc will figure the result is
|
||||
* a compile-time constant if you pass in a constant. So this can be
|
||||
* used to initialize static variables.
|
||||
*/
|
||||
#if HOST_BIG_ENDIAN
|
||||
# define const_le64(_x) \
|
||||
((((_x) & 0x00000000000000ffU) << 56) | \
|
||||
(((_x) & 0x000000000000ff00U) << 40) | \
|
||||
(((_x) & 0x0000000000ff0000U) << 24) | \
|
||||
(((_x) & 0x00000000ff000000U) << 8) | \
|
||||
(((_x) & 0x000000ff00000000U) >> 8) | \
|
||||
(((_x) & 0x0000ff0000000000U) >> 24) | \
|
||||
(((_x) & 0x00ff000000000000U) >> 40) | \
|
||||
(((_x) & 0xff00000000000000U) >> 56))
|
||||
# define const_le32(_x) \
|
||||
((((_x) & 0x000000ffU) << 24) | \
|
||||
(((_x) & 0x0000ff00U) << 8) | \
|
||||
@@ -139,6 +148,7 @@ CPU_CONVERT(le, 64, uint64_t)
|
||||
((((_x) & 0x00ff) << 8) | \
|
||||
(((_x) & 0xff00) >> 8))
|
||||
#else
|
||||
# define const_le64(_x) (_x)
|
||||
# define const_le32(_x) (_x)
|
||||
# define const_le16(_x) (_x)
|
||||
#endif
|
||||
|
||||
Reference in new issue
Block a user