[PATCH] Allow 64-bit enum values

Siddhesh Poyarekar siddhesh@redhat.com
Wed Mar 28 04:19:00 GMT 2012


On Tue, 27 Mar 2012 18:59:50 +0200
Jan Kratochvil <jan.kratochvil@redhat.com> wrote:
> Sorry for respoding so late but what is the point of this enum and
> offsets separation? Both need to become 64bit anyway so why to
> separate them?
> 
> Or you find it a better coding style this way?

Better coding style is one of the reasons, to make the meaning of the
elements unambiguous. The main reason for this separation is to match
the types of bitpos and type.length exactly to retain the possibility
of a typedef'd struct for their type. Something like:

typedef struct
{
  ULONGEST val;
} struct_off_t;

#define STRUCT_OFF_VAL(s) ((s).val)

#define TYPE_LENGTH_VAL(t) STRUCT_OFF_VAL(TYPE_LENGTH(t))
#define TYPE_FIELD_BITPOS_VAL(t) STRUCT_OFF_VAL(TYPE_FIELD_BITPOS(t))

and do arithmetic like this:

---
struct_off_t offset;

return TYPE_LENGTH_VAL(t) + STRUCT_OFF_VAL(offset)
       - TYPE_FIELD_BITPOS_VAL(t)
---

I hope this is OK.


Regards,
Siddhesh



More information about the Gdb-patches mailing list