From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Fri, 22 Oct 2004 11:20:42 -0600 From: "Ronald G. Minnich" To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu> Subject: Re: [9fans] am I nuts? does 8c support packed structs? In-Reply-To: <5ae212d006c8c514c89c49f0258ebd36@vitanuova.com> Message-ID: References: <5ae212d006c8c514c89c49f0258ebd36@vitanuova.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Topicbox-Message-UUID: f3e5a38e-eacd-11e9-9e20-41e7f4b1d025 On Fri, 22 Oct 2004, C H Forsyth wrote: > hj were only dicks on the mips it seems, but it's easy to add it to 8c. > Here's a test of dicks on 8c today: #include #include #pragma hjdicks on struct a {unsigned long x; char c; }; #pragma hjdicks off struct a a; main(){ print("size %d\n", sizeof(a)); } This yields 8, with dicks on or off. In gcc, for this: struct a {unsigned long x; char c; } __attribute__ ((packed)); struct a *a = 0; main(){ printf("size %d, addr %p\n", sizeof(*a), &a->c); } you get a size of 5. "How do you create TCP headers without packed structs?" is one question I got. I guess Plan 9 is quite possibly the "here's how" except of course everyone did this before packed structs (or even gcc, or even before C compilers that aligned structs and struct members for that matter -- was there a C compiler before gcc? one wonders. The mind boggles). Unless there's another 8c pragma I have not heard of, I'll stuck to marshalling data by hand. ron