[RFA] leb128.h: New file.
Jan Kratochvil
jan.kratochvil@redhat.com
Mon May 21 14:21:00 GMT 2012
On Mon, 21 May 2012 02:30:58 +0200, Doug Evans wrote:
> Ping.
> On Thu, May 17, 2012 at 11:29 AM, Doug Evans <dje@google.com> wrote:
[...]
> > --- /dev/null  1 Jan 1970 00:00:00 -0000
> > +++ leb128.h   17 May 2012 18:23:29 -0000
[...]
> > +/* Get a definition for NULL. Â */
> > +#include <stdio.h>
I think <stddef.h> for NULL.
[...]
> > +static inline int
Return type should be size_t or ptrdiff_t. Likewise for other functions.
> > +read_uleb128 (const unsigned char *buf, const unsigned char *buf_end,
> > + Â Â Â Â Â Â uint64_t *r)
> > +{
> > + Â const unsigned char *p = buf;
> > + Â unsigned int shift = 0;
> > + Â uint64_t result = 0;
> > + Â unsigned char byte;
> > +
> > + Â while (1)
> > + Â Â {
> > + Â Â Â if (p >= buf_end)
> > + Â Â Â return 0;
> > +
> > + Â Â Â byte = *p++;
> > + Â Â Â result |= ((uint64_t) (byte & 0x7f)) << shift;
> > + Â Â Â if ((byte & 0x80) == 0)
> > + Â Â Â break;
> > + Â Â Â shift += 7;
> > + Â Â }
> > +
> > + Â *r = result;
> > + Â return p - buf;
> > +}
[...]
Regards,
Jan
More information about the Binutils
mailing list