[9] in Pthreads mailing list archive
Re: netdb interfaces
daemon@ATHENA.MIT.EDU (Rich Salz)
Sat Jun 10 03:25:05 1995
From: Rich Salz <rsalz@osf.org>
Date: Sat, 10 Jun 1995 02:57:55 -0400
To: ghudson@MIT.EDU, raeburn@cygnus.com
Cc: pthreads@MIT.EDU
>I don't think any object can ever require alignment greater than its
>own size.
You gotta be careful not to confuse alignment and padding. For example:
struct x { short s; char c; };
I can't find anything in the standard that limits the alignment
requirements an object can have.
>How about implementing it as a structure with a variable-length tail?
Don't do this; it's gross and ugly and nasty and (quoting Ritchie)
"unwarranted chumminess with the compiler." But it works -- DCE RPC
is rife with that construct, and it works. But I hate it.
I don't understand the problem -- what are you trying to do?
Does this solve it, perhaps at the cost of wasting a few bytes?
#define SZ sizeof (struct servent) / sizeof (char*)
union u {
struct servent s;
char *pad[SZ];
};
x = malloc(sizeof (union u) + (1+n_pointers/SZ)*sizeof (union u));
x->s.aliases = &x[1];
/r$