]> err.no Git - util-linux/commitdiff
fdisk: use swab macros from bitops.h
authorKarel Zak <kzak@redhat.com>
Mon, 17 Dec 2007 12:26:38 +0000 (13:26 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 17 Dec 2007 12:42:58 +0000 (13:42 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
fdisk/gpt.c

index be7c0175a69ca6f2cedc0f636de69830f850a75d..2c96b02624bee1b24cd43f094bdcfe1565859c1e 100644 (file)
 
 #include "gpt.h"
 #include "blkdev.h"
-
-#define _GET_BYTE(x, n)                ( ((x) >> (8 * (n))) & 0xff )
-
-#define _PED_SWAP64(x)         ( (_GET_BYTE(x, 0) << 56)       \
-                               + (_GET_BYTE(x, 1) << 48)       \
-                               + (_GET_BYTE(x, 2) << 40)       \
-                               + (_GET_BYTE(x, 3) << 32)       \
-                               + (_GET_BYTE(x, 4) << 24)       \
-                               + (_GET_BYTE(x, 5) << 16)       \
-                               + (_GET_BYTE(x, 6) << 8)        \
-                               + (_GET_BYTE(x, 7) << 0) )
-
-#define PED_SWAP64(x)           ((uint64_t) _PED_SWAP64( (uint64_t) (x) ))
-
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-# define CPU_TO_LE64(x)        (x)
-#else
-# define CPU_TO_LE64(x)        PED_SWAP64(x)
-#endif
+#include "bitops.h"
 
 #define GPT_HEADER_SIGNATURE 0x5452415020494645LL
 #define GPT_PRIMARY_PARTITION_TABLE_LBA 1
@@ -211,7 +193,7 @@ gpt_check_signature(int fd, uint64_t lba)
 
        if ((gpt = alloc_read_gpt_header(fd, lba)))
        {
-               if (gpt->Signature == CPU_TO_LE64(GPT_HEADER_SIGNATURE))
+               if (gpt->Signature == cpu_to_le64(GPT_HEADER_SIGNATURE))
                        res = 1;
                free(gpt);
        }