#define SIZE16 2
#define SIZE32 4
+#if SHORTSIZE != SIZE16 || LONGSIZE != SIZE32
+# define PERL_NATINT_PACK
+#endif
+
#if BYTEORDER > 0xFFFF && defined(_CRAY) && !defined(_CRAYMPP)
# if BYTEORDER == 0x12345678
# define OFF16(p) (char*)(p)
register U32 culong;
double cdouble;
int commas = 0;
+#ifdef PERL_NATINT_PACK
int natint; /* native integer */
int unatint; /* unsigned native integer */
+#endif
if (gimme != G_ARRAY) { /* arrange to do first one only */
/*SUPPRESS 530*/
while (pat < patend) {
reparse:
datumtype = *pat++ & 0xFF;
+#ifdef PERL_NATINT_PACK
natint = 0;
+#endif
if (isSPACE(datumtype))
continue;
if (*pat == '_') {
char *natstr = "sSiIlL";
if (strchr(natstr, datumtype)) {
+#ifdef PERL_NATINT_PACK
natint = 1;
+#endif
pat++;
}
else
}
break;
case 's':
+#if SHORTSIZE == SIZE16
+ along = (strend - s) / SIZE16;
+#else
along = (strend - s) / (natint ? sizeof(short) : SIZE16);
+#endif
if (len > along)
len = along;
if (checksum) {
+#if SHORTSIZE != SIZE16
if (natint) {
while (len-- > 0) {
COPYNN(s, &ashort, sizeof(short));
}
}
- else {
+ else
+#endif
+ {
while (len-- > 0) {
COPY16(s, &ashort);
s += SIZE16;
else {
EXTEND(SP, len);
EXTEND_MORTAL(len);
+#if SHORTSIZE != SIZE16
if (natint) {
while (len-- > 0) {
COPYNN(s, &ashort, sizeof(short));
PUSHs(sv_2mortal(sv));
}
}
- else {
+ else
+#endif
+ {
while (len-- > 0) {
COPY16(s, &ashort);
s += SIZE16;
case 'v':
case 'n':
case 'S':
+#if SHORTSIZE == SIZE16
+ along = (strend - s) / SIZE16;
+#else
unatint = natint && datumtype == 'S';
along = (strend - s) / (unatint ? sizeof(unsigned short) : SIZE16);
+#endif
if (len > along)
len = along;
if (checksum) {
+#if SHORTSIZE != SIZE16
if (unatint) {
while (len-- > 0) {
COPYNN(s, &aushort, sizeof(unsigned short));
culong += aushort;
}
}
- else {
+ else
+#endif
+ {
while (len-- > 0) {
COPY16(s, &aushort);
s += SIZE16;
else {
EXTEND(SP, len);
EXTEND_MORTAL(len);
+#if SHORTSIZE != SIZE16
if (unatint) {
while (len-- > 0) {
COPYNN(s, &aushort, sizeof(unsigned short));
s += sizeof(unsigned short);
sv = NEWSV(39, 0);
- sv_setiv(sv, (IV)aushort);
+ sv_setiv(sv, (UV)aushort);
PUSHs(sv_2mortal(sv));
}
}
- else {
+ else
+#endif
+ {
while (len-- > 0) {
COPY16(s, &aushort);
s += SIZE16;
if (datumtype == 'v')
aushort = vtohs(aushort);
#endif
- sv_setiv(sv, (IV)aushort);
+ sv_setiv(sv, (UV)aushort);
PUSHs(sv_2mortal(sv));
}
}
}
break;
case 'l':
+#if LONGSIZE == SIZE32
+ along = (strend - s) / SIZE32;
+#else
along = (strend - s) / (natint ? sizeof(long) : SIZE32);
+#endif
if (len > along)
len = along;
if (checksum) {
+#if LONGSIZE != SIZE32
if (natint) {
while (len-- > 0) {
COPYNN(s, &along, sizeof(long));
culong += along;
}
}
- else {
+ else
+#endif
+ {
while (len-- > 0) {
COPY32(s, &along);
s += SIZE32;
else {
EXTEND(SP, len);
EXTEND_MORTAL(len);
+#if LONGSIZE != SIZE32
if (natint) {
while (len-- > 0) {
COPYNN(s, &along, sizeof(long));
PUSHs(sv_2mortal(sv));
}
}
- else {
+ else
+#endif
+ {
while (len-- > 0) {
COPY32(s, &along);
s += SIZE32;
case 'V':
case 'N':
case 'L':
- unatint = natint && datumtype;
+#if LONGSIZE == SIZE32
+ along = (strend - s) / SIZE32;
+#else
+ unatint = natint && datumtype == 'L';
along = (strend - s) / (unatint ? sizeof(unsigned long) : SIZE32);
+#endif
if (len > along)
len = along;
if (checksum) {
+#if LONGSIZE != SIZE32
if (unatint) {
while (len-- > 0) {
COPYNN(s, &aulong, sizeof(unsigned long));
culong += aulong;
}
}
- else {
+ else
+#endif
+ {
while (len-- > 0) {
COPY32(s, &aulong);
s += SIZE32;
else {
EXTEND(SP, len);
EXTEND_MORTAL(len);
+#if LONGSIZE != SIZE32
if (unatint) {
while (len-- > 0) {
COPYNN(s, &aulong, sizeof(unsigned long));
PUSHs(sv_2mortal(sv));
}
}
- else {
+ else
+#endif
+ {
while (len-- > 0) {
COPY32(s, &aulong);
s += SIZE32;
float afloat;
double adouble;
int commas = 0;
+#ifdef PERL_NATINT_PACK
int natint; /* native integer */
+#endif
items = SP - MARK;
MARK++;
while (pat < patend) {
#define NEXTFROM (items-- > 0 ? *MARK++ : &PL_sv_no)
datumtype = *pat++ & 0xFF;
+#ifdef PERL_NATINT_PACK
natint = 0;
+#endif
if (isSPACE(datumtype))
continue;
if (*pat == '_') {
char *natstr = "sSiIlL";
if (strchr(natstr, datumtype)) {
+#ifdef PERL_NATINT_PACK
natint = 1;
+#endif
pat++;
}
else
}
break;
case 'S':
+#if SHORTSIZE != SIZE16
if (natint) {
unsigned short aushort;
sv_catpvn(cat, (char *)&aushort, sizeof(unsigned short));
}
}
- else {
+ else
+#endif
+ {
U16 aushort;
while (len-- > 0) {
fromstr = NEXTFROM;
- aushort = (U16)SvIV(fromstr);
+ aushort = (U16)SvUV(fromstr);
CAT16(cat, &aushort);
}
+
}
break;
case 's':
+#if SHORTSIZE != 2
if (natint) {
while (len-- > 0) {
fromstr = NEXTFROM;
sv_catpvn(cat, (char *)&ashort, sizeof(short));
}
}
- else {
+ else
+#endif
+ {
while (len-- > 0) {
fromstr = NEXTFROM;
ashort = (I16)SvIV(fromstr);
}
break;
case 'L':
+#if LONGSIZE != SIZE32
if (natint) {
while (len-- > 0) {
fromstr = NEXTFROM;
sv_catpvn(cat, (char *)&aulong, sizeof(unsigned long));
}
}
- else {
+ else
+#endif
+ {
while (len-- > 0) {
fromstr = NEXTFROM;
aulong = SvUV(fromstr);
}
break;
case 'l':
+#if LONGSIZE != SIZE32
if (natint) {
while (len-- > 0) {
fromstr = NEXTFROM;
sv_catpvn(cat, (char *)&along, sizeof(long));
}
}
- else {
+ else
+#endif
+ {
while (len-- > 0) {
fromstr = NEXTFROM;
along = SvIV(fromstr);