Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: arduino/ArduinoCore-avr
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: c8c514c
Choose a base ref
...
head repository: arduino/ArduinoCore-avr
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1980548
Choose a head ref
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on Nov 13, 2017

  1. Correct implementation of gcc specific internal functions

    Last bit not implemented by a4496b9
    Squash and rebase of arduino/Arduino#108
    kibergus authored and facchinm committed Nov 13, 2017
    Copy the full SHA
    1980548 View commit details
Showing with 49 additions and 11 deletions.
  1. +49 −11 cores/arduino/abi.cpp
60 changes: 49 additions & 11 deletions cores/arduino/abi.cpp
Original file line number Diff line number Diff line change
@@ -15,21 +15,59 @@
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <abi.h>
#include <stdint.h>
#include <exception>

#include <stdlib.h>
#include <avr/io.h>
#include <avr/interrupt.h>

extern "C" void __cxa_pure_virtual(void) __attribute__ ((__noreturn__));
extern "C" void __cxa_deleted_virtual(void) __attribute__ ((__noreturn__));
namespace {
// guard is an integer type big enough to hold flag and a mutex.
// By default gcc uses long long int and avr ABI does not change it
// So we have 32 or 64 bits available. Actually, we need 16.

void __cxa_pure_virtual(void) {
// We might want to write some diagnostics to uart in this case
//std::terminate();
abort();
inline char& flag_part(__guard *g) {
return *(reinterpret_cast<char*>(g));
}

void __cxa_deleted_virtual(void) {
// We might want to write some diagnostics to uart in this case
//std::terminate();
abort();
inline uint8_t& sreg_part(__guard *g) {
return *(reinterpret_cast<uint8_t*>(g) + sizeof(char));
}
}

int __cxa_guard_acquire(__guard *g) {
uint8_t oldSREG = SREG;
cli();
// Initialization of static variable has to be done with blocked interrupts
// because if this function is called from interrupt and sees that somebody
// else is already doing initialization it MUST wait until initializations
// is complete. That's impossible.
// If you don't want this overhead compile with -fno-threadsafe-statics
if (flag_part(g)) {
SREG = oldSREG;
return false;
} else {
sreg_part(g) = oldSREG;
return true;
}
}

void __cxa_guard_release (__guard *g) {
flag_part(g) = 1;
SREG = sreg_part(g);
}

void __cxa_guard_abort (__guard *g) {
SREG = sreg_part(g);
}

void __cxa_pure_virtual(void) {
// We might want to write some diagnostics to uart in this case
std::terminate();
}

void __cxa_deleted_virtual(void) {
// We might want to write some diagnostics to uart in this case
std::terminate();
}