Re: [PATCH 1/8] kgdb: core API and gdb protocol handler

From: Ray Lee
Date: Sat Feb 09 2008 - 16:51:18 EST


2008/2/9 Ray Lee <ray-lk@xxxxxxxxxxxxx>:
> On Feb 9, 2008 9:27 AM, Christoph Hellwig <hch@xxxxxxxxxxxxx> wrote:
> > On Sat, Feb 09, 2008 at 07:35:07AM -0600, jason.wessel@xxxxxxxxxxxxx wrote:
> > > +#ifdef __BIG_ENDIAN
> > > + *buf++ = hexchars[(tmp_s >> 12) & 0xf];
> > > + *buf++ = hexchars[(tmp_s >> 8) & 0xf];
> > > + *buf++ = hexchars[(tmp_s >> 4) & 0xf];
> > > + *buf++ = hexchars[tmp_s & 0xf];
> > > +#else
> > > + *buf++ = hexchars[(tmp_s >> 4) & 0xf];
> > > + *buf++ = hexchars[tmp_s & 0xf];
> > > + *buf++ = hexchars[(tmp_s >> 12) & 0xf];
> > > + *buf++ = hexchars[(tmp_s >> 8) & 0xf];
> > > +#endif
> >
> > This is really ugly, but I don't really know a good way around it
> > either.
>
> void u32_to_hex(u32 val, unsigned char *buf)
> {
> int i;
>
> for (i=7; i>=0; i--) {
> buf[i] = hexchars[ val & 0x0f ];
> val >>= 4;
> }
> }
>
> u32_to_hex(tmp_s, buf);
> buf += 8;
>

Sorry, rewrote what I thought I read, not what was there. I guess
you'd want it more along the lines of

void u32_to_hex(u32 x, unsigned char *buf)
{
int i;
int val = cpu_to_be32( x );

for (i=7; ...
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/