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.

114 lines
3.8 KiB

  1. /***
  2. *assert.h - define the assert macro
  3. *
  4. * Copyright (c) 1985-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * Defines the assert(exp) macro.
  8. * [ANSI/System V]
  9. *
  10. * [Public]
  11. *
  12. *Revision History:
  13. * 12-18-87 JCR Added _FAR_ to declarations
  14. * 01-18-88 JCR Added fflush(stderr) to go with new stderr buffering scheme
  15. * 02-10-88 JCR Cleaned up white space
  16. * 05-19-88 JCR Use routine _assert() to save space
  17. * 07-14-88 JCR Allow user's to enable/disable assert multiple times in
  18. * a single module [ANSI]
  19. * 10-19-88 JCR Revised to also work for the 386 (small model only)
  20. * 12-22-88 JCR Assert() must be an expression (no 'if' statements)
  21. * 05-03-89 JCR Added _INTERNAL_IFSTRIP for relinc usage
  22. * 07-27-89 GJF Cleanup, now specific to the 386
  23. * 10-30-89 GJF Fixed copyright
  24. * 11-02-89 JCR Changed "DLL" to "_DLL"
  25. * 02-27-90 GJF Added #include <cruntime.h> stuff. Also, removed some
  26. * (now) useless preprocessor directives.
  27. * 03-21-90 GJF Replaced _cdecl with _CALLTYPE1 in prototype.
  28. * 07-31-90 SBM added ((void)0) to NDEBUG definition, now ANSI
  29. * 08-20-91 JCR C++ and ANSI naming
  30. * 08-26-92 GJF Function calling type and variable type macros.
  31. * 09-25-92 SRW Don't use ? in assert macro to keep CFRONT happy.
  32. * 01-21-93 GJF Removed support for C6-386's _cdecl.
  33. * 02-01-93 GJF Replaced SteveWo's assert macro with an ANSI-conformant
  34. * one. Also got rid of '//' comment characters.
  35. * 04-06-93 SKS Replace _CRTAPI1/2 with __cdecl, _CRTVAR1 with nothing
  36. * 04-07-93 SKS Add _CRTIMP keyword for CRT DLL model
  37. * 09-01-93 GJF Merged Cuda and NT SDK versions.
  38. * 02-11-95 CFW Add _CRTBLD to avoid users getting wrong headers.
  39. * 02-14-95 CFW Clean up Mac merge.
  40. * 03-02-95 CFW Removed _INC_ASSERT. According to ANSI, must be able
  41. * to include this file more than once.
  42. * 12-14-95 JWM Add "#pragma once".
  43. * 12-19-95 JWM Removed "#pragma once" - ANSI restriction.
  44. * 02-20-97 GJF Cleaned out obsolete support for _CRTAPI* and _NTSDK.
  45. * Also, detab-ed.
  46. * 09-30-97 JWM Restored not-so-obsolete _CRTAPI1 support.
  47. * 10-07-97 RDL Added IA64.
  48. * 05-13-99 PML Remove _CRTAPI1
  49. * 05-17-99 PML Remove all Macintosh support.
  50. *
  51. ****/
  52. #if !defined(_WIN32)
  53. #error ERROR: Only Win32 target supported!
  54. #endif
  55. #ifndef _CRTBLD
  56. /* This version of the header files is NOT for user programs.
  57. * It is intended for use when building the C runtimes ONLY.
  58. * The version intended for public use will not have this message.
  59. */
  60. #error ERROR: Use of C runtime library internal header file.
  61. #endif /* _CRTBLD */
  62. #ifndef _INTERNAL_IFSTRIP_
  63. #ifndef _ASSERT_OK
  64. #error assert.h not for CRT internal use, use dbgint.h
  65. #endif /* _ASSERT_OK */
  66. #include <cruntime.h>
  67. #endif /* _INTERNAL_IFSTRIP_ */
  68. /* Define _CRTIMP */
  69. #ifndef _CRTIMP
  70. #ifdef CRTDLL
  71. #define _CRTIMP __declspec(dllexport)
  72. #else /* ndef CRTDLL */
  73. #ifdef _DLL
  74. #define _CRTIMP __declspec(dllimport)
  75. #else /* ndef _DLL */
  76. #define _CRTIMP
  77. #endif /* _DLL */
  78. #endif /* CRTDLL */
  79. #endif /* _CRTIMP */
  80. /* Define __cdecl for non-Microsoft compilers */
  81. #if ( !defined(_MSC_VER) && !defined(__cdecl) )
  82. #define __cdecl
  83. #endif
  84. #undef assert
  85. #ifdef NDEBUG
  86. #define assert(exp) ((void)0)
  87. #else
  88. #ifdef __cplusplus
  89. extern "C" {
  90. #endif
  91. _CRTIMP void __cdecl _assert(void *, void *, unsigned);
  92. #ifdef __cplusplus
  93. }
  94. #endif
  95. #define assert(exp) (void)( (exp) || (_assert(#exp, __FILE__, __LINE__), 0) )
  96. #endif /* NDEBUG */