xref: /haiku/src/add-ons/kernel/file_systems/reiserfs/cpp.h (revision 7749d0bb0c358a3279b1b9cc76d8376e900130a5)
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 #ifdef __cplusplus
10 
11 #include <new>
12 #include <stdlib.h>
13 
14 using namespace std;
15 
16 // Oh no! C++ in the kernel! Are you nuts?
17 //
18 //	- no exceptions
19 //	- (almost) no virtuals (well, the Query code now uses them)
20 //	- it's basically only the C++ syntax, and type checking
21 //	- since one tend to encapsulate everything in classes, it has a slightly
22 //	  higher memory overhead
23 //	- nicer code
24 //	- easier to maintain
25 
26 
27 inline void *operator new(size_t size, const nothrow_t&) throw()
28 {
29 	return malloc(size);
30 }
31 
32 inline void *operator new[](size_t size, const nothrow_t&) throw()
33 {
34 	return malloc(size);
35 }
36 
37 inline void operator delete(void *ptr)
38 {
39 	free(ptr);
40 }
41 
42 inline void operator delete[](void *ptr)
43 {
44 	free(ptr);
45 }
46 
47 // now we're using virtuals
48 extern "C" void __pure_virtual();
49 
50 //extern nothrow_t _dontthrow;
51 //#define new new (_dontthrow)
52 
53 #endif	// __cplusplus
54 
55 #endif	/* CPP_H */
56