This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Remove NOTHROW from {,v}{,f}{print,scan}f, {,f}printf_unlocked and __{,v}{,f}printf_chk builtins


On Tue, Sep 04, 2007 at 09:30:09AM -0700, Mark Mitchell wrote:
> > In glibc the following functions aren't throw(), because they are
> > possible cancellation points (when a thread doing say a write within
> > fprintf is cancelled, we need forced unwinding to work).
> 
> Can we conditionalize this in some way?  On a system without threads, or
> if the user is explicitly writing single-threaded code, these functions
> are in fact nothrow.  On an embedded C++ system, we don't want to pay
> the overhead for thinking that every call to these functions might throw
> an exception.

Conditionalizing on what?  Requiring to use a new switch for all
compilations that might be used in threaded programs would be a nightmare.

What we could do is when we see a prototype, update the NOTHROW state
not only of the DECL_ANTICIPATED builtin, but also its __builtin_* variant.
So, say both
printf
and
__builtin_printf
builtins would be originally without NOTHROW, but if a:
extern "C" int printf (const char *, ...) throw ();
prototype is seen, both would be made TREE_NOTHROW.  Currently we make
only the former TREE_NOTHROW:

      /* Whether or not the builtin can throw exceptions has no
         bearing on this declarator.  */
      TREE_NOTHROW (olddecl) = 0;

That would mean that if no prototype is present, we'd use the conservative
choice, but if a prototype is provided, we could know better.

BTW, several other functions are already not NOTHROW for years:
http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02897.html
it is just that the NOTHROW for the *printf has been not explicit
in builtins.def and therefore missed in the above patch.

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]