Add fart.hton module
This commit is contained in:
parent
42e2508766
commit
5b449506cb
35
src/fart/hton.d
Normal file
35
src/fart/hton.d
Normal 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);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user