>
> On Fri, 26 Oct 2007, Linus Torvalds wrote:
> >
> > On Fri, 26 Oct 2007, Bart Van Assche wrote:
> > >
> > > You can find my proposal to improve gcc here:
> > >
http://gcc.gnu.org/ml/gcc/2007-10/msg00465.html
> >
> > Btw, I think this is fine per se, but putting "__attribute__((acquire))"
> > on the functions that acquire a lock does seem to be problematic, in that
> > quite often you might well want to inline those things. How would you
> > handle that?
>
> Thinking some more about this, you really have two cases:
> - full functions taking/releasing locks (possibly conditionally, ie
> with something like trylock and/or based on argument values).
>
> You simply *cannot* require these to be marked, because the locking may
> have been done indirectly. Yes, you can mark things like
> "pthread_mutex_trylock()" as being an acquire-function, but the fact
> is, users will then wrap these things in *other* functions, and return
> their return values.
>
> Ergo: a compiler *must* assume that a function call that it
> didn't inline involves locking. There's no point in adding some
> gcc-specific attributes to system header files, because it's not going
> to fix anything in any portable program.