Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 02 Mar 2003 17:14:58 +0100
From:      "Poul-Henning Kamp" <phk@phk.freebsd.dk>
To:        arch@freebsd.org
Subject:   caddr_t, d_ioctl_t and cdevsw{} in general.
Message-ID:  <8322.1046621698@critter.freebsd.dk>

next in thread | raw e-mail | index | archive | help

>des         2003/03/02 07:29:13 PST
>
>  FreeBSD src repository
>
>  Modified files:
>    sys/sys              uio.h 
>    sys/kern             kern_subr.c 
>  Log:
>  Convert one of our main caddr_t consumers, uiomove(9), to void *.

One of the other ones are cdevsw->d_ioctl(), where I would really
like to make the pointer argument a "void *".

Unfortunately, we have approx 140 statically initialized instances
of struct cdevsw {} in our tree, so any modification to this structure
makes a major mess and flagday, and 's/caddr_t[ ]*/void */' is not
sufficient reason alone.

(The worry that we may break source compatibility with previous
FreeBSD's or other operating systems is likely false economy because
SMPng may change semantics so much that any such compatibility at
best is illusory.)

There are other changes to struct cdevsw{} which are pending, I just
eliminated the d_psize element for instance, and we probably need to
pass a file descriptor to d_open(), d_close() and possibly d_ioctl()
in the future.

My intent is to postpone any flag-day for as long as I can, but if
I can see it being required, I will attempt to get it over with
before RELENG_5 if at all possible.

But...

It would be perfect to have a versioned API instead of the cdevsw{},
one way to do this would be to abandon the cdevsw{} and assign the
methods to members in the dev_t directly, something like
	dev = make_dev(...);
	dev->d_open = fooopen;
	dev->d_close = fooclose;
	dev->d_ioctl = fooioctl;
	...
But this would be wasteful, most devices under a driver uses the
same methods so the indirection through cdevsw{} saves space, and
it would be fairly tedious and repetitive in drivers with more than
one make_dev() call.

I know a lot of people will cry "KOBJ", and while we can avoid the
cache-collision by caching the methods in the dev_t at make_dev()
time, the loss of type-checking in this API worries me a lot:  This
is one of the API's which we have most new-to-FreeBSD people writing
against.  I don't think we can introduce type-safety in KOBJ as it
stands.

And besides, we have the same issue over in VOP_* and a few other
places.

I _really_ think it is time to seriously consider using an augmented
'C' dialect where we build in some of these "OOlite" concepts, and
write a preprocessor for it which outputs C.

Any takers ?

-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk@FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




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