Jon Medhurst | e31266f | 2014-08-04 15:47:44 +0100 | [diff] [blame] | 1 | /** |
| 2 | * Minimal set of C++ functions so that libstdc++ is not required |
| 3 | * |
Jon Medhurst | b1d0744 | 2015-05-08 12:04:18 +0100 | [diff] [blame] | 4 | * Copyright (C) ARM Limited 2010-2015. All rights reserved. |
Jon Medhurst | e31266f | 2014-08-04 15:47:44 +0100 | [diff] [blame] | 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License version 2 as |
| 8 | * published by the Free Software Foundation. |
| 9 | */ |
| 10 | |
| 11 | #include <stdio.h> |
| 12 | #include <stdlib.h> |
| 13 | |
| 14 | void operator delete(void *ptr) { |
| 15 | if (ptr != NULL) { |
| 16 | free(ptr); |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | void operator delete[](void *ptr) { |
| 21 | operator delete(ptr); |
| 22 | } |
| 23 | |
| 24 | void *operator new(size_t size) { |
| 25 | void *ptr = malloc(size == 0 ? 1 : size); |
| 26 | if (ptr == NULL) { |
| 27 | abort(); |
| 28 | } |
| 29 | return ptr; |
| 30 | } |
| 31 | |
| 32 | void *operator new[](size_t size) { |
| 33 | return operator new(size); |
| 34 | } |
| 35 | |
| 36 | extern "C" |
| 37 | void __cxa_pure_virtual() { |
| 38 | printf("pure virtual method called\n"); |
| 39 | abort(); |
| 40 | } |