[openib-general] Re: [PATCH] use union in ibv_get_device_guid()

Michael S. Tsirkin mst at mellanox.co.il
Wed Sep 7 13:11:54 PDT 2005


Quoting r. Roland Dreier <rolandd at cisco.com>:
> --- libibverbs/include/infiniband/arch.h	(revision 3327)
> +++ libibverbs/include/infiniband/arch.h	(working copy)
> @@ -35,6 +35,17 @@
>  #ifndef INFINIBAND_ARCH_H
>  #define INFINIBAND_ARCH_H
>  
> +#include <endian.h>
> +#include <byteswap.h>
> +
> +#if __BYTE_ORDER == __LITTLE_ENDIAN
> +static inline uint64_t htonll(uint64_t x) { return bswap_64(x); }
> +static inline uint64_t ntohll(uint64_t x) { return bswap_64(x); }
> +#elif __BYTE_ORDER == __BIG_ENDIAN
> +static inline uint64_t htonll(uint64_t x) { return x; }
> +static inline uint64_t ntohll(uint64_t x) { return x; }
> +#endif
> +
>  /*
>   * Architecture-specific defines.  Currently, an architecture is
>   * required to implement the following operations:

Lets also add
#else
#error __BYTE_ORDER differs from both __LITTLE_ENDIAN and __BIG_ENDIAN
#endif
just in case?

-- 
MST



More information about the general mailing list