Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Alignment Issues with *ManagedStruct?

Newsgroups: perl.perl6.internals
Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.stanford.edu!nntp.perl.org
Return-Path: <l...@toetsch.at>
Mailing-List: contact perl6-internals-h...@perl.org; run by ezmlm
Delivered-To: mailing list perl6-intern...@perl.org
Received: (qmail 95915 invoked by uid 76); 4 Feb 2004 22:12:15 -0000
Received: from qma...@one.develooper.com (HELO ran-out.mx.develooper.com) (64.81.84.115) by onion.perl.org (qpsmtpd/0.26) with SMTP; Wed, 04 Feb 2004 14:12:15 -0800
Received: (qmail 29451 invoked by uid 225); 4 Feb 2004 21:52:43 -0000
Delivered-To: perl6-intern...@perl.org
Received: (qmail 29409 invoked by uid 507); 4 Feb 2004 21:52:40 -0000
Received: from mail.nextra.at (HELO mail.nextra.at) (195.170.70.100)  by one.develooper.com (qpsmtpd/0.27-dev) with ESMTP; Wed, 04 Feb 2004 13:52:08 -0800
Received: from lux.leo.home (at24a01-dial-141.nextranet.at [195.170.73.141])	by mail.nextra.at (20030919/20030919/nextra) with ESMTP id i14LoFwp002310;	Wed, 4 Feb 2004 22:50:16 +0100 (MET)
Received: from thu8.leo.home (thu8.leo.home [192.168.1.5])	by lux.leo.home (Postfix on linux 2.0.36 (i386)) with ESMTP	id 1FBF9118023; Wed,  4 Feb 2004 22:36:50 +0100 (MET)
Received: (from lt@localhost)	by thu8.leo.home (8.10.2/8.10.2/SuSE Linux 8.10.0-0.3) id i14LaMw28693;	Wed, 4 Feb 2004 22:36:22 +0100
Message-ID: <200402042136.i14LaMw28693@thu8.leo.home>
To: chroma...@wgz.org (Chromatic)
Subject: Re: Alignment Issues with *ManagedStruct?
In-Reply-To: <1075925266.25662.28.camel@localhost>
References: <1075792412.21791.36.camel@localhost>  <200402030858.i138wmZ05366@thu8.leo.home>  <1075845748.23721.32.camel@localhost>  <200402040852.i148qYa10172@thu8.leo.home> <1075925266.25662.28.camel@localhost>
Reply-To: l...@toetsch.at
Cc: perl6-intern...@perl.org
Date: Wed, 4 Feb 2004 22:36:22 +0100
X-Spam-Check-By: one.develooper.com
X-Spam-Status: No, hits=-1.0 required=7.0 tests=CARRIAGE_RETURNS,IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES,SPAM_PHRASE_02_03 version=2.44
X-SMTPD: qpsmtpd/0.26, http://develooper.com/code/qpsmtpd/
Approved: n...@nntp.perl.org
From: l...@toetsch.at (Leopold Toetsch)

Chromatic <chroma...@wgz.org> wrote:

> In this case, it doesn't, as the struct I'm emulating is:

> 	typedef struct {
>     		Uint8 type; /* SDL_KEYDOWN or SDL_KEYUP */
>     		Uint8 which;    /* The keyboard device index */
>     		Uint8 state;    /* SDL_PRESSED or SDL_RELEASED */
> 	    	SDL_keysym keysym;
> 	} SDL_KeyboardEvent;

> SDL_keysym itself is a struct:

> 	typedef struct {
>     		Uint8 scancode;         /* hardware specific */
>     		SDLKey sym;         /* SDL virtual keysym */
>     		SDLMod mod;         /* current key modifiers */
>     		Uint16 unicode;         /* translated character */
> 	} SDL_keysym;

> SDLKey and SDLMod are both enums.

> As I understand it (and correct me if I'm wrong), SDL_keysym needs a
> byte of padding on my architecture within SDL_KeyboardEvent.

Brr. I don't know. I've to ask my debugger for that :) If you have
SDL_keysym alone, that needs 3 bytes additional alignment. But don't ask
me about the combined structure.

But I'd say that there are four adjacent Uint8 taking one word, then is
another word (SDLkey sym). Or a structure starts aligned ...

We don't have a notion of nested structures. They could go just inline,
i.e. without extra syntax. Pointers to structures are of course missing
too, that's a different thingy.

> I can add
> that padding manually, but I'm not convinced that'll be portable to
> different architectures.

Automatic alignment based on the data type sizes is for sure better.

> -- c

leo