Source code of Windows XP (NT5)
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.

326 lines
13 KiB

  1. /***
  2. *process.h - definition and declarations for process control functions
  3. *
  4. * Copyright (c) 1985-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * This file defines the modeflag values for spawnxx calls.
  8. * Also contains the function argument declarations for all
  9. * process control related routines.
  10. *
  11. * [Public]
  12. *
  13. *Revision History:
  14. * 08/24/87 JCR Added P_NOWAITO
  15. * 10/20/87 JCR Removed "MSC40_ONLY" entries and "MSSDK_ONLY" comments
  16. * 12-11-87 JCR Added "_loadds" functionality
  17. * 12-18-87 JCR Added _FAR_ to declarations
  18. * 01-11-88 JCR Added _beginthread/_endthread
  19. * 01-15-88 JCR Got rid of _p_overlay for MTRHEAD/DLL
  20. * 02-10-88 JCR Cleaned up white space
  21. * 05-08-88 SKS Removed bogus comment about "DOS 4"; Added "P_DETACH"
  22. * 08-22-88 GJF Modified to also work for the 386 (small model only)
  23. * 09-14-88 JCR Added _cexit and _c_exit declarations
  24. * 05-03-89 JCR Added _INTERNAL_IFSTRIP for relinc usage
  25. * 06-08-89 JCR 386 _beginthread does NOT take a stackpointer arg
  26. * 08-01-89 GJF Cleanup, now specific to OS/2 2.0 (i.e., 386 flat model)
  27. * 10-30-89 GJF Fixed copyright
  28. * 11-02-89 JCR Changed "DLL" to "_DLL"
  29. * 11-17-89 GJF Added const attribute to appropriate arg types
  30. * 03-01-90 GJF Added #ifndef _INC_PROCESS and #include <cruntime.h>
  31. * stuff. Also, removed some (now) useless preprocessor
  32. * directives.
  33. * 03-21-90 GJF Replaced _cdecl with _CALLTYPE1 or _CALLTYPE2 in
  34. * prototypes.
  35. * 04-10-90 GJF Replaced remaining instances of _cdecl (with _CALLTYPE1
  36. * or _VARTYPE1, as appropriate).
  37. * 10-12-90 GJF Changed return type of _beginthread() to unsigned long.
  38. * 01-17-91 GJF ANSI naming.
  39. * 08-20-91 JCR C++ and ANSI naming
  40. * 08-26-91 BWM Added prototypes for _loaddll, unloaddll, and
  41. * _getdllprocaddr.
  42. * 09-28-91 JCR ANSI names: DOSX32=prototypes, WIN32=#defines for now
  43. * 07-22-92 GJF Deleted references to _wait for Win32.
  44. * 08-05-92 GJF Function calling type and variable type macros.
  45. * 08-28-92 GJF #ifdef-ed out for POSIX.
  46. * 09-03-92 GJF Merged two changes above.
  47. * 01-21-93 GJF Removed support for C6-386's _cdecl.
  48. * 03-20-93 SKS Remove obsolete _loaddll, unloaddll, _getdllprocaddr.
  49. * 04-07-93 SKS Add _CRTIMP keyword for CRT DLL model
  50. * Use link-time aliases for old names, not #define's
  51. * 10-11-93 GJF Merged NT and Cuda versions.
  52. * 12-06-93 CFW Add wCRT_INIT.
  53. * 12-07-93 CFW Add wide exec/spawn protos.
  54. * 02-16-94 SKS Add _beginthreadex(), _endthreadex()
  55. * 12-28-94 JCF Merged with mac header
  56. * 02-11-95 CFW Add _CRTBLD to avoid users getting wrong headers.
  57. * 02-13-95 CFW Fixed Mac merge.
  58. * 02-14-95 CFW Clean up Mac merge.
  59. * 05-24-95 CFW "spawn" not a mac oldames.
  60. * 12-14-95 JWM Add "#pragma once".
  61. * 02-20-97 GJF Cleaned out obsolete support for _CRTAPI* and _NTSDK.
  62. * Also, detab-ed.
  63. * 09-30-97 JWM Restored not-so-obsolete _CRTAPI1 support.
  64. * 10-07-97 RDL Added IA64.
  65. * 02-06-98 GJF Changes for Win64: changed return and argument types to
  66. * to intptr_t and uintptr_t where appropriate.
  67. * 02-10-98 GJF Changes for Win64: fixed a couple of prototypes
  68. * 05-13-99 PML Remove _CRTAPI1
  69. * 05-17-99 PML Remove all Macintosh support.
  70. * 06-05-99 PML Win64: int -> intptr_t for !__STDC__ variants.
  71. * 10-06-99 PML Add _W64 modifier to types which are 32 bits in Win32,
  72. * 64 bits in Win64.
  73. *
  74. ****/
  75. #if _MSC_VER > 1000 /*IFSTRIP=IGN*/
  76. #pragma once
  77. #endif
  78. #ifndef _INC_PROCESS
  79. #define _INC_PROCESS
  80. #if !defined(_WIN32)
  81. #error ERROR: Only Win32 target supported!
  82. #endif
  83. #ifndef _CRTBLD
  84. /* This version of the header files is NOT for user programs.
  85. * It is intended for use when building the C runtimes ONLY.
  86. * The version intended for public use will not have this message.
  87. */
  88. #error ERROR: Use of C runtime library internal header file.
  89. #endif /* _CRTBLD */
  90. #ifndef _POSIX_
  91. #ifdef __cplusplus
  92. extern "C" {
  93. #endif
  94. #ifndef _INTERNAL_IFSTRIP_
  95. #include <cruntime.h>
  96. #endif /* _INTERNAL_IFSTRIP_ */
  97. #if !defined(_W64)
  98. #if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 /*IFSTRIP=IGN*/
  99. #define _W64 __w64
  100. #else
  101. #define _W64
  102. #endif
  103. #endif
  104. /* Define _CRTIMP */
  105. #ifndef _CRTIMP
  106. #ifdef CRTDLL
  107. #define _CRTIMP __declspec(dllexport)
  108. #else /* ndef CRTDLL */
  109. #ifdef _DLL
  110. #define _CRTIMP __declspec(dllimport)
  111. #else /* ndef _DLL */
  112. #define _CRTIMP
  113. #endif /* _DLL */
  114. #endif /* CRTDLL */
  115. #endif /* _CRTIMP */
  116. /* Define __cdecl for non-Microsoft compilers */
  117. #if ( !defined(_MSC_VER) && !defined(__cdecl) )
  118. #define __cdecl
  119. #endif
  120. #ifndef _INTPTR_T_DEFINED
  121. #ifdef _WIN64
  122. typedef __int64 intptr_t;
  123. #else
  124. typedef _W64 int intptr_t;
  125. #endif
  126. #define _INTPTR_T_DEFINED
  127. #endif
  128. #ifndef _UINTPTR_T_DEFINED
  129. #ifdef _WIN64
  130. typedef unsigned __int64 uintptr_t;
  131. #else
  132. typedef _W64 unsigned int uintptr_t;
  133. #endif
  134. #define _UINTPTR_T_DEFINED
  135. #endif
  136. #ifndef _WCHAR_T_DEFINED
  137. typedef unsigned short wchar_t;
  138. #define _WCHAR_T_DEFINED
  139. #endif
  140. /* modeflag values for _spawnxx routines */
  141. #define _P_WAIT 0
  142. #define _P_NOWAIT 1
  143. #define _OLD_P_OVERLAY 2
  144. #define _P_NOWAITO 3
  145. #define _P_DETACH 4
  146. #ifdef _MT
  147. #define _P_OVERLAY 2
  148. #else
  149. extern int _p_overlay;
  150. #define _P_OVERLAY _p_overlay
  151. #endif /* _MT */
  152. /* Action codes for _cwait(). The action code argument to _cwait is ignored
  153. on Win32 though it is accepted for compatibilty with old MS CRT libs */
  154. #define _WAIT_CHILD 0
  155. #define _WAIT_GRANDCHILD 1
  156. /* function prototypes */
  157. #ifdef _MT
  158. _CRTIMP uintptr_t __cdecl _beginthread (void (__cdecl *) (void *),
  159. unsigned, void *);
  160. _CRTIMP void __cdecl _endthread(void);
  161. _CRTIMP uintptr_t __cdecl _beginthreadex(void *, unsigned,
  162. unsigned (__stdcall *) (void *), void *, unsigned, unsigned *);
  163. _CRTIMP void __cdecl _endthreadex(unsigned);
  164. #endif
  165. #if _MSC_VER >= 1200 /*IFSTRIP=IGN*/
  166. _CRTIMP __declspec(noreturn) void __cdecl abort(void);
  167. _CRTIMP __declspec(noreturn) void __cdecl exit(int);
  168. _CRTIMP __declspec(noreturn) void __cdecl _exit(int);
  169. #else
  170. _CRTIMP void __cdecl abort(void);
  171. _CRTIMP void __cdecl exit(int);
  172. _CRTIMP void __cdecl _exit(int);
  173. #endif
  174. _CRTIMP void __cdecl _cexit(void);
  175. _CRTIMP void __cdecl _c_exit(void);
  176. _CRTIMP int __cdecl _getpid(void);
  177. _CRTIMP intptr_t __cdecl _cwait(int *, intptr_t, int);
  178. _CRTIMP intptr_t __cdecl _execl(const char *, const char *, ...);
  179. _CRTIMP intptr_t __cdecl _execle(const char *, const char *, ...);
  180. _CRTIMP intptr_t __cdecl _execlp(const char *, const char *, ...);
  181. _CRTIMP intptr_t __cdecl _execlpe(const char *, const char *, ...);
  182. _CRTIMP intptr_t __cdecl _execv(const char *, const char * const *);
  183. _CRTIMP intptr_t __cdecl _execve(const char *, const char * const *, const char * const *);
  184. _CRTIMP intptr_t __cdecl _execvp(const char *, const char * const *);
  185. _CRTIMP intptr_t __cdecl _execvpe(const char *, const char * const *, const char * const *);
  186. _CRTIMP intptr_t __cdecl _spawnl(int, const char *, const char *, ...);
  187. _CRTIMP intptr_t __cdecl _spawnle(int, const char *, const char *, ...);
  188. _CRTIMP intptr_t __cdecl _spawnlp(int, const char *, const char *, ...);
  189. _CRTIMP intptr_t __cdecl _spawnlpe(int, const char *, const char *, ...);
  190. _CRTIMP intptr_t __cdecl _spawnv(int, const char *, const char * const *);
  191. _CRTIMP intptr_t __cdecl _spawnve(int, const char *, const char * const *,
  192. const char * const *);
  193. _CRTIMP intptr_t __cdecl _spawnvp(int, const char *, const char * const *);
  194. _CRTIMP intptr_t __cdecl _spawnvpe(int, const char *, const char * const *,
  195. const char * const *);
  196. _CRTIMP int __cdecl system(const char *);
  197. #ifndef _WPROCESS_DEFINED
  198. /* wide function prototypes, also declared in wchar.h */
  199. _CRTIMP intptr_t __cdecl _wexecl(const wchar_t *, const wchar_t *, ...);
  200. _CRTIMP intptr_t __cdecl _wexecle(const wchar_t *, const wchar_t *, ...);
  201. _CRTIMP intptr_t __cdecl _wexeclp(const wchar_t *, const wchar_t *, ...);
  202. _CRTIMP intptr_t __cdecl _wexeclpe(const wchar_t *, const wchar_t *, ...);
  203. _CRTIMP intptr_t __cdecl _wexecv(const wchar_t *, const wchar_t * const *);
  204. _CRTIMP intptr_t __cdecl _wexecve(const wchar_t *, const wchar_t * const *, const wchar_t * const *);
  205. _CRTIMP intptr_t __cdecl _wexecvp(const wchar_t *, const wchar_t * const *);
  206. _CRTIMP intptr_t __cdecl _wexecvpe(const wchar_t *, const wchar_t * const *, const wchar_t * const *);
  207. _CRTIMP intptr_t __cdecl _wspawnl(int, const wchar_t *, const wchar_t *, ...);
  208. _CRTIMP intptr_t __cdecl _wspawnle(int, const wchar_t *, const wchar_t *, ...);
  209. _CRTIMP intptr_t __cdecl _wspawnlp(int, const wchar_t *, const wchar_t *, ...);
  210. _CRTIMP intptr_t __cdecl _wspawnlpe(int, const wchar_t *, const wchar_t *, ...);
  211. _CRTIMP intptr_t __cdecl _wspawnv(int, const wchar_t *, const wchar_t * const *);
  212. _CRTIMP intptr_t __cdecl _wspawnve(int, const wchar_t *, const wchar_t * const *,
  213. const wchar_t * const *);
  214. _CRTIMP intptr_t __cdecl _wspawnvp(int, const wchar_t *, const wchar_t * const *);
  215. _CRTIMP intptr_t __cdecl _wspawnvpe(int, const wchar_t *, const wchar_t * const *,
  216. const wchar_t * const *);
  217. _CRTIMP int __cdecl _wsystem(const wchar_t *);
  218. #define _WPROCESS_DEFINED
  219. #endif
  220. /* --------- The following functions are OBSOLETE --------- */
  221. /*
  222. * The Win32 API LoadLibrary, FreeLibrary and GetProcAddress should be used
  223. * instead.
  224. */
  225. intptr_t __cdecl _loaddll(char *);
  226. int __cdecl _unloaddll(intptr_t);
  227. int (__cdecl * __cdecl _getdllprocaddr(intptr_t, char *, intptr_t))();
  228. /* --------- The preceding functions are OBSOLETE --------- */
  229. #ifdef _DECL_DLLMAIN
  230. /*
  231. * Declare DLL notification (initialization/termination) routines
  232. * The preferred method is for the user to provide DllMain() which will
  233. * be called automatically by the DLL entry point defined by the C run-
  234. * time library code. If the user wants to define the DLL entry point
  235. * routine, the user's entry point must call _CRT_INIT on all types of
  236. * notifications, as the very first thing on attach notifications and
  237. * as the very last thing on detach notifications.
  238. */
  239. #ifdef _WINDOWS_ /* Use types from WINDOWS.H */
  240. BOOL WINAPI DllMain(HANDLE, DWORD, LPVOID);
  241. BOOL WINAPI _CRT_INIT(HANDLE, DWORD, LPVOID);
  242. BOOL WINAPI _wCRT_INIT(HANDLE, DWORD, LPVOID);
  243. extern BOOL (WINAPI *_pRawDllMain)(HANDLE, DWORD, LPVOID);
  244. #else
  245. int __stdcall DllMain(void *, unsigned, void *);
  246. int __stdcall _CRT_INIT(void *, unsigned, void *);
  247. int __stdcall _wCRT_INIT(void *, unsigned, void *);
  248. extern int (__stdcall *_pRawDllMain)(void *, unsigned, void *);
  249. #endif /* _WINDOWS_ */
  250. #endif
  251. #if !__STDC__
  252. /* Non-ANSI names for compatibility */
  253. #define P_WAIT _P_WAIT
  254. #define P_NOWAIT _P_NOWAIT
  255. #define P_OVERLAY _P_OVERLAY
  256. #define OLD_P_OVERLAY _OLD_P_OVERLAY
  257. #define P_NOWAITO _P_NOWAITO
  258. #define P_DETACH _P_DETACH
  259. #define WAIT_CHILD _WAIT_CHILD
  260. #define WAIT_GRANDCHILD _WAIT_GRANDCHILD
  261. /* current declarations */
  262. _CRTIMP intptr_t __cdecl cwait(int *, intptr_t, int);
  263. _CRTIMP intptr_t __cdecl execl(const char *, const char *, ...);
  264. _CRTIMP intptr_t __cdecl execle(const char *, const char *, ...);
  265. _CRTIMP intptr_t __cdecl execlp(const char *, const char *, ...);
  266. _CRTIMP intptr_t __cdecl execlpe(const char *, const char *, ...);
  267. _CRTIMP intptr_t __cdecl execv(const char *, const char * const *);
  268. _CRTIMP intptr_t __cdecl execve(const char *, const char * const *, const char * const *);
  269. _CRTIMP intptr_t __cdecl execvp(const char *, const char * const *);
  270. _CRTIMP intptr_t __cdecl execvpe(const char *, const char * const *, const char * const *);
  271. _CRTIMP intptr_t __cdecl spawnl(int, const char *, const char *, ...);
  272. _CRTIMP intptr_t __cdecl spawnle(int, const char *, const char *, ...);
  273. _CRTIMP intptr_t __cdecl spawnlp(int, const char *, const char *, ...);
  274. _CRTIMP intptr_t __cdecl spawnlpe(int, const char *, const char *, ...);
  275. _CRTIMP intptr_t __cdecl spawnv(int, const char *, const char * const *);
  276. _CRTIMP intptr_t __cdecl spawnve(int, const char *, const char * const *,
  277. const char * const *);
  278. _CRTIMP intptr_t __cdecl spawnvp(int, const char *, const char * const *);
  279. _CRTIMP intptr_t __cdecl spawnvpe(int, const char *, const char * const *,
  280. const char * const *);
  281. _CRTIMP int __cdecl getpid(void);
  282. #endif /* __STDC__ */
  283. #ifdef __cplusplus
  284. }
  285. #endif
  286. #endif /* _POSIX_ */
  287. #endif /* _INC_PROCESS */