[2686] in Kerberos_V5_Development
Re: More Unicos porting hell (struct inaddr)
daemon@ATHENA.MIT.EDU (Assar Westerlund)
Tue Oct 28 16:37:46 1997
To: Ken Hornstein <kenh@cmf.nrl.navy.mil>
Cc: krbdev@MIT.EDU
From: Assar Westerlund <assar@sics.se>
Date: 28 Oct 1997 22:37:23 +0100
In-Reply-To: Ken Hornstein's message of "Tue, 28 Oct 1997 13:56:20 -0500"
Ken Hornstein <kenh@cmf.nrl.navy.mil> writes:
> I _know_ I'm starting to sound like a broken record ... buuutttt ...
But Crays are weird. Yeah, I know. :-)
> Under Unicos, the declaration for struct in_addr is as follows:
>
> struct in_addr {
> #ifndef _CRAY
> u_long s_addr;
> #else /* _CRAY */
> struct {
> u_long st_addr:32;
> } s_da;
> #define s_addr s_da.st_addr
> #define SIZEOF_in_addr 4
> #endif /* _CRAY */
> };
>
> memcpy((char *)p, (char *)&sender->sin_addr, ...)
>
> Is that "correct"? It seems to work fine.
I'm afraid it's not. Assuming sizeof(struct in_addr) == 8, there's no
portable way of telling where in those bytes the compiler will choose
to store `st_addr'.
But the code seems to work on the Cray I've access to.
I don't think there's any portable way other than this:
unsigned char foo[4];
foo[0] = sin_addr.s_addr & 0xFF;
foo[1] = ...
/assar