Changeset View
Changeset View
Standalone View
Standalone View
sys/contrib/openzfs/include/os/freebsd/spl/sys/byteorder.h
Show First 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | |||||
#define LE_32(x) BMASK_32(x) | #define LE_32(x) BMASK_32(x) | ||||
#define LE_64(x) BMASK_64(x) | #define LE_64(x) BMASK_64(x) | ||||
#define BE_8(x) BSWAP_8(x) | #define BE_8(x) BSWAP_8(x) | ||||
#define BE_16(x) BSWAP_16(x) | #define BE_16(x) BSWAP_16(x) | ||||
#define BE_32(x) BSWAP_32(x) | #define BE_32(x) BSWAP_32(x) | ||||
#define BE_64(x) BSWAP_64(x) | #define BE_64(x) BSWAP_64(x) | ||||
#endif | #endif | ||||
#if !defined(_STANDALONE) | |||||
#if BYTE_ORDER == _BIG_ENDIAN | #if BYTE_ORDER == _BIG_ENDIAN | ||||
#define htonll(x) BMASK_64(x) | #define htonll(x) BMASK_64(x) | ||||
#define ntohll(x) BMASK_64(x) | #define ntohll(x) BMASK_64(x) | ||||
#else | #else /* BYTE_ORDER == _LITTLE_ENDIAN */ | ||||
#ifndef __LP64__ | #ifndef __LP64__ | ||||
static __inline__ uint64_t | static __inline__ uint64_t | ||||
htonll(uint64_t n) | htonll(uint64_t n) | ||||
{ | { | ||||
return ((((uint64_t)htonl(n)) << 32) + htonl(n >> 32)); | return ((((uint64_t)htonl(n)) << 32) + htonl(n >> 32)); | ||||
} | } | ||||
static __inline__ uint64_t | static __inline__ uint64_t | ||||
ntohll(uint64_t n) | ntohll(uint64_t n) | ||||
{ | { | ||||
return ((((uint64_t)ntohl(n)) << 32) + ntohl(n >> 32)); | return ((((uint64_t)ntohl(n)) << 32) + ntohl(n >> 32)); | ||||
} | } | ||||
#else | #else /* !__LP64__ */ | ||||
#define htonll(x) BSWAP_64(x) | #define htonll(x) BSWAP_64(x) | ||||
#define ntohll(x) BSWAP_64(x) | #define ntohll(x) BSWAP_64(x) | ||||
#endif | #endif /* __LP64__ */ | ||||
#endif | #endif /* BYTE_ORDER */ | ||||
#endif /* _STANDALONE */ | |||||
#define BE_IN32(xa) htonl(*((uint32_t *)(void *)(xa))) | #define BE_IN32(xa) htonl(*((uint32_t *)(void *)(xa))) | ||||
#endif /* _OPENSOLARIS_SYS_BYTEORDER_H_ */ | #endif /* _OPENSOLARIS_SYS_BYTEORDER_H_ */ |