> > i think a bug is setting inuxi8[i+4] = inuxi8[i] for 0<=i<4.
> > mikro; diffy -c *.c
> > diff -c /n/dump/2013/0821/sys/src/cmd/6l/obj.c obj.c
> > /n/dump/2013/0821/sys/src/cmd/6l/obj.c:1455,1471 - obj.c:1455,1471
> > int i, c;
> >
> > for(i=0; i<4; i++) {
> > - c = find1(0x04030201L, i+1);
> > + c = find1(0x0807060504030201ULL, i+1);
>
> Why not
> for(i=0; i<8; i++) {
> Else what is the point of
> c = find1(0x0807060504030201ULL, i+1);
> Just eyeballing. I haven't looked at the actual code.
as it turns out, floating point is already swapped by Ieee, and
anything less than or equal to 4 bytes is cast uprated to a ulong,
not a uvlong.
this version produces the same output with -a as on amd64.
i think it's a little more clear to straightforwardly set up the nuxi,
and special case the word-swapping in the floating point.
ideally, the low and high words would be merged to a vlong.
this fix likely won't survive its encounter with review intact, but
at least for now i can compile amd64 binaries on mips.
once a final form is in place a fix should be applied to all
compilers.
- erik
----
/n/atom/plan9/sys/src/cmd/6l/obj.c:1449,1472 - obj.c:1449,1482
}
}
+ 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;
- 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;
- }
+ 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 swapping. */
+ for(i = 4; i < 8; i++)
+ fnuxi8[i] = fnuxi8[i-4]+4;
+
if(debug['v']) {
Bprint(&bso, "inuxi = ");
for(i=0; i<1; i++)
/n/atom/plan9/sys/src/cmd/6l/obj.c:1489,1523 - obj.c:1499,1504
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