> #define TRIO_DOUBLE_INDEX(x) (((unsigned char *)&internalEndianMagic)[7-(x)])

this is actually done in /sys/src/9/port/devcons.c too:

        static uvlong uvorder = 0x0001020304050607ULL;
        
        static uchar*
        le2vlong(vlong *to, uchar *f)
        {
                uchar *t, *o;
                int i;
        
                t = (uchar*)to;
                o = (uchar*)&uvorder;
                for(i = 0; i < sizeof(vlong); i++)
                        t[o[i]] = f[i];
                return f+sizeof(vlong);
        }
        
        static uchar*
        vlong2le(uchar *t, vlong from)
        {
                uchar *f, *o;
                int i;
        
                f = (uchar*)&from;
                o = (uchar*)&uvorder;
                for(i = 0; i < sizeof(vlong); i++)
                        t[i] = f[o[i]];
                return t+sizeof(vlong);
        }

presotto wrote the code but said he learned the trick from ken.

there, of course, we have a real compiler and don't have to
write uvlong constants as floating point numbers
(wow that seems fragile).

russ

Reply via email to