[linux-mm-cc] [RFC] LZO de/compression support - take 6
nitingupta910 at gmail.com
Wed May 30 01:54:36 EDT 2007
On 5/30/07, Jan Engelhardt <jengelh at linux01.gwdg.de> wrote:
> On May 28 2007 20:04, Nitin Gupta wrote:
> > * Changelog vs. original LZO:
> > 1) Used standard/kernel defined data types: (this eliminated _huge_
> > #ifdef chunks)
> > lzo_bytep -> unsigned char *
> > lzo_uint -> size_t
> > lzo_xint -> size_t
> Is this safe (as far as compressed LZO stream is concerned) --
> or is it even needed (could it be unsigned int)?
> > - m_pos -= (*(const unsigned short *)ip) >> 2;
> > -#else
> > - m_pos = op - 1;
> > - m_pos -= (ip >> 2) + (ip << 6);
> > -#endif
> > + m_pos = op - 1 - (cpu_to_le16(*(const u16 *)ip) >> 2);
> > (Andrey suggested le16_to_cpu for above but I think it should be cpu_to_le16).
> > *** Need testing on big endian machine ***
> On i386, both cpu_to_le16 and le16_to_cpu do nothing.
> On sparc for example, cpu_to_leXX and leXX_to_cpu do 'the same' ;-)
> they swap 1234<->4321.
> It is the bytestream (ip) that is reinterpreted as uint16_t.
> And I really doubt that the LZO author has a big-endian machine,
> given the days of ubiquitous x86.
> le16_to_cpu it is.
I just missed the point that leXX_to_cpu() and cpu_to_leXX() are
identical on BE machine anyway. But then why you think it should be
le_16_cpu() -- how will this make any difference?
For your ref (from big_endian.h):
#define __cpu_to_le16(x) ((__force __le16)__swab16((x)))
#define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
More information about the linux-mm-cc