ia64/xen-unstable

changeset 17802:07ba9aeee347

minios: use inlines instead of macros for bswap*

Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Jun 09 09:46:16 2008 +0100 (2008-06-09)
parents 268a9f8286f3
children caa2b155a42d
files extras/mini-os/include/byteswap.h
line diff
     1.1 --- a/extras/mini-os/include/byteswap.h	Mon Jun 09 09:45:38 2008 +0100
     1.2 +++ b/extras/mini-os/include/byteswap.h	Mon Jun 09 09:46:16 2008 +0100
     1.3 @@ -2,21 +2,32 @@
     1.4  #define _BYTESWAP_H_
     1.5  
     1.6  /* Unfortunately not provided by newlib.  */
     1.7 -#define bswap_16(x) \
     1.8 -    ((((x) & 0xff00) >> 8) | (((x) & 0xff) << 8))
     1.9 -
    1.10 -#define bswap_32(x) \
    1.11 -    ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >>  8) | \
    1.12 -     (((x) & 0x0000ff00) <<  8) | (((x) & 0x000000ff) << 24))
    1.13  
    1.14 -#define bswap_64(x) \
    1.15 -    ((((x) & 0xff00000000000000ULL) >> 56) | \
    1.16 -     (((x) & 0x00ff000000000000ULL) >> 40) | \
    1.17 -     (((x) & 0x0000ff0000000000ULL) >> 24) | \
    1.18 -     (((x) & 0x000000ff00000000ULL) >>  8) | \
    1.19 -     (((x) & 0x00000000ff000000ULL) <<  8) | \
    1.20 -     (((x) & 0x0000000000ff0000ULL) << 24) | \
    1.21 -     (((x) & 0x000000000000ff00ULL) << 40) | \
    1.22 -     (((x) & 0x00000000000000ffULL) << 56))
    1.23 +#include <types.h>
    1.24 +static inline uint16_t bswap_16(uint16_t x)
    1.25 +{
    1.26 +    return
    1.27 +    ((((x) & 0xff00) >> 8) | (((x) & 0xff) << 8));
    1.28 +}
    1.29 +
    1.30 +static inline uint32_t bswap_32(uint32_t x)
    1.31 +{
    1.32 +    return
    1.33 +    ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >>  8) |
    1.34 +     (((x) & 0x0000ff00) <<  8) | (((x) & 0x000000ff) << 24));
    1.35 +}
    1.36 +
    1.37 +static inline uint64_t bswap_64(uint64_t x)
    1.38 +{
    1.39 +    return
    1.40 +    ((((x) & 0xff00000000000000ULL) >> 56) |
    1.41 +     (((x) & 0x00ff000000000000ULL) >> 40) |
    1.42 +     (((x) & 0x0000ff0000000000ULL) >> 24) |
    1.43 +     (((x) & 0x000000ff00000000ULL) >>  8) |
    1.44 +     (((x) & 0x00000000ff000000ULL) <<  8) |
    1.45 +     (((x) & 0x0000000000ff0000ULL) << 24) |
    1.46 +     (((x) & 0x000000000000ff00ULL) << 40) |
    1.47 +     (((x) & 0x00000000000000ffULL) << 56));
    1.48 +}
    1.49  
    1.50  #endif /* _BYTESWAP_H */