9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] ureg alignment
@ 2014-05-09 14:21 erik quanstrom
  2014-05-09 14:28 ` Steven Stallion
  2014-05-09 14:56 ` Charles Forsyth
  0 siblings, 2 replies; 7+ messages in thread
From: erik quanstrom @ 2014-05-09 14:21 UTC (permalink / raw)
  To: 9fans

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



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-05-09 15:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-09 14:21 [9fans] ureg alignment erik quanstrom
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

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).