byteswap ops had extra mask ops - removed

This commit is contained in:
Denis Vlasenko 2006-11-27 16:48:17 +00:00
parent 3ece72dc3f
commit 10d0d4eec7
4 changed files with 17 additions and 21 deletions

View File

@ -327,8 +327,8 @@ _INLINE_ __u16 blkid_swab16(__u16 val)
_INLINE_ __u64 blkid_swab64(__u64 val) _INLINE_ __u64 blkid_swab64(__u64 val)
{ {
return (blkid_swab32(val >> 32) | return blkid_swab32(val >> 32) |
(((__u64) blkid_swab32(val & 0xFFFFFFFFUL)) << 32)); ( ((__u64)blkid_swab32((__u32)val)) << 32 );
} }
#endif #endif
@ -341,14 +341,14 @@ _INLINE_ __u16 blkid_swab16(__u16 val)
_INLINE_ __u32 blkid_swab32(__u32 val) _INLINE_ __u32 blkid_swab32(__u32 val)
{ {
return ((val>>24) | ((val>>8)&0xFF00) | return (val>>24) | ((val>>8) & 0xFF00) |
((val<<8)&0xFF0000) | (val<<24)); ((val<<8) & 0xFF0000) | (val<<24);
} }
_INLINE_ __u64 blkid_swab64(__u64 val) _INLINE_ __u64 blkid_swab64(__u64 val)
{ {
return (blkid_swab32(val >> 32) | return blkid_swab32(val >> 32) |
(((__u64) blkid_swab32(val & 0xFFFFFFFFUL)) << 32)); ( ((__u64)blkid_swab32((__u32)val)) << 32 );
} }
#endif #endif

View File

@ -379,19 +379,19 @@ STATIC_OSF void xbsd_print_disklabel(int);
#define SGI_XVM 0x0d #define SGI_XVM 0x0d
#define SGI_ENTIRE_DISK SGI_VOLUME #define SGI_ENTIRE_DISK SGI_VOLUME
#if defined(CONFIG_FEATURE_SGI_LABEL) || defined(CONFIG_FEATURE_SUN_LABEL) #if defined(CONFIG_FEATURE_SGI_LABEL) || defined(CONFIG_FEATURE_SUN_LABEL)
static unsigned short static uint16_t
__swap16(unsigned short x) __swap16(uint16_t x)
{ {
return (((uint16_t)(x) & 0xFF) << 8) | (((uint16_t)(x) & 0xFF00) >> 8); return (x << 8) | (x >> 8);
} }
static uint32_t static uint32_t
__swap32(uint32_t x) __swap32(uint32_t x)
{ {
return (((x & 0xFF) << 24) | return (x << 24) |
((x & 0xFF00) << 8) | ((x & 0xFF00) << 8) |
((x & 0xFF0000) >> 8) | ((x & 0xFF0000) >> 8) |
((x & 0xFF000000) >> 24)); (x >> 24);
} }
#endif #endif

View File

@ -84,10 +84,8 @@ typedef struct {
#define SGI_INFO_MAGIC 0x00072959 #define SGI_INFO_MAGIC 0x00072959
#define SGI_INFO_MAGIC_SWAPPED 0x59290700 #define SGI_INFO_MAGIC_SWAPPED 0x59290700
#define SGI_SSWAP16(x) (sgi_other_endian ? __swap16(x) \ #define SGI_SSWAP16(x) (sgi_other_endian ? __swap16(x) : (uint16_t)(x))
: (uint16_t)(x)) #define SGI_SSWAP32(x) (sgi_other_endian ? __swap32(x) : (uint32_t)(x))
#define SGI_SSWAP32(x) (sgi_other_endian ? __swap32(x) \
: (uint32_t)(x))
#define sgilabel ((sgi_partition *)MBRbuffer) #define sgilabel ((sgi_partition *)MBRbuffer)
#define sgiparam (sgilabel->devparam) #define sgiparam (sgilabel->devparam)

View File

@ -2,10 +2,8 @@
#define SUN_LABEL_MAGIC 0xDABE #define SUN_LABEL_MAGIC 0xDABE
#define SUN_LABEL_MAGIC_SWAPPED 0xBEDA #define SUN_LABEL_MAGIC_SWAPPED 0xBEDA
#define SUN_SSWAP16(x) (sun_other_endian ? __swap16(x) \ #define SUN_SSWAP16(x) (sun_other_endian ? __swap16(x) : (uint16_t)(x))
: (uint16_t)(x)) #define SUN_SSWAP32(x) (sun_other_endian ? __swap32(x) : (uint32_t)(x))
#define SUN_SSWAP32(x) (sun_other_endian ? __swap32(x) \
: (uint32_t)(x))
/* Copied from linux/major.h */ /* Copied from linux/major.h */
#define FLOPPY_MAJOR 2 #define FLOPPY_MAJOR 2