[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH 1 of 4 v2] blktap: remove local definitions and include byteswap.h



On Tue, 2011-12-20 at 02:19 +0000, Roger Pau Monne wrote:
> # HG changeset patch
> # User Roger Pau Monne <roger.pau@xxxxxxxxxxxxx>
> # Date 1324344433 -3600
> # Node ID 29f5b0afe971335eea4f547efed00b132ade5c64
> # Parent  d23344a87ad7d3d3acae83171586358b081e3f4e
> blktap: remove local definitions and include byteswap.h
> 
> Use the same approach as tools/blktap2/include/libvhd.h, remove local
> definitions of bswap* and include byteswap.h.

The end result of this patch isn't quite the same as libvhd.h. There it
does:

        #if defined(__linux__)
        #include <endian.h>
        #include <byteswap.h>
        #elif defined(__NetBSD__)
        #include <sys/endian.h>
        #include <sys/bswap.h>
        #endif

while here we end up with:

        #if defined(__NetBSD__)
        #include <sys/endian.h>
        #include <sys/types.h>
        #elif defined(__OpenBSD__)
        #include <machine/endian.h>
        #define bswap_16(x) swap16(x)
        #define bswap_32(x) swap32(x)
        #define bswap_64(x) swap64(x)
        #else
        #include <byteswap.h>
        #endif
        
I think that last #else should be an explicit #elif defined(__linux__)
for consistency and so that future porters don't wander around looking
for byteswap.h before realising they need a new #elif clause.

>  Also remove the
> HAVE_BYTESWAP_H ifdef, since it was not defined in this context (it's
> defined by QEMU).
> 
> Signed-off-by: Roger Pau Monne <roger.pau@xxxxxxxxxxxxx>
> 
> diff -r d23344a87ad7 -r 29f5b0afe971 tools/blktap/drivers/bswap.h
> --- a/tools/blktap/drivers/bswap.h    Tue Dec 20 02:21:25 2011 +0100
> +++ b/tools/blktap/drivers/bswap.h    Tue Dec 20 02:27:13 2011 +0100
> @@ -15,43 +15,7 @@
>  #define bswap_64(x) swap64(x)
>  #else
>  
> -#ifdef HAVE_BYTESWAP_H
>  #include <byteswap.h>
> -#else
> -
> -#define bswap_16(x) \
> -({ \
> -     uint16_t __x = (x); \
> -     ((uint16_t)( \
> -             (((uint16_t)(__x) & (uint16_t)0x00ffU) << 8) | \
> -             (((uint16_t)(__x) & (uint16_t)0xff00U) >> 8) )); \
> -})
> -
> -#define bswap_32(x) \
> -({ \
> -     uint32_t __x = (x); \
> -     ((uint32_t)( \
> -             (((uint32_t)(__x) & (uint32_t)0x000000ffUL) << 24) | \
> -             (((uint32_t)(__x) & (uint32_t)0x0000ff00UL) <<  8) | \
> -             (((uint32_t)(__x) & (uint32_t)0x00ff0000UL) >>  8) | \
> -             (((uint32_t)(__x) & (uint32_t)0xff000000UL) >> 24) )); \
> -})
> -
> -#define bswap_64(x) \
> -({ \
> -     uint64_t __x = (x); \
> -     ((uint64_t)( \
> -             (uint64_t)(((uint64_t)(__x) & (uint64_t)0x00000000000000ffULL) 
> << 56) | \
> -             (uint64_t)(((uint64_t)(__x) & (uint64_t)0x000000000000ff00ULL) 
> << 40) | \
> -             (uint64_t)(((uint64_t)(__x) & (uint64_t)0x0000000000ff0000ULL) 
> << 24) | \
> -             (uint64_t)(((uint64_t)(__x) & (uint64_t)0x00000000ff000000ULL) 
> <<  8) | \
> -             (uint64_t)(((uint64_t)(__x) & (uint64_t)0x000000ff00000000ULL) 
> >>  8) | \
> -             (uint64_t)(((uint64_t)(__x) & (uint64_t)0x0000ff0000000000ULL) 
> >> 24) | \
> -             (uint64_t)(((uint64_t)(__x) & (uint64_t)0x00ff000000000000ULL) 
> >> 40) | \
> -             (uint64_t)(((uint64_t)(__x) & (uint64_t)0xff00000000000000ULL) 
> >> 56) )); \
> -})
> -
> -#endif /* !HAVE_BYTESWAP_H */
>  
>  static inline uint16_t bswap16(uint16_t x)
>  {
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@xxxxxxxxxxxxxxxxxxx
> http://lists.xensource.com/xen-devel



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.