Re: [PATCH v2] Expand bitpos and type.length to LONGEST and ULONGEST

Jan Kratochvil
2012-05-24T15:01:30Z

On Thu, 24 May 2012 03:36:34 +0200, Siddhesh Poyarekar wrote:
> On Wed, 23 May 2012 19:46:10 +0200, Jan wrote:
> > On Wed, 23 May 2012 15:52:45 +0200, Siddhesh Poyarekar wrote:
> > > > > static void
> > > > > -copy_bitwise (gdb_byte *dest, unsigned int dest_offset_bits,
> > > > > - const gdb_byte *source, unsigned int
> > > > > source_offset_bits,
> > > > > - unsigned int bit_count,
> > > > > +copy_bitwise (gdb_byte *dest, ULONGEST dest_offset_bits,
> > > > > + const gdb_byte *source, ULONGEST source_offset,
> > > > > + ULONGEST bit_count,
> > > > > int bits_big_endian)
> > > > > {
> > > > > - unsigned int dest_avail;
> > > > > + unsigned int dest_avail, source_offset_bits;
> > > > > int datum;
> > > > >
> > > > > /* Reduce everything to byte-size pieces. */
> > > > > dest += dest_offset_bits / 8;
> > > > > dest_offset_bits %= 8;
> > > > > - source += source_offset_bits / 8;
> > > > > - source_offset_bits %= 8;
> > > > > + source += source_offset / 8;
> > > > > + source_offset_bits = source_offset % 8;
[...]
> dest_offset_bits is safe to be truncated when passing into insert_bits.
> The trouble with source_offset_bits is that its pointer is passed into
> extract_bits, because of which the function signature change becomes
> non-optional unless just a cast is OK here.

Understood/agreed, due to:
datum = extract_bits (&source, &source_offset_bits, 8, bits_big_endian);

Thanks,
Jan