]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
2008-07-24 Pavel Roskin <proski@gnu.org>
authorproski <proski@localhost>
Thu, 24 Jul 2008 23:36:13 +0000 (23:36 +0000)
committerproski <proski@localhost>
Thu, 24 Jul 2008 23:36:13 +0000 (23:36 +0000)
* include/grub/types.h: Use __builtin_bswap32() and
__builtin_bswap64() with gcc 4.3 and newer.

ChangeLog
include/grub/types.h

index 33600bb36542acf68c3489e1e66aef93de7ee8c0..cfcdb07595ed7c7abe24793f7f274384e6a67feb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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,
index c51652ff05e1734103ae9ad3d963fd662bf0e463..d2044292dad5dbf246c499f03eb9a4a46a64e9b2 100644 (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)