32-bit big endian machines couldn't properly compile amd64 binaries because the halves of 64-bit integers or doubles got reordered. this simplifies things, and fixes the issue Reference: /n/atom/patch/applied/6cletab Date: Sun Aug 16 03:50:40 CES 2015 Signed-off-by: quanstro@quanstro.net --- /sys/src/cmd/6l/l.h Sun Aug 16 03:49:50 2015 +++ /sys/src/cmd/6l/l.h Sun Aug 16 03:49:51 2015 @@ -381,8 +381,6 @@ vlong entryvalue(void); void errorexit(void); void export(void); -int find1(long, int); -int find2(long, int); void follow(void); void gethunk(void); void histtoauto(void); --- /sys/src/cmd/6l/obj.c Sun Aug 16 03:49:54 2015 +++ /sys/src/cmd/6l/obj.c Sun Aug 16 03:49:56 2015 @@ -1449,24 +1449,34 @@ } } +static uvlong lorder = 0x0706050403020100ull; + +void +letab(uchar *t, int w, int n) +{ + uchar *o; + uint i; + + o = (uchar*)&lorder; + o += (o[0]!=0)*(8-w); /* if big endian, use tail not head */ + for(i = 0; i < n; i++) + t[i] = o[i]; +} + void nuxiinit(void) { - int i, c; + int i; + + letab(inuxi1, 4, 1); /* cast to 4 bytes, 1 byte tab */ + letab(inuxi2, 4, 2); + letab(inuxi4, 4, 4); + letab(inuxi8, 8, 8); + letab(fnuxi4, 4, 4); + letab(fnuxi8, 4, 4); /* undo Ieee word swap */ + for(i = 4; i < 8; i++) + fnuxi8[i] = fnuxi8[i-4]+4; - for(i=0; i<4; i++) { - c = find1(0x04030201L, i+1); - if(i < 2) - inuxi2[i] = c; - if(i < 1) - inuxi1[i] = c; - inuxi4[i] = c; - inuxi8[i] = c; - inuxi8[i+4] = c+4; - fnuxi4[i] = c; - fnuxi8[i] = c; - fnuxi8[i+4] = c+4; - } if(debug['v']) { Bprint(&bso, "inuxi = "); for(i=0; i<1; i++) @@ -1489,35 +1499,6 @@ Bprint(&bso, "\n"); } Bflush(&bso); -} - -int -find1(long l, int c) -{ - char *p; - int i; - - p = (char*)&l; - for(i=0; i<4; i++) - if(*p++ == c) - return i; - return 0; -} - -int -find2(long l, int c) -{ - short *p; - int i; - - p = (short*)&l; - for(i=0; i<4; i+=2) { - if(((*p >> 8) & 0xff) == c) - return i; - if((*p++ & 0xff) == c) - return i+1; - } - return 0; } long