epoc32/include/stdapis/stlport/stl/_new.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
     1.1 --- a/epoc32/include/stdapis/stlport/stl/_new.h	Tue Nov 24 13:55:44 2009 +0000
     1.2 +++ b/epoc32/include/stdapis/stlport/stl/_new.h	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -1,1 +1,208 @@
     1.4 -_new.h
     1.5 +/*
     1.6 +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
     1.7 +
     1.8 +* Redistribution and use in source and binary forms, with or without 
     1.9 +* modification, are permitted provided that the following conditions are met:
    1.10 +
    1.11 +* Redistributions of source code must retain the above copyright notice, this 
    1.12 +* list of conditions and the following disclaimer.
    1.13 +* Redistributions in binary form must reproduce the above copyright notice, 
    1.14 +* this list of conditions and the following disclaimer in the documentation 
    1.15 +* and/or other materials provided with the distribution.
    1.16 +* Neither the name of Nokia Corporation nor the names of its contributors 
    1.17 +* may be used to endorse or promote products derived from this software 
    1.18 +* without specific prior written permission.
    1.19 +
    1.20 +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
    1.21 +* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
    1.22 +* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
    1.23 +* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 
    1.24 +* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
    1.25 +* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
    1.26 +* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
    1.27 +* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 
    1.28 +* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    1.29 +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    1.30 +*
    1.31 +* Description:
    1.32 +*
    1.33 +*/
    1.34 +
    1.35 +#ifndef _STLP_NEW_H_HEADER
    1.36 +# define _STLP_NEW_H_HEADER
    1.37 +
    1.38 +# ifdef _STLP_NO_BAD_ALLOC
    1.39 +# ifndef _STLP_NEW_DONT_THROW
    1.40 +#   define _STLP_NEW_DONT_THROW 1
    1.41 +# endif /* _STLP_NEW_DONT_THROW */
    1.42 +
    1.43 +#  include <exception>
    1.44 +
    1.45 +
    1.46 +_STLP_BEGIN_NAMESPACE
    1.47 +
    1.48 +#if defined(__SYMBIAN32__) && defined( __WINSCW__)
    1.49 +// already defined symcpp.h included from rvct2_2.h
    1.50 +struct nothrow_t {};
    1.51 +#endif
    1.52 +
    1.53 +
    1.54 +# ifdef _STLP_OWN_IOSTREAMS
    1.55 +#ifdef __ARMCC__
    1.56 +extern _STLP_DECLSPEC const nothrow_t nothrow;
    1.57 +#else
    1.58 +extern IMPORT_C const nothrow_t& GetNoThrowObj();
    1.59 +#define nothrow GetNoThrowObj()
    1.60 +#endif
    1.61 +# else
    1.62 +#  define nothrow nothrow_t()
    1.63 +# endif
    1.64 +#ifndef _STLP_EXCEPTION_BASE
    1.65 +#  define _STLP_EXCEPTION_BASE exception
    1.66 +#endif
    1.67 +
    1.68 +class bad_alloc : public _STLP_EXCEPTION_BASE { 
    1.69 +public:
    1.70 +  bad_alloc () _STLP_NOTHROW_INHERENTLY { }
    1.71 +  bad_alloc(const bad_alloc&) _STLP_NOTHROW_INHERENTLY { }
    1.72 +  bad_alloc& operator=(const bad_alloc&) _STLP_NOTHROW_INHERENTLY {return *this;}
    1.73 +  ~bad_alloc () _STLP_NOTHROW_INHERENTLY { }
    1.74 +  const char* what() const _STLP_NOTHROW_INHERENTLY { return "bad alloc"; }
    1.75 +};
    1.76 +
    1.77 +_STLP_END_NAMESPACE
    1.78 +
    1.79 +#endif /* _STLP_NO_BAD_ALLOC */
    1.80 +
    1.81 +#if defined (_STLP_WINCE)
    1.82 +_STLP_BEGIN_NAMESPACE
    1.83 +
    1.84 +inline void* _STLP_CALL __stl_new(size_t __n) {
    1.85 +  return ::malloc(__n);
    1.86 +}
    1.87 +
    1.88 +inline void _STLP_CALL __stl_delete(void* __p) {
    1.89 +  free(__p);
    1.90 +}
    1.91 +
    1.92 +#ifndef __cdecl
    1.93 +# define __cdecl
    1.94 +#endif
    1.95 +
    1.96 +_STLP_END_NAMESPACE
    1.97 +
    1.98 +#else /* _STLP_WINCE */
    1.99 +
   1.100 +#include <new>
   1.101 +
   1.102 +# ifndef _STLP_NO_BAD_ALLOC
   1.103 +#  ifdef _STLP_USE_OWN_NAMESPACE
   1.104 +
   1.105 +    _STLP_BEGIN_NAMESPACE
   1.106 +    using _STLP_VENDOR_EXCEPT_STD::bad_alloc;
   1.107 +    using _STLP_VENDOR_EXCEPT_STD::nothrow_t;
   1.108 +    using _STLP_VENDOR_EXCEPT_STD::nothrow;
   1.109 +
   1.110 +#  if defined (_STLP_GLOBAL_NEW_HANDLER)
   1.111 +    using ::new_handler;
   1.112 +    using ::set_new_handler;
   1.113 +#  else
   1.114 +    using _STLP_VENDOR_EXCEPT_STD::new_handler;
   1.115 +    using _STLP_VENDOR_EXCEPT_STD::set_new_handler;
   1.116 +#  endif
   1.117 +    
   1.118 +    _STLP_END_NAMESPACE
   1.119 +
   1.120 +#  endif /* _STLP_OWN_NAMESPACE */
   1.121 +
   1.122 +# endif /* _STLP_NO_BAD_ALLOC */
   1.123 +
   1.124 +# if defined (_STLP_NO_NEW_NEW_HEADER) || defined (_STLP_NEW_DONT_THROW) || defined (__SYMBIAN32__) \
   1.125 +                    || defined (__WINS__) && ! defined (_STLP_CHECK_NULL_ALLOC)
   1.126 +#  define _STLP_CHECK_NULL_ALLOC(__x) void* __y = __x;if (__y == 0){_STLP_THROW(bad_alloc());}return __y
   1.127 +# if defined (__SYMBIAN32__)
   1.128 +//# define _STLP_NEW operator new
   1.129 +#define _STLP_NEW  ::malloc
   1.130 +#endif
   1.131 +/*
   1.132 +# elif defined (__SYMBIAN32__) || defined (__WINS__)
   1.133 +#  ifndef _STLP_USE_TRAP_LEAVE
   1.134 +#   define _STLP_CHECK_NULL_ALLOC(__x) void* __y = __x;if (__y == 0){abort();}return __y
   1.135 +#  else
   1.136 +#   define _STLP_NEW(x) :: operator new (x, ELeave) 
   1.137 +#   define _STLP_CHECK_NULL_ALLOC(__x) return __x
   1.138 +#  endif
   1.139 +*/
   1.140 +# else
   1.141 +#  define _STLP_CHECK_NULL_ALLOC(__x) return __x
   1.142 +# endif
   1.143 +
   1.144 +#ifndef _STLP_NEW
   1.145 +# define _STLP_NEW ::operator new
   1.146 +#endif
   1.147 +# define _STLP_PLACEMENT_NEW ::new
   1.148 +
   1.149 +_STLP_BEGIN_NAMESPACE
   1.150 +
   1.151 +#ifdef __SYMBIAN32__
   1.152 +
   1.153 +typedef void(*new_handler)();
   1.154 +
   1.155 +_STLP_DECLSPEC new_handler set_new_handler(new_handler pnew) throw();
   1.156 +
   1.157 +#endif
   1.158 +
   1.159 +#if (( defined(__IBMCPP__)|| defined(__OS400__) || defined (__xlC__) || defined (qTidyHeap)) && defined(__DEBUG_ALLOC__) )
   1.160 +inline void*  _STLP_CALL __stl_new(size_t __n) {  _STLP_CHECK_NULL_ALLOC(_STLP_NEW(__n, __FILE__, __LINE__)); }
   1.161 +inline void _STLP_CALL __stl_delete(void* __p) { ::operator delete(__p, __FILE__, __LINE__); }
   1.162 +#else
   1.163 +inline void*  _STLP_CALL __stl_new(size_t __n)   { return ::operator new(__n); }
   1.164 +inline void   _STLP_CALL __stl_delete(void* __p) { ::operator delete(__p); }
   1.165 +#endif
   1.166 +_STLP_END_NAMESPACE
   1.167 +
   1.168 +
   1.169 +# endif /* _STLP_WINCE */
   1.170 +
   1.171 +#if defined(__SYMBIAN32__) && !defined(__GCCE__)
   1.172 +_STLP_DECLSPEC void *operator new(unsigned int aSize);
   1.173 +
   1.174 +_STLP_DECLSPEC void *operator new[](unsigned int aSize);
   1.175 +#endif
   1.176 +
   1.177 +_STLP_DECLSPEC void operator delete(void* aPtr) throw();
   1.178 +
   1.179 +_STLP_DECLSPEC void operator delete[](void* aPtr) throw();
   1.180 +
   1.181 +_STLP_DECLSPEC void* operator new(unsigned int aSize, const std::nothrow_t& /*aNoThrow*/) throw();
   1.182 +
   1.183 +_STLP_DECLSPEC void* operator new[](unsigned int aSize, const std::nothrow_t& aNoThrow) throw();
   1.184 +
   1.185 +_STLP_DECLSPEC void operator delete(void* aPtr, const std::nothrow_t& /*aNoThrow*/) throw();
   1.186 +
   1.187 +_STLP_DECLSPEC void operator delete[](void* aPtr, const std::nothrow_t& /*aNoThrow*/) throw();
   1.188 +
   1.189 +
   1.190 +// placement delete
   1.191 +#ifndef __PLACEMENT_VEC_NEW_INLINE
   1.192 +#define __PLACEMENT_VEC_NEW_INLINE
   1.193 +inline void* operator new[](unsigned int /*aSize*/, void* aBase) throw()
   1.194 +	{return aBase;}
   1.195 +inline void operator delete[](void* /*aPtr*/, void* /*aBase*/) throw()
   1.196 +    {
   1.197 +    
   1.198 +    }
   1.199 +#endif
   1.200 +
   1.201 +#ifndef __PLACEMENT_NEW_INLINE
   1.202 +#define __PLACEMENT_NEW_INLINE
   1.203 +inline void* operator new(unsigned int /*aSize*/, void* aBase) throw()
   1.204 +	{return aBase;}
   1.205 +
   1.206 +// Global placement operator delete
   1.207 +inline void operator delete(void* /*aPtr*/, void* /*aBase*/) throw()
   1.208 +	{}
   1.209 +#endif //__PLACEMENT_NEW_INLINE
   1.210 +
   1.211 +
   1.212 +#endif /* _STLP_NEW_H_HEADER */