2008-07-24 Pavel Roskin <proski@gnu.org>

* include/grub/types.h: Use __builtin_bswap32() and
	__builtin_bswap64() with gcc 4.3 and newer.
This commit is contained in:
proski 2008-07-24 23:36:13 +00:00
parent 6af9849fbd
commit 01453bfcd7
2 changed files with 17 additions and 0 deletions

View file

@ -1,3 +1,8 @@
2008-07-24 Pavel Roskin <proski@gnu.org>
* include/grub/types.h: Use __builtin_bswap32() and
__builtin_bswap64() with gcc 4.3 and newer.
2008-07-24 Christian Franke <franke@computer.org>
* util/i386/pc/grub-install.in: If `--debug' is specified,

View file

@ -111,6 +111,17 @@ typedef grub_uint64_t grub_disk_addr_t;
(grub_uint16_t) ((_x << 8) | (_x >> 8)); \
})
#if defined(__GNUC__) && (__GNUC__ > 3) && (__GNUC__ > 4 || __GNUC_MINOR__ >= 3)
static inline grub_uint32_t grub_swap_bytes32(grub_uint32_t x)
{
return __builtin_bswap32(x);
}
static inline grub_uint64_t grub_swap_bytes64(grub_uint64_t x)
{
return __builtin_bswap64(x);
}
#else /* not gcc 4.3 or newer */
#define grub_swap_bytes32(x) \
({ \
grub_uint32_t _x = (x); \
@ -132,6 +143,7 @@ typedef grub_uint64_t grub_disk_addr_t;
| ((_x & (grub_uint64_t) 0xFF000000000000ULL) >> 40) \
| (_x >> 56)); \
})
#endif /* not gcc 4.3 or newer */
#ifdef GRUB_CPU_WORDS_BIGENDIAN
# define grub_cpu_to_le16(x) grub_swap_bytes16(x)