blob: caf6f1efdcde286b2576b206ea4ae10b45ab837b [file] [log] [blame]
Jon Medhurste31266f2014-08-04 15:47:44 +01001/**
2 * Minimal set of C++ functions so that libstdc++ is not required
3 *
Jon Medhurstb1d07442015-05-08 12:04:18 +01004 * Copyright (C) ARM Limited 2010-2015. All rights reserved.
Jon Medhurste31266f2014-08-04 15:47:44 +01005 *
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
14void operator delete(void *ptr) {
15 if (ptr != NULL) {
16 free(ptr);
17 }
18}
19
20void operator delete[](void *ptr) {
21 operator delete(ptr);
22}
23
24void *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
32void *operator new[](size_t size) {
33 return operator new(size);
34}
35
36extern "C"
37void __cxa_pure_virtual() {
38 printf("pure virtual method called\n");
39 abort();
40}