qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 1/2] Type-safe ioport callbacks


From: Avi Kivity
Subject: Re: [Qemu-devel] [PATCH 1/2] Type-safe ioport callbacks
Date: Mon, 25 Oct 2010 12:00:52 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.9) Gecko/20100921 Fedora/3.1.4-1.fc13 Lightning/1.0b3pre Thunderbird/3.1.4

 On 10/24/2010 08:14 PM, Blue Swirl wrote:
On Sun, Oct 24, 2010 at 3:34 PM, Avi Kivity<address@hidden>  wrote:
>  The current ioport callbacks are not type-safe, in that they accept an 
"opaque"
>  pointer as an argument whose type must match the argument to the registration
>  function; this is not checked by the compiler.
>
>  This patch adds an alternative that is type-safe.  Instead of an opaque
>  argument, both registation and the callback use a new IOPort type.  The
>  callback then uses container_of() to access its main structures.
>
>  Currently the old and new methods exist side by side; once the old way is 
gone,
>  we can also save a bunch of memory since the new method requires one pointer
>  per ioport instead of 6.
>
>  Signed-off-by: Avi Kivity<address@hidden>

If we are going to change the interface, let's do it so that it's
useful for other uses too:
http://article.gmane.org/gmane.comp.emulators.qemu/76984

I don't really see why we need registration; cpu_register_io() takes function pointers, a size, and an opaque, and gives an integer handle in return. With the IOPort object approach, you set up the IOPort with function pointers, size is implied, and the opaque is derived using container_of(); the handle is simply the address of the object.

>  +typedef struct IOPort {
>  +    IOPortOps *ops;

const

Yup, will fix.  Will repost once we agree on the approach.

--
error compiling committee.c: too many arguments to function




reply via email to

[Prev in Thread] Current Thread [Next in Thread]