Add fart.hton module

This commit is contained in:
Josh Holtrop 2023-10-09 19:13:11 -04:00
parent 42e2508766
commit 5b449506cb

35
src/fart/hton.d Normal file
View File

@ -0,0 +1,35 @@
/**
* @file
*
* Host to network byte-swapping functions.
*/
module fart.hton;
version (BigEndian)
{
public uint htonl(uint v)
{
return v;
}
public uint ntohl(uint v)
{
return v;
}
}
version (LittleEndian)
{
import core.bitop;
public uint htonl(uint v)
{
return bswap(v);
}
public uint ntohl(uint v)
{
return bswap(v);
}
}