[M3devel] m3gap.... it's an alignment issue

Jay K jay.krell at cornell.edu
Fri Oct 8 20:36:44 CEST 2010


I may have broken this, a while ago. I may have relaxed all the alignments long ago.
We have very little interfacing with C now and most of that is with our own C,
where I avoid small types.
We have had at least temporary problems related to our rules being sort of too strict.
  The need for -munaligned-double or such. (which reminds me I should try that again).
  Where our rules were ok but gcc's default for to align stuff more.
  Where our layout and gcc's didn't agree.

How bad would it be to generate or write a C layer that copies stuff into "idealized" structs?
  Where the types are all INTEGER or LONGINT or pointers.

 - Jay

----------------------------------------
> From: dragisha at m3w.org
> To: m3devel at elegosoft.com
> Date: Fri, 8 Oct 2010 16:17:00 +0200
> Subject: Re: [M3devel] m3gap.... it's an alignment issue
>
> WindowStar is
> TYPE
> Window = RECORD
> user_data: void_star
> END;
> WindowStar = UNTRACED REF Window;
>
> and this whole record is
> typedef struct {
> GdkEventType type;
> GdkWindow *window;
> gint8 send_event;
> guint32 time;
> guint state;
> guint keyval;
> gint length;
> gchar *string;
> guint16 hardware_keycode;
> guint8 group;
> guint is_modifier : 1;
> } GdkEventKey;
>
> in C.
>
> It's Modula-3 BYTESIZE is 64, and C sizeof() is 56. window field is aligned at 8 bytes (thank you Jay for m3gap 8_56!) and C's GdkWindow * is aligned at 4 bytes.
>
> As I don't use window field I'll split it in two placeholder int's, but this is, IMO, interesting point.
>
> dd
>
> On Tue, 2010-10-05 at 15:32 +0200, Dragiša Durić wrote:
> > EventKey = RECORD
> > type: EventType;
> > window: WindowStar;
> > send_event: char;
> > time: unsigned_long_int;
> > state: unsigned_int;
> > keyval: unsigned_int;
> > length: int;
> > string: char_star;
> > hardware_keycode: unsigned_short_int;
> > group: unsigned_char;
> > END;
> >
> > also with m3gdb....
> >
> > (m3gdb) p event
> > $1 = {4type = 8 '\b', _m3gap_8_56 = {}, window = 0x0,
> > send_event = 0 '\000',
> --
> Dragiša Durić 
>
 		 	   		  


More information about the M3devel mailing list