From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=37317 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PrsHg-0005HO-2z for qemu-devel@nongnu.org; Tue, 22 Feb 2011 08:28:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PrsHe-0007nD-S2 for qemu-devel@nongnu.org; Tue, 22 Feb 2011 08:28:07 -0500 Received: from mx1.redhat.com ([209.132.183.28]:19009) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PrsHe-0007mv-Jp for qemu-devel@nongnu.org; Tue, 22 Feb 2011 08:28:06 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p1MDS5d0014303 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 22 Feb 2011 08:28:05 -0500 Message-ID: <4D63B9E2.5060201@redhat.com> Date: Tue, 22 Feb 2011 15:28:02 +0200 From: Avi Kivity MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 2/7] iohandlers: Introduce a new API References: <3d41a2ca603b8132e2496976e89fca09fc246683.1298369272.git.amit.shah@redhat.com> In-Reply-To: <3d41a2ca603b8132e2496976e89fca09fc246683.1298369272.git.amit.shah@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Amit Shah Cc: qemu list , Gerd Hoffmann On 02/22/2011 12:18 PM, Amit Shah wrote: > Introduce a new iohandler api that doesn't have multiple callbacks. > Instead, a single callback and a mask of events that got set will be > passed on to the handler. This will ease our transition to a poll() > interface instead of the current select() that happens on the fds. > > > + > +/* iohandler masks */ > +#define IOH_MASK_CAN_READ (1U<< 0) > +#define IOH_MASK_READ (1U<< 1) > +#define IOH_MASK_WRITE (1U<< 2) > + > +typedef int IOAllHandler(void *opaque, unsigned int mask); Strange name. Drop the opaque, instead put the IOHandler in there (or maybe the CharDev?) and use container_of(). > + > +int assign_iohandler(int fd, IOAllHandler *handler, unsigned int mask, > + void *opaque); > +int remove_iohandler(int fd); > +int update_fd_mask(int fd, unsigned int mask); > +int get_fd_mask(int fd, unsigned int *mask); > + iohandler_init(IOHandler *ioh, int fd, IOEventHandler *handler, unsigned mask) iohandler_del(IOHandler *ioh) iohandler_set_event_mask(IOHandler *ioh, unsigned mask) iohandler_event_mask(IOHandler *ioh) No opaques, use an object as a key so you don't have to search for it. -- error compiling committee.c: too many arguments to function