[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