[ofw] Re: [ofa-general] [RFC] 3/5: IB ACM: libibacm
Sean Hefty
sean.hefty at intel.com
Fri Sep 18 15:23:40 PDT 2009
>Rough hack. Does windows have stdint.h, byteswap.h, and endian.h?
If not, adding the headers with the needed definitions is trivial.
>+/* 16bit */
>+#if __BYTE_ORDER == __LITTLE_ENDIAN
>+#define CL_NTOH16( x ) (uint16_t)( \
>+ (((uint16_t)(x) & 0x00FF) << 8) | \
>+ (((uint16_t)(x) & 0xFF00) >> 8) )
>+#else
>+#define CL_NTOH16( x ) (x)
>+#endif
>+#define CL_HTON16 CL_NTOH16
>+
>+/* 32bit */
>+#if __BYTE_ORDER == __LITTLE_ENDIAN
>+#define CL_NTOH32( x ) (uint32_t)( \
>+ (((uint32_t)(x) & 0x000000FF) << 24) | \
>+ (((uint32_t)(x) & 0x0000FF00) << 8) | \
>+ (((uint32_t)(x) & 0x00FF0000) >> 8) | \
>+ (((uint32_t)(x) & 0xFF000000) >> 24) )
>+#else
>+#define CL_NTOH32( x ) (x)
>+#endif
>+#define CL_HTON32 CL_NTOH32
>+
>+/* 64bit */
>+#if __BYTE_ORDER == __LITTLE_ENDIAN
>+#define CL_NTOH64( x ) (uint64_t)(
\
>+ (((uint64_t)(x) & 0x00000000000000FFULL) << 56) |
\
>+ (((uint64_t)(x) & 0x000000000000FF00ULL) << 40) |
\
>+ (((uint64_t)(x) & 0x0000000000FF0000ULL) << 24) |
\
>+ (((uint64_t)(x) & 0x00000000FF000000ULL) << 8 ) |
\
>+ (((uint64_t)(x) & 0x000000FF00000000ULL) >> 8 ) |
\
>+ (((uint64_t)(x) & 0x0000FF0000000000ULL) >> 24) |
\
>+ (((uint64_t)(x) & 0x00FF000000000000ULL) >> 40) |
\
>+ (((uint64_t)(x) & 0xFF00000000000000ULL) >> 56) )
>+#else
>+#define CL_NTOH64( x ) (x)
>+#endif
>+#define CL_HTON64 CL_NTOH64
>+
>+#if __BYTE_ORDER == __LITTLE_ENDIAN
>+#define cl_ntoh16(x) bswap_16(x)
>+#define cl_hton16(x) bswap_16(x)
>+#define cl_ntoh32(x) bswap_32(x)
>+#define cl_hton32(x) bswap_32(x)
>+#define cl_ntoh64(x) (uint64_t)bswap_64(x)
>+#define cl_hton64(x) (uint64_t)bswap_64(x)
>+#else /* Big Endian */
>+#define cl_ntoh16(x) (x)
>+#define cl_hton16(x) (x)
>+#define cl_ntoh32(x) (x)
>+#define cl_hton32(x) (x)
>+#define cl_ntoh64(x) (x)
>+#define cl_hton64(x) (x)
>+#endif
Why the different defines for cl_noth and CL_NTOH?
More information about the ofw
mailing list