This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA] leb128.h: New file.


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]