Whamcloud - gitweb
LU-4674 endianness: Fix __{LITTLE,BIG}_ENDIAN macro usage 41/9641/4
authorSwapnil Pimpale <spimpale@ddn.com>
Thu, 13 Mar 2014 11:11:07 +0000 (16:41 +0530)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 25 Mar 2014 23:53:03 +0000 (23:53 +0000)
Fixed the userspace code where __{LITTLE,BIG}_ENDIAN is tested
with #ifdef. This patch replaces those checks
with #if __BYTE_ORDER == __{LITTLE,BIG}_ENDIAN

Signed-off-by: Swapnil Pimpale <spimpale@ddn.com>
Change-Id: I92d4cf0c880d8032ea5023cb47ccfe7236dd03ab
Reviewed-on: http://review.whamcloud.com/9641
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Jian Yu <jian.yu@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
libcfs/include/libcfs/user-tcpip.h
libcfs/libcfs/posix/posix-crc32.c
lnet/klnds/mxlnd/mxlnd_cb.c
lustre/include/liblustre.h

index 4997d06..9812fb9 100644 (file)
@@ -42,6 +42,7 @@
 #ifndef __KERNEL__
 
 #include <sys/uio.h>
+#include <endian.h>
 
 /*
  * Functions to get network interfaces info
@@ -97,13 +98,13 @@ int libcfs_sock_create(cfs_socket_t **sockp, int *fatal,
         ((unsigned char *)&addr)[2], \
         ((unsigned char *)&addr)[3]
 
-#if defined(__LITTLE_ENDIAN) || defined(_LITTLE_ENDIAN)
+#if __BYTE_ORDER == __LITTLE_ENDIAN
 #define HIPQUAD(addr)                \
         ((unsigned char *)&addr)[3], \
         ((unsigned char *)&addr)[2], \
         ((unsigned char *)&addr)[1], \
         ((unsigned char *)&addr)[0]
-#elif defined(__BIG_ENDIAN) || defined(_BIG_ENDIAN)
+#elif __BYTE_ORDER == __BIG_ENDIAN
 #define HIPQUAD NIPQUAD
 #else
 #error "Undefined byteorder??"
index 972c5ff..4937c8c 100644 (file)
@@ -2,6 +2,7 @@
  *      This file contains part of linux kernel implementation of crc32
  *      kernel version 2.6.32
  */
+#include <endian.h>
 #include <libcfs/libcfs.h>
 #define CRCPOLY_LE      0xedb88320
 #define CRC_LE_BITS     8
@@ -34,7 +35,7 @@ unsigned int crc32_le(unsigned int crc, unsigned char const *p, size_t len)
        const unsigned int      *b = (unsigned int *)p;
        const unsigned int      *tab = crc32table_le;
 
-# ifdef __LITTLE_ENDIAN
+# if __BYTE_ORDER == __LITTLE_ENDIAN
 #  define DO_CRC(x) crc = tab[(crc ^ (x)) & 255] ^ (crc>>8)
 # else
 #  define DO_CRC(x) crc = tab[((crc >> 24) ^ (x)) & 255] ^ (crc<<8)
index f2a0568..104820c 100644 (file)
@@ -855,7 +855,7 @@ mxlnd_ip2nic_id(u32 ip, u64 *nic_id, int tries)
 
         if (tmp_id == 0ULL)
                 ret = -EHOSTUNREACH;
-#ifdef __LITTLE_ENDIAN
+#if __BYTE_ORDER == __LITTLE_ENDIAN
         *nic_id = ___arch__swab64(tmp_id);
 #else
         *nic_id = tmp_id;
index e0ba5be..4929dd9 100644 (file)
@@ -46,6 +46,7 @@
  * @{
  */
 #include <fcntl.h>
+#include <endian.h>
 #include <sys/queue.h>
 
 #ifdef __KERNEL__
@@ -89,7 +90,7 @@ void *inter_module_get(char *arg);
 
 static __inline__ int ext2_set_bit(int nr, void *addr)
 {
-#ifdef __BIG_ENDIAN
+#if __BYTE_ORDER == __BIG_ENDIAN
        return set_bit((nr ^ ((BITS_PER_LONG-1) & ~0x7)), addr);
 #else
        return set_bit(nr, addr);
@@ -98,7 +99,7 @@ static __inline__ int ext2_set_bit(int nr, void *addr)
 
 static inline int ext2_clear_bit(int nr, void *addr)
 {
-#ifdef __BIG_ENDIAN
+#if __BYTE_ORDER == __BIG_ENDIAN
        return clear_bit((nr ^ ((BITS_PER_LONG-1) & ~0x7)), addr);
 #else
        return clear_bit(nr, addr);
@@ -107,7 +108,7 @@ static inline int ext2_clear_bit(int nr, void *addr)
 
 static __inline__ int ext2_test_bit(int nr, void *addr)
 {
-#ifdef __BIG_ENDIAN
+#if __BYTE_ORDER == __BIG_ENDIAN
         __const__ unsigned char *tmp = (__const__ unsigned char *) addr;
         return (tmp[nr >> 3] >> (nr & 7)) & 1;
 #else