1 | /* $Id: kernel_cpp.h 93115 2022-01-01 11:31:46Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * Kernel C++, Haiku private.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2012-2022 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | /*
|
---|
19 | * This code is based on:
|
---|
20 | *
|
---|
21 | * VirtualBox Guest Additions for Haiku. C++ in the kernel.
|
---|
22 | *
|
---|
23 | * Copyright 2002-2009, Axel Dörfler, axeld@pinc-software.de.
|
---|
24 | * Distributed under the terms of the MIT License.
|
---|
25 | */
|
---|
26 |
|
---|
27 | #ifndef GA_INCLUDED_SRC_haiku_SharedFolders_kernel_cpp_h
|
---|
28 | #define GA_INCLUDED_SRC_haiku_SharedFolders_kernel_cpp_h
|
---|
29 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
30 | # pragma once
|
---|
31 | #endif
|
---|
32 |
|
---|
33 | #ifdef __cplusplus
|
---|
34 |
|
---|
35 | #include <new>
|
---|
36 | #include <stdlib.h>
|
---|
37 |
|
---|
38 | #if _KERNEL_MODE || _LOADER_MODE
|
---|
39 |
|
---|
40 | using namespace std;
|
---|
41 | extern const nothrow_t std::nothrow;
|
---|
42 |
|
---|
43 | // We need new() versions we can use when also linking against libgcc.
|
---|
44 | // std::nothrow can't be used since it's defined in both libgcc and
|
---|
45 | // kernel_cpp.cpp.
|
---|
46 | typedef struct {} mynothrow_t;
|
---|
47 | extern const mynothrow_t mynothrow;
|
---|
48 |
|
---|
49 |
|
---|
50 | inline void *
|
---|
51 | operator new(size_t size) throw (std::bad_alloc)
|
---|
52 | {
|
---|
53 | // we don't actually throw any exceptions, but we have to
|
---|
54 | // keep the prototype as specified in <new>, or else GCC 3
|
---|
55 | // won't like us
|
---|
56 | return malloc(size);
|
---|
57 | }
|
---|
58 |
|
---|
59 |
|
---|
60 | inline void *
|
---|
61 | operator new[](size_t size) throw (std::bad_alloc)
|
---|
62 | {
|
---|
63 | return malloc(size);
|
---|
64 | }
|
---|
65 |
|
---|
66 |
|
---|
67 | inline void *
|
---|
68 | operator new(size_t size, const std::nothrow_t &) throw ()
|
---|
69 | {
|
---|
70 | return malloc(size);
|
---|
71 | }
|
---|
72 |
|
---|
73 |
|
---|
74 | inline void *
|
---|
75 | operator new[](size_t size, const std::nothrow_t &) throw ()
|
---|
76 | {
|
---|
77 | return malloc(size);
|
---|
78 | }
|
---|
79 |
|
---|
80 |
|
---|
81 | inline void *
|
---|
82 | operator new(size_t size, const mynothrow_t &) throw ()
|
---|
83 | {
|
---|
84 | return malloc(size);
|
---|
85 | }
|
---|
86 |
|
---|
87 |
|
---|
88 | inline void *
|
---|
89 | operator new[](size_t size, const mynothrow_t &) throw ()
|
---|
90 | {
|
---|
91 | return malloc(size);
|
---|
92 | }
|
---|
93 |
|
---|
94 |
|
---|
95 | inline void
|
---|
96 | operator delete(void *ptr) throw ()
|
---|
97 | {
|
---|
98 | free(ptr);
|
---|
99 | }
|
---|
100 |
|
---|
101 |
|
---|
102 | inline void
|
---|
103 | operator delete[](void *ptr) throw ()
|
---|
104 | {
|
---|
105 | free(ptr);
|
---|
106 | }
|
---|
107 |
|
---|
108 | #endif // #if _KERNEL_MODE
|
---|
109 |
|
---|
110 | #endif // __cplusplus
|
---|
111 |
|
---|
112 | #endif /* !GA_INCLUDED_SRC_haiku_SharedFolders_kernel_cpp_h */
|
---|