VirtualBox

source: vbox/trunk/src/VBox/Additions/haiku/SharedFolders/kernel_cpp.h@ 92179

Last change on this file since 92179 was 92179, checked in by vboxsync, 3 years ago

Add/haiku: Force UTF-8 encoding on files with non-ASCII names in the copyright headers.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.3 KB
Line 
1/* $Id: kernel_cpp.h 92179 2021-11-02 21:44:49Z vboxsync $ */
2/** @file
3 * Kernel C++, Haiku private.
4 */
5
6/*
7 * Copyright (C) 2012-2020 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
40using namespace std;
41extern 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.
46typedef struct {} mynothrow_t;
47extern const mynothrow_t mynothrow;
48
49
50inline void *
51operator 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
60inline void *
61operator new[](size_t size) throw (std::bad_alloc)
62{
63 return malloc(size);
64}
65
66
67inline void *
68operator new(size_t size, const std::nothrow_t &) throw ()
69{
70 return malloc(size);
71}
72
73
74inline void *
75operator new[](size_t size, const std::nothrow_t &) throw ()
76{
77 return malloc(size);
78}
79
80
81inline void *
82operator new(size_t size, const mynothrow_t &) throw ()
83{
84 return malloc(size);
85}
86
87
88inline void *
89operator new[](size_t size, const mynothrow_t &) throw ()
90{
91 return malloc(size);
92}
93
94
95inline void
96operator delete(void *ptr) throw ()
97{
98 free(ptr);
99}
100
101
102inline void
103operator 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 */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette