-#if BYTEORDER == 0x4321 || BYTEORDER == 0x87654321 /* big-endian */
-
-# define DO_BO_UNPACK(var, type) \
- STMT_START { \
- if (TYPE_ENDIANNESS(datumtype) == TYPE_IS_LITTLE_ENDIAN) { \
- var = my_letoh ## type (var); \
- } \
- } STMT_END
-
-# define DO_BO_PACK(var, type) \
- STMT_START { \
- if (TYPE_ENDIANNESS(datumtype) == TYPE_IS_LITTLE_ENDIAN) { \
- var = my_htole ## type (var); \
- } \
- } STMT_END
-
-# define DO_BO_UNPACK_PTR(var, type, pre_cast, post_cast) \
- STMT_START { \
- if (TYPE_ENDIANNESS(datumtype) == TYPE_IS_LITTLE_ENDIAN) { \
- my_letohn(&var, sizeof(var)); \
- } \
- } STMT_END
-
-# define DO_BO_PACK_PTR(var, type, pre_cast, post_cast) \
- STMT_START { \
- if (TYPE_ENDIANNESS(datumtype) == TYPE_IS_LITTLE_ENDIAN) { \
- my_htolen(&var, sizeof(var)); \
- } \
- } STMT_END
-
-# define DO_BO_UNPACK_N(var, type) \
- STMT_START { \
- if (TYPE_ENDIANNESS(datumtype) == TYPE_IS_LITTLE_ENDIAN) { \
- my_letohn(&var, sizeof(var)); \
- } \
- } STMT_END
-
-# define DO_BO_PACK_N(var, type) \
- STMT_START { \
- if (TYPE_ENDIANNESS(datumtype) == TYPE_IS_LITTLE_ENDIAN) { \
- my_htolen(&var, sizeof(var)); \
- } \
- } STMT_END
-
-# elif BYTEORDER == 0x1234 || BYTEORDER == 0x12345678 /* little-endian */
-
-# define DO_BO_UNPACK(var, type) \
- STMT_START { \
- if (TYPE_ENDIANNESS(datumtype) == TYPE_IS_BIG_ENDIAN) { \
- var = my_betoh ## type (var); \
- } \
- } STMT_END
-
-# define DO_BO_PACK(var, type) \
- STMT_START { \
- if (TYPE_ENDIANNESS(datumtype) == TYPE_IS_BIG_ENDIAN) { \
- var = my_htobe ## type (var); \
- } \
- } STMT_END
-
-# define DO_BO_UNPACK_PTR(var, type, pre_cast, post_cast) \
- STMT_START { \
- if (TYPE_ENDIANNESS(datumtype) == TYPE_IS_BIG_ENDIAN) { \
- my_betohn(&var, sizeof(var)); \
- } \
- } STMT_END
-
-# define DO_BO_PACK_PTR(var, type, pre_cast, post_cast) \
- STMT_START { \
- if (TYPE_ENDIANNESS(datumtype) == TYPE_IS_BIG_ENDIAN) { \
- my_htoben(&var, sizeof(var)); \
- } \
- } STMT_END
-
-# define DO_BO_UNPACK_N(var, type) \
- STMT_START { \
- if (TYPE_ENDIANNESS(datumtype) == TYPE_IS_BIG_ENDIAN) { \
- my_betohn(&var, sizeof(var)); \
- } \
- } STMT_END
-
-# define DO_BO_PACK_N(var, type) \
- STMT_START { \
- if (TYPE_ENDIANNESS(datumtype) == TYPE_IS_BIG_ENDIAN) { \
- my_htoben(&var, sizeof(var)); \
- } \
- } STMT_END
-
-#else
-# define DO_BO_UNPACK(var, type) BO_CANT_DOIT(unpack, type)
-# define DO_BO_PACK(var, type) BO_CANT_DOIT(pack, type)
-# define DO_BO_UNPACK_PTR(var, type, pre_cast, post_cast) \
- BO_CANT_DOIT(unpack, type)
-# define DO_BO_PACK_PTR(var, type, pre_cast, post_cast) \
- BO_CANT_DOIT(pack, type)
-# define DO_BO_UNPACK_N(var, type) BO_CANT_DOIT(unpack, type)
-# define DO_BO_PACK_N(var, type) BO_CANT_DOIT(pack, type)
-#endif
-
-# define BO_CANT_DOIT(action, type) \
- STMT_START { \
- switch (TYPE_ENDIANNESS(datumtype)) { \
- case TYPE_IS_BIG_ENDIAN: \
- Perl_croak(aTHX_ "Can't %s big-endian %ss on this " \
- "platform", #action, #type); \
- break; \
- case TYPE_IS_LITTLE_ENDIAN: \
- Perl_croak(aTHX_ "Can't %s little-endian %ss on this " \
- "platform", #action, #type); \
- break; \
- default: \
- break; \
- } \
- } STMT_END
-
-# if PTRSIZE == INTSIZE
-# define DO_BO_UNPACK_PC(var) DO_BO_UNPACK_PTR(var, i, int, char)
-# define DO_BO_PACK_PC(var) DO_BO_PACK_PTR(var, i, int, char)
-# elif PTRSIZE == LONGSIZE
-# if LONGSIZE < IVSIZE && IVSIZE == 8
-# define DO_BO_UNPACK_PC(var) DO_BO_UNPACK_PTR(var, 64, IV, char)
-# define DO_BO_PACK_PC(var) DO_BO_PACK_PTR(var, 64, IV, char)
-# else
-# define DO_BO_UNPACK_PC(var) DO_BO_UNPACK_PTR(var, l, IV, char)
-# define DO_BO_PACK_PC(var) DO_BO_PACK_PTR(var, l, IV, char)
-# endif
-# elif PTRSIZE == IVSIZE
-# define DO_BO_UNPACK_PC(var) DO_BO_UNPACK_PTR(var, l, IV, char)
-# define DO_BO_PACK_PC(var) DO_BO_PACK_PTR(var, l, IV, char)
-# else
-# define DO_BO_UNPACK_PC(var) BO_CANT_DOIT(unpack, pointer)
-# define DO_BO_PACK_PC(var) BO_CANT_DOIT(pack, pointer)
-# endif
-