From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:35548) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TJn3s-0003mr-Fp for qemu-devel@nongnu.org; Thu, 04 Oct 2012 11:10:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TJn3k-0007N3-Nw for qemu-devel@nongnu.org; Thu, 04 Oct 2012 11:10:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:16067) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TJmR2-0007a8-Fd for qemu-devel@nongnu.org; Thu, 04 Oct 2012 10:29:56 -0400 Message-ID: <506D9D5E.70303@redhat.com> Date: Thu, 04 Oct 2012 16:29:50 +0200 From: Avi Kivity MIME-Version: 1.0 References: <1349280245-16341-1-git-send-email-avi@redhat.com> <1349280245-16341-9-git-send-email-avi@redhat.com> <87pq4yib8y.fsf@codemonkey.ws> In-Reply-To: <87pq4yib8y.fsf@codemonkey.ws> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC v1 08/22] memory: provide defaults for MemoryListener operations List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Blue Swirl , Paolo Bonzini , "Michael S. Tsirkin" , qemu-devel@nongnu.org, liu ping fan On 10/04/2012 04:05 PM, Anthony Liguori wrote: > Avi Kivity writes: > >> Many listeners don't need to respond to all MemoryListener callbacks; >> provide suitable defaults instead. >> >> +#define MEMORY_LISTENER_DEFAULT_OPS \ >> + .begin = memory_listener_default_global, \ >> + .commit = memory_listener_default_global, \ >> + .region_add = memory_listener_default_section, \ >> + .region_del = memory_listener_default_section, \ >> + .region_nop = memory_listener_default_section, \ >> + .log_start = memory_listener_default_section, \ >> + .log_stop = memory_listener_default_section, \ >> + .log_sync = memory_listener_default_section, \ >> + .log_global_start = memory_listener_default_global, \ >> + .log_global_stop = memory_listener_default_global, \ >> + .eventfd_add = memory_listener_default_eventfd, \ >> + .eventfd_del = memory_listener_default_eventfd \ >> + >> +void memory_listener_default_global(MemoryListener *listener); >> +void memory_listener_default_section(MemoryListener *listener, >> + MemoryRegionSection *section); >> +void memory_listener_default_eventfd(MemoryListener *listener, >> + MemoryRegionSection *section, >> + bool match_data, uint64_t data, EventNotifier *e); >> + >> /** >> * memory_region_init: Initialize a memory region >> * > > I think it'd be nicer to check for NULL when invoking the functions in > the memory core. > > Then you avoid the exported stub functions entirely. Yes, that's the common style, but I happen not to like the extra check, both from a performance point of view (doesn't apply here of course) and from a readability point of view. -- error compiling committee.c: too many arguments to function