Path: utzoo!mnetor!uunet!husc6!think!barmar From: barmar@think.COM (Barry Margolin) Newsgroups: comp.arch Subject: Re: RISC data alignment Message-ID: <16950@think.UUCP> Date: 19 Feb 88 18:21:21 GMT References: <2635@calmasd.GE.COM> <28200092@ccvaxa> <496@ecrcvax.UUCP> <3001@bloom-beacon.MIT.EDU> <2047@rti.UUCP> Sender: usenet@think.UUCP Reply-To: barmar@fafnir.think.com.UUCP (Barry Margolin) Organization: Thinking Machines Corporation, Cambridge, MA Lines: 28 In article <2047@rti.UUCP> mcm@rti.UUCP (Mike Mitchell) writes: >I have written device drivers where I created a structure to hold >the memory-mapped status registers. Some of the hardware had very >strange memory alignments, and if the structure elements were changed, >the driver would break. Such uses are inherently non-portable, so all that matters is whether the particular C compiler you are using provides a way to specify the order. Also, there is nothing in C that requires a particular alignment scheme, so a C compiler that aligned shorts at double-word boundaries would be within its rights, although it would screw up your example (all that the C spec specifies is that the addresses increase, but not by how much). > struct ttport { > short t_tbaud; /* xmit baud rate */ > char t_txt; /* transmitted character */ > short t_rbaud; /* recv baud rate */ > char t_rec; /* received character */ > } *csr = 0xFF8000; /* address of device */ And that assignment definitely isn't portable. Barry Margolin Thinking Machines Corp. barmar@think.com uunet!think!barmar