gm2
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gm2] translating C bit fields


From: Dragiša Durić
Subject: Re: [Gm2] translating C bit fields
Date: Wed, 23 Nov 2011 12:40:41 +0100

Gaius,

IMO - we also need a mechanism to fix a sequence of fields to word boundary. Obviousy, a field without "BY" will fit to its default alignment position, but what if we have

type = RECORD
  foo: INTEGER BY 2;
  bar: CARDINAL BY 4;
  butalso: CARDINAL BY 2; (* and we need to have this aligned to some boundary… *)
END;

Alignment can be pretty complicated these days when on same architecture some people decide to align 64 bit values to  byte positions divisible by 8… And other do not. I met such a situation while wrapping Gtk2 to Modula-3… gcc aligns such values to divisible-by-4 byte positions, while cm3 aligns to divisible-by-8…

dd

On Nov 23, 2011, at 12:26 PM, Gaius Mulley wrote:

Hi Scott,

I wonder whether a more pragmatic approach might be to mirror the C
semantics for bit fields but with Modula-2 syntax of course.  So for
example:


  type = RECORD
            foo: INTEGER BY 2;
            bar: CARDINAL BY 4;
         END ;


reply via email to

[Prev in Thread] Current Thread [Next in Thread]