Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 04 Mar 2003 20:09:54 -0700 (MST)
From:      "M. Warner Losh" <imp@bsdimp.com>
To:        kutulu@kutulu.org
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: D_KQFILTER & ltmdm: Patch for review?
Message-ID:  <20030304.200954.18843267.imp@bsdimp.com>
In-Reply-To: <20030304.194917.100118237.imp@bsdimp.com>
References:  <01be01c2e2b6$30742b00$29330f0a@lcapps.educate.com> <20030304.194917.100118237.imp@bsdimp.com>

next in thread | previous in thread | raw e-mail | index | archive | help
In message: <20030304.194917.100118237.imp@bsdimp.com>
            "M. Warner Losh" <imp@bsdimp.com> 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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030304.200954.18843267.imp>