ref: ac53b78d88d7f460ada21633fb1dc8ee96b53a36
dir: /lib/std/endian.myr/
pkg std = generic hosttonet : (v : @a -> @a) generic nettohost : (v : @a -> @a) ;; /* 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); 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); i++ ret <<= 8 ret |= v & 0xff v >>= 8 ;; -> ret }