epoc32/include/stdapis/stlport/stl/_new.h
branchSymbian3
changeset 4 837f303aceeb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/stdapis/stlport/stl/_new.h	Wed Mar 31 12:33:34 2010 +0100
     1.3 @@ -0,0 +1,198 @@
     1.4 +/*
     1.5 +* Copyright (c) 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 "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 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +#ifndef _STLP_NEW_H_HEADER
    1.23 +# define _STLP_NEW_H_HEADER
    1.24 +
    1.25 +# ifdef _STLP_NO_BAD_ALLOC
    1.26 +# ifndef _STLP_NEW_DONT_THROW
    1.27 +#   define _STLP_NEW_DONT_THROW 1
    1.28 +# endif /* _STLP_NEW_DONT_THROW */
    1.29 +
    1.30 +#  include <exception>
    1.31 +
    1.32 +
    1.33 +_STLP_BEGIN_NAMESPACE
    1.34 +
    1.35 +#if defined(__SYMBIAN32__) && ( defined( __WINSCW__) || defined(__GCCXML__)) 
    1.36 +
    1.37 +// already defined symcpp.h included from rvct2_2.h
    1.38 +struct nothrow_t {};
    1.39 +#endif
    1.40 +
    1.41 +
    1.42 +
    1.43 +# ifdef _STLP_OWN_IOSTREAMS
    1.44 +#ifdef __ARMCC__
    1.45 +extern _STLP_DECLSPEC const nothrow_t nothrow;
    1.46 +#else
    1.47 +extern IMPORT_C const nothrow_t& GetNoThrowObj();
    1.48 +#define nothrow GetNoThrowObj()
    1.49 +#endif
    1.50 +# else
    1.51 +#  define nothrow nothrow_t()
    1.52 +# endif
    1.53 +#ifndef _STLP_EXCEPTION_BASE
    1.54 +#  define _STLP_EXCEPTION_BASE exception
    1.55 +#endif
    1.56 +
    1.57 +class bad_alloc : public _STLP_EXCEPTION_BASE { 
    1.58 +public:
    1.59 +  bad_alloc () _STLP_NOTHROW_INHERENTLY { }
    1.60 +  bad_alloc(const bad_alloc&) _STLP_NOTHROW_INHERENTLY { }
    1.61 +  bad_alloc& operator=(const bad_alloc&) _STLP_NOTHROW_INHERENTLY {return *this;}
    1.62 +  ~bad_alloc () _STLP_NOTHROW_INHERENTLY { }
    1.63 +  const char* what() const _STLP_NOTHROW_INHERENTLY { return "bad alloc"; }
    1.64 +};
    1.65 +
    1.66 +_STLP_END_NAMESPACE
    1.67 +
    1.68 +#endif /* _STLP_NO_BAD_ALLOC */
    1.69 +
    1.70 +#if defined (_STLP_WINCE)
    1.71 +_STLP_BEGIN_NAMESPACE
    1.72 +
    1.73 +inline void* _STLP_CALL __stl_new(size_t __n) {
    1.74 +  return ::malloc(__n);
    1.75 +}
    1.76 +
    1.77 +inline void _STLP_CALL __stl_delete(void* __p) {
    1.78 +  free(__p);
    1.79 +}
    1.80 +
    1.81 +#ifndef __cdecl
    1.82 +# define __cdecl
    1.83 +#endif
    1.84 +
    1.85 +_STLP_END_NAMESPACE
    1.86 +
    1.87 +#else /* _STLP_WINCE */
    1.88 +
    1.89 +#include <new>
    1.90 +
    1.91 +# ifndef _STLP_NO_BAD_ALLOC
    1.92 +#  ifdef _STLP_USE_OWN_NAMESPACE
    1.93 +
    1.94 +    _STLP_BEGIN_NAMESPACE
    1.95 +    using _STLP_VENDOR_EXCEPT_STD::bad_alloc;
    1.96 +    using _STLP_VENDOR_EXCEPT_STD::nothrow_t;
    1.97 +    using _STLP_VENDOR_EXCEPT_STD::nothrow;
    1.98 +
    1.99 +#  if defined (_STLP_GLOBAL_NEW_HANDLER)
   1.100 +    using ::new_handler;
   1.101 +    using ::set_new_handler;
   1.102 +#  else
   1.103 +    using _STLP_VENDOR_EXCEPT_STD::new_handler;
   1.104 +    using _STLP_VENDOR_EXCEPT_STD::set_new_handler;
   1.105 +#  endif
   1.106 +    
   1.107 +    _STLP_END_NAMESPACE
   1.108 +
   1.109 +#  endif /* _STLP_OWN_NAMESPACE */
   1.110 +
   1.111 +# endif /* _STLP_NO_BAD_ALLOC */
   1.112 +
   1.113 +# if defined (_STLP_NO_NEW_NEW_HEADER) || defined (_STLP_NEW_DONT_THROW) || defined (__SYMBIAN32__) \
   1.114 +                    || defined (__WINS__) && ! defined (_STLP_CHECK_NULL_ALLOC)
   1.115 +#  define _STLP_CHECK_NULL_ALLOC(__x) void* __y = __x;if (__y == 0){_STLP_THROW(bad_alloc());}return __y
   1.116 +# if defined (__SYMBIAN32__)
   1.117 +//# define _STLP_NEW operator new
   1.118 +#define _STLP_NEW  ::malloc
   1.119 +#endif
   1.120 +/*
   1.121 +# elif defined (__SYMBIAN32__) || defined (__WINS__)
   1.122 +#  ifndef _STLP_USE_TRAP_LEAVE
   1.123 +#   define _STLP_CHECK_NULL_ALLOC(__x) void* __y = __x;if (__y == 0){abort();}return __y
   1.124 +#  else
   1.125 +#   define _STLP_NEW(x) :: operator new (x, ELeave) 
   1.126 +#   define _STLP_CHECK_NULL_ALLOC(__x) return __x
   1.127 +#  endif
   1.128 +*/
   1.129 +# else
   1.130 +#  define _STLP_CHECK_NULL_ALLOC(__x) return __x
   1.131 +# endif
   1.132 +
   1.133 +#ifndef _STLP_NEW
   1.134 +# define _STLP_NEW ::operator new
   1.135 +#endif
   1.136 +# define _STLP_PLACEMENT_NEW ::new
   1.137 +
   1.138 +_STLP_BEGIN_NAMESPACE
   1.139 +
   1.140 +#ifdef __SYMBIAN32__
   1.141 +
   1.142 +typedef void(*new_handler)();
   1.143 +
   1.144 +_STLP_DECLSPEC new_handler set_new_handler(new_handler pnew)  __NO_THROW;
   1.145 +
   1.146 +#endif
   1.147 +
   1.148 +#if (( defined(__IBMCPP__)|| defined(__OS400__) || defined (__xlC__) || defined (qTidyHeap)) && defined(__DEBUG_ALLOC__) )
   1.149 +inline void*  _STLP_CALL __stl_new(size_t __n) {  _STLP_CHECK_NULL_ALLOC(_STLP_NEW(__n, __FILE__, __LINE__)); }
   1.150 +inline void _STLP_CALL __stl_delete(void* __p) { ::operator delete(__p, __FILE__, __LINE__); }
   1.151 +#else
   1.152 +inline void*  _STLP_CALL __stl_new(size_t __n)   { return ::operator new(__n); }
   1.153 +inline void   _STLP_CALL __stl_delete(void* __p) { ::operator delete(__p); }
   1.154 +#endif
   1.155 +_STLP_END_NAMESPACE
   1.156 +
   1.157 +
   1.158 +# endif /* _STLP_WINCE */
   1.159 +
   1.160 +#if defined(__SYMBIAN32__) && !defined(__GCCE__)
   1.161 +_STLP_DECLSPEC void *operator new(unsigned int aSize);
   1.162 +
   1.163 +_STLP_DECLSPEC void *operator new[](unsigned int aSize);
   1.164 +#endif
   1.165 +
   1.166 +_STLP_DECLSPEC void operator delete(void* aPtr) __NO_THROW;
   1.167 +
   1.168 +_STLP_DECLSPEC void operator delete[](void* aPtr) __NO_THROW;
   1.169 +
   1.170 +_STLP_DECLSPEC void* operator new(unsigned int aSize, const std::nothrow_t& /*aNoThrow*/)  __NO_THROW;
   1.171 +
   1.172 +_STLP_DECLSPEC void* operator new[](unsigned int aSize, const std::nothrow_t& aNoThrow)  __NO_THROW;
   1.173 +
   1.174 +_STLP_DECLSPEC void operator delete(void* aPtr, const std::nothrow_t& /*aNoThrow*/)  __NO_THROW;
   1.175 +
   1.176 +_STLP_DECLSPEC void operator delete[](void* aPtr, const std::nothrow_t& /*aNoThrow*/)  __NO_THROW;
   1.177 +
   1.178 +
   1.179 +// placement delete
   1.180 +#ifndef __PLACEMENT_VEC_NEW_INLINE
   1.181 +#define __PLACEMENT_VEC_NEW_INLINE
   1.182 +inline void* operator new[](unsigned int /*aSize*/, void* aBase)  __NO_THROW
   1.183 +	{return aBase;}
   1.184 +inline void operator delete[](void* /*aPtr*/, void* /*aBase*/)  __NO_THROW
   1.185 +    {
   1.186 +    
   1.187 +    }
   1.188 +#endif
   1.189 +
   1.190 +#ifndef __PLACEMENT_NEW_INLINE
   1.191 +#define __PLACEMENT_NEW_INLINE
   1.192 +inline void* operator new(unsigned int /*aSize*/, void* aBase)  __NO_THROW
   1.193 +	{return aBase;}
   1.194 +
   1.195 +// Global placement operator delete
   1.196 +inline void operator delete(void* /*aPtr*/, void* /*aBase*/)  __NO_THROW
   1.197 +	{}
   1.198 +#endif //__PLACEMENT_NEW_INLINE
   1.199 +
   1.200 +
   1.201 +#endif /* _STLP_NEW_H_HEADER */