diff --git a/hardware/arduino/avr/cores/arduino/Printable.h b/hardware/arduino/avr/cores/arduino/Printable.h index d03c9af62..2a1b2e9f2 100644 --- a/hardware/arduino/avr/cores/arduino/Printable.h +++ b/hardware/arduino/avr/cores/arduino/Printable.h @@ -20,7 +20,7 @@ #ifndef Printable_h #define Printable_h -#include +#include class Print; diff --git a/hardware/arduino/sam/cores/arduino/cxxabi-compat.cpp b/hardware/arduino/avr/cores/arduino/abi.cpp similarity index 55% rename from hardware/arduino/sam/cores/arduino/cxxabi-compat.cpp rename to hardware/arduino/avr/cores/arduino/abi.cpp index 7370b0be1..8d719b8e6 100644 --- a/hardware/arduino/sam/cores/arduino/cxxabi-compat.cpp +++ b/hardware/arduino/avr/cores/arduino/abi.cpp @@ -1,5 +1,5 @@ /* - Copyright (c) 2011 Arduino. All right reserved. + Copyright (c) 2014 Arduino. All right reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -8,7 +8,7 @@ This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public @@ -16,11 +16,20 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -extern "C" void __cxa_pure_virtual(void) ; +#include -/* We compile with nodefaultlibs, so we need to provide an error - * handler for an empty pure virtual function */ -extern "C" void __cxa_pure_virtual(void) { - while(1) - ; +extern "C" void __cxa_pure_virtual(void) __attribute__ ((__noreturn__)); +extern "C" void __cxa_deleted_virtual(void) __attribute__ ((__noreturn__)); + +void __cxa_pure_virtual(void) { + // We might want to write some diagnostics to uart in this case + //std::terminate(); + abort(); } + +void __cxa_deleted_virtual(void) { + // We might want to write some diagnostics to uart in this case + //std::terminate(); + abort(); +} + diff --git a/hardware/arduino/avr/cores/arduino/new.cpp b/hardware/arduino/avr/cores/arduino/new.cpp index b81031e90..cf6f89c17 100644 --- a/hardware/arduino/avr/cores/arduino/new.cpp +++ b/hardware/arduino/avr/cores/arduino/new.cpp @@ -1,28 +1,36 @@ -#include +/* + Copyright (c) 2014 Arduino. All right reserved. -void * operator new(size_t size) -{ + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + 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 + +void *operator new(size_t size) { return malloc(size); } -void * operator new[](size_t size) -{ +void *operator new[](size_t size) { return malloc(size); } -void operator delete(void * ptr) -{ +void operator delete(void * ptr) { free(ptr); } -void operator delete[](void * ptr) -{ +void operator delete[](void * ptr) { free(ptr); } -int __cxa_guard_acquire(__guard *g) {return !*(char *)(g);}; -void __cxa_guard_release (__guard *g) {*(char *)g = 1;}; -void __cxa_guard_abort (__guard *) {}; - -void __cxa_pure_virtual(void) {}; - diff --git a/hardware/arduino/avr/cores/arduino/new.h b/hardware/arduino/avr/cores/arduino/new.h index 991c86c75..6e1b68f0d 100644 --- a/hardware/arduino/avr/cores/arduino/new.h +++ b/hardware/arduino/avr/cores/arduino/new.h @@ -1,6 +1,20 @@ -/* Header to define new/delete operators as they aren't provided by avr-gcc by default - Taken from http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=59453 - */ +/* + Copyright (c) 2014 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ #ifndef NEW_H #define NEW_H @@ -12,13 +26,5 @@ void * operator new[](size_t size); void operator delete(void * ptr); void operator delete[](void * ptr); -__extension__ typedef int __guard __attribute__((mode (__DI__))); - -extern "C" int __cxa_guard_acquire(__guard *); -extern "C" void __cxa_guard_release (__guard *); -extern "C" void __cxa_guard_abort (__guard *); - -extern "C" void __cxa_pure_virtual(void); - #endif diff --git a/hardware/arduino/avr/platform.txt b/hardware/arduino/avr/platform.txt index f7e6734e1..9a2565fe6 100644 --- a/hardware/arduino/avr/platform.txt +++ b/hardware/arduino/avr/platform.txt @@ -21,7 +21,7 @@ compiler.c.elf.flags=-w -Os -Wl,--gc-sections compiler.c.elf.cmd=avr-gcc compiler.S.flags=-c -g -x assembler-with-cpp compiler.cpp.cmd=avr-g++ -compiler.cpp.flags=-c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD +compiler.cpp.flags=-c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD compiler.ar.cmd=avr-ar compiler.ar.flags=rcs compiler.objcopy.cmd=avr-objcopy diff --git a/hardware/arduino/sam/cores/arduino/abi.cpp b/hardware/arduino/sam/cores/arduino/abi.cpp new file mode 100644 index 000000000..962f601b8 --- /dev/null +++ b/hardware/arduino/sam/cores/arduino/abi.cpp @@ -0,0 +1,37 @@ +/* + Copyright (c) 2014 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + 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 + +extern "C" void __cxa_pure_virtual(void) __attribute__ ((__noreturn__)); +extern "C" void __cxa_deleted_virtual(void) __attribute__ ((__noreturn__)); + +void __cxa_pure_virtual(void) { + // We might want to write some diagnostics to uart in this case + //std::terminate(); + while (1) + ; +} + +void __cxa_deleted_virtual(void) { + // We might want to write some diagnostics to uart in this case + //std::terminate(); + while (1) + ; +} + diff --git a/hardware/arduino/sam/platform.txt b/hardware/arduino/sam/platform.txt index 4f7c58a9f..239674e0f 100644 --- a/hardware/arduino/sam/platform.txt +++ b/hardware/arduino/sam/platform.txt @@ -13,11 +13,11 @@ version=1.5.8 compiler.path={runtime.ide.path}/hardware/tools/gcc-arm-none-eabi-4.8.3-2014q1/bin/ compiler.c.cmd=arm-none-eabi-gcc compiler.c.flags=-c -g -Os -w -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -Dprintf=iprintf -compiler.c.elf.cmd=arm-none-eabi-g++ +compiler.c.elf.cmd=arm-none-eabi-gcc compiler.c.elf.flags=-Os -Wl,--gc-sections compiler.S.flags=-c -g -x assembler-with-cpp compiler.cpp.cmd=arm-none-eabi-g++ -compiler.cpp.flags=-c -g -Os -w -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -Dprintf=iprintf +compiler.cpp.flags=-c -g -Os -w -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -Dprintf=iprintf compiler.ar.cmd=arm-none-eabi-ar compiler.ar.flags=rcs compiler.objcopy.cmd=arm-none-eabi-objcopy