From 01816b99db022ba88c38bbb2fb34c2ab6fb68726 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Mon, 8 Sep 2014 14:33:40 +0200 Subject: [PATCH] Added gcc internal functions --- cores/arduino/abi.cpp | 37 +++++++++++++++++++++++++++++++++++++ cores/arduino/new.cpp | 36 ++++++++++++++++++++++++++++++++++++ platform.txt | 2 +- 3 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 cores/arduino/abi.cpp create mode 100644 cores/arduino/new.cpp diff --git a/cores/arduino/abi.cpp b/cores/arduino/abi.cpp new file mode 100644 index 00000000..962f601b --- /dev/null +++ b/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/cores/arduino/new.cpp b/cores/arduino/new.cpp new file mode 100644 index 00000000..f1897758 --- /dev/null +++ b/cores/arduino/new.cpp @@ -0,0 +1,36 @@ +/* + 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 + +void *operator new(size_t size) { + return malloc(size); +} + +void *operator new[](size_t size) { + return malloc(size); +} + +void operator delete(void * ptr) { + free(ptr); +} + +void operator delete[](void * ptr) { + free(ptr); +} + diff --git a/platform.txt b/platform.txt index 8f52aed9..c34ed0fa 100644 --- a/platform.txt +++ b/platform.txt @@ -17,7 +17,7 @@ compiler.c.elf.cmd=arm-none-eabi-gcc compiler.c.elf.flags=-Os -Wl,--gc-sections -save-temps compiler.S.flags=-c -g -x assembler-with-cpp compiler.cpp.cmd=arm-none-eabi-g++ -compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g -Os -w -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -Dprintf=iprintf +compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g -Os -w -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -Dprintf=iprintf #-std=gnu++11 compiler.ar.cmd=arm-none-eabi-ar compiler.ar.flags=rcs