From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M2taU-0003uI-Te for qemu-devel@nongnu.org; Sat, 09 May 2009 16:56:02 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M2taP-0003tf-SH for qemu-devel@nongnu.org; Sat, 09 May 2009 16:56:02 -0400 Received: from [199.232.76.173] (port=34123 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M2taP-0003tc-MA for qemu-devel@nongnu.org; Sat, 09 May 2009 16:55:57 -0400 Received: from mail-gx0-f176.google.com ([209.85.217.176]:49601) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1M2taP-0005Yl-C4 for qemu-devel@nongnu.org; Sat, 09 May 2009 16:55:57 -0400 Received: by gxk24 with SMTP id 24so5589492gxk.10 for ; Sat, 09 May 2009 13:55:56 -0700 (PDT) Message-ID: <4A05EDD8.6030208@codemonkey.ws> Date: Sat, 09 May 2009 15:55:52 -0500 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [RFC] New device API References: <200905051231.09759.paul@codesourcery.com> <4A0083F5.7050606@codemonkey.ws> <200905060152.02351.paul@codesourcery.com> <200905060204.32068.paul@codesourcery.com> In-Reply-To: <200905060204.32068.paul@codesourcery.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: Paul Brook Cc: qemu-devel@nongnu.org Paul Brook wrote: > On Wednesday 06 May 2009, Paul Brook wrote: > >>>> The attached patch is my attempt at a new internal API for device >>>> creation in qemu. >>>> >>> Instead of recreating constructors, I think we should just use GCC's >>> constructor attribute. This gives us ordering which will be important >>> when dealing with buses. >>> >> The reason I'm not using constructors is because you have to workaround >> ordering issues. All constructors are run before main(), so there's a very >> limited amount they can actually do, and constructor priorities are not >> available on all hosts. >> > > Oh, the other thing is that constructors don't work when you put objects in a > static library. You need am explicit dependency to pull in objects. > Not if you enable -Wl,--whole-archive. It ends up looking like: gcc -o test-stub -g -Wall -O test-stub.c -Wl,--whole-archive libtest.a -Wl,--no-whole-archive -L. And I've confirmed this works. Regards, Anthony Liguori > Paul > > >