From owner-cvs-all Tue Jul 3 14:50:18 2001 Delivered-To: cvs-all@freebsd.org Received: from sax.sax.de (sax.sax.de [193.175.26.33]) by hub.freebsd.org (Postfix) with ESMTP id B231B37B406; Tue, 3 Jul 2001 14:50:09 -0700 (PDT) (envelope-from j@uriah.heep.sax.de) Received: (from uucp@localhost) by sax.sax.de (8.9.3/8.9.3) with UUCP id XAA21118; Tue, 3 Jul 2001 23:50:08 +0200 (CEST) Received: (from j@localhost) by uriah.heep.sax.de (8.11.4/8.11.4) id f63LXLC08427; Tue, 3 Jul 2001 23:33:21 +0200 (MET DST) (envelope-from j) Date: Tue, 3 Jul 2001 23:33:21 +0200 From: Joerg Wunsch To: cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sys/sys bio.h Message-ID: <20010703233321.C3398@uriah.heep.sax.de> Reply-To: Joerg Wunsch References: <20010703193214.A3398@uriah.heep.sax.de> <200107032051.f63KpIm01502@mass.dis.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0.1i In-Reply-To: <200107032051.f63KpIm01502@mass.dis.org>; from msmith@FreeBSD.org on Tue, Jul 03, 2001 at 01:51:18PM -0700 X-Phone: +49-351-2012 669 X-PGP-Fingerprint: DC 47 E6 E4 FF A6 E9 8F 93 21 E0 7D F9 12 D6 4E Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG As Mike Smith wrote: > > Because i need to fill in a cmd value anyway, and neither of the > > existing didn't fit well. Maybe a single CMD_PRIVATE value would have > > sufficed, but i rather followed the other examples (CMD_FLAG{1,2} > > etc). > > Neither of these was at all necesssary. Well, a bio_cmd /is/ necessary. ;-) > > Also, using a void * would have complicated matters pretty much. It's > > invalid to abuse a void * as an int > > Er, no it's not. > > void *foo; > int bar; > > bar = (int)(uintptr_t)foo; > > foo = (void *)(uintptr_t)bar; I think that's wrong C. AFAIR, an arbitrary /pointer/ is allowed to be cast to a void *, and then cast back to just that arbitrary pointer, and this is the only valid operation on void pointers. Casting a scaler type to a void * and back is not a valid operation. (First, the machine might have a different bit length for pointers and scalars, and IMHO it's even possible that a machine has an entirely different address space for pointers and scalars, something like the IA32 architecture has different address spaces for memory and IO pointers.) Someone with a better standards background than me might comment on this. For the time being, here's the reference to K&R2 (p 199): ``A6.8 Pointers to Void Any pointer to an object may be converted to type void * without loss of information. If the result is converted back to the original pointer type, the original pointer is recovered. [...]'' So only pointers are allowed here. > If you need a private 'command' structure to pass stuff around > inside your driver, perhaps you should just create one? I don't need a private structure (i would have malloced it then), just a few values in a private scalar variable/field (only a couple of values would have sufficed for me, but bde pointed out that something like the ATA driver might have use for more distinct values here). No, the normal driver's softc doesn't work very well since it's not coupled to a request. (It would incidentally have worked just in that case, since the caller waits for the strategy function to complete, so noone else can setup a new request during that time. But abusing the device's softc for things that logically belong into struct bio wouldn't make things better.) BIO_FORMAT has probably been wrong as well. It could have been covered by a BIO_PRIVATE command + 32 bits of driver-private space in struct bio that are not declared to be a pointer. -- cheers, J"org .-.-. --... ...-- -.. . DL8DTL http://www.sax.de/~joerg/ NIC: JW11-RIPE Never trust an operating system you don't have sources for. ;-) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message