Mailing List Archive
tlug.jp Mailing List tlug archive tlug Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]Re: [tlug] Portability of Misaligned Data Access . . . . . . .
- Date: Thu, 27 Jul 2006 12:12:19 +0900
- From: "Stephen J. Turnbull" <stephen@example.com>
- Subject: Re: [tlug] Portability of Misaligned Data Access . . . . . . .
- References: <20060726125907.GH5111@example.com> <87ejw8corz.fsf@example.com> <20060726164125.4959ce4e.jep200404@example.com> <Pine.BSF.4.58.0607261946521.68592@example.com>
- Organization: The XEmacs Project
- User-agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.5-b27 (linux)
>>>>> "Joe" == Joe Larabell <fred62@???> writes: Joe> In the interest of pedantic portability, C already has a Joe> methor for ensuring that data which must be accessed in Joe> different ways is aligned correctly: union u { char as_str[ sizeof( double ) + 1 ]; struct s { double as_dbl; char a_null; }; }; Joe> As confusing as this looks, this should line the double up Joe> with the first 'n' bytes of the string and match the sizes of Joe> the two representations on any mahine. Yeah, but it's a *lot* uglier than that. Remember the header! What you really need is something like: union { struct { char pad[6]; char input[10]; } namadata; struct { union { struct { char pad[6]; char header[2]; } prefix; double align; } double payload; } yakidata; } do_you_really_expect_to_pull_this_off_interrobang; and even then there's no guarantee you'll get a packed structure, or even that sizeof(char) == 1. I really have to wonder if the format produced by ibrd() really is struct { char header[2]; double payload; } and not struct { char header[2]; char number[8]; } The former looks like an exceptionally nasty and pointless form of data torture. -- School of Systems and Information Engineering http://turnbull.sk.tsukuba.ac.jp University of Tsukuba Tennodai 1-1-1 Tsukuba 305-8573 JAPAN Ask not how you can "do" free software business; ask what your business can "do for" free software.
- Follow-Ups:
- Re: [tlug] Portability of Misaligned Data Access . . . . . . .
- From: Joe Larabell
- References:
- [tlug] issues with format of double (or IEEE754)
- From: Michal Hajek
- Re: [tlug] issues with format of double (or IEEE754)
- From: Stephen J. Turnbull
- [tlug] Portability of Misaligned Data Access . . . . . . . (was Re: issues with format of double (or IEEE754))
- From: Jim
- Re: [tlug] Portability of Misaligned Data Access . . . . . . . (was Re: issues with format of double (or IEEE754))
- From: Joe Larabell
Home | Main Index | Thread Index
- Prev by Date: Re: [tlug] result_normal_plus[2]='\0' likely clobbers payload
- Next by Date: [tlug] Emacs batch commands, over many files
- Previous by thread: Re: [tlug] Portability of Misaligned Data Access . . . . . . . (was Re: issues with format of double (or IEEE754))
- Next by thread: Re: [tlug] Portability of Misaligned Data Access . . . . . . .
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links