} \
} 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_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_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
-
#define PACK_SIZE_CANNOT_CSUM 0x80
#define PACK_SIZE_UNPREDICTABLE 0x40 /* Not a fixed size element */
#define PACK_SIZE_MASK 0x3F
while (len-- > 0) {
const char *aptr;
SHIFT_VAR(utf8, s, strend, aptr, datumtype);
- DO_BO_UNPACK_PC(aptr);
+ DO_BO_UNPACK(aptr, pointer);
/* newSVpv generates undef if aptr is NULL */
mPUSHs(newSVpv(aptr, 0));
}
if (s + sizeof(char*) <= strend) {
char *aptr;
SHIFT_VAR(utf8, s, strend, aptr, datumtype);
- DO_BO_UNPACK_PC(aptr);
+ DO_BO_UNPACK(aptr, pointer);
/* newSVpvn generates undef if aptr is NULL */
PUSHs(newSVpvn_flags(aptr, len, SVs_TEMP));
}
while (len-- > 0) {
float afloat;
SHIFT_VAR(utf8, s, strend, afloat, datumtype);
- DO_BO_UNPACK_N(afloat, float);
+ DO_BO_UNPACK(afloat, float);
if (!checksum)
mPUSHn(afloat);
else
while (len-- > 0) {
double adouble;
SHIFT_VAR(utf8, s, strend, adouble, datumtype);
- DO_BO_UNPACK_N(adouble, double);
+ DO_BO_UNPACK(adouble, double);
if (!checksum)
mPUSHn(adouble);
else
while (len-- > 0) {
NV_bytes anv;
SHIFT_BYTES(utf8, s, strend, anv.bytes, sizeof(anv.bytes), datumtype);
- DO_BO_UNPACK_N(anv.nv, NV);
+ DO_BO_UNPACK(anv.nv, NV);
if (!checksum)
mPUSHn(anv.nv);
else
while (len-- > 0) {
ld_bytes aldouble;
SHIFT_BYTES(utf8, s, strend, aldouble.bytes, sizeof(aldouble.bytes), datumtype);
- DO_BO_UNPACK_N(aldouble.ld, long double);
+ DO_BO_UNPACK(aldouble.ld, long double);
if (!checksum)
mPUSHn(aldouble.ld);
else
# else
afloat = (float)anv;
# endif
- DO_BO_PACK_N(afloat, float);
+ DO_BO_PACK(afloat, float);
PUSH_VAR(utf8, cur, afloat);
}
break;
# else
adouble = (double)anv;
# endif
- DO_BO_PACK_N(adouble, double);
+ DO_BO_PACK(adouble, double);
PUSH_VAR(utf8, cur, adouble);
}
break;
#else
anv.nv = SvNV(fromstr);
#endif
- DO_BO_PACK_N(anv, NV);
+ DO_BO_PACK(anv, NV);
PUSH_BYTES(utf8, cur, anv.bytes, sizeof(anv.bytes));
}
break;
# else
aldouble.ld = (long double)SvNV(fromstr);
# endif
- DO_BO_PACK_N(aldouble, long double);
+ DO_BO_PACK(aldouble, long double);
PUSH_BYTES(utf8, cur, aldouble.bytes, sizeof(aldouble.bytes));
}
break;
else
aptr = SvPV_force_flags_nolen(fromstr, 0);
}
- DO_BO_PACK_PC(aptr);
+ DO_BO_PACK(aptr, pointer);
PUSH_VAR(utf8, cur, aptr);
}
break;