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: Factor __aeabi_atexit into its own object file


Paolo Carlini wrote:
> Mark Mitchell wrote:
> 
>> How about this patch, as a solution?  (To replace the quick hack I
>> checked in when you reported this to me.)
>>  
> Ah, if I understand it correctly (i'm not very familiar with
> attribute((nothrow)), just browsed the docs about it), seems a very good
> idea to me. But now I suspect such attribute could be potentially
> usefully added to many more functions? Could you clarify?

__attribute__((nothrow)) is the C equivalent of "throw ()".  In C++
programs, you should just use "throw()", but in C programs, you can use
"__attribute__((nothrow))".  Of course, in C, this only matters if
you're using -fexceptions so that you can unwind through C code.

In general, most all-C libraries that can be called from C++ code should
use these no-throw markers (either attribute or exception specification)
so that C++ application code will understand that the C functions don't
thrown exceptions.  That will make the C++ programs smaller (smaller EH
tables), and, perhaps, faster.  GLIBC already does this.  (I don't know
if it uses the C attributes, but it certainly uses "throw()" in C++.)

To answer your other question, yes, there are definitely more places in
<cxxabi.h> that we could use the markers.  However, some of them are a
little tricky; like, you wouldn't think that cxa_guard_acquire could
throw an exception, but it acquires mutexes, and that's a POSIX threads
cancellation point, and cancellation with GLIBC is implemented as an
exception, so actually, that function can throw exceptions.  We could of
course try to get fancy and add the markers only for single-threaded code.

Basically, I was picking a simple case that mattered to an application I
was investigating.  (The surprising thing there was that a main program
compiled with -fno-exceptions ended up with EH support routines because
it had a global object with a destructor; that required the use of
aeabi_atexit, and that routine calls cxa_atexit, so if the compiler
can't tell that cxa_atexit doesn't throw exceptions, then aeabi_atexit
pulls in EH support routines.)  I would hope that once we get the
machinery in, people will add the markers in more places.

Thanks,

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713


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