ref: 804ca7d4abe311fb94e02c8e1cd56aad8865a959
dir: /lib/std/endian.myr/
pkg std = generic hosttonet : (v : @a::(integral,numeric) -> @a::(integral,numeric)) generic nettohost : (v : @a::(integral,numeric) -> @a::(integral,numeric)) ;; /* FIXME: we only support little endian platforms right now, so we assume a little endian machine. FIX THIS. */ generic hosttonet = {v : @a::(integral,numeric) var i var ret ret = 0 for i = 0; i < sizeof(@a::(integral,numeric)); i++ ret <<= 8 ret |= v & 0xff v >>= 8 ;; -> ret } generic nettohost = {v : @a::(integral,numeric) var i var ret ret = 0 for i = 0; i < sizeof(@a::(integral,numeric)); i++ ret <<= 8 ret |= v & 0xff v >>= 8 ;; -> ret }