From owner-freebsd-hackers Tue Mar 4 19:10: 8 2003 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 DDA2A37B401 for ; Tue, 4 Mar 2003 19:10:05 -0800 (PST) Received: from harmony.village.org (rover.bsdimp.com [204.144.255.66]) by mx1.FreeBSD.org (Postfix) with ESMTP id F134043FAF for ; Tue, 4 Mar 2003 19:10:04 -0800 (PST) (envelope-from imp@bsdimp.com) Received: from localhost (warner@rover2.village.org [10.0.0.1]) by harmony.village.org (8.12.8/8.12.3) with ESMTP id h253A3A7025110; Tue, 4 Mar 2003 20:10:03 -0700 (MST) (envelope-from imp@bsdimp.com) Date: Tue, 04 Mar 2003 20:09:54 -0700 (MST) Message-Id: <20030304.200954.18843267.imp@bsdimp.com> To: kutulu@kutulu.org Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: D_KQFILTER & ltmdm: Patch for review? From: "M. Warner Losh" In-Reply-To: <20030304.194917.100118237.imp@bsdimp.com> References: <01be01c2e2b6$30742b00$29330f0a@lcapps.educate.com> <20030304.194917.100118237.imp@bsdimp.com> X-Mailer: Mew version 2.1 on Emacs 21.2 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG In message: <20030304.194917.100118237.imp@bsdimp.com> "M. Warner Losh" writes: : : static struct cdevsw sio_cdevsw = { : : +#if __FreeBSD_version >= 500104 /* >= 20030303 */ : : This syntax works even for old versions of FreeBSD. You can make it : safe by including all the noFoo functions. phk got rid of them : because it is safe in >= 500104 to do that. Since you want to run on : multiple versions, it would be better/safer to do that. Eg, here's what I'd do to sys/pccard if I had to MFC it before MFCing the nofoo patches: #if __FreeBSD_version < 500104 #define CDEV_MAJOR 50 #else #define CDEV_MAJOR MAJOR_AUTO #endif static struct cdevsw crd_cdevsw = { .d_open = crdopen, .d_close = crdclose, .d_read = crdread, .d_write = crdwrite, .d_ioctl = crdioctl, .d_poll = crdpoll, .d_mmap = nommap, .d_strategy = nostrategy, .d_name = "crd", .d_maj = CDEV_MAJOR, .d_dump = nodump, .d_flags = 0, .d_kqfilter = nokqfilter; #if __FreeBSD_version < 500104 .d_psize = nopsize, #endif }; It is a little ugly, and phk wouldn't like it, but it would be portable back to about FreeBSD 4.2 or so for those drivers that try to do that. Well, I'm not 100% sure about 4.2, but I know that 4.5's compiler groks the above. However, I plan on merging the NULL patches soon (after the thaw), so it could become the following: static struct cdevsw crd_cdevsw = { .d_open = crdopen, .d_close = crdclose, .d_read = crdread, .d_write = crdwrite, .d_ioctl = crdioctl, .d_poll = crdpoll, .d_strategy = nostrategy, .d_name = "crd", .d_maj = CDEV_MAJOR, }; but would work only on 4.8+a little and newer (which for my purposes is fine). Warner To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message