Date: Fri, 8 Oct 2004 20:56:39 -0500 From: Dan Nelson <dnelson@allantgroup.com> To: "Li, Qing" <qing.li@bluecoat.com> Cc: freebsd-hackers@freebsd.org Subject: Re: Bit field definition ? Message-ID: <20041009015639.GB3106@dan.emsphone.com> In-Reply-To: <00CDF9AA240E204FA6E923BD35BC643606BF68E3@bcs-mail.internal.cacheflow.com> References: <00CDF9AA240E204FA6E923BD35BC643606BF68E3@bcs-mail.internal.cacheflow.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20041009015639.GB3106>