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.

137 lines
2.9 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 __cdecl for non-Microsoft compilers */
  43. #if ( !defined(_MSC_VER) && !defined(__cdecl) )
  44. #define __cdecl
  45. #endif
  46. /* types and structures */
  47. #ifndef _SIZE_T_DEFINED
  48. #ifdef _WIN64
  49. typedef unsigned __int64 size_t;
  50. #else
  51. typedef _W64 unsigned int size_t;
  52. #endif
  53. #define _SIZE_T_DEFINED
  54. #endif
  55. #ifdef _MSC_EXTENSIONS
  56. typedef void (__cdecl * new_handler) ();
  57. _CRTIMP new_handler __cdecl set_new_handler(new_handler);
  58. #endif
  59. #ifndef __NOTHROW_T_DEFINED
  60. #define __NOTHROW_T_DEFINED
  61. namespace std {
  62. /* placement new tag type to suppress exceptions */
  63. struct nothrow_t {};
  64. /* constant for placement new tag */
  65. extern const nothrow_t nothrow;
  66. };
  67. void *__cdecl operator new(size_t, const std::nothrow_t&) throw();
  68. void __cdecl operator delete(void *, const std::nothrow_t&) throw();
  69. #if _MSC_FULL_VER >= 13009179
  70. void *__cdecl operator new[](size_t, const std::nothrow_t&) throw();
  71. void __cdecl operator delete[](void *, const std::nothrow_t&) throw();
  72. #endif
  73. #endif
  74. #ifndef __PLACEMENT_NEW_INLINE
  75. #define __PLACEMENT_NEW_INLINE
  76. inline void *__cdecl operator new(size_t, void *_P)
  77. {return (_P); }
  78. #if _MSC_VER >= 1200
  79. inline void __cdecl operator delete(void *, void *)
  80. {return; }
  81. #endif
  82. #endif
  83. /*
  84. * new mode flag -- when set, makes malloc() behave like new()
  85. */
  86. _CRTIMP int __cdecl _query_new_mode( void );
  87. _CRTIMP int __cdecl _set_new_mode( int );
  88. #ifndef _PNH_DEFINED
  89. typedef int (__cdecl * _PNH)( size_t );
  90. #define _PNH_DEFINED
  91. #endif
  92. _CRTIMP _PNH __cdecl _query_new_handler( void );
  93. _CRTIMP _PNH __cdecl _set_new_handler( _PNH );
  94. /*
  95. * Microsoft extension:
  96. *
  97. * _NO_ANSI_NEW_HANDLER de-activates the ANSI new_handler. Use this special value
  98. * to support old style (_set_new_handler) behavior.
  99. */
  100. #ifndef _NO_ANSI_NH_DEFINED
  101. #define _NO_ANSI_NEW_HANDLER ((new_handler)-1)
  102. #define _NO_ANSI_NH_DEFINED
  103. #endif
  104. #pragma pop_macro("new")
  105. #endif /* __cplusplus */
  106. #endif /* _INC_NEW */