[ENet-discuss] ENET_HOST_TO_NET/ENET_NET_TO_HOST
Lee Salzman
lsalzman at gmail.com
Sun Jul 14 05:04:10 PDT 2013
Well, there would need to be a check that the platform is little-endian as well, so it would need to check for x86/arm platforms and it could use those, otherwise default to the ntoh/hton versions.
On 07/14/2013 01:27 PM, dmex wrote:
> Hello,
>
> On Windows the htons/htonl/ntohs/ntohl functions are much older and slower
> than the same functions found on other Operating Systems since the Windows
> versions of these functions do not make use of the native bswap processor
> instruction.
>
> Intrinsic functions are available in both stdlib.h and intrin.h on multiple
> platforms for solving this issue, you can simply define the following in
> win32.h or enet.h for slightly better enet library performance:
>
> #define ntohl(x) _byteswap_ulong(x)
> #define ntohs(x) _byteswap_ushort(x)
> #define htonl(x) _byteswap_ulong(x)
> #define htons(x) _byteswap_ushort(x)
>
> #define ENET_HOST_TO_NET_16(value) (htons(value))
> #define ENET_HOST_TO_NET_32(value) (htonl(value))
> #define ENET_NET_TO_HOST_16(value) (ntohs(value))
> #define ENET_NET_TO_HOST_32(value) (ntohl(value))
>
> Would it be possible to include these in the enet library by default?
>
> -dmex
>
> _______________________________________________
> ENet-discuss mailing list
> ENet-discuss at cubik.org
> http://lists.cubik.org/mailman/listinfo/enet-discuss
>
More information about the ENet-discuss
mailing list