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.

148 lines
3.2 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. ****/
  12. #if _MSC_VER > 1000
  13. #pragma once
  14. #endif
  15. #ifndef _INC_NEW
  16. #define _INC_NEW
  17. #ifdef __cplusplus
  18. #ifndef _MSC_EXTENSIONS
  19. #include <new>
  20. #endif
  21. #if !defined(_WIN32)
  22. #error ERROR: Only Win32 target supported!
  23. #endif
  24. /* Protect against #define of new */
  25. #pragma push_macro("new")
  26. #undef new
  27. #if !defined(_W64)
  28. #if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
  29. #define _W64 __w64
  30. #else
  31. #define _W64
  32. #endif
  33. #endif
  34. /* Define _CRTIMP */
  35. #ifndef _CRTIMP
  36. #ifdef _DLL
  37. #define _CRTIMP __declspec(dllimport)
  38. #else /* ndef _DLL */
  39. #define _CRTIMP
  40. #endif /* _DLL */
  41. #endif /* _CRTIMP */
  42. /* Define _CRTIMP2 */
  43. #ifndef _CRTIMP2
  44. #if defined(_DLL) && !defined(_STATIC_CPPLIB)
  45. #define _CRTIMP2 __declspec(dllimport)
  46. #else /* ndef _DLL && !STATIC_CPPLIB */
  47. #define _CRTIMP2
  48. #endif /* _DLL && !STATIC_CPPLIB */
  49. #endif /* _CRTIMP2 */
  50. /* Define __cdecl for non-Microsoft compilers */
  51. #if ( !defined(_MSC_VER) && !defined(__cdecl) )
  52. #define __cdecl
  53. #endif
  54. /* types and structures */
  55. #ifndef _SIZE_T_DEFINED
  56. #ifdef _WIN64
  57. typedef unsigned __int64 size_t;
  58. #else
  59. typedef _W64 unsigned int size_t;
  60. #endif
  61. #define _SIZE_T_DEFINED
  62. #endif
  63. #ifdef _MSC_EXTENSIONS
  64. namespace std {
  65. typedef void (__cdecl * new_handler) ();
  66. _CRTIMP2 new_handler __cdecl set_new_handler(new_handler) throw();
  67. };
  68. using std::new_handler;
  69. using std::set_new_handler;
  70. #endif
  71. #ifndef __NOTHROW_T_DEFINED
  72. #define __NOTHROW_T_DEFINED
  73. namespace std {
  74. /* placement new tag type to suppress exceptions */
  75. struct nothrow_t {};
  76. /* constant for placement new tag */
  77. extern const nothrow_t nothrow;
  78. };
  79. void *__cdecl operator new(size_t, const std::nothrow_t&) throw();
  80. void *__cdecl operator new[](size_t, const std::nothrow_t&) throw();
  81. void __cdecl operator delete(void *, const std::nothrow_t&) throw();
  82. void __cdecl operator delete[](void *, const std::nothrow_t&) throw();
  83. #endif
  84. #ifndef __PLACEMENT_NEW_INLINE
  85. #define __PLACEMENT_NEW_INLINE
  86. inline void *__cdecl operator new(size_t, void *_P)
  87. {return (_P); }
  88. #if _MSC_VER >= 1200
  89. inline void __cdecl operator delete(void *, void *)
  90. {return; }
  91. #endif
  92. #endif
  93. /*
  94. * new mode flag -- when set, makes malloc() behave like new()
  95. */
  96. _CRTIMP int __cdecl _query_new_mode( void );
  97. _CRTIMP int __cdecl _set_new_mode( int );
  98. #ifndef _PNH_DEFINED
  99. typedef int (__cdecl * _PNH)( size_t );
  100. #define _PNH_DEFINED
  101. #endif
  102. _CRTIMP _PNH __cdecl _query_new_handler( void );
  103. _CRTIMP _PNH __cdecl _set_new_handler( _PNH );
  104. /*
  105. * Microsoft extension:
  106. *
  107. * _NO_ANSI_NEW_HANDLER de-activates the ANSI new_handler. Use this special value
  108. * to support old style (_set_new_handler) behavior.
  109. */
  110. #ifndef _NO_ANSI_NH_DEFINED
  111. #define _NO_ANSI_NEW_HANDLER ((new_handler)-1)
  112. #define _NO_ANSI_NH_DEFINED
  113. #endif
  114. #pragma pop_macro("new")
  115. #endif /* __cplusplus */
  116. #endif /* _INC_NEW */