From 01453bfcd7aa74c4b16a271734f40a4980a99678 Mon Sep 17 00:00:00 2001 From: proski Date: Thu, 24 Jul 2008 23:36:13 +0000 Subject: [PATCH] 2008-07-24 Pavel Roskin * include/grub/types.h: Use __builtin_bswap32() and __builtin_bswap64() with gcc 4.3 and newer. --- ChangeLog | 5 +++++ include/grub/types.h | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/ChangeLog b/ChangeLog index 33600bb36..cfcdb0759 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-07-24 Pavel Roskin + + * include/grub/types.h: Use __builtin_bswap32() and + __builtin_bswap64() with gcc 4.3 and newer. + 2008-07-24 Christian Franke * util/i386/pc/grub-install.in: If `--debug' is specified, diff --git a/include/grub/types.h b/include/grub/types.h index c51652ff0..d2044292d 100644 --- a/include/grub/types.h +++ b/include/grub/types.h @@ -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)