Source code of Windows XP (NT5)
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.

196 lines
5.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. *
  56. ****/
  57. #if _MSC_VER > 1000 /*IFSTRIP=IGN*/
  58. #pragma once
  59. #endif
  60. #ifndef _INC_NEW
  61. #define _INC_NEW
  62. #ifdef __cplusplus
  63. #ifndef _MSC_EXTENSIONS
  64. #include <new>
  65. #endif
  66. #if !defined(_WIN32)
  67. #error ERROR: Only Win32 target supported!
  68. #endif
  69. #ifndef _CRTBLD
  70. /* This version of the header files is NOT for user programs.
  71. * It is intended for use when building the C runtimes ONLY.
  72. * The version intended for public use will not have this message.
  73. */
  74. #error ERROR: Use of C runtime library internal header file.
  75. #endif /* _CRTBLD */
  76. #ifndef _INTERNAL_IFSTRIP_
  77. #include <cruntime.h>
  78. #endif /* _INTERNAL_IFSTRIP_ */
  79. #if !defined(_W64)
  80. #if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 /*IFSTRIP=IGN*/
  81. #define _W64 __w64
  82. #else
  83. #define _W64
  84. #endif
  85. #endif
  86. /* Define _CRTIMP */
  87. #ifndef _CRTIMP
  88. #ifdef CRTDLL
  89. #define _CRTIMP __declspec(dllexport)
  90. #else /* ndef CRTDLL */
  91. #ifdef _DLL
  92. #define _CRTIMP __declspec(dllimport)
  93. #else /* ndef _DLL */
  94. #define _CRTIMP
  95. #endif /* _DLL */
  96. #endif /* CRTDLL */
  97. #endif /* _CRTIMP */
  98. #ifndef _USE_OLD_STDCPP
  99. /* Define _CRTIMP2 */
  100. #ifndef _CRTIMP2
  101. #if defined(CRTDLL2)
  102. #define _CRTIMP2 __declspec(dllexport)
  103. #else /* ndef CRTDLL2 */
  104. #if defined(_DLL) && !defined(_STATIC_CPPLIB)
  105. #define _CRTIMP2 __declspec(dllimport)
  106. #else /* ndef _DLL && !STATIC_CPPLIB */
  107. #define _CRTIMP2
  108. #endif /* _DLL && !STATIC_CPPLIB */
  109. #endif /* CRTDLL2 */
  110. #endif /* _CRTIMP2 */
  111. #endif /* _USE_OLD_STDCPP */
  112. /* Define __cdecl for non-Microsoft compilers */
  113. #if ( !defined(_MSC_VER) && !defined(__cdecl) )
  114. #define __cdecl
  115. #endif
  116. /* types and structures */
  117. #ifndef _SIZE_T_DEFINED
  118. #ifdef _WIN64
  119. typedef unsigned __int64 size_t;
  120. #else
  121. typedef _W64 unsigned int size_t;
  122. #endif
  123. #define _SIZE_T_DEFINED
  124. #endif
  125. #ifdef _MSC_EXTENSIONS
  126. #ifdef _USE_OLD_STDCPP
  127. typedef void (__cdecl * new_handler) ();
  128. _CRTIMP new_handler __cdecl set_new_handler(new_handler);
  129. #else
  130. namespace std {
  131. typedef void (__cdecl * new_handler) ();
  132. _CRTIMP2 new_handler __cdecl set_new_handler(new_handler) throw();
  133. };
  134. using std::new_handler;
  135. using std::set_new_handler;
  136. #endif
  137. #endif
  138. #ifndef __PLACEMENT_NEW_INLINE
  139. #define __PLACEMENT_NEW_INLINE
  140. inline void *__cdecl operator new(size_t, void *_P)
  141. {return (_P); }
  142. #if _MSC_VER >= 1200 /*IFSTRIP=IGN*/
  143. inline void __cdecl operator delete(void *, void *)
  144. {return; }
  145. #endif
  146. #endif
  147. /*
  148. * new mode flag -- when set, makes malloc() behave like new()
  149. */
  150. _CRTIMP int __cdecl _query_new_mode( void );
  151. _CRTIMP int __cdecl _set_new_mode( int );
  152. #ifndef _PNH_DEFINED
  153. typedef int (__cdecl * _PNH)( size_t );
  154. #define _PNH_DEFINED
  155. #endif
  156. _CRTIMP _PNH __cdecl _query_new_handler( void );
  157. _CRTIMP _PNH __cdecl _set_new_handler( _PNH );
  158. /*
  159. * Microsoft extension:
  160. *
  161. * _NO_ANSI_NEW_HANDLER de-activates the ANSI new_handler. Use this special value
  162. * to support old style (_set_new_handler) behavior.
  163. */
  164. #ifndef _NO_ANSI_NH_DEFINED
  165. #define _NO_ANSI_NEW_HANDLER ((new_handler)-1)
  166. #define _NO_ANSI_NH_DEFINED
  167. #endif
  168. #endif /* __cplusplus */
  169. #endif /* _INC_NEW */