9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: erik quanstrom <quanstro@quanstro.net>
To: 9fans@9fans.net
Subject: [9fans] ureg alignment
Date: Fri,  9 May 2014 10:21:50 -0400	[thread overview]
Message-ID: <51d4d8ec419f841a99baf30ede300c25@brasstown.quanstro.net> (raw)

on 64-bit machines, the unions in the ureg.h can lead to
internal padding.  (power64 avoids this issue because everything
is 64-bit aligned anyway.)  to sidestep the issue, i think
it might make sense to use #defines.  for example, for arm
the conversion would look something like this:

typedef struct Ureg {
	ulong	r0;
	ulong	r1;
	ulong	r2;
	ulong	r3;
	ulong	r4;
	ulong	r5;
	ulong	r6;
	ulong	r7;
	ulong	r8;
	ulong	r9;
	ulong	r10;
	ulong	r11;
	ulong	r12;	/* sb */
	ulong	r13;
#define	sp	r13
	ulong	r14;
#define	link	r14
	ulong	type;	/* of exception */
	ulong	psr;
	ulong	pc;	/* interrupted addr */
} Ureg;

is there any reason not to do this?

- erik



             reply	other threads:[~2014-05-09 14:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-09 14:21 erik quanstrom [this message]
2014-05-09 14:28 ` Steven Stallion
2014-05-09 14:31   ` erik quanstrom
2014-05-09 14:56 ` Charles Forsyth
2014-05-09 15:29   ` erik quanstrom
2014-05-09 15:45     ` Charles Forsyth
2014-05-09 15:52       ` erik quanstrom

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51d4d8ec419f841a99baf30ede300c25@brasstown.quanstro.net \
    --to=quanstro@quanstro.net \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).