This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB 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: [PATCH] Allow 64-bit enum values


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


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