1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/cppstdlib/inc/new Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,158 @@
1.4 +/*
1.5 + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(- * * ies).
1.6 + * All rights reserved.
1.7 + * This component and the accompanying materials are made available
1.8 + * under the terms of the License "Eclipse Public License v1.0"
1.9 + * which accompanies this distribution, and is available
1.10 + * at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 + *
1.12 + * Initial Contributors:
1.13 + * Nokia Corporation - initial contribution.
1.14 + *
1.15 + * Contributors:
1.16 + *
1.17 + * Description:
1.18 + * Name : new
1.19 + * Part of : standard c++ library.
1.20 + *
1.21 + */
1.22 +
1.23 +
1.24 +#ifndef _SYMCPP_NEW_H_
1.25 +#define _SYMCPP_NEW_H_
1.26 +
1.27 +
1.28 +#ifndef _STLP_FEATURES_H
1.29 +# include <stl/config/features.h>
1.30 +#endif
1.31 +
1.32 +
1.33 +
1.34 +# ifdef __EABI__
1.35 +# include <stl/_cstddef.h> //Include the STLP internal header to make macros/typedefs expected of <csddef> available.
1.36 +# define _STLP_CSTDDEF //Define this macro so that <cstddef> doesn't get included by new_eabi.h
1.37 +
1.38 +#include "exception"
1.39 +
1.40 +namespace std
1.41 +{
1.42 + typedef unsigned size_t;
1.43 +
1.44 + class bad_alloc : public exception
1.45 + {
1.46 + public:
1.47 + IMPORT_C bad_alloc() __NO_THROW;
1.48 + IMPORT_C bad_alloc(const bad_alloc&) __NO_THROW;
1.49 + IMPORT_C bad_alloc& operator=(const bad_alloc&) __NO_THROW; // { return *this;}
1.50 +
1.51 + IMPORT_C virtual ~bad_alloc() __NO_THROW; // {}
1.52 + IMPORT_C virtual const char* what() const __NO_THROW; // { return "bad_alloc";}
1.53 + };
1.54 +
1.55 + struct nothrow_t {};
1.56 + extern const nothrow_t nothrow;
1.57 +
1.58 + typedef void (*new_handler)();
1.59 +
1.60 + IMPORT_C new_handler set_new_handler(new_handler) __NO_THROW;
1.61 +}
1.62 +
1.63 +// Single-object form
1.64 +
1.65 +IMPORT_C void* operator new(std::size_t) __THROW(std::bad_alloc);
1.66 +IMPORT_C void operator delete(void*) __NO_THROW;
1.67 +
1.68 +IMPORT_C void* operator new(std::size_t, const std::nothrow_t&) __NO_THROW;
1.69 +IMPORT_C void operator delete(void*, const std::nothrow_t&) __NO_THROW;
1.70 +
1.71 +#ifndef __PLACEMENT_NEW_INLINE
1.72 + #define __PLACEMENT_NEW_INLINE
1.73 + inline void* operator new(std::size_t, void* p) __NO_THROW
1.74 + {
1.75 + return p;
1.76 + }
1.77 +
1.78 + inline void operator delete(void*, void*) __NO_THROW
1.79 + {
1.80 + }
1.81 +#endif
1.82 +
1.83 +// Array form
1.84 +
1.85 +IMPORT_C void* operator new[](std::size_t) __THROW(std::bad_alloc);
1.86 +IMPORT_C void operator delete[](void*) __NO_THROW;
1.87 +
1.88 +IMPORT_C void* operator new[](std::size_t, const std::nothrow_t&) __NO_THROW;
1.89 +IMPORT_C void operator delete[](void*, const std::nothrow_t&) __NO_THROW;
1.90 +
1.91 +#ifndef __PLACEMENT_VEC_NEW_INLINE
1.92 + #define __PLACEMENT_VEC_NEW_INLINE
1.93 + inline void* operator new[](std::size_t, void* p) __NO_THROW
1.94 + {
1.95 + return p;
1.96 + }
1.97 +
1.98 + inline void operator delete[](void*, void*) __NO_THROW
1.99 + {
1.100 + }
1.101 +#endif
1.102 +
1.103 +// Symbian additions (not part of standard C++).
1.104 +IMPORT_C void* operator new(std::size_t, std::size_t) __NO_THROW;
1.105 +IMPORT_C void operator delete(void*, std::size_t) __NO_THROW;
1.106 +
1.107 +
1.108 +
1.109 +
1.110 +
1.111 +# else
1.112 +# include <exception>
1.113 +# include <stl/_cstddef.h>
1.114 +# include <e32def.h>
1.115 +namespace std {
1.116 +
1.117 + struct nothrow_t { };
1.118 + extern const nothrow_t nothrow;
1.119 +
1.120 + class bad_alloc : public exception {
1.121 + public :
1.122 + bad_alloc () __NO_THROW {};
1.123 + bad_alloc ( const bad_alloc &) __NO_THROW {};
1.124 + bad_alloc & operator =( const bad_alloc &) __NO_THROW { return *this;}
1.125 + virtual const char * what () const __NO_THROW { return "bad_alloc";}
1.126 + };
1.127 +
1.128 + typedef void (* new_handler )();
1.129 + new_handler set_new_handler ( new_handler new_p ) __NO_THROW;
1.130 +}
1.131 +
1.132 +IMPORT_C void* operator new (std::size_t) __THROW(std::bad_alloc);
1.133 +IMPORT_C void operator delete (void*) __NO_THROW;
1.134 +
1.135 +IMPORT_C void* operator new (std::size_t, const std::nothrow_t&) __NO_THROW;
1.136 +IMPORT_C void operator delete (void*, const std::nothrow_t&) __NO_THROW;
1.137 +
1.138 +IMPORT_C void* operator new[] (std::size_t) __THROW(std::bad_alloc);
1.139 +IMPORT_C void operator delete[] (void*) __NO_THROW;
1.140 +
1.141 +IMPORT_C void* operator new[] (std::size_t, const std::nothrow_t&) __NO_THROW;
1.142 +IMPORT_C void operator delete[] (void*, const std::nothrow_t&) __NO_THROW;
1.143 +
1.144 +# ifndef __PLACEMENT_NEW_INLINE
1.145 +# define __PLACEMENT_NEW_INLINE
1.146 +inline void* operator new(std::size_t, void* aBase) __NO_THROW
1.147 + {return aBase;}
1.148 +
1.149 +inline void operator delete(void*, void*) __NO_THROW {}
1.150 +# endif //__PLACEMENT_NEW_INLINE
1.151 +
1.152 +# ifndef __PLACEMENT_VEC_NEW_INLINE
1.153 +# define __PLACEMENT_VEC_NEW_INLINE
1.154 +inline void* operator new[](std::size_t, void* aBase) __NO_THROW
1.155 + {return aBase;}
1.156 +
1.157 +inline void operator delete[](void* , void*) __NO_THROW {}
1.158 +# endif //__PLACEMENT_VEC_NEW_INLINE
1.159 +
1.160 +# endif //__EABI__
1.161 +#endif //_SYMCPP_NEW_H_