Re: [PATCH] Allow 64-bit enum values

Siddhesh Poyarekar
2012-03-28T04:19:57Z

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