From owner-freebsd-questions@FreeBSD.ORG Thu Mar 3 21:03:33 2011 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E90BA106564A for ; Thu, 3 Mar 2011 21:03:33 +0000 (UTC) (envelope-from erikt@midgard.homeip.net) Received: from ch-smtp02.sth.basefarm.net (ch-smtp02.sth.basefarm.net [80.76.149.213]) by mx1.freebsd.org (Postfix) with ESMTP id 79D618FC16 for ; Thu, 3 Mar 2011 21:03:33 +0000 (UTC) Received: from c83-255-51-20.bredband.comhem.se ([83.255.51.20]:27809 helo=falcon.midgard.homeip.net) by ch-smtp02.sth.basefarm.net with esmtp (Exim 4.73) (envelope-from ) id 1PvFTP-00040B-7G for freebsd-questions@freebsd.org; Thu, 03 Mar 2011 21:50:13 +0100 Received: (qmail 29780 invoked from network); 3 Mar 2011 21:50:10 +0100 Received: from owl.midgard.homeip.net (10.1.5.7) by falcon.midgard.homeip.net with ESMTP; 3 Mar 2011 21:50:10 +0100 Received: (qmail 47685 invoked by uid 1001); 3 Mar 2011 21:50:10 +0100 Date: Thu, 3 Mar 2011 21:50:10 +0100 From: Erik Trulsson To: Frank Solensky Message-ID: <20110303205010.GA47653@owl.midgard.homeip.net> References: <910E776A-D865-4F78-8BE5-E974326636D0@solensky.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <910E776A-D865-4F78-8BE5-E974326636D0@solensky.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Originating-IP: 83.255.51.20 X-Scan-Result: No virus found in message 1PvFTP-00040B-7G. X-Scan-Signature: ch-smtp02.sth.basefarm.net 1PvFTP-00040B-7G 1aafc1c9830b4c3582292ab65108945b Cc: freebsd-questions@freebsd.org Subject: Re: Bit order == byte order?? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Mar 2011 21:03:34 -0000 On Thu, Mar 03, 2011 at 11:26:12AM -0500, Frank Solensky wrote: > In sys/netinet/ip.h, the first octet of the ip header structure tests > the byte ordering to determine the ordering of the header length > (ip_hl) and version (ip_v) fields. > > My question: that always works? While my reading of the language > specification document leaves both the ordering of the bits within a > byte and the bytes within a longer field as implementation choices, > the two are independent of each other. > > I haven't run into a CPU where this assumption was proven incorrect. > It just surprised me to see that recently Unless you have a CPU where memory is addressed bit-by-bit rather than byte-by-byte the ordering of bits within a byte is not only completely irrelevant, it is also pretty much impossible to determine programatically. -- Erik Trulsson ertr1013@student.uu.se