Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site watdaisy.UUCP Path: utzoo!watmath!watdaisy!ndiamond From: ndiamond@watdaisy.UUCP (Norman Diamond) Newsgroups: net.lang.c Subject: Re: Un-alignment in structures Message-ID: <7108@watdaisy.UUCP> Date: Thu, 21-Mar-85 19:41:29 EST Article-I.D.: watdaisy.7108 Posted: Thu Mar 21 19:41:29 1985 Date-Received: Fri, 22-Mar-85 01:25:16 EST References: <9239@brl-tgr.ARPA>, <120@mit-athena.UUCP> <2821@ncsu.UUCP> Organization: U of Waterloo, Ontario Lines: 43 > When asking for unaligned structures in C, don't forget to ask that > they be unaligned at the BIT level, because you might want to read > tapes containing 36 or 60 bit words. A 36-bit or 60-bit machine already has to make adjustments, regardless of programming language or compiler or options. 9-track tapes, with 1 parity bit, have 8-bit bytes written on them. Similarly, networks are generally specified to have 7-bit or 8-bit data, or 7-bit padded with a zero bit or with parity. The machine already must do some conversion. Why make it so much harder for a C programmer to complete the conversion? > Also make sure that the compiler > supports viewing numbers as having their bytes interchanged, because you > might want to go from the VAX to something sane, occasionally. If a machine's ports reverse the bytes from the protocol specified by the network, then that machine's programs must make adjustments. Again, why should C make it harder? Or if it's on tape, it is already known that data other than character strings cannot really be regarded as portable. > So we'll have to go > with the next-best thing: a library of good, generic data-conversion routines. > Fortunately, C provides lots of support for writing generic procedures. But to overcome the padding, they will have to be in assembly or will have to convert bytes (out of a char array) into ints. For that matter, even the char array doesn't work well on some machines; it may have to be assembly. Yes I understand the earlier suggestion about a smiley face -- though the submission wasn't just a joke, it was rhetoric with a certain message intended. I replied to the message. -- Norman Diamond UUCP: {decvax|utzoo|ihnp4|allegra}!watmath!watdaisy!ndiamond CSNET: ndiamond%watdaisy@waterloo.csnet ARPA: ndiamond%watdaisy%waterloo.csnet@csnet-relay.arpa "Opinions are those of the keyboard, and do not reflect on me or higher-ups."