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.

215 lines
6.5 KiB

  1. /***
  2. *stddef.h - definitions/declarations for common constants, types, variables
  3. *
  4. * Copyright (c) 1985-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * This file contains definitions and declarations for some commonly
  8. * used constants, types, and variables.
  9. * [ANSI]
  10. *
  11. * [Public]
  12. *
  13. *Revision History:
  14. * 10-02-87 JCR Changed NULL definition #else to #elif (C || L || H)
  15. * 12-11-87 JCR Added "_loadds" functionality
  16. * 12-16-87 JCR Added threadid definition
  17. * 12-18-87 JCR Added _FAR_ to declarations
  18. * 02-10-88 JCR Cleaned up white space
  19. * 08-19-88 GJF Revised to also work for the 386
  20. * 05-03-89 JCR Added _INTERNAL_IFSTRIP for relinc usage
  21. * 06-06-89 JCR 386: Made _threadid a function
  22. * 08-01-89 GJF Cleanup, now specific to OS/2 2.0 (i.e., 386 flat
  23. * model). Also added parens to *_errno definition
  24. * (same as 11-14-88 change to CRT version).
  25. * 10-30-89 GJF Fixed copyright
  26. * 11-02-89 JCR Changed "DLL" to "_DLL"
  27. * 03-02-90 GJF Added #ifndef _INC_STDDEF and #include <cruntime.h>
  28. * stuff. Also, removed some (now) useless preprocessor
  29. * directives.
  30. * 04-10-90 GJF Replaced _cdecl with _VARTYPE1 or _CALLTYPE1, as
  31. * appropriate.
  32. * 08-16-90 SBM Made MTHREAD _errno return int *
  33. * 10-09-90 GJF Changed return type of __threadid() to unsigned long *.
  34. * 11-12-90 GJF Changed NULL to (void *)0.
  35. * 02-11-91 GJF Added offsetof() macro.
  36. * 02-12-91 GJF Only #define NULL if it isn't #define-d.
  37. * 03-21-91 KRS Added wchar_t typedef, also in stdlib.h.
  38. * 06-27-91 GJF Revised __threadid, added __threadhandle, both
  39. * for Win32 [_WIN32_].
  40. * 08-20-91 JCR C++ and ANSI naming
  41. * 01-29-92 GJF Got rid of macro defining _threadhandle to be
  42. * __threadhandle (no reason for the former name to be
  43. * be defined).
  44. * 08-05-92 GJF Function calling type and variable type macros.
  45. * 01-21-93 GJF Removed support for C6-386's _cdecl.
  46. * 04-06-93 SKS Replace _CRTAPI1/2 with __cdecl, _CRTVAR1 with nothing
  47. * Remove support for OS/2, etc.
  48. * 04-07-93 SKS Add _CRTIMP keyword for CRT DLL model
  49. * Use link-time aliases for old names, not #define's
  50. * 10-12-93 GJF Support NT and Cuda versions. Also, replace MTHREAD
  51. * with _MT.
  52. * 03-14-94 GJF Made declaration of errno match one in stdlib.h.
  53. * 06-06-94 SKS Change if def(_MT) to if def(_MT) || def(_DLL)
  54. * This will support single-thread apps using MSVCRT*.DLL
  55. * 02-11-95 CFW Add _CRTBLD to avoid users getting wrong headers.
  56. * 02-14-95 CFW Clean up Mac merge.
  57. * 04-03-95 JCF Remove #ifdef _WIN32 around wchar_t.
  58. * 12-14-95 JWM Add "#pragma once".
  59. * 02-05-97 GJF Cleaned out obsolete support for _CRTAPI* and _NTSDK.
  60. * Also, detab-ed
  61. * 09-30-97 JWM Restored not-so-obsolete _CRTAPI1 support.
  62. * 10-07-97 RDL Added IA64.
  63. * 01-30-98 GJF Added appropriate defs for ptrdiff_t and offsetof
  64. * 02-03-98 GJF Changes for Win64: added int_ptr and uint_ptr.
  65. * 12-15-98 GJF Changes for 64-bit size_t.
  66. * 05-13-99 PML Remove _CRTAPI1
  67. * 05-17-99 PML Remove all Macintosh support.
  68. * 10-06-99 PML Add _W64 modifier to types which are 32 bits in Win32,
  69. * 64 bits in Win64.
  70. *
  71. ****/
  72. #if _MSC_VER > 1000 /*IFSTRIP=IGN*/
  73. #pragma once
  74. #endif
  75. #ifndef _INC_STDDEF
  76. #define _INC_STDDEF
  77. #if !defined(_WIN32)
  78. #error ERROR: Only Win32 target supported!
  79. #endif
  80. #ifndef _CRTBLD
  81. /* This version of the header files is NOT for user programs.
  82. * It is intended for use when building the C runtimes ONLY.
  83. * The version intended for public use will not have this message.
  84. */
  85. #error ERROR: Use of C runtime library internal header file.
  86. #endif /* _CRTBLD */
  87. #ifdef __cplusplus
  88. extern "C" {
  89. #endif
  90. #ifndef _INTERNAL_IFSTRIP_
  91. #include <cruntime.h>
  92. #endif /* _INTERNAL_IFSTRIP_ */
  93. #if !defined(_W64)
  94. #if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 /*IFSTRIP=IGN*/
  95. #define _W64 __w64
  96. #else
  97. #define _W64
  98. #endif
  99. #endif
  100. /* Define _CRTIMP */
  101. #ifndef _CRTIMP
  102. #ifdef CRTDLL
  103. #define _CRTIMP __declspec(dllexport)
  104. #else /* ndef CRTDLL */
  105. #ifdef _DLL
  106. #define _CRTIMP __declspec(dllimport)
  107. #else /* ndef _DLL */
  108. #define _CRTIMP
  109. #endif /* _DLL */
  110. #endif /* CRTDLL */
  111. #endif /* _CRTIMP */
  112. /* Define __cdecl for non-Microsoft compilers */
  113. #if ( !defined(_MSC_VER) && !defined(__cdecl) )
  114. #define __cdecl
  115. #endif
  116. /* Define NULL pointer value */
  117. #ifndef NULL
  118. #ifdef __cplusplus
  119. #define NULL 0
  120. #else
  121. #define NULL ((void *)0)
  122. #endif
  123. #endif
  124. /* Declare reference to errno */
  125. #if defined(_MT) || defined(_DLL)
  126. _CRTIMP extern int * __cdecl _errno(void);
  127. #define errno (*_errno())
  128. #else /* ndef _MT && ndef _DLL */
  129. _CRTIMP extern int errno;
  130. #endif /* _MT || _DLL */
  131. /* Define the implementation dependent size types */
  132. #ifndef _INTPTR_T_DEFINED
  133. #ifdef _WIN64
  134. typedef __int64 intptr_t;
  135. #else
  136. typedef _W64 int intptr_t;
  137. #endif
  138. #define _INTPTR_T_DEFINED
  139. #endif
  140. #ifndef _UINTPTR_T_DEFINED
  141. #ifdef _WIN64
  142. typedef unsigned __int64 uintptr_t;
  143. #else
  144. typedef _W64 unsigned int uintptr_t;
  145. #endif
  146. #define _UINTPTR_T_DEFINED
  147. #endif
  148. #ifndef _PTRDIFF_T_DEFINED
  149. #ifdef _WIN64
  150. typedef __int64 ptrdiff_t;
  151. #else
  152. typedef _W64 int ptrdiff_t;
  153. #endif
  154. #define _PTRDIFF_T_DEFINED
  155. #endif
  156. #ifndef _SIZE_T_DEFINED
  157. #ifdef _WIN64
  158. typedef unsigned __int64 size_t;
  159. #else
  160. typedef _W64 unsigned int size_t;
  161. #endif
  162. #define _SIZE_T_DEFINED
  163. #endif
  164. #ifndef _WCHAR_T_DEFINED
  165. typedef unsigned short wchar_t;
  166. #define _WCHAR_T_DEFINED
  167. #endif
  168. /* Define offsetof macro */
  169. #ifdef _WIN64
  170. #define offsetof(s,m) (size_t)( (ptrdiff_t)&(((s *)0)->m) )
  171. #else
  172. #define offsetof(s,m) (size_t)&(((s *)0)->m)
  173. #endif
  174. #ifdef _MT
  175. _CRTIMP extern unsigned long __cdecl __threadid(void);
  176. #define _threadid (__threadid())
  177. _CRTIMP extern uintptr_t __cdecl __threadhandle(void);
  178. #endif
  179. #ifdef __cplusplus
  180. }
  181. #endif
  182. #endif /* _INC_STDDEF */