williamr@4
|
1 |
/*
|
williamr@4
|
2 |
* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(- * * ies).
|
williamr@4
|
3 |
* All rights reserved.
|
williamr@4
|
4 |
* This component and the accompanying materials are made available
|
williamr@4
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
williamr@4
|
6 |
* which accompanies this distribution, and is available
|
williamr@4
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
williamr@4
|
8 |
*
|
williamr@4
|
9 |
* Initial Contributors:
|
williamr@4
|
10 |
* Nokia Corporation - initial contribution.
|
williamr@4
|
11 |
*
|
williamr@4
|
12 |
* Contributors:
|
williamr@4
|
13 |
*
|
williamr@4
|
14 |
* Description:
|
williamr@4
|
15 |
* Name : new
|
williamr@4
|
16 |
* Part of : standard c++ library.
|
williamr@4
|
17 |
*
|
williamr@4
|
18 |
*/
|
williamr@4
|
19 |
|
williamr@4
|
20 |
|
williamr@4
|
21 |
#ifndef _SYMCPP_NEW_H_
|
williamr@4
|
22 |
#define _SYMCPP_NEW_H_
|
williamr@4
|
23 |
|
williamr@4
|
24 |
|
williamr@4
|
25 |
#ifndef _STLP_FEATURES_H
|
williamr@4
|
26 |
# include <stl/config/features.h>
|
williamr@4
|
27 |
#endif
|
williamr@4
|
28 |
|
williamr@4
|
29 |
|
williamr@4
|
30 |
|
williamr@4
|
31 |
# ifdef __EABI__
|
williamr@4
|
32 |
# include <stl/_cstddef.h> //Include the STLP internal header to make macros/typedefs expected of <csddef> available.
|
williamr@4
|
33 |
# define _STLP_CSTDDEF //Define this macro so that <cstddef> doesn't get included by new_eabi.h
|
williamr@4
|
34 |
|
williamr@4
|
35 |
#include "exception"
|
williamr@4
|
36 |
|
williamr@4
|
37 |
namespace std
|
williamr@4
|
38 |
{
|
williamr@4
|
39 |
typedef unsigned size_t;
|
williamr@4
|
40 |
|
williamr@4
|
41 |
class bad_alloc : public exception
|
williamr@4
|
42 |
{
|
williamr@4
|
43 |
public:
|
williamr@4
|
44 |
IMPORT_C bad_alloc() __NO_THROW;
|
williamr@4
|
45 |
IMPORT_C bad_alloc(const bad_alloc&) __NO_THROW;
|
williamr@4
|
46 |
IMPORT_C bad_alloc& operator=(const bad_alloc&) __NO_THROW; // { return *this;}
|
williamr@4
|
47 |
|
williamr@4
|
48 |
IMPORT_C virtual ~bad_alloc() __NO_THROW; // {}
|
williamr@4
|
49 |
IMPORT_C virtual const char* what() const __NO_THROW; // { return "bad_alloc";}
|
williamr@4
|
50 |
};
|
williamr@4
|
51 |
|
williamr@4
|
52 |
struct nothrow_t {};
|
williamr@4
|
53 |
extern const nothrow_t nothrow;
|
williamr@4
|
54 |
|
williamr@4
|
55 |
typedef void (*new_handler)();
|
williamr@4
|
56 |
|
williamr@4
|
57 |
IMPORT_C new_handler set_new_handler(new_handler) __NO_THROW;
|
williamr@4
|
58 |
}
|
williamr@4
|
59 |
|
williamr@4
|
60 |
// Single-object form
|
williamr@4
|
61 |
|
williamr@4
|
62 |
IMPORT_C void* operator new(std::size_t) __THROW(std::bad_alloc);
|
williamr@4
|
63 |
IMPORT_C void operator delete(void*) __NO_THROW;
|
williamr@4
|
64 |
|
williamr@4
|
65 |
IMPORT_C void* operator new(std::size_t, const std::nothrow_t&) __NO_THROW;
|
williamr@4
|
66 |
IMPORT_C void operator delete(void*, const std::nothrow_t&) __NO_THROW;
|
williamr@4
|
67 |
|
williamr@4
|
68 |
#ifndef __PLACEMENT_NEW_INLINE
|
williamr@4
|
69 |
#define __PLACEMENT_NEW_INLINE
|
williamr@4
|
70 |
inline void* operator new(std::size_t, void* p) __NO_THROW
|
williamr@4
|
71 |
{
|
williamr@4
|
72 |
return p;
|
williamr@4
|
73 |
}
|
williamr@4
|
74 |
|
williamr@4
|
75 |
inline void operator delete(void*, void*) __NO_THROW
|
williamr@4
|
76 |
{
|
williamr@4
|
77 |
}
|
williamr@4
|
78 |
#endif
|
williamr@4
|
79 |
|
williamr@4
|
80 |
// Array form
|
williamr@4
|
81 |
|
williamr@4
|
82 |
IMPORT_C void* operator new[](std::size_t) __THROW(std::bad_alloc);
|
williamr@4
|
83 |
IMPORT_C void operator delete[](void*) __NO_THROW;
|
williamr@4
|
84 |
|
williamr@4
|
85 |
IMPORT_C void* operator new[](std::size_t, const std::nothrow_t&) __NO_THROW;
|
williamr@4
|
86 |
IMPORT_C void operator delete[](void*, const std::nothrow_t&) __NO_THROW;
|
williamr@4
|
87 |
|
williamr@4
|
88 |
#ifndef __PLACEMENT_VEC_NEW_INLINE
|
williamr@4
|
89 |
#define __PLACEMENT_VEC_NEW_INLINE
|
williamr@4
|
90 |
inline void* operator new[](std::size_t, void* p) __NO_THROW
|
williamr@4
|
91 |
{
|
williamr@4
|
92 |
return p;
|
williamr@4
|
93 |
}
|
williamr@4
|
94 |
|
williamr@4
|
95 |
inline void operator delete[](void*, void*) __NO_THROW
|
williamr@4
|
96 |
{
|
williamr@4
|
97 |
}
|
williamr@4
|
98 |
#endif
|
williamr@4
|
99 |
|
williamr@4
|
100 |
// Symbian additions (not part of standard C++).
|
williamr@4
|
101 |
IMPORT_C void* operator new(std::size_t, std::size_t) __NO_THROW;
|
williamr@4
|
102 |
IMPORT_C void operator delete(void*, std::size_t) __NO_THROW;
|
williamr@4
|
103 |
|
williamr@4
|
104 |
|
williamr@4
|
105 |
|
williamr@4
|
106 |
|
williamr@4
|
107 |
|
williamr@4
|
108 |
# else
|
williamr@4
|
109 |
# include <exception>
|
williamr@4
|
110 |
# include <stl/_cstddef.h>
|
williamr@4
|
111 |
# include <e32def.h>
|
williamr@4
|
112 |
namespace std {
|
williamr@4
|
113 |
|
williamr@4
|
114 |
struct nothrow_t { };
|
williamr@4
|
115 |
extern const nothrow_t nothrow;
|
williamr@4
|
116 |
|
williamr@4
|
117 |
class bad_alloc : public exception {
|
williamr@4
|
118 |
public :
|
williamr@4
|
119 |
bad_alloc () __NO_THROW {};
|
williamr@4
|
120 |
bad_alloc ( const bad_alloc &) __NO_THROW {};
|
williamr@4
|
121 |
bad_alloc & operator =( const bad_alloc &) __NO_THROW { return *this;}
|
williamr@4
|
122 |
virtual const char * what () const __NO_THROW { return "bad_alloc";}
|
williamr@4
|
123 |
};
|
williamr@4
|
124 |
|
williamr@4
|
125 |
typedef void (* new_handler )();
|
williamr@4
|
126 |
new_handler set_new_handler ( new_handler new_p ) __NO_THROW;
|
williamr@4
|
127 |
}
|
williamr@4
|
128 |
|
williamr@4
|
129 |
IMPORT_C void* operator new (std::size_t) __THROW(std::bad_alloc);
|
williamr@4
|
130 |
IMPORT_C void operator delete (void*) __NO_THROW;
|
williamr@4
|
131 |
|
williamr@4
|
132 |
IMPORT_C void* operator new (std::size_t, const std::nothrow_t&) __NO_THROW;
|
williamr@4
|
133 |
IMPORT_C void operator delete (void*, const std::nothrow_t&) __NO_THROW;
|
williamr@4
|
134 |
|
williamr@4
|
135 |
IMPORT_C void* operator new[] (std::size_t) __THROW(std::bad_alloc);
|
williamr@4
|
136 |
IMPORT_C void operator delete[] (void*) __NO_THROW;
|
williamr@4
|
137 |
|
williamr@4
|
138 |
IMPORT_C void* operator new[] (std::size_t, const std::nothrow_t&) __NO_THROW;
|
williamr@4
|
139 |
IMPORT_C void operator delete[] (void*, const std::nothrow_t&) __NO_THROW;
|
williamr@4
|
140 |
|
williamr@4
|
141 |
# ifndef __PLACEMENT_NEW_INLINE
|
williamr@4
|
142 |
# define __PLACEMENT_NEW_INLINE
|
williamr@4
|
143 |
inline void* operator new(std::size_t, void* aBase) __NO_THROW
|
williamr@4
|
144 |
{return aBase;}
|
williamr@4
|
145 |
|
williamr@4
|
146 |
inline void operator delete(void*, void*) __NO_THROW {}
|
williamr@4
|
147 |
# endif //__PLACEMENT_NEW_INLINE
|
williamr@4
|
148 |
|
williamr@4
|
149 |
# ifndef __PLACEMENT_VEC_NEW_INLINE
|
williamr@4
|
150 |
# define __PLACEMENT_VEC_NEW_INLINE
|
williamr@4
|
151 |
inline void* operator new[](std::size_t, void* aBase) __NO_THROW
|
williamr@4
|
152 |
{return aBase;}
|
williamr@4
|
153 |
|
williamr@4
|
154 |
inline void operator delete[](void* , void*) __NO_THROW {}
|
williamr@4
|
155 |
# endif //__PLACEMENT_VEC_NEW_INLINE
|
williamr@4
|
156 |
|
williamr@4
|
157 |
# endif //__EABI__
|
williamr@4
|
158 |
#endif //_SYMCPP_NEW_H_
|