From owner-freebsd-hackers@FreeBSD.ORG Sat Oct 9 01:57:02 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4F3C616A4CE for ; Sat, 9 Oct 2004 01:57:02 +0000 (GMT) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id E8DF243D2D for ; Sat, 9 Oct 2004 01:57:01 +0000 (GMT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.12.11/8.12.11) id i991udox086584; Fri, 8 Oct 2004 20:56:39 -0500 (CDT) (envelope-from dan) Date: Fri, 8 Oct 2004 20:56:39 -0500 From: Dan Nelson To: "Li, Qing" Message-ID: <20041009015639.GB3106@dan.emsphone.com> References: <00CDF9AA240E204FA6E923BD35BC643606BF68E3@bcs-mail.internal.cacheflow.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <00CDF9AA240E204FA6E923BD35BC643606BF68E3@bcs-mail.internal.cacheflow.com> X-OS: FreeBSD 5.3-BETA7 X-message-flag: Outlook Error User-Agent: Mutt/1.5.6i cc: freebsd-hackers@freebsd.org Subject: Re: Bit field definition ? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Oct 2004 01:57:02 -0000 In the last episode (Oct 08), Li, Qing said: > The bit fields "th_x2" and "th_off" in "struct tcphdr", > even though defined as "u_int", actually occupies 1 byte. u_int th_x2:4, /* (unused) */ th_off:4; /* data offset */ The :4 after each variable means 4 bits long, so both fields together take up 8 bits = 1 byte. That's the whole purpose of bitfields :) -- Dan Nelson dnelson@allantgroup.com