Add fart.hton module
This commit is contained in:
1 parent
42e2508766
commit
5b449506cb
1 file changed
+35
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user