Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 1 Feb 2002 04:14:12 +0100
From:      Cliff Sarginson <cliff@raggedclown.net>
To:        freebsd-questions@freebsd.org
Subject:   Re: unsigned char portability
Message-ID:  <20020201031412.GA1950@raggedclown.net>
In-Reply-To: <a3cdi5$19e5$1@kemoauc.mips.inka.de>
References:  <F74DyNdauuNi4kysRWz00010abe@hotmail.com> <a3cdi5$19e5$1@kemoauc.mips.inka.de>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Jan 31, 2002 at 09:39:17PM +0000, Christian Weisgerber wrote:
> June Carey <carey_june@hotmail.com> wrote:
> 
> > I have a question I was hoping someone could answer.
> > Does the "unsigned char" C type have any machine architecture portability 
> > problems ?
> 
> For one thing, you don't know its size.  I'm told there are C
> implementations on DSPs and such that have 32-bit chars, simply
> because those processors don't support other datasizes or byte
> addressing.  Now whether you care about portability to such platforms
> is a different matter.
>

That doesn't matter, as long as you don't take liberties on it's assumed
size, i.e. if it matters use "sizeof", don't fiddle with it inside an aggregate 
like a struct except as a member of that struct, you can always treat is an
unsigned 8 bit quantity even on a Risc machine, where it's "real" size
will probably not be 8 bits (it is irrelevant whether the OS is FreeBSD
or not).

> As far as FreeBSD is concerned, i.e. any platform FreeBSD is likely
> to be ported to, you can assume an unsigned char to refer to an
> unsigned 8-bit integer.
> 
> > I rather suspect the answer is NO, since I seem to recall that "The Design 
> > and Implementation of the 4.4BSD Operating System" book mentions that 
> > bytes/octets are network portable in their native bit-ordering.
> 
> Just like memory, networks tend to treat the octet as the atomic
> unit of transmission.  Of course you need to worry about bit-ordering
> any time you serialize an octet, but that is usually handled in
> hardware.
> 
> -- 
> Christian "naddy" Weisgerber                          naddy@mips.inka.de
> 
> 
> To Unsubscribe: send mail to majordomo@FreeBSD.org
> with "unsubscribe freebsd-questions" in the body of the message

-- 
Regards
Cliff



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020201031412.GA1950>