From owner-cvs-src@FreeBSD.ORG Sun Apr 6 00:36:13 2003 Return-Path: Delivered-To: cvs-src@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 936FC37B401; Sun, 6 Apr 2003 00:36:13 -0800 (PST) Received: from fafoe.dyndns.org (chello212186121237.14.vie.surfer.at [212.186.121.237]) by mx1.FreeBSD.org (Postfix) with ESMTP id AD96643F93; Sun, 6 Apr 2003 00:36:12 -0800 (PST) (envelope-from stefan@fafoe.dyndns.org) Received: from frog.fafoe (frog.fafoe [192.168.2.101]) by fafoe.dyndns.org (Postfix) with ESMTP id 754DB3FC4; Sun, 6 Apr 2003 10:36:08 +0200 (CEST) Received: by frog.fafoe (Postfix, from userid 1001) id 0F25C136; Sun, 6 Apr 2003 10:36:07 +0200 (CEST) Date: Sun, 6 Apr 2003 10:36:06 +0200 From: Stefan Farfeleder To: Bruce Evans References: <200304052346.h35Nkwoi037742@repoman.freebsd.org> <20030406134416.A3578@gamplex.bde.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030406134416.A3578@gamplex.bde.org> User-Agent: Mutt/1.5.4i Message-Id: <20030406083608.754DB3FC4@fafoe.dyndns.org> cc: Maxime Henrion cc: cvs-src@FreeBSD.org cc: src-committers@FreeBSD.org cc: cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sys/dev/fxp if_fxpreg.h X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Apr 2003 08:36:14 -0000 On Sun, Apr 06, 2003 at 02:16:07PM +1000, Bruce Evans wrote: > On Sat, 5 Apr 2003, Maxime Henrion wrote: > > > mux 2003/04/05 15:46:58 PST > > > > FreeBSD src repository > > > > Modified files: > > sys/dev/fxp if_fxpreg.h > > Log: > > ... > > - Change some u_int to u_int8_t which make more sense here since > > we're really defining bytes. That produces the same code due to > > how bitfields work. > > This gives undefined behaviour and thus produces random code if it is > compiled by a C compiler (unless Bool_t happens to be u_int8_t). From > n869.txt: > > [#8] A bit-field shall have a type that is a qualified or > unqualified version of _Bool, signed int, or unsigned int. > > I fixed this bug in many places, including in rev.1.13 of if_fxpreg.h. > but it keeps getting reintroduced :-(. > > Bit-fields of other integer types are an unportable gcc extension. > They affect the struct layout in unportable apparently-undocumented > ways. IIRC, they don't affect internal padding but they do affect the > size and alignment the struct -- a struct that has only uint8_t > bit-fields in it has only the size and alignment requirements of > uint8_t, while a struct with only u_int bit-fields in it has the size > and alignment requirements of u_int. This may be controlled to some > extent using other unportable gcc extensions. FYI, the final standard says 4 A bit-field shall have a type that is a qualified or unqualified version of _Bool, signed int, unsigned int, or some other implementation-defined type. and moved it from the Semantics to the Constraints section, so a C compiler not supporting u_int8_t has to issue at least a diagnostic before producing random code :) Regards, Stefan Farfeleder