|
|
|
| 1 |
|
/*** |
| 2 |
|
*crtdbg.h - Supports debugging features of the C runtime library. |
| 3 |
|
* |
| 4 |
|
* Copyright (c) Microsoft Corporation. All rights reserved. |
| 5 |
|
* |
| 6 |
|
*Purpose: |
| 7 |
|
* Support CRT debugging features. |
| 8 |
|
* |
| 9 |
|
* [Public] |
| 10 |
|
* |
| 11 |
|
****/ |
| 12 |
|
|
| 13 |
|
#if _MSC_VER > 1000 |
| 14 |
|
#pragma once |
| 15 |
|
#endif |
| 16 |
|
|
| 17 |
|
#include <crtdefs.h> |
| 18 |
|
|
| 19 |
|
#ifndef _INC_CRTDBG |
| 20 |
|
#define _INC_CRTDBG |
| 21 |
|
|
| 22 |
|
#ifdef _MSC_VER |
| 23 |
|
#pragma pack(push,_CRT_PACKING) |
| 24 |
|
#endif /* _MSC_VER */ |
| 25 |
|
|
| 26 |
|
/* Define NULL here since we depend on it and for back-compat |
| 27 |
|
*/ |
| 28 |
|
#ifndef NULL |
| 29 |
|
#ifdef __cplusplus |
| 30 |
|
#define NULL 0 |
| 31 |
|
#else |
| 32 |
|
#define NULL ((void *)0) |
| 33 |
|
#endif |
| 34 |
|
#endif |
| 35 |
|
|
| 36 |
|
#ifdef __cplusplus |
| 37 |
|
extern "C" { |
| 38 |
|
#endif /* __cplusplus */ |
| 39 |
|
|
| 40 |
|
/**************************************************************************** |
| 41 |
|
* |
| 42 |
|
* Debug Reporting |
| 43 |
|
* |
| 44 |
|
***************************************************************************/ |
| 45 |
|
|
| 46 |
|
typedef void *_HFILE; /* file handle pointer */ |
| 47 |
|
|
| 48 |
|
#define _CRT_WARN 0 |
| 49 |
|
#define _CRT_ERROR 1 |
| 50 |
|
#define _CRT_ASSERT 2 |
| 51 |
|
#define _CRT_ERRCNT 3 |
| 52 |
|
|
| 53 |
|
#define _CRTDBG_MODE_FILE 0x1 |
| 54 |
|
#define _CRTDBG_MODE_DEBUG 0x2 |
| 55 |
|
#define _CRTDBG_MODE_WNDW 0x4 |
| 56 |
|
#define _CRTDBG_REPORT_MODE -1 |
| 57 |
|
|
| 58 |
|
#define _CRTDBG_INVALID_HFILE ((_HFILE)-1) |
| 59 |
|
#define _CRTDBG_HFILE_ERROR ((_HFILE)-2) |
| 60 |
|
#define _CRTDBG_FILE_STDOUT ((_HFILE)-4) |
| 61 |
|
#define _CRTDBG_FILE_STDERR ((_HFILE)-5) |
| 62 |
|
#define _CRTDBG_REPORT_FILE ((_HFILE)-6) |
| 63 |
|
|
| 64 |
|
#if !defined(_M_CEE_PURE) |
| 65 |
|
typedef int (__cdecl * _CRT_REPORT_HOOK)(int, char *, int *); |
| 66 |
|
typedef int (__cdecl * _CRT_REPORT_HOOKW)(int, wchar_t *, int *); |
| 67 |
|
#else |
| 68 |
|
typedef int (__clrcall * _CRT_REPORT_HOOK)(int, char *, int *); |
| 69 |
|
typedef int (__clrcall * _CRT_REPORT_HOOKW)(int, wchar_t *, int *); |
| 70 |
|
#endif |
| 71 |
|
|
| 72 |
|
#if defined(_M_CEE) |
| 73 |
|
typedef int (__clrcall *_CRT_REPORT_HOOK_M)(int, char *, int *); |
| 74 |
|
typedef int (__clrcall *_CRT_REPORT_HOOKW_M)(int, wchar_t *, int *); |
| 75 |
|
#endif |
| 76 |
|
|
| 77 |
|
#define _CRT_RPTHOOK_INSTALL 0 |
| 78 |
|
#define _CRT_RPTHOOK_REMOVE 1 |
| 79 |
|
|
| 80 |
|
/**************************************************************************** |
| 81 |
|
* |
| 82 |
|
* Heap |
| 83 |
|
* |
| 84 |
|
***************************************************************************/ |
| 85 |
|
|
| 86 |
|
/**************************************************************************** |
| 87 |
|
* |
| 88 |
|
* Client-defined allocation hook |
| 89 |
|
* |
| 90 |
|
***************************************************************************/ |
| 91 |
|
|
| 92 |
|
#define _HOOK_ALLOC 1 |
| 93 |
|
#define _HOOK_REALLOC 2 |
| 94 |
|
#define _HOOK_FREE 3 |
| 95 |
|
|
| 96 |
|
#if !defined(_M_CEE_PURE) |
| 97 |
|
typedef int (__cdecl * _CRT_ALLOC_HOOK)(int, void *, size_t, int, long, const unsigned char *, int); |
| 98 |
|
#else |
| 99 |
|
typedef int (__clrcall * _CRT_ALLOC_HOOK)(int, void *, size_t, int, long, const unsigned char *, int); |
| 100 |
|
#endif |
| 101 |
|
#if defined(_M_CEE) |
| 102 |
|
typedef int (__clrcall * _CRT_ALLOC_HOOK_M)(int, void *, size_t, int, long, const unsigned char *, int); |
| 103 |
|
#endif |
| 104 |
|
|
| 105 |
|
/**************************************************************************** |
| 106 |
|
* |
| 107 |
|
* Memory management |
| 108 |
|
* |
| 109 |
|
***************************************************************************/ |
| 110 |
|
|
| 111 |
|
/* |
| 112 |
|
* Bit values for _crtDbgFlag flag: |
| 113 |
|
* |
| 114 |
|
* These bitflags control debug heap behavior. |
| 115 |
|
*/ |
| 116 |
|
|
| 117 |
|
#define _CRTDBG_ALLOC_MEM_DF 0x01 /* Turn on debug allocation */ |
| 118 |
|
#define _CRTDBG_DELAY_FREE_MEM_DF 0x02 /* Don't actually free memory */ |
| 119 |
|
#define _CRTDBG_CHECK_ALWAYS_DF 0x04 /* Check heap every alloc/dealloc */ |
| 120 |
|
#define _CRTDBG_RESERVED_DF 0x08 /* Reserved - do not use */ |
| 121 |
|
#define _CRTDBG_CHECK_CRT_DF 0x10 /* Leak check/diff CRT blocks */ |
| 122 |
|
#define _CRTDBG_LEAK_CHECK_DF 0x20 /* Leak check at program exit */ |
| 123 |
|
|
| 124 |
|
/* |
| 125 |
|
* Some bit values for _crtDbgFlag which correspond to frequencies for checking |
| 126 |
|
* the the heap. |
| 127 |
|
*/ |
| 128 |
|
#define _CRTDBG_CHECK_EVERY_16_DF 0x00100000 /* check heap every 16 heap ops */ |
| 129 |
|
#define _CRTDBG_CHECK_EVERY_128_DF 0x00800000 /* check heap every 128 heap ops */ |
| 130 |
|
#define _CRTDBG_CHECK_EVERY_1024_DF 0x04000000 /* check heap every 1024 heap ops */ |
| 131 |
|
/* |
| 132 |
|
We do not check the heap by default at this point because the cost was too high |
| 133 |
|
for some applications. You can still turn this feature on manually. |
| 134 |
|
*/ |
| 135 |
|
#define _CRTDBG_CHECK_DEFAULT_DF 0 |
| 136 |
|
|
| 137 |
|
#define _CRTDBG_REPORT_FLAG -1 /* Query bitflag status */ |
| 138 |
|
|
| 139 |
|
#define _BLOCK_TYPE(block) (block & 0xFFFF) |
| 140 |
|
#define _BLOCK_SUBTYPE(block) (block >> 16 & 0xFFFF) |
| 141 |
|
|
| 142 |
|
|
| 143 |
|
/**************************************************************************** |
| 144 |
|
* |
| 145 |
|
* Memory state |
| 146 |
|
* |
| 147 |
|
***************************************************************************/ |
| 148 |
|
|
| 149 |
|
/* Memory block identification */ |
| 150 |
|
#define _FREE_BLOCK 0 |
| 151 |
|
#define _NORMAL_BLOCK 1 |
| 152 |
|
#define _CRT_BLOCK 2 |
| 153 |
|
#define _IGNORE_BLOCK 3 |
| 154 |
|
#define _CLIENT_BLOCK 4 |
| 155 |
|
#define _MAX_BLOCKS 5 |
| 156 |
|
|
| 157 |
|
#if !defined(_M_CEE_PURE) |
| 158 |
|
typedef void (__cdecl * _CRT_DUMP_CLIENT)(void *, size_t); |
| 159 |
|
#else |
| 160 |
|
typedef void (__clrcall * _CRT_DUMP_CLIENT)(void *, size_t); |
| 161 |
|
#endif |
| 162 |
|
#if defined(_M_CEE) |
| 163 |
|
typedef void (__clrcall * _CRT_DUMP_CLIENT_M)(void *, size_t); |
| 164 |
|
#endif |
| 165 |
|
|
| 166 |
|
struct _CrtMemBlockHeader; |
| 167 |
|
typedef struct _CrtMemState |
| 168 |
|
{ |
| 169 |
|
struct _CrtMemBlockHeader * pBlockHeader; |
| 170 |
|
size_t lCounts[_MAX_BLOCKS]; |
| 171 |
|
size_t lSizes[_MAX_BLOCKS]; |
| 172 |
|
size_t lHighWaterCount; |
| 173 |
|
size_t lTotalCount; |
| 174 |
|
} _CrtMemState; |
| 175 |
|
|
| 176 |
|
|
| 177 |
|
/**************************************************************************** |
| 178 |
|
* |
| 179 |
|
* Declarations, prototype and function-like macros |
| 180 |
|
* |
| 181 |
|
***************************************************************************/ |
| 182 |
|
|
| 183 |
|
/* _STATIC_ASSERT is for enforcing boolean/integral conditions at compile time. |
| 184 |
|
Since it is purely a compile-time mechanism that generates no code, the check |
| 185 |
|
is left in even if _DEBUG is not defined. */ |
| 186 |
|
|
| 187 |
|
#ifndef _STATIC_ASSERT |
| 188 |
|
#define _STATIC_ASSERT(expr) typedef char __static_assert_t[ (expr) ] |
| 189 |
|
#endif |
| 190 |
|
|
| 191 |
|
#ifndef _DEBUG |
| 192 |
|
|
| 193 |
|
/**************************************************************************** |
| 194 |
|
* |
| 195 |
|
* Debug OFF |
| 196 |
|
* Debug OFF |
| 197 |
|
* Debug OFF |
| 198 |
|
* |
| 199 |
|
***************************************************************************/ |
| 200 |
|
|
| 201 |
|
/* We allow our basic _ASSERT macros to be overridden by pre-existing definitions. |
| 202 |
|
This is not the ideal mechanism, but is helpful in some scenarios and helps avoid |
| 203 |
|
multiple definition problems */ |
| 204 |
|
|
| 205 |
|
#ifndef _ASSERT |
| 206 |
|
#define _ASSERT(expr) ((void)0) |
| 207 |
|
#endif |
| 208 |
|
|
| 209 |
|
#ifndef _ASSERTE |
| 210 |
|
#define _ASSERTE(expr) ((void)0) |
| 211 |
|
#endif |
| 212 |
|
|
| 213 |
|
#ifndef _ASSERT_EXPR |
| 214 |
|
#define _ASSERT_EXPR(expr, expr_str) ((void)0) |
| 215 |
|
#endif |
| 216 |
|
|
| 217 |
|
#ifndef _ASSERT_BASE |
| 218 |
|
#define _ASSERT_BASE _ASSERT_EXPR |
| 219 |
|
#endif |
| 220 |
|
|
| 221 |
|
#define _RPT0(rptno, msg) |
| 222 |
|
#define _RPTW0(rptno, msg) |
| 223 |
|
|
| 224 |
|
#define _RPT1(rptno, msg, arg1) |
| 225 |
|
#define _RPTW1(rptno, msg, arg1) |
| 226 |
|
|
| 227 |
|
#define _RPT2(rptno, msg, arg1, arg2) |
| 228 |
|
#define _RPTW2(rptno, msg, arg1, arg2) |
| 229 |
|
|
| 230 |
|
#define _RPT3(rptno, msg, arg1, arg2, arg3) |
| 231 |
|
#define _RPTW3(rptno, msg, arg1, arg2, arg3) |
| 232 |
|
|
| 233 |
|
#define _RPT4(rptno, msg, arg1, arg2, arg3, arg4) |
| 234 |
|
#define _RPTW4(rptno, msg, arg1, arg2, arg3, arg4) |
| 235 |
|
|
| 236 |
|
#define _RPT5(rptno, msg, arg1, arg2, arg3, arg4, arg5) |
| 237 |
|
#define _RPTW5(rptno, msg, arg1, arg2, arg3, arg4, arg5) |
| 238 |
|
|
| 239 |
|
|
| 240 |
|
#define _RPTF0(rptno, msg) |
| 241 |
|
#define _RPTFW0(rptno, msg) |
| 242 |
|
|
| 243 |
|
#define _RPTF1(rptno, msg, arg1) |
| 244 |
|
#define _RPTFW1(rptno, msg, arg1) |
| 245 |
|
|
| 246 |
|
#define _RPTF2(rptno, msg, arg1, arg2) |
| 247 |
|
#define _RPTFW2(rptno, msg, arg1, arg2) |
| 248 |
|
|
| 249 |
|
#define _RPTF3(rptno, msg, arg1, arg2, arg3) |
| 250 |
|
#define _RPTFW3(rptno, msg, arg1, arg2, arg3) |
| 251 |
|
|
| 252 |
|
#define _RPTF4(rptno, msg, arg1, arg2, arg3, arg4) |
| 253 |
|
#define _RPTFW4(rptno, msg, arg1, arg2, arg3, arg4) |
| 254 |
|
|
| 255 |
|
#define _RPTF5(rptno, msg, arg1, arg2, arg3, arg4, arg5) |
| 256 |
|
#define _RPTFW5(rptno, msg, arg1, arg2, arg3, arg4, arg5) |
| 257 |
|
|
| 258 |
|
#define _malloc_dbg(s, t, f, l) malloc(s) |
| 259 |
|
#define _calloc_dbg(c, s, t, f, l) calloc(c, s) |
| 260 |
|
#define _realloc_dbg(p, s, t, f, l) realloc(p, s) |
| 261 |
|
#define _recalloc_dbg(p, c, s, t, f, l) _recalloc(p, c, s) |
| 262 |
|
#define _expand_dbg(p, s, t, f, l) _expand(p, s) |
| 263 |
|
#define _free_dbg(p, t) free(p) |
| 264 |
|
#define _msize_dbg(p, t) _msize(p) |
| 265 |
|
|
| 266 |
|
#define _aligned_msize_dbg(p, a, o) _aligned_msize(p, a, o) |
| 267 |
|
#define _aligned_malloc_dbg(s, a, f, l) _aligned_malloc(s, a) |
| 268 |
|
#define _aligned_realloc_dbg(p, s, a, f, l) _aligned_realloc(p, s, a) |
| 269 |
|
#define _aligned_recalloc_dbg(p, c, s, a, f, l) _aligned_recalloc(p, c, s, a) |
| 270 |
|
#define _aligned_free_dbg(p) _aligned_free(p) |
| 271 |
|
#define _aligned_offset_malloc_dbg(s, a, o, f, l) _aligned_offset_malloc(s, a, o) |
| 272 |
|
#define _aligned_offset_realloc_dbg(p, s, a, o, f, l) _aligned_offset_realloc(p, s, a, o) |
| 273 |
|
#define _aligned_offset_recalloc_dbg(p, c, s, a, o, f, l) _aligned_offset_recalloc(p, c, s, a, o) |
| 274 |
|
|
| 275 |
|
#define _malloca_dbg(s, t, f, l) _malloca(s) |
| 276 |
|
#define _freea_dbg(p, t) _freea(p) |
| 277 |
|
|
| 278 |
|
#define _strdup_dbg(s, t, f, l) _strdup(s) |
| 279 |
|
#define _wcsdup_dbg(s, t, f, l) _wcsdup(s) |
| 280 |
|
#define _mbsdup_dbg(s, t, f, l) _mbsdup(s) |
| 281 |
|
#define _tempnam_dbg(s1, s2, t, f, l) _tempnam(s1, s2) |
| 282 |
|
#define _wtempnam_dbg(s1, s2, t, f, l) _wtempnam(s1, s2) |
| 283 |
|
#define _fullpath_dbg(s1, s2, le, t, f, l) _fullpath(s1, s2, le) |
| 284 |
|
#define _wfullpath_dbg(s1, s2, le, t, f, l) _wfullpath(s1, s2, le) |
| 285 |
|
#define _getcwd_dbg(s, le, t, f, l) _getcwd(s, le) |
| 286 |
|
#define _wgetcwd_dbg(s, le, t, f, l) _wgetcwd(s, le) |
| 287 |
|
#define _getdcwd_dbg(d, s, le, t, f, l) _getdcwd(d, s, le) |
| 288 |
|
#define _wgetdcwd_dbg(d, s, le, t, f, l) _wgetdcwd(d, s, le) |
| 289 |
|
#define _getdcwd_lk_dbg(d, s, le, t, f, l) _getdcwd_nolock(d, s, le) |
| 290 |
|
#define _wgetdcwd_lk_dbg(d, s, le, t, f, l) _wgetdcwd_nolock(d, s, le) |
| 291 |
|
#define _dupenv_s_dbg(ps1, size, s2, t, f, l) _dupenv_s(ps1, size, s2) |
| 292 |
|
#define _wdupenv_s_dbg(ps1, size, s2, t, f, l) _wdupenv_s(ps1, size, s2) |
| 293 |
|
|
| 294 |
|
#define _CrtSetReportHook(f) ((_CRT_REPORT_HOOK)0) |
| 295 |
|
#define _CrtGetReportHook() ((_CRT_REPORT_HOOK)0) |
| 296 |
|
#define _CrtSetReportHook2(t, f) ((int)0) |
| 297 |
|
#define _CrtSetReportHookW2(t, f) ((int)0) |
| 298 |
|
#define _CrtSetReportMode(t, f) ((int)0) |
| 299 |
|
#define _CrtSetReportFile(t, f) ((_HFILE)0) |
| 300 |
|
|
| 301 |
|
#define _CrtDbgBreak() ((void)0) |
| 302 |
|
|
| 303 |
|
#define _CrtSetBreakAlloc(a) ((long)0) |
| 304 |
|
|
| 305 |
|
#define _CrtSetAllocHook(f) ((_CRT_ALLOC_HOOK)0) |
| 306 |
|
#define _CrtGetAllocHook() ((_CRT_ALLOC_HOOK)0) |
| 307 |
|
|
| 308 |
|
#define _CrtCheckMemory() ((int)1) |
| 309 |
|
#define _CrtSetDbgFlag(f) ((int)0) |
| 310 |
|
#define _CrtDoForAllClientObjects(f, c) ((void)0) |
| 311 |
|
#define _CrtIsValidPointer(p, n, r) ((int)1) |
| 312 |
|
#define _CrtIsValidHeapPointer(p) ((int)1) |
| 313 |
|
#define _CrtIsMemoryBlock(p, t, r, f, l) ((int)1) |
| 314 |
|
#define _CrtReportBlockType(p) ((int)-1) |
| 315 |
|
|
| 316 |
|
#define _CrtSetDumpClient(f) ((_CRT_DUMP_CLIENT)0) |
| 317 |
|
#define _CrtGetDumpClient() ((_CRT_DUMP_CLIENT)0) |
| 318 |
|
|
| 319 |
|
#define _CrtMemCheckpoint(s) ((void)0) |
| 320 |
|
#define _CrtMemDifference(s1, s2, s3) ((int)0) |
| 321 |
|
#define _CrtMemDumpAllObjectsSince(s) ((void)0) |
| 322 |
|
#define _CrtMemDumpStatistics(s) ((void)0) |
| 323 |
|
#define _CrtDumpMemoryLeaks() ((int)0) |
| 324 |
|
#define _CrtSetDebugFillThreshold(t) ((size_t)0) |
| 325 |
|
|
| 326 |
|
#define _CrtSetCheckCount(f) ((int)0) |
| 327 |
|
#define _CrtGetCheckCount() ((int)0) |
| 328 |
|
|
| 329 |
|
#else /* _DEBUG */ |
| 330 |
|
|
| 331 |
|
|
| 332 |
|
/**************************************************************************** |
| 333 |
|
* |
| 334 |
|
* Debug ON |
| 335 |
|
* Debug ON |
| 336 |
|
* Debug ON |
| 337 |
|
* |
| 338 |
|
***************************************************************************/ |
| 339 |
|
|
| 340 |
|
|
| 341 |
|
/* Define _MRTIMP */ |
| 342 |
|
|
| 343 |
|
#ifndef _MRTIMP |
| 344 |
|
#define _MRTIMP __declspec(dllimport) |
| 345 |
|
#endif /* _MRTIMP */ |
| 346 |
|
|
| 347 |
|
/* Define _CRTIMP */ |
| 348 |
|
|
| 349 |
|
#ifndef _CRTIMP |
| 350 |
|
#ifdef _DLL |
| 351 |
|
#define _CRTIMP __declspec(dllimport) |
| 352 |
|
#else /* ndef _DLL */ |
| 353 |
|
#define _CRTIMP |
| 354 |
|
#endif /* _DLL */ |
| 355 |
|
#endif /* _CRTIMP */ |
| 356 |
|
|
| 357 |
|
/**************************************************************************** |
| 358 |
|
* |
| 359 |
|
* Debug Reporting |
| 360 |
|
* |
| 361 |
|
***************************************************************************/ |
| 362 |
|
|
| 363 |
|
#if !defined(_M_CEE_PURE) |
| 364 |
|
_CRTIMP extern long _crtAssertBusy; |
| 365 |
|
#endif /* !defined(_M_CEE_PURE) */ |
| 366 |
|
|
| 367 |
|
#if !defined(_M_CEE_PURE) |
| 368 |
|
_CRTIMP _CRT_REPORT_HOOK __cdecl _CrtGetReportHook( |
| 369 |
|
void |
| 370 |
|
); |
| 371 |
|
#endif |
| 372 |
|
|
| 373 |
|
/* _CrtSetReportHook[[W]2]: |
| 374 |
|
* For IJW, we need 2 versions: 1 for clrcall and one for cdecl. |
| 375 |
|
* For pure and native, we just need clrcall and cdecl, respectively. |
| 376 |
|
*/ |
| 377 |
|
#if !defined(_M_CEE_PURE) |
| 378 |
|
_CRTIMP _CRT_REPORT_HOOK __cdecl _CrtSetReportHook( |
| 379 |
|
_In_opt_ _CRT_REPORT_HOOK _PFnNewHook |
| 380 |
|
); |
| 381 |
|
|
| 382 |
|
_CRTIMP int __cdecl _CrtSetReportHook2( |
| 383 |
|
_In_ int _Mode, |
| 384 |
|
_In_opt_ _CRT_REPORT_HOOK _PFnNewHook |
| 385 |
|
); |
| 386 |
|
|
| 387 |
|
_CRTIMP int __cdecl _CrtSetReportHookW2( |
| 388 |
|
_In_ int _Mode, |
| 389 |
|
_In_opt_ _CRT_REPORT_HOOKW _PFnNewHook |
| 390 |
|
); |
| 391 |
|
#else |
| 392 |
|
extern "C++" |
| 393 |
|
{ |
| 394 |
|
_MRTIMP _CRT_REPORT_HOOK __cdecl _CrtSetReportHook( |
| 395 |
|
_In_opt_ _CRT_REPORT_HOOK _PFnNewHook |
| 396 |
|
); |
| 397 |
|
|
| 398 |
|
_MRTIMP int __cdecl _CrtSetReportHook2( |
| 399 |
|
_In_ int _Mode, |
| 400 |
|
_In_opt_ _CRT_REPORT_HOOK _PFnNewHook |
| 401 |
|
); |
| 402 |
|
|
| 403 |
|
|
| 404 |
|
_MRTIMP int __cdecl _CrtSetReportHookW2( |
| 405 |
|
_In_ int _Mode, |
| 406 |
|
_In_opt_ _CRT_REPORT_HOOKW _PFnNewHook |
| 407 |
|
); |
| 408 |
|
} |
| 409 |
|
#endif |
| 410 |
|
|
| 411 |
|
#if defined(_M_CEE_MIXED) |
| 412 |
|
extern "C++" |
| 413 |
|
{ |
| 414 |
|
_MRTIMP _CRT_REPORT_HOOK_M __cdecl _CrtSetReportHook( |
| 415 |
|
_In_opt_ _CRT_REPORT_HOOK_M _PFnNewHook |
| 416 |
|
); |
| 417 |
|
|
| 418 |
|
|
| 419 |
|
_MRTIMP int __cdecl _CrtSetReportHook2( |
| 420 |
|
_In_ int _Mode, |
| 421 |
|
_In_opt_ _CRT_REPORT_HOOK_M _PFnNewHook |
| 422 |
|
); |
| 423 |
|
|
| 424 |
|
|
| 425 |
|
_MRTIMP int __cdecl _CrtSetReportHookW2( |
| 426 |
|
_In_ int _Mode, |
| 427 |
|
_In_opt_ _CRT_REPORT_HOOKW_M _PFnNewHook |
| 428 |
|
); |
| 429 |
|
|
| 430 |
|
/* |
| 431 |
|
This overload allows NULL to be passed unambiguously in the mixed case |
| 432 |
|
*/ |
| 433 |
|
_MRTIMP _CRT_REPORT_HOOK __cdecl _CrtSetReportHook( |
| 434 |
|
_In_ int _PFnNewHook |
| 435 |
|
); |
| 436 |
|
} |
| 437 |
|
#endif |
| 438 |
|
|
| 439 |
|
|
| 440 |
|
_CRTIMP int __cdecl _CrtSetReportMode( |
| 441 |
|
_In_ int _ReportType, |
| 442 |
|
_In_ int _ReportMode |
| 443 |
|
); |
| 444 |
|
|
| 445 |
|
_CRTIMP _HFILE __cdecl _CrtSetReportFile( |
| 446 |
|
_In_ int _ReportType, |
| 447 |
|
_In_opt_ _HFILE _ReportFile |
| 448 |
|
); |
| 449 |
|
|
| 450 |
|
_CRTIMP int __cdecl _CrtDbgReport( |
| 451 |
|
_In_ int _ReportType, |
| 452 |
|
_In_opt_z_ const char * _Filename, |
| 453 |
|
_In_ int _Linenumber, |
| 454 |
|
_In_opt_z_ const char * _ModuleName, |
| 455 |
|
_In_opt_z_ const char * _Format, |
| 456 |
|
...); |
| 457 |
|
|
| 458 |
|
_CRTIMP size_t __cdecl _CrtSetDebugFillThreshold( |
| 459 |
|
_In_ size_t _NewDebugFillThreshold |
| 460 |
|
); |
| 461 |
|
|
| 462 |
|
#if !defined(_NATIVE_WCHAR_T_DEFINED) && defined(_M_CEE_PURE) |
| 463 |
|
extern "C++" |
| 464 |
|
#endif |
| 465 |
|
_CRTIMP int __cdecl _CrtDbgReportW( |
| 466 |
|
_In_ int _ReportType, |
| 467 |
|
_In_opt_z_ const wchar_t * _Filename, |
| 468 |
|
_In_ int _LineNumber, |
| 469 |
|
_In_opt_z_ const wchar_t * _ModuleName, |
| 470 |
|
_In_opt_z_ const wchar_t * _Format, |
| 471 |
|
...); |
| 472 |
|
|
| 473 |
|
/* Asserts */ |
| 474 |
|
/* We use !! below to ensure that any overloaded operators used to evaluate expr do not end up at operator || */ |
| 475 |
|
#define _ASSERT_EXPR(expr, msg) \ |
| 476 |
|
(void) ((!!(expr)) || \ |
| 477 |
|
(1 != _CrtDbgReportW(_CRT_ASSERT, _CRT_WIDE(__FILE__), __LINE__, NULL, msg)) || \ |
| 478 |
|
(_CrtDbgBreak(), 0)) |
| 479 |
|
|
| 480 |
|
#ifndef _ASSERT |
| 481 |
|
#define _ASSERT(expr) _ASSERT_EXPR((expr), NULL) |
| 482 |
|
#endif |
| 483 |
|
|
| 484 |
|
#ifndef _ASSERTE |
| 485 |
|
#define _ASSERTE(expr) _ASSERT_EXPR((expr), _CRT_WIDE(#expr)) |
| 486 |
|
#endif |
| 487 |
|
|
| 488 |
|
/* |
| 489 |
|
We retain _ASSERT_BASE solely for backwards compatibility with those who used it even though they |
| 490 |
|
should not have done so since it was not documented. |
| 491 |
|
*/ |
| 492 |
|
#ifndef _ASSERT_BASE |
| 493 |
|
#define _ASSERT_BASE _ASSERT_EXPR |
| 494 |
|
#endif |
| 495 |
|
|
| 496 |
|
/* Reports with no file/line info */ |
| 497 |
|
|
| 498 |
|
#if _MSC_VER >= 1300 || !defined(_M_IX86) || defined(_CRT_PORTABLE) |
| 499 |
|
#define _RPT_BASE(args) \ |
| 500 |
|
(void) ((1 != _CrtDbgReport args) || \ |
| 501 |
|
(_CrtDbgBreak(), 0)) |
| 502 |
|
|
| 503 |
|
#define _RPT_BASE_W(args) \ |
| 504 |
|
(void) ((1 != _CrtDbgReportW args) || \ |
| 505 |
|
(_CrtDbgBreak(), 0)) |
| 506 |
|
#else |
| 507 |
|
#define _RPT_BASE(args) \ |
| 508 |
|
do { if ((1 == _CrtDbgReport args)) \ |
| 509 |
|
_CrtDbgBreak(); } while (0) |
| 510 |
|
|
| 511 |
|
#define _RPT_BASE_W(args) \ |
| 512 |
|
do { if ((1 == _CrtDbgReportW args)) \ |
| 513 |
|
_CrtDbgBreak(); } while (0) |
| 514 |
|
#endif |
| 515 |
|
|
| 516 |
|
#define _RPT0(rptno, msg) \ |
| 517 |
|
_RPT_BASE((rptno, NULL, 0, NULL, "%s", msg)) |
| 518 |
|
|
| 519 |
|
#define _RPTW0(rptno, msg) \ |
| 520 |
|
_RPT_BASE_W((rptno, NULL, 0, NULL, L"%s", msg)) |
| 521 |
|
|
| 522 |
|
#define _RPT1(rptno, msg, arg1) \ |
| 523 |
|
_RPT_BASE((rptno, NULL, 0, NULL, msg, arg1)) |
| 524 |
|
|
| 525 |
|
#define _RPTW1(rptno, msg, arg1) \ |
| 526 |
|
_RPT_BASE_W((rptno, NULL, 0, NULL, msg, arg1)) |
| 527 |
|
|
| 528 |
|
#define _RPT2(rptno, msg, arg1, arg2) \ |
| 529 |
|
_RPT_BASE((rptno, NULL, 0, NULL, msg, arg1, arg2)) |
| 530 |
|
|
| 531 |
|
#define _RPTW2(rptno, msg, arg1, arg2) \ |
| 532 |
|
_RPT_BASE_W((rptno, NULL, 0, NULL, msg, arg1, arg2)) |
| 533 |
|
|
| 534 |
|
#define _RPT3(rptno, msg, arg1, arg2, arg3) \ |
| 535 |
|
_RPT_BASE((rptno, NULL, 0, NULL, msg, arg1, arg2, arg3)) |