gator: Merge gator version 5.23.1
[profile/mobile/platform/kernel/linux-3.10-sc7730.git] / tools / gator / daemon / c++.cpp
1 /**
2  * Minimal set of C++ functions so that libstdc++ is not required
3  *
4  * Copyright (C) ARM Limited 2010-2015. All rights reserved.
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 }