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

Dragiša Durić dragisha at m3w.org
Fri Oct 8 16:17:00 CEST 2010


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 = {<No data fields>}, window = 0x0,
> send_event = 0 '\000', 
-- 
Dragiša Durić <dragisha at m3w.org>




More information about the M3devel mailing list