From owner-freebsd-questions Thu Jan 31 19:14:24 2002 Delivered-To: freebsd-questions@freebsd.org Received: from post.mail.nl.demon.net (post-10.mail.nl.demon.net [194.159.73.20]) by hub.freebsd.org (Postfix) with ESMTP id 7C13E37B41A for ; Thu, 31 Jan 2002 19:14:20 -0800 (PST) Received: from [212.238.194.207] (helo=tanya.raggedclown.net) by post.mail.nl.demon.net with esmtp (Exim 3.33 #1) id 16WU9X-0002fj-00 for freebsd-questions@freebsd.org; Fri, 01 Feb 2002 03:14:15 +0000 Received: by tanya.raggedclown.net (tanya.raggedclown.intra, from userid 500) id 0146A44F6B; Fri, 1 Feb 2002 04:14:12 +0100 (CET) Date: Fri, 1 Feb 2002 04:14:12 +0100 From: Cliff Sarginson To: freebsd-questions@freebsd.org Subject: Re: unsigned char portability Message-ID: <20020201031412.GA1950@raggedclown.net> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.3.24i Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Thu, Jan 31, 2002 at 09:39:17PM +0000, Christian Weisgerber wrote: > June Carey 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