Skip to content

Commit 29ca2cb

Browse files
committed
Merge pull request #2284 from cmaglie/ide-1.5.x-cxx-abi-compat
Correct implementation of gcc specific internal functions (take 2)
2 parents 44e3ef0 + dd423d3 commit 29ca2cb

File tree

4 files changed

+76
-27
lines changed

4 files changed

+76
-27
lines changed

hardware/arduino/avr/cores/arduino/Printable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#ifndef Printable_h
2121
#define Printable_h
2222

23-
#include <new.h>
23+
#include <stdlib.h>
2424

2525
class Print;
2626

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
Copyright (c) 2014 Arduino. All right reserved.
3+
4+
This library is free software; you can redistribute it and/or
5+
modify it under the terms of the GNU Lesser General Public
6+
License as published by the Free Software Foundation; either
7+
version 2.1 of the License, or (at your option) any later version.
8+
9+
This library is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12+
See the GNU Lesser General Public License for more details.
13+
14+
You should have received a copy of the GNU Lesser General Public
15+
License along with this library; if not, write to the Free Software
16+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17+
*/
18+
19+
#include <stdlib.h>
20+
21+
extern "C" void __cxa_pure_virtual(void) __attribute__ ((__noreturn__));
22+
extern "C" void __cxa_deleted_virtual(void) __attribute__ ((__noreturn__));
23+
24+
void __cxa_pure_virtual(void) {
25+
// We might want to write some diagnostics to uart in this case
26+
//std::terminate();
27+
abort();
28+
}
29+
30+
void __cxa_deleted_virtual(void) {
31+
// We might want to write some diagnostics to uart in this case
32+
//std::terminate();
33+
abort();
34+
}
35+

hardware/arduino/avr/cores/arduino/new.cpp

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,36 @@
1-
#include <new.h>
1+
/*
2+
Copyright (c) 2014 Arduino. All right reserved.
23
3-
void * operator new(size_t size)
4-
{
4+
This library is free software; you can redistribute it and/or
5+
modify it under the terms of the GNU Lesser General Public
6+
License as published by the Free Software Foundation; either
7+
version 2.1 of the License, or (at your option) any later version.
8+
9+
This library is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12+
See the GNU Lesser General Public License for more details.
13+
14+
You should have received a copy of the GNU Lesser General Public
15+
License along with this library; if not, write to the Free Software
16+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17+
*/
18+
19+
#include <stdlib.h>
20+
21+
void *operator new(size_t size) {
522
return malloc(size);
623
}
724

8-
void * operator new[](size_t size)
9-
{
25+
void *operator new[](size_t size) {
1026
return malloc(size);
1127
}
1228

13-
void operator delete(void * ptr)
14-
{
29+
void operator delete(void * ptr) {
1530
free(ptr);
1631
}
1732

18-
void operator delete[](void * ptr)
19-
{
33+
void operator delete[](void * ptr) {
2034
free(ptr);
2135
}
2236

23-
int __cxa_guard_acquire(__guard *g) {return !*(char *)(g);};
24-
void __cxa_guard_release (__guard *g) {*(char *)g = 1;};
25-
void __cxa_guard_abort (__guard *) {};
26-
27-
void __cxa_pure_virtual(void) {};
28-
Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
1-
/* Header to define new/delete operators as they aren't provided by avr-gcc by default
2-
Taken from http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=59453
3-
*/
1+
/*
2+
Copyright (c) 2014 Arduino. All right reserved.
3+
4+
This library is free software; you can redistribute it and/or
5+
modify it under the terms of the GNU Lesser General Public
6+
License as published by the Free Software Foundation; either
7+
version 2.1 of the License, or (at your option) any later version.
8+
9+
This library is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12+
See the GNU Lesser General Public License for more details.
13+
14+
You should have received a copy of the GNU Lesser General Public
15+
License along with this library; if not, write to the Free Software
16+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17+
*/
418

519
#ifndef NEW_H
620
#define NEW_H
@@ -12,13 +26,5 @@ void * operator new[](size_t size);
1226
void operator delete(void * ptr);
1327
void operator delete[](void * ptr);
1428

15-
__extension__ typedef int __guard __attribute__((mode (__DI__)));
16-
17-
extern "C" int __cxa_guard_acquire(__guard *);
18-
extern "C" void __cxa_guard_release (__guard *);
19-
extern "C" void __cxa_guard_abort (__guard *);
20-
21-
extern "C" void __cxa_pure_virtual(void);
22-
2329
#endif
2430

0 commit comments

Comments
 (0)