Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 31 Jan 2002 21:39:17 +0000 (UTC)
From:      naddy@mips.inka.de (Christian Weisgerber)
To:        freebsd-questions@freebsd.org
Subject:   Re: unsigned char portability
Message-ID:  <a3cdi5$19e5$1@kemoauc.mips.inka.de>
References:  <F74DyNdauuNi4kysRWz00010abe@hotmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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.

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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?a3cdi5$19e5$1>