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

From: Ray Lee
Date: Sat Feb 09 2008 - 14:46:47 EST


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;
--
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/