9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: "Ronald G. Minnich" <rminnich@lanl.gov>
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?
Date: Fri, 22 Oct 2004 11:20:42 -0600	[thread overview]
Message-ID: <Pine.LNX.4.58.0410221109560.15945@linux.site> (raw)
In-Reply-To: <5ae212d006c8c514c89c49f0258ebd36@vitanuova.com>



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 <u.h>
#include <libc.h>

#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



  parent reply	other threads:[~2004-10-22 17:20 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-22 15:26 Ronald G. Minnich
2004-10-22 15:30 ` Russ Cox
2004-10-22 15:49   ` C H Forsyth
2004-10-22 16:37     ` Ronald G. Minnich
2004-10-22 16:54       ` C H Forsyth
2004-10-22 21:13         ` Bruce Ellis
2004-10-22 21:00           ` Charles Forsyth
2004-10-22 16:51     ` Russ Cox
2004-10-22 17:27       ` Ronald G. Minnich
2004-10-22 17:20     ` Ronald G. Minnich [this message]
2004-10-22 17:28       ` Russ Cox
2004-10-22 17:30         ` Ronald G. Minnich
2004-10-22 17:29       ` jmk
2004-10-22 17:31         ` Ronald G. Minnich
2004-10-22 17:50           ` Brantley Coile
2004-10-22 18:32         ` C H Forsyth
2004-10-22 18:14       ` Charles Forsyth
2004-10-22 19:25       ` boyd, rounin
2004-10-22 19:35         ` Ronald G. Minnich
2004-10-22 19:38           ` boyd, rounin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.58.0410221109560.15945@linux.site \
    --to=rminnich@lanl.gov \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).