Hello. I was searching for standard C++ library for AVR platform and have found https://github.com/maniacbug/StandardCplusplus Then I've looked through it and quite liked the realization. But I have a question about exception handling in case if exceptions are disabled.
Suppose I call operator new(std::size_t numBytes) and malloc returns NULL. Then std::__throw_bad_alloc() is called. And, as far as I have exceptions disabled folowing code is executed: _UCXXEXPORT void __throw_bad_alloc(){ abort(); } According to documentation: void abort (void) The abort() function causes abnormal program termination to occur. This realization disables interrupts and jumps to _exit() function with argument equal to 1. In the limited AVR environment, execution is effectively halted by entering an infinite loop. But this is not what I want. I know that things went bad and I want to reset device immediately instead of waiting until watchdog does it. If __throw_bad_alloc() instead of abort() called std::terminate() I could set up special terminate handler and have any behavior I need. And std::terminate seen a better option than abort() because we actually have an uncaught exception (nobody can cat exceptions when they are disabled) or exception during throwing exception (because they are disabled). Can this be done or am I missing something? Another issue is that at least on avr port there is no realization for std::terminate. So I've written it. But it seems, that normally it would be added from gcc by src/abi/libsupc/Makefile which is missing in AVR port. Do I understand things right? Thanks.
terminate.patch
Description: Binary data
_______________________________________________ uClibc mailing list uClibc@uclibc.org http://lists.busybox.net/mailman/listinfo/uclibc