1 #ifndef CPP_H 2 #define CPP_H 3 /* cpp - C++ in the kernel 4 ** 5 ** Initial version by Axel Dörfler, axeld@pinc-software.de 6 ** This file may be used under the terms of the OpenBeOS License. 7 */ 8 9 10 #include <new> 11 #include <stdlib.h> 12 13 14 using namespace std; 15 16 17 // Oh no! C++ in the kernel! Are you nuts? 18 // 19 // - no exceptions 20 // - (almost) no virtuals (well, the Query code now uses them) 21 // - it's basically only the C++ syntax, and type checking 22 // - since one tend to encapsulate everything in classes, it has a slightly 23 // higher memory overhead 24 // - nicer code 25 // - easier to maintain 26 27 28 inline void * 29 operator new(size_t size) throw (std::bad_alloc) 30 { 31 // we don't actually throw any exceptions, but we have to 32 // keep the prototype as specified in <new>, or else GCC 3 33 // won't like us 34 return malloc(size); 35 } 36 37 38 inline void * 39 operator new[](size_t size) throw (std::bad_alloc) 40 { 41 return malloc(size); 42 } 43 44 45 inline void * 46 operator new(size_t size, const std::nothrow_t &) throw () 47 { 48 return malloc(size); 49 } 50 51 52 inline void * 53 operator new[](size_t size, const std::nothrow_t &) throw () 54 { 55 return malloc(size); 56 } 57 58 59 inline void 60 operator delete(void *ptr) throw () 61 { 62 free(ptr); 63 } 64 65 66 inline void 67 operator delete[](void *ptr) throw () 68 { 69 free(ptr); 70 } 71 72 // we're using virtuals 73 extern "C" void __pure_virtual(); 74 75 76 #endif /* CPP_H */ 77