[ENet-discuss] ENET_HOST_TO_NET/ENET_NET_TO_HOST
dmex
dmex04 at gmail.com
Sun Jul 14 10:35:54 PDT 2013
You don't need to check for platform support... Intrinsics are special, the
compiler will emit the appropriate code if the function is not supported for
the target processor at compile time.
-----Original Message-----
From: enet-discuss-bounces at cubik.org [mailto:enet-discuss-bounces at cubik.org]
On Behalf Of Lee Salzman
Sent: Sunday, 14 July 2013 8:04 PM
To: Discussion of the ENet library
Subject: Re: [ENet-discuss] ENET_HOST_TO_NET/ENET_NET_TO_HOST
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
>
_______________________________________________
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