Subject: Re: Fun with structure alignment
To: Richard Earnshaw <rearnsha@buzzard.freeserve.co.uk>
From: Ben Harris <bjh21@netbsd.org>
List: port-arm32
Date: 02/12/2001 23:56:37
On Mon, 12 Feb 2001, Richard Earnshaw wrote:

> > I've just been reminded of the awkward state of structure alignment in
> > NetBSD/arm32, and it looks to me like this could actually turn out to be a
> > serious problem.
> > 
> > The problem is that some of the structures passed between the kernel and
> > user space (e.g. struct wscons_keymap) are affected by changing the
> > structure padding rules.  This means that if NetBSD/arm32 is going to move
> > to the standard ARM padding rules, there'll need to be a compatibility
> > layer to allow old binaries to run.  Anyone feel like implementing it?
> 
> I don't think it's as much structure alignment that is changing but
> structure padding.  This will only affect structures that contain
> other structures that are in turn not naturally word-sized (structures
> whose only members are less than one word in size).
> 
> Are there many such structures that pass across the interface?

Well, struct wscons_keymap looks like this:

typedef u_int16_t keysym_t;

struct wscons_keymap {
        keysym_t command;
        keysym_t group1[2];
        keysym_t group2[2];
};

An array of these gets passed across when wsconsctl gets or sets the
keymap.  Are arrays affected?

Hmm.  Perhaps I was being a little too twitchy.  I haven't yet found
another structure that looks like it might cause problems.

> PS.  wscons was never implemented for RPC or SHARK.  Was it ever done
> for CATS?

The port/feature cross reference (<URL:http://www.netbsd.org/developers/
features/>) lists wscons on arm32 as "Partial", so presumably something's
using it.

-- 
Ben Harris                                                   <bjh21@netbsd.org>
Portmaster, NetBSD/arm26               <URL:http://www.netbsd.org/Ports/arm26/>