Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

220 lines
6.8 KiB

  1. /***
  2. *new.h - declarations and definitions for C++ memory allocation functions
  3. *
  4. * Copyright (c) 1990-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * Contains the declarations for C++ memory allocation functions.
  8. *
  9. * [Public]
  10. *
  11. *Revision History:
  12. * 03-07-90 WAJ Initial version.
  13. * 04-09-91 JCR ANSI keyword conformance
  14. * 08-12-91 JCR Renamed new.hxx to new.h
  15. * 08-13-91 JCR Better set_new_handler names (ANSI, etc.).
  16. * 10-03-91 JCR Added _OS2_IFSTRIP switches for ifstrip'ing purposes
  17. * 10-30-91 JCR Changed "nhew" to "hnew" (typo in name!)
  18. * 11-13-91 JCR 32-bit version.
  19. * 06-03-92 KRS Fix CAVIAR #850: _CALLTYPE1 missing from prototype.
  20. * 08-05-92 GJF Function calling type and variable type macros.
  21. * 01-21-93 GJF Removed support for C6-386's _cdecl.
  22. * 04-06-93 SKS Replace _CRTAPI1/2 with __cdecl, _CRTVAR1 with nothing
  23. * 04-07-93 SKS Add _CRTIMP keyword for CRT DLL model
  24. * 10-11-93 GJF Support NT SDK and Cuda builds.
  25. * 03-03-94 SKS Add _query_new_handler(), _set/_query_new_mode().
  26. * 03-31-94 GJF Conditionalized typedef of _PNH so multiple
  27. * inclusions of new.h will work.
  28. * 05-03-94 CFW Add set_new_handler.
  29. * 06-03-94 SKS Remove set_new_hander -- it does NOT conform to ANSI
  30. * C++ working standard. We may implement it later.
  31. * 02-11-95 CFW Add _CRTBLD to avoid users getting wrong headers.
  32. * 02-14-95 CFW Clean up Mac merge.
  33. * 04-10-95 CFW Add set_new_handler stub, fix _INC_NEW.
  34. * 04-19-95 CFW Change set_new_handler comments, add placement new.
  35. * 05-24-95 CFW Add ANSI new handler.
  36. * 06-23-95 CFW ANSI new handler removed from build.
  37. * 10-05-95 SKS Add __cdecl to new_handler prototype so that the
  38. * cleansed new.h matches the checked-in version.
  39. * 12-14-95 JWM Add "#pragma once".
  40. * 03-04-96 JWM Replaced by C++ header "new".
  41. * 03-04-96 JWM MS-specific restored.
  42. * 02-20-97 GJF Cleaned out obsolete support for _CRTAPI* and _NTSDK.
  43. * Also, detab-ed.
  44. * 04-18-97 JWM Placement operator delete() added.
  45. * 04-21-97 JWM Placement operator delete() now #if _MSC_VER >= 1200.
  46. * 09-30-97 JWM Restored not-so-obsolete _CRTAPI1 support.
  47. * 10-07-97 RDL Added IA64.
  48. * 12-15-98 GJF Changes for 64-bit size_t.
  49. * 05-13-99 PML Remove _CRTAPI1
  50. * 05-17-99 PML Remove all Macintosh support.
  51. * 10-06-99 PML Add _W64 modifier to types which are 32 bits in Win32,
  52. * 64 bits in Win64.
  53. * 03-18-01 PML Define new_handler/set_new_handler compatibly with
  54. * definitions in <new> (vs7#194908).
  55. * 06-15-01 PML Duplicate defs of std::nothrow_t, std::nothrow from
  56. * header <new> (vs7#237394)
  57. *
  58. ****/
  59. #if _MSC_VER > 1000 /*IFSTRIP=IGN*/
  60. #pragma once
  61. #endif
  62. #ifndef _INC_NEW
  63. #define _INC_NEW
  64. #ifdef __cplusplus
  65. #ifndef _MSC_EXTENSIONS
  66. #include <new>
  67. #endif
  68. #if !defined(_WIN32)
  69. #error ERROR: Only Win32 target supported!
  70. #endif
  71. #ifndef _CRTBLD
  72. /* This version of the header files is NOT for user programs.
  73. * It is intended for use when building the C runtimes ONLY.
  74. * The version intended for public use will not have this message.
  75. */
  76. #error ERROR: Use of C runtime library internal header file.
  77. #endif /* _CRTBLD */
  78. /* Protect against #define of new */
  79. #pragma push_macro("new")
  80. #undef new
  81. #ifndef _INTERNAL_IFSTRIP_
  82. #include <cruntime.h>
  83. #endif /* _INTERNAL_IFSTRIP_ */
  84. #if !defined(_W64)
  85. #if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 /*IFSTRIP=IGN*/
  86. #define _W64 __w64
  87. #else
  88. #define _W64
  89. #endif
  90. #endif
  91. /* Define _CRTIMP */
  92. #ifndef _CRTIMP
  93. #ifdef CRTDLL
  94. #define _CRTIMP __declspec(dllexport)
  95. #else /* ndef CRTDLL */
  96. #ifdef _DLL
  97. #define _CRTIMP __declspec(dllimport)
  98. #else /* ndef _DLL */
  99. #define _CRTIMP
  100. #endif /* _DLL */
  101. #endif /* CRTDLL */
  102. #endif /* _CRTIMP */
  103. #ifndef _USE_OLD_STDCPP
  104. /* Define _CRTIMP2 */
  105. #ifndef _CRTIMP2
  106. #if defined(CRTDLL2)
  107. #define _CRTIMP2 __declspec(dllexport)
  108. #else /* ndef CRTDLL2 */
  109. #if defined(_DLL) && !defined(_STATIC_CPPLIB)
  110. #define _CRTIMP2 __declspec(dllimport)
  111. #else /* ndef _DLL && !STATIC_CPPLIB */
  112. #define _CRTIMP2
  113. #endif /* _DLL && !STATIC_CPPLIB */
  114. #endif /* CRTDLL2 */
  115. #endif /* _CRTIMP2 */
  116. #endif /* _USE_OLD_STDCPP */
  117. /* Define __cdecl for non-Microsoft compilers */
  118. #if ( !defined(_MSC_VER) && !defined(__cdecl) )
  119. #define __cdecl
  120. #endif
  121. /* types and structures */
  122. #ifndef _SIZE_T_DEFINED
  123. #ifdef _WIN64
  124. typedef unsigned __int64 size_t;
  125. #else
  126. typedef _W64 unsigned int size_t;
  127. #endif
  128. #define _SIZE_T_DEFINED
  129. #endif
  130. #ifdef _MSC_EXTENSIONS
  131. #ifdef _USE_OLD_STDCPP
  132. typedef void (__cdecl * new_handler) ();
  133. _CRTIMP new_handler __cdecl set_new_handler(new_handler);
  134. #else
  135. namespace std {
  136. typedef void (__cdecl * new_handler) ();
  137. _CRTIMP2 new_handler __cdecl set_new_handler(new_handler) throw();
  138. };
  139. using std::new_handler;
  140. using std::set_new_handler;
  141. #endif
  142. #endif
  143. #ifndef __NOTHROW_T_DEFINED
  144. #define __NOTHROW_T_DEFINED
  145. namespace std {
  146. /* placement new tag type to suppress exceptions */
  147. struct nothrow_t {};
  148. /* constant for placement new tag */
  149. extern const nothrow_t nothrow;
  150. };
  151. void *__cdecl operator new(size_t, const std::nothrow_t&) throw();
  152. void *__cdecl operator new[](size_t, const std::nothrow_t&) throw();
  153. void __cdecl operator delete(void *, const std::nothrow_t&) throw();
  154. void __cdecl operator delete[](void *, const std::nothrow_t&) throw();
  155. #endif
  156. #ifndef __PLACEMENT_NEW_INLINE
  157. #define __PLACEMENT_NEW_INLINE
  158. inline void *__cdecl operator new(size_t, void *_P)
  159. {return (_P); }
  160. #if _MSC_VER >= 1200 /*IFSTRIP=IGN*/
  161. inline void __cdecl operator delete(void *, void *)
  162. {return; }
  163. #endif
  164. #endif
  165. /*
  166. * new mode flag -- when set, makes malloc() behave like new()
  167. */
  168. _CRTIMP int __cdecl _query_new_mode( void );
  169. _CRTIMP int __cdecl _set_new_mode( int );
  170. #ifndef _PNH_DEFINED
  171. typedef int (__cdecl * _PNH)( size_t );
  172. #define _PNH_DEFINED
  173. #endif
  174. _CRTIMP _PNH __cdecl _query_new_handler( void );
  175. _CRTIMP _PNH __cdecl _set_new_handler( _PNH );
  176. /*
  177. * Microsoft extension:
  178. *
  179. * _NO_ANSI_NEW_HANDLER de-activates the ANSI new_handler. Use this special value
  180. * to support old style (_set_new_handler) behavior.
  181. */
  182. #ifndef _NO_ANSI_NH_DEFINED
  183. #define _NO_ANSI_NEW_HANDLER ((new_handler)-1)
  184. #define _NO_ANSI_NH_DEFINED
  185. #endif
  186. #pragma pop_macro("new")
  187. #endif /* __cplusplus */
  188. #endif /* _INC_NEW */