#define HAS_NTOHS
#endif
#ifndef HAS_HTONL
-#if (BYTEORDER & 0xffff) != 0x4321
#define HAS_HTONS
#define HAS_HTONL
#define HAS_NTOHS
#define HAS_NTOHL
+# if (BYTEORDER & 0xffff) == 0x4321
+/* Big endian system, so ntohl, ntohs, htonl and htons do not need to
+ re-order their values. However, to behave identically to the alternative
+ implementations, they should truncate to the correct size. */
+# define ntohl(x) ((x)&0xFFFFFFFF)
+# define htonl(x) ntohl(x)
+# define ntohs(x) ((x)&0xFFFF)
+# define htons(x) ntohs(x)
+# else
#define MYSWAP
#define htons my_swap
#define htonl my_htonl
#define ntohs my_swap
#define ntohl my_ntohl
#endif
-#else
-#if (BYTEORDER & 0xffff) == 0x4321
-#undef HAS_HTONS
-#undef HAS_HTONL
-#undef HAS_NTOHS
-#undef HAS_NTOHL
-#endif
#endif
/*
#endif
SHIFT16(utf8, s, strend, &au16, datumtype);
DO_BO_UNPACK(au16, 16);
-#ifdef HAS_NTOHS
if (datumtype == 'n')
au16 = PerlSock_ntohs(au16);
-#endif
if (datumtype == 'v')
au16 = vtohs(au16);
if (!checksum)
ai16 = 0;
# endif
SHIFT16(utf8, s, strend, &ai16, datumtype);
-# ifdef HAS_NTOHS
if (datumtype == ('n' | TYPE_IS_SHRIEKING))
ai16 = (I16) PerlSock_ntohs((U16) ai16);
-# endif /* HAS_NTOHS */
if (datumtype == ('v' | TYPE_IS_SHRIEKING))
ai16 = (I16) vtohs((U16) ai16);
if (!checksum)
#endif
SHIFT32(utf8, s, strend, &au32, datumtype);
DO_BO_UNPACK(au32, 32);
-#ifdef HAS_NTOHL
if (datumtype == 'N')
au32 = PerlSock_ntohl(au32);
-#endif
if (datumtype == 'V')
au32 = vtohl(au32);
if (!checksum)
ai32 = 0;
#endif
SHIFT32(utf8, s, strend, &ai32, datumtype);
-#ifdef HAS_NTOHL
if (datumtype == ('N' | TYPE_IS_SHRIEKING))
ai32 = (I32)PerlSock_ntohl((U32)ai32);
-#endif
if (datumtype == ('V' | TYPE_IS_SHRIEKING))
ai32 = (I32)vtohl((U32)ai32);
if (!checksum)
I16 ai16;
fromstr = NEXTFROM;
ai16 = (I16)SvIV(fromstr);
-#ifdef HAS_HTONS
ai16 = PerlSock_htons(ai16);
-#endif
PUSH16(utf8, cur, &ai16);
}
break;
U32 au32;
fromstr = NEXTFROM;
au32 = SvUV(fromstr);
-#ifdef HAS_HTONL
au32 = PerlSock_htonl(au32);
-#endif
PUSH32(utf8, cur, &au32);
}
break;
#ifdef HAS_GETSERVBYPORT
const char * const proto = POPpbytex;
unsigned short port = (unsigned short)POPu;
-#ifdef HAS_HTONS
port = PerlSock_htons(port);
-#endif
sent = PerlSock_getservbyport(port, (proto && !*proto) ? NULL : proto);
#else
DIE(aTHX_ PL_no_sock_func, "getservbyport");
PUSHs(sv = sv_newmortal());
if (sent) {
if (which == OP_GSBYNAME) {
-#ifdef HAS_NTOHS
sv_setiv(sv, (IV)PerlSock_ntohs(sent->s_port));
-#else
- sv_setiv(sv, (IV)(sent->s_port));
-#endif
}
else
sv_setpv(sv, sent->s_name);
if (sent) {
mPUSHs(newSVpv(sent->s_name, 0));
PUSHs(space_join_names_mortal(sent->s_aliases));
-#ifdef HAS_NTOHS
mPUSHi(PerlSock_ntohs(sent->s_port));
-#else
- mPUSHi(sent->s_port);
-#endif
mPUSHs(newSVpv(sent->s_proto, 0));
}