[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gm2] translating C bit fields
From: |
Gaius Mulley |
Subject: |
Re: [Gm2] translating C bit fields |
Date: |
Wed, 23 Nov 2011 14:29:39 +0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) |
Dragiša Durić <address@hidden> writes:
> 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…
Hi Dragiša,
ok - how about:
type = RECORD
foo: INTEGER BY 2;
bar: CARDINAL BY 4;
butalso: CARDINAL MOD 4 BY 2; (* and we need to have this aligned to some
boundary *)
END;
so we extend the ebnf to include:
FieldAlignment := [ ByteAlignment | BitAlignment ] =:
BitAlignment := [ 'MOD' ConstExpression ] 'BY' ConstExpression =:
ByteAlignment := "__ATTRIBUTE__" "(" "(" Ident "(" ConstExpression ")" ")" ")"
=:
where the MOD indicates the byte alignment and BY indicates the bit
length? MOD 0 indicates packed, MOD 1 the next byte.
regards,
Gaius
- [Gm2] translating C bit fields, SiTex Graphics, 2011/11/16
- Re: [Gm2] translating C bit fields, Gaius Mulley, 2011/11/19
- Re: [Gm2] translating C bit fields, SiTex Graphics, 2011/11/21
- Re: [Gm2] translating C bit fields, Gaius Mulley, 2011/11/23
- Re: [Gm2] translating C bit fields, Dragiša Durić, 2011/11/23
- Re: [Gm2] translating C bit fields,
Gaius Mulley <=
- Re: [Gm2] translating C bit fields, Dragiša Durić, 2011/11/23
- Re: [Gm2] translating C bit fields, SiTex Graphics, 2011/11/23
- Re: [Gm2] translating C bit fields, Dragiša Durić, 2011/11/23
- Re: [Gm2] translating C bit fields, Fischlin Andreas, 2011/11/24
- Re: [Gm2] translating C bit fields, Gaius Mulley, 2011/11/23