putle on big endian machines failed because it started at the wrong end of the number. the following version is temptingly cleaner, but is a miserable performer on mips (10x the run time), and shows poorly on arm as well. /* slow as molassas on risc-style machines */ void putle(uchar *t, uvlong r, int w) { uint i; for(i = 0; i < w; i++) t[i] = r>>i*8; } Reference: /n/atom/patch/applied2013/putleonbe Date: Sat Oct 12 08:58:45 CES 2013 Signed-off-by: quanstro@quanstro.net --- /sys/src/libc/port/getbe.c Sat Oct 12 08:44:14 2013 +++ /sys/src/libc/port/getbe.c Sat Oct 12 08:44:15 2013 @@ -20,10 +20,13 @@ putle(uchar *t, uvlong r, int w) { uchar *o, *f; - uint i; + uint i, k; f = (uchar*)&r; o = (uchar*)&lorder; + k = (o[0]!=0)*(8-w); /* if big endian, use tail not head */ + o += k; + f += k; for(i = 0; i < w; i++) t[o[i]] = f[i]; }