diff --git a/src/fart/hton.d b/src/fart/hton.d new file mode 100644 index 0000000..b1aed31 --- /dev/null +++ b/src/fart/hton.d @@ -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); + } +}