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.

208 lines
4.9 KiB

  1. /***
  2. *malloc.h - declarations and definitions for memory allocation functions
  3. *
  4. * Copyright (c) 1985-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * Contains the function declarations for memory allocation functions;
  8. * also defines manifest constants and types used by the heap routines.
  9. * [System V]
  10. *
  11. * [Public]
  12. *
  13. ****/
  14. #if _MSC_VER > 1000
  15. #pragma once
  16. #endif
  17. #ifndef _INC_MALLOC
  18. #define _INC_MALLOC
  19. #if !defined(_WIN32)
  20. #error ERROR: Only Win32 target supported!
  21. #endif
  22. #ifdef _MSC_VER
  23. /*
  24. * Currently, all MS C compilers for Win32 platforms default to 8 byte
  25. * alignment.
  26. */
  27. #pragma pack(push,8)
  28. #endif /* _MSC_VER */
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32. #if !defined(_W64)
  33. #if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
  34. #define _W64 __w64
  35. #else
  36. #define _W64
  37. #endif
  38. #endif
  39. /* Define _CRTIMP */
  40. #ifndef _CRTIMP
  41. #ifdef _DLL
  42. #define _CRTIMP __declspec(dllimport)
  43. #else /* ndef _DLL */
  44. #define _CRTIMP
  45. #endif /* _DLL */
  46. #endif /* _CRTIMP */
  47. /* Define _CRTNOALIAS, _CRTRESTRICT */
  48. #if _MSC_FULL_VER >= 14002050
  49. #ifndef _CRTNOALIAS
  50. #define _CRTNOALIAS __declspec(noalias)
  51. #endif /* _CRTNOALIAS */
  52. #ifndef _CRTRESTRICT
  53. #define _CRTRESTRICT __declspec(restrict)
  54. #endif /* _CRTRESTRICT */
  55. #else
  56. #ifndef _CRTNOALIAS
  57. #define _CRTNOALIAS
  58. #endif /* _CRTNOALIAS */
  59. #ifndef _CRTRESTRICT
  60. #define _CRTRESTRICT
  61. #endif /* _CRTRESTRICT */
  62. #endif
  63. /* Define __cdecl for non-Microsoft compilers */
  64. #if ( !defined(_MSC_VER) && !defined(__cdecl) )
  65. #define __cdecl
  66. #endif
  67. #ifndef _SIZE_T_DEFINED
  68. #ifdef _WIN64
  69. typedef unsigned __int64 size_t;
  70. #else
  71. typedef _W64 unsigned int size_t;
  72. #endif
  73. #define _SIZE_T_DEFINED
  74. #endif
  75. #ifndef _INTPTR_T_DEFINED
  76. #ifdef _WIN64
  77. typedef __int64 intptr_t;
  78. #else
  79. typedef _W64 int intptr_t;
  80. #endif
  81. #define _INTPTR_T_DEFINED
  82. #endif
  83. /* Maximum heap request the heap manager will attempt */
  84. #ifdef _WIN64
  85. #define _HEAP_MAXREQ 0xFFFFFFFFFFFFFFE0
  86. #else
  87. #define _HEAP_MAXREQ 0xFFFFFFE0
  88. #endif
  89. /* Constants for _heapchk/_heapset/_heapwalk routines */
  90. #define _HEAPEMPTY (-1)
  91. #define _HEAPOK (-2)
  92. #define _HEAPBADBEGIN (-3)
  93. #define _HEAPBADNODE (-4)
  94. #define _HEAPEND (-5)
  95. #define _HEAPBADPTR (-6)
  96. #define _FREEENTRY 0
  97. #define _USEDENTRY 1
  98. #ifndef _HEAPINFO_DEFINED
  99. typedef struct _heapinfo {
  100. int * _pentry;
  101. size_t _size;
  102. int _useflag;
  103. } _HEAPINFO;
  104. #define _HEAPINFO_DEFINED
  105. #endif
  106. /* External variable declarations */
  107. extern unsigned int _amblksiz;
  108. #define _mm_free(a) _aligned_free(a)
  109. #define _mm_malloc(a, b) _aligned_malloc(a, b)
  110. /* Function prototypes */
  111. _CRTIMP _CRTNOALIAS _CRTRESTRICT void * __cdecl calloc(size_t, size_t);
  112. _CRTIMP _CRTNOALIAS void __cdecl free(void *);
  113. _CRTIMP _CRTNOALIAS _CRTRESTRICT void * __cdecl malloc(size_t);
  114. _CRTIMP _CRTNOALIAS _CRTRESTRICT void * __cdecl realloc(void *, size_t);
  115. _CRTIMP _CRTNOALIAS void __cdecl _aligned_free(void *);
  116. _CRTIMP _CRTNOALIAS _CRTRESTRICT void * __cdecl _aligned_malloc(size_t, size_t);
  117. _CRTIMP _CRTNOALIAS _CRTRESTRICT void * __cdecl _aligned_offset_malloc(size_t, size_t, size_t);
  118. _CRTIMP _CRTNOALIAS _CRTRESTRICT void * __cdecl _aligned_realloc(void *, size_t, size_t);
  119. _CRTIMP _CRTNOALIAS _CRTRESTRICT void * __cdecl _aligned_offset_realloc(void *, size_t, size_t, size_t);
  120. #ifndef _POSIX_
  121. void * __cdecl _alloca(size_t);
  122. _CRTIMP void * __cdecl _expand(void *, size_t);
  123. _CRTIMP size_t __cdecl _get_sbh_threshold(void);
  124. _CRTIMP int __cdecl _set_sbh_threshold(size_t);
  125. _CRTIMP int __cdecl _heapadd(void *, size_t);
  126. _CRTIMP int __cdecl _heapchk(void);
  127. _CRTIMP int __cdecl _heapmin(void);
  128. _CRTIMP int __cdecl _heapset(unsigned int);
  129. _CRTIMP int __cdecl _heapwalk(_HEAPINFO *);
  130. _CRTIMP size_t __cdecl _heapused(size_t *, size_t *);
  131. _CRTIMP size_t __cdecl _msize(void *);
  132. _CRTIMP int __cdecl _resetstkoflw (void);
  133. int __cdecl _resetstkoflw_downlevel(void);
  134. _CRTIMP intptr_t __cdecl _get_heap_handle(void);
  135. #if !__STDC__
  136. /* Non-ANSI names for compatibility */
  137. #define alloca _alloca
  138. #endif /* __STDC__*/
  139. #endif /* _POSIX_ */
  140. #ifdef HEAPHOOK
  141. #ifndef _HEAPHOOK_DEFINED
  142. /* hook function type */
  143. typedef int (__cdecl * _HEAPHOOK)(int, size_t, void *, void **);
  144. #define _HEAPHOOK_DEFINED
  145. #endif /* _HEAPHOOK_DEFINED */
  146. /* set hook function */
  147. _CRTIMP _HEAPHOOK __cdecl _setheaphook(_HEAPHOOK);
  148. /* hook function must handle these types */
  149. #define _HEAP_MALLOC 1
  150. #define _HEAP_CALLOC 2
  151. #define _HEAP_FREE 3
  152. #define _HEAP_REALLOC 4
  153. #define _HEAP_MSIZE 5
  154. #define _HEAP_EXPAND 6
  155. #endif /* HEAPHOOK */
  156. #ifdef __cplusplus
  157. }
  158. #endif
  159. #ifdef _MSC_VER
  160. #pragma pack(pop)
  161. #endif /* _MSC_VER */
  162. #endif /* _INC_MALLOC */