1
2 /***
3 *new.h - declarations and definitions for C++ memory allocation functions
4 *
5 *           Copyright (c) Microsoft Corporation. All rights reserved.
6 *
7 *Purpose:
8 *           Contains the declarations for C++ memory allocation functions.
9 *
10 *           [Public]
11 *
12 ****/
13
14 #if        _MSC_VER > 1000
15 #pragma once
16 #endif
17
18 #ifndef _INC_NEW
19 #define _INC_NEW
20
21 #ifdef  __cplusplus
22
23 #ifndef _MSC_EXTENSIONS
24 #include <new>
25 #endif
26
27 #include <crtdefs.h>
28
29 /* Protect against #define of new */
30 #pragma push_macro("new")
31 #undef  new
32
33 /* Define _CRTIMP2 */
34 #ifndef _CRTIMP2
35 #if defined(_DLL) && !defined(_STATIC_CPPLIB)
36 #define _CRTIMP2 __declspec(dllimport)
37 #else     /* ndef _DLL && !STATIC_CPPLIB */
38 #define _CRTIMP2
39 #endif  /* _DLL && !STATIC_CPPLIB */
40 #endif  /* _CRTIMP2 */
41
42 /* Define __cdecl for non-Microsoft compilers */
43
44 #if        ( !defined(_MSC_VER) && !defined(__cdecl) )
45 #define __cdecl
46 #endif
47
48 #ifdef  _MSC_EXTENSIONS
49
50 namespace std {
51
52 #ifdef _M_CEE_PURE
53 typedef void (__clrcall * new_handler) ();
54 #else
55 typedef void (__cdecl * new_handler) ();
56 #endif
57 #ifdef _M_CEE
58 typedef void (__clrcall * _new_handler_m) ();
59 #endif
60 _CRTIMP2 new_handler __cdecl set_new_handler(_In_opt_ new_handler _NewHandler) throw();
61 #ifdef _M_CEE_MIXED
62 extern "C++" _MRTIMP _new_handler_m __cdecl set_new_handler(_In_opt_ _new_handler_m _NewHandler) throw();
63 extern "C++" _CRTIMP2 new_handler __cdecl set_new_handler(int) throw();
64 #endif
65
66 };
67
68 #ifdef _M_CEE
69 using std::_new_handler_m;
70 #endif
71 using std::new_handler;
72 using std::set_new_handler;
73 #endif
74
75 #ifndef __NOTHROW_T_DEFINED
76 #define __NOTHROW_T_DEFINED
77 namespace std {
78              /* placement new tag type to suppress exceptions */
Lines 79 ... 88 are skipped.
89 #endif
90
91 #ifndef __PLACEMENT_NEW_INLINE
92 #define __PLACEMENT_NEW_INLINE
93 inline void *__CRTDECL operator new(size_t, void *_Where)
94              {return (_Where); }
95 #if        _MSC_VER >= 1200
96 inline void __CRTDECL operator delete(void *, void *)
97              {return; }
98 #endif
99 #endif
100
101
102 /* 
103  * new mode flag -- when set, makes malloc() behave like new()
104  */
105
106 _CRTIMP int __cdecl _query_new_mode( void );
107 _CRTIMP int __cdecl _set_new_mode( _In_ int _NewMode);
108
109 #ifndef _PNH_DEFINED
110 #ifdef _M_CEE_PURE
111 typedef int (__clrcall * _PNH)( size_t );
112 #else
113 typedef int (__cdecl * _PNH)( size_t );
114 #endif
115 #define _PNH_DEFINED
116 #endif
117
118 _CRTIMP _PNH __cdecl _query_new_handler( void );
119 _CRTIMP _PNH __cdecl _set_new_handler( _In_opt_ _PNH _NewHandler);
120
121 #if _MSC_VER >= 1400 && defined(_M_CEE)
122 #ifndef __MPNH_DEFINED
123 typedef int (__clrcall * __MPNH)( size_t );
124 #define __MPNH_DEFINED
125 #endif
126
127 _MRTIMP __MPNH __cdecl __query_new_handler_m( void );
128 #ifdef _M_CEE_MIXED
129 /* _set_new_handler(int) is used to disambiguate NULL/0 */
130 _CRTIMP _PNH __cdecl _set_new_handler( _In_ int _NewHandler);
131 extern "C++" _MRTIMP __MPNH __cdecl _set_new_handler(_In_opt_ __MPNH _NewHandler);
132 #endif
133 #endif
134
135 /*
136  * Microsoft extension: 
137  *
138  * _NO_ANSI_NEW_HANDLER de-activates the ANSI new_handler. Use this special value
139  * to support old style (_set_new_handler) behavior.
140  */
141
142 #ifndef _NO_ANSI_NH_DEFINED
143 #define _NO_ANSI_NEW_HANDLER  ((new_handler)-1)
144 #define _NO_ANSI_NEW_HANDLER_M  ((_new_handler_m)-1)
145 #define _NO_ANSI_NH_DEFINED
146 #endif
147
148 #pragma pop_macro("new")
149
150 #endif  /* __cplusplus */
151
152 #endif  /* _INC_NEW */
153