problem with detzcode on machines w/64 bit longs

Robert Elz kre at munnari.OZ.AU
Sat Mar 11 11:36:19 UTC 1995

    Date:        Fri, 10 Mar 1995 13:00:53 -0700
    From:        Chris Torek <torek at BSDI.COM>
    Message-ID:  <199503102000.NAA17819 at BSDI.COM>

    If one is to resort to #ifdef's, the original suggestion of testing
    the top bit and OR'ing in ~0L << 32 should work, using something like:

Gawd - Chris, really, wouldn't just ...

 	result = codep[0] & 0x80 ? ~0L : 0L;
  	for (i = 0; i < 4; ++i)
  		result = (result << 8) | (codep[i] & 0xff);
  	return result;

work rather more easily, without ifdefs, without caring
whether char's are signed or not, without caring what is the
size of a long (though since four 8 bit values are being packed
in it had better be at least 32 bits), and without caring
just what weird specific length casts the compiler might
have, nor whether it compiles correct code for conversings
involving such things (which some I have seen don't), etc...

It is assuming that chars are 8 bits, or more correctly, at
least 8 bits (which was assumed there before as well).


More information about the tz mailing list