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