[Libvir] __attribute__((constructor)) anyone?

Would anyone object to a patch using __attribute__((constructor)) throughout libvirt rather than all this if(!initialised) initialise() stuff? Rich. -- Emerging Technologies, Red Hat http://et.redhat.com/~rjones/ 64 Baker Street, London, W1U 7DF Mobile: +44 7866 314 421 "[Negative numbers] darken the very whole doctrines of the equations and make dark of the things which are in their nature excessively obvious and simple" (Francis Maseres FRS, mathematician, 1759)

On Sat, Feb 17, 2007 at 01:58:04PM +0000, Richard W.M. Jones wrote:
Would anyone object to a patch using __attribute__((constructor)) throughout libvirt rather than all this if(!initialised) initialise() stuff?
I don't think that annotation is widely supported enough by constructors for us to be able to use it - in particular I think it'd be a problem for the Solaris guys using libvirt unless they switched to GCC instead of the Sun compilers/linkers. Regards, Dan. -- |=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|

On Thu, 2007-02-22 at 20:00 +0000, Daniel P. Berrange wrote:
On Sat, Feb 17, 2007 at 01:58:04PM +0000, Richard W.M. Jones wrote:
Would anyone object to a patch using __attribute__((constructor)) throughout libvirt rather than all this if(!initialised) initialise() stuff?
I don't think that annotation is widely supported enough by constructors for us to be able to use it - in particular I think it'd be a problem for the Solaris guys using libvirt unless they switched to GCC instead of the Sun compilers/linkers.
A better reason[1], IMHO is that it just makes code more obtuse for little gain - e.g. what order are they called in? And you'd have weird stuff where the handler set by virSetErrorFunc() would not be called if an error occurred in a constructor, requiring the library user to also use a constructor in order to call virSetErrorFunc() ... Cheers, Mark. [1] - Because I wouldn't be surprised if forte does actually support it

Mark McLoughlin wrote:
On Thu, 2007-02-22 at 20:00 +0000, Daniel P. Berrange wrote:
Would anyone object to a patch using __attribute__((constructor)) throughout libvirt rather than all this if(!initialised) initialise() stuff? I don't think that annotation is widely supported enough by constructors for us to be able to use it - in particular I think it'd be a problem for
On Sat, Feb 17, 2007 at 01:58:04PM +0000, Richard W.M. Jones wrote: the Solaris guys using libvirt unless they switched to GCC instead of the Sun compilers/linkers.
A better reason[1], IMHO is that it just makes code more obtuse for little gain - e.g. what order are they called in? And you'd have weird stuff where the handler set by virSetErrorFunc() would not be called if an error occurred in a constructor, requiring the library user to also use a constructor in order to call virSetErrorFunc() ...
Actually this is an argument for using constructors, because the linker should order them in a sensible order taking into account module dependencies. Anyhow, I take the point about people using non-GCC compilers (and I'm a bit surprised too ...) Does anyone know if the Solaris compiler supports C99 idioms? The remote patch currently uses C99 idioms all over the place ... Rich. -- Emerging Technologies, Red Hat http://et.redhat.com/~rjones/ 64 Baker Street, London, W1U 7DF Mobile: +44 7866 314 421 "[Negative numbers] darken the very whole doctrines of the equations and make dark of the things which are in their nature excessively obvious and simple" (Francis Maseres FRS, mathematician, 1759)

On Fri, Feb 23, 2007 at 10:34:45AM +0000, Richard W.M. Jones wrote:
Mark McLoughlin wrote:
On Thu, 2007-02-22 at 20:00 +0000, Daniel P. Berrange wrote:
Would anyone object to a patch using __attribute__((constructor)) throughout libvirt rather than all this if(!initialised) initialise() stuff? I don't think that annotation is widely supported enough by constructors for us to be able to use it - in particular I think it'd be a problem for
On Sat, Feb 17, 2007 at 01:58:04PM +0000, Richard W.M. Jones wrote: the Solaris guys using libvirt unless they switched to GCC instead of the Sun compilers/linkers.
A better reason[1], IMHO is that it just makes code more obtuse for little gain - e.g. what order are they called in? And you'd have weird stuff where the handler set by virSetErrorFunc() would not be called if an error occurred in a constructor, requiring the library user to also use a constructor in order to call virSetErrorFunc() ...
Actually this is an argument for using constructors, because the linker should order them in a sensible order taking into account module dependencies. Anyhow, I take the point about people using non-GCC compilers (and I'm a bit surprised too ...) Does anyone know if the Solaris compiler supports C99 idioms? The remote patch currently uses C99 idioms all over the place ...
This page indicates that Sun Studio 8 does do C99 if the user asks for it with the -xc99 flag http://docs.sun.com/source/817-0924/c99.app.html Dan. -- |=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|
participants (3)
-
Daniel P. Berrange
-
Mark McLoughlin
-
Richard W.M. Jones