From owner-freebsd-current Fri Sep 7 3:55:59 2001 Delivered-To: freebsd-current@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id DE8F337B407; Fri, 7 Sep 2001 03:55:55 -0700 (PDT) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id UAA13658; Fri, 7 Sep 2001 20:55:52 +1000 Date: Fri, 7 Sep 2001 20:55:11 +1000 (EST) From: Bruce Evans X-X-Sender: To: John Baldwin Cc: Julian Elischer , Subject: RE: RFC: hack volatile bzero and bcopy In-Reply-To: Message-ID: <20010907203306.J38152-100000@alphplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Thu, 6 Sep 2001, John Baldwin wrote: > On 07-Sep-01 Julian Elischer wrote: > > > > Here is a hack to remove the 20 or so warning messages from if_ie.c No hacks please. I fixed some of these locally a few years ago without using any hacks, but gave up. if_ie.c should be rewritten to not use volatile qualifiers to a fault. > > Most of them are due to the supply of volatile pointers to bcopy and > > bzero. > > > > I do the following to produce macros that call bzero and bcopy, but > > don't produce > > warning messages when called with volatile arguments. > > > > typedef void Xcopy( void volatile *, void volatile *, int); > >#define VBCOPY(A,B,L) (*(Xcopy *)&bcopy)((A),(B),(L)) > > typedef void Xzero( void volatile *, int); > >#define VBZERO(A,L) (*(Xzero *)&bzero)((A),(L)) This just breaks the warning. > sys/cdef.h already has some rather general purpose macros for thsi sort of > thing in the form of __DEVOLATILE(), __DECONST(), and __DEQUALIFY(). These will be terminated with extreme prejudice. Making it easy to break the warnings for removing const qualifiers is bad enough, but there are cases where removing const qualifiers is not a bug. I can't think of any cases where removing volatile qualifiers is not a bug. Well, there are cases where volatile memory becomes unvolatile because you lock it while it is being accessed, but these cases are probably better handled by not declaring it as volatile. In the case of if_ie.c and bcopy(), bcopy() is not suitable for copying memory that doesn't behave like RAM. Some optimized versions of it do out of order and/or repeated copies. This might be very bad for volatile device memory. I think rewriting if_ie.c to use bus_space would make most of the warnings go away automatically. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message