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.

1416 lines
35 KiB

  1. /*++ BUILD Version: 0001 // Increment this if a change has global effects
  2. --*/
  3. //+---------------------------------------------------------------------------
  4. //
  5. // Microsoft Windows
  6. // Copyright (C) Microsoft Corporation, 1994
  7. //
  8. // File: build.h
  9. //
  10. // Contents: Main Include file for build.exe
  11. //
  12. // History: 16-May-89 SteveWo Created
  13. // 26-Jul-94 LyleC Cleanup/Add Support for Pass0
  14. //
  15. //----------------------------------------------------------------------------
  16. #include <assert.h>
  17. #include <process.h>
  18. #include <stdio.h>
  19. #include <stddef.h>
  20. #include <stdlib.h>
  21. #include <stdarg.h>
  22. #include <limits.h>
  23. #include <malloc.h>
  24. #include <errno.h>
  25. #include <ctype.h>
  26. #include <signal.h>
  27. #include <string.h>
  28. #include <time.h>
  29. #include <io.h>
  30. #include <conio.h>
  31. #include <sys\types.h>
  32. #include <sys\stat.h>
  33. #define INC_OLE2
  34. #include <windows.h>
  35. #define UINT DWORD
  36. #define HDIR HANDLE
  37. VOID
  38. ClearLine(VOID);
  39. //
  40. // Types and Constant Definitions
  41. //
  42. #if DBG
  43. #define DEBUG_1 (fDebug & 1)
  44. #else
  45. #define DEBUG_1 FALSE
  46. #endif
  47. BOOL fDebug;
  48. #define DEBUG_2 (fDebug & 3)
  49. #define DEBUG_4 (fDebug & 4)
  50. //
  51. // Target specific dirs file name.
  52. //
  53. extern LPSTR pszTargetDirs;
  54. #define MAX_TARGET_MACHINES 4
  55. typedef struct _TARGET_MACHINE_INFO {
  56. UCHAR SourceSubDirMask; // TMIDIR_I386
  57. LPSTR Description; // "i386"
  58. LPSTR Switch; // "-386"
  59. LPSTR Switch2; // "-x86"
  60. LPSTR MakeVariable; // "386=1"
  61. LPSTR SourceVariable; // "i386_SOURCES"
  62. LPSTR ObjectVariable; // "386_OBJECTS"
  63. LPSTR AssociateDirectory; // "i386"
  64. LPSTR SourceDirectory; // "i386"
  65. LPSTR TargetDirs; // "i386dirs"
  66. LPSTR ObjectDirectory[2]; // "i386" -- initialize only first entry
  67. ULONG DirIncludeMask; // Platform/Group/etc.
  68. LPSTR ObjectMacro; // don't initialize
  69. } TARGET_MACHINE_INFO, *PTARGET_MACHINE_INFO;
  70. #define DIR_INCLUDE_NONE 0x00000000
  71. #define DIR_INCLUDE_X86 0x00000001
  72. // 0x00000002
  73. #define DIR_INCLUDE_IA64 0x00000004
  74. // 0x00000008
  75. #define DIR_INCLUDE_WIN32 0x00000010
  76. #define DIR_INCLUDE_WIN64 0x00000020
  77. #define DIR_INCLUDE_RISC 0x00000040
  78. #define DIR_INCLUDE_AMD64 0x00000080
  79. #define DIR_INCLUDE_ARM 0x00000100
  80. #define DIR_INCLUDE_ALL 0xffffffff
  81. // It's possible to have SOURCES= entries of the following forms:
  82. // entry SourceSubDirMask
  83. // ----- ----------------
  84. // foo.c 0
  85. // i386\foo.c 1
  86. // amd64\foo.c 2
  87. // ia64\foo.c 4
  88. // arm\foo.c 8
  89. // ..\foo.c 80
  90. // ..\i386\foo.c 81
  91. // ..\amd64\foo.c 82
  92. // ..\ia64\foo.c 84
  93. // ..\arm\foo.c 88
  94. #define TMIDIR_I386 0x0001
  95. #define TMIDIR_AMD64 0x0002
  96. #define TMIDIR_IA64 0x0004
  97. #define TMIDIR_ARM 0x0008
  98. #define TMIDIR_PARENT 0x0080 // or'd in with above bits
  99. #define SIG_DIRREC 0x44644464 // "DdDd"
  100. #ifdef SIG_DIRREC
  101. #define SIG_FILEREC 0x46664666 // "FfFf"
  102. #define SIG_INCLUDEREC 0x49694969 // "IiIi"
  103. #define SIG_SOURCEREC 0x53735373 // "SsSs"
  104. #define SigCheck(s) s
  105. #else
  106. #define SigCheck(s)
  107. #endif
  108. #define AssertDir(pdr) \
  109. SigCheck(assert((pdr) != NULL && (pdr)->Sig == SIG_DIRREC))
  110. #define AssertOptionalDir(pdr) \
  111. SigCheck(assert((pdr) == NULL || (pdr)->Sig == SIG_DIRREC))
  112. #define AssertFile(pfr) \
  113. SigCheck(assert((pfr) != NULL && (pfr)->Sig == SIG_FILEREC))
  114. #define AssertOptionalFile(pfr) \
  115. SigCheck(assert((pfr) == NULL || (pfr)->Sig == SIG_FILEREC))
  116. #define AssertInclude(pir) \
  117. SigCheck(assert((pir) != NULL && (pir)->Sig == SIG_INCLUDEREC))
  118. #define AssertOptionalInclude(pir) \
  119. SigCheck(assert((pir) == NULL || (pir)->Sig == SIG_INCLUDEREC))
  120. #define AssertSource(psr) \
  121. SigCheck(assert((psr) != NULL && (psr)->Sig == SIG_SOURCEREC))
  122. #define AssertOptionalSource(psr) \
  123. SigCheck(assert((psr) == NULL || (psr)->Sig == SIG_SOURCEREC))
  124. //
  125. // Information about source directories is stored an in-memory database.
  126. // The information is saved on disk by writing the contents of the database
  127. // to "build.dat". It is reloaded from disk for subsequent invocations,
  128. // and re-written only when it has been updated.
  129. //
  130. typedef struct _INCLUDEREC {
  131. SigCheck(ULONG Sig;)
  132. struct _INCLUDEREC *Next; // static list describes original arcs
  133. struct _INCLUDEREC *NextTree; // dynamic list -- cycles are collapsed
  134. struct _FILEREC *pfrCycleRoot;
  135. struct _FILEREC *pfrInclude;
  136. USHORT Version;
  137. USHORT IncFlags;
  138. char Name[1];
  139. } INCLUDEREC, *PINCLUDEREC;
  140. #define INCLUDEDB_LOCAL 0x0001 // include "foo.h"
  141. #define INCLUDEDB_POST_HDRSTOP 0x0002 // appears after #pragma hdrstop
  142. #define INCLUDEDB_MISSING 0x0400 // include file was once missing
  143. #define INCLUDEDB_GLOBAL 0x0800 // include file is in global directory
  144. #define INCLUDEDB_SNAPPED 0x1000 // include file snapped
  145. #define INCLUDEDB_CYCLEALLOC 0x2000 // allocated to flatten cycle
  146. #define INCLUDEDB_CYCLEROOT 0x4000 // moved to root file to flatten cycle
  147. #define INCLUDEDB_CYCLEORPHAN 0x8000 // orphaned to flatten cycle
  148. // Flags preserved when loading build.dat:
  149. #define INCLUDEDB_DBPRESERVE (INCLUDEDB_LOCAL | INCLUDEDB_POST_HDRSTOP)
  150. #define IsCleanTree(pir) \
  151. ((pir)->NextTree == NULL && \
  152. ((pir)->IncFlags & \
  153. (INCLUDEDB_CYCLEALLOC | INCLUDEDB_CYCLEROOT | INCLUDEDB_CYCLEORPHAN)) == 0)
  154. #if DBG
  155. VOID AssertCleanTree(INCLUDEREC *pir, OPTIONAL struct _FILEREC *pfr);
  156. #else
  157. #define AssertCleanTree(pir, pfr) assert(IsCleanTree(pir))
  158. #endif
  159. //
  160. // Make file description structure definition.
  161. //
  162. typedef struct _FILEDESC {
  163. LPSTR pszPattern; // pattern to match file name
  164. LPSTR pszCommentToEOL; // comment-to-eol string
  165. BOOL fNeedFileRec; // TRUE => file needs a file record
  166. ULONG FileFlags; // flags to be set in file record
  167. ULONG DirFlags; // flags to be set in directory record
  168. } FILEDESC;
  169. extern FILEDESC FileDesc[];
  170. typedef struct _FILEREC {
  171. SigCheck(ULONG Sig;)
  172. struct _FILEREC *Next;
  173. struct _DIRREC *Dir;
  174. INCLUDEREC *IncludeFiles; // static list describes original arcs
  175. INCLUDEREC *IncludeFilesTree; // dynamic list -- cycles are collapsed
  176. struct _FILEREC *NewestDependency;
  177. LPSTR pszCommentToEOL; // comment-to-eol string in source
  178. ULONG DateTime;
  179. ULONG DateTimeTree; // Newest DateTime for included tree
  180. ULONG TotalSourceLines; // line count in all included files
  181. ULONG FileFlags;
  182. ULONG SourceLines;
  183. USHORT Attr;
  184. USHORT SubDirIndex;
  185. USHORT Version;
  186. USHORT GlobalSequence; // Sequence number for dynamic include tree
  187. USHORT LocalSequence; // Sequence number for dynamic include tree
  188. USHORT idScan; // id used for detecting multiple inclusion
  189. USHORT CheckSum; // Name checksum
  190. UCHAR fDependActive; // TRUE-> we're scanning at or below this file.
  191. char Name[1];
  192. } FILEREC, *PFILEREC;
  193. #define FILEDB_SOURCE 0x00000001
  194. #define FILEDB_DIR 0x00000002
  195. #define FILEDB_HEADER 0x00000004
  196. #define FILEDB_ASM 0x00000008
  197. #define FILEDB_MASM 0x00000010
  198. #define FILEDB_RC 0x00000020
  199. #define FILEDB_C 0x00000040
  200. #define FILEDB_MIDL 0x00000080
  201. #define FILEDB_ASN 0x00000100
  202. #define FILEDB_JAVA 0x00000200
  203. #define FILEDB_MOF 0x00000400
  204. #define FILEDB_CSHARP 0x00000800
  205. #define FILEDB_SCANNED 0x00001000
  206. #define FILEDB_OBJECTS_LIST 0x00002000
  207. #define FILEDB_FILE_MISSING 0x00004000
  208. #define FILEDB_MKTYPLIB 0x00008000
  209. #define FILEDB_MULTIPLEPASS 0x00010000
  210. #define FILEDB_PASS0 0x00020000
  211. #define FILEDB_SOURCEREC_EXISTS 0x00040000
  212. #define FILEDB_VBP 0x00080000
  213. #define FILEDB_VB_NET 0x00100000
  214. // Flags preserved when loading build.dat:
  215. #define FILEDB_DBPRESERVE (FILEDB_SOURCE | \
  216. FILEDB_DIR | \
  217. FILEDB_HEADER | \
  218. FILEDB_ASM | \
  219. FILEDB_MASM | \
  220. FILEDB_RC | \
  221. FILEDB_C | \
  222. FILEDB_MIDL | \
  223. FILEDB_ASN | \
  224. FILEDB_JAVA | \
  225. FILEDB_MOF | \
  226. FILEDB_VBP | \
  227. FILEDB_VB_NET | \
  228. FILEDB_CSHARP | \
  229. FILEDB_MKTYPLIB | \
  230. FILEDB_MULTIPLEPASS | \
  231. FILEDB_PASS0)
  232. typedef struct _SOURCEREC {
  233. SigCheck(ULONG Sig;)
  234. struct _SOURCEREC *psrNext;
  235. FILEREC *pfrSource;
  236. UCHAR SourceSubDirMask;
  237. UCHAR SrcFlags;
  238. } SOURCEREC;
  239. #define SOURCEDB_SOURCES_LIST 0x01
  240. #define SOURCEDB_FILE_MISSING 0x02
  241. #define SOURCEDB_PCH 0x04
  242. #define SOURCEDB_OUT_OF_DATE 0x08
  243. #define SOURCEDB_COMPILE_NEEDED 0x10
  244. typedef struct _DIRSUP {
  245. LPSTR TestType;
  246. LPSTR LocalIncludePath;
  247. LPSTR UserIncludePath;
  248. LPSTR LastIncludePath;
  249. LPSTR NTIncludePath;
  250. LPSTR PchIncludeDir;
  251. LPSTR PchInclude;
  252. LPSTR PchTargetDir;
  253. LPSTR PchTarget;
  254. LPSTR PassZeroHdrDir;
  255. LPSTR PassZeroSrcDir1;
  256. LPSTR PassZeroSrcDir2;
  257. LPSTR ConditionalIncludes;
  258. ULONG DateTimeSources;
  259. ULONG IdlType;
  260. ULONG fNoTarget;
  261. LPSTR SourcesVariables[MAX_TARGET_MACHINES + 2];
  262. SOURCEREC *psrSourcesList[MAX_TARGET_MACHINES + 2];
  263. } DIRSUP;
  264. typedef struct _DIRREC {
  265. SigCheck(ULONG Sig;)
  266. struct _DIRREC *Next;
  267. LIST_ENTRY Produces;
  268. LIST_ENTRY Consumes;
  269. DIRSUP *pds; // Used to preserve info from pass zero
  270. PFILEREC Files;
  271. LPSTR TargetPath;
  272. LPSTR TargetPathLib;
  273. LPSTR TargetName;
  274. LPSTR TargetExt;
  275. LPSTR KernelTest;
  276. LPSTR UserAppls;
  277. LPSTR UserTests;
  278. LPSTR NTTargetFile0;
  279. LPSTR Pch;
  280. LPSTR PchObj;
  281. LONG SourceLinesToCompile;
  282. LONG PassZeroLines;
  283. ULONG DirFlags;
  284. ULONG RecurseLevel;
  285. USHORT FindCount;
  286. USHORT CountSubDirs;
  287. SHORT CountOfFilesToCompile;
  288. SHORT CountOfPassZeroFiles;
  289. USHORT CheckSum; // Name checksum
  290. char Name[1];
  291. } DIRREC, *PDIRREC;
  292. #define DIRDB_SOURCES 0x00000001
  293. #define DIRDB_DIRS 0x00000002
  294. #define DIRDB_MAKEFILE 0x00000004
  295. #define DIRDB_MAKEFIL0 0x00000008
  296. #define DIRDB_TARGETFILE0 0x00000010
  297. #define DIRDB_TARGETFILES 0x00000020
  298. #define DIRDB_RESOURCE 0x00000040
  299. #define DIRDB_PASS0 0x00000080
  300. #define DIRDB_SOURCES_SET 0x00000100
  301. #define DIRDB_SYNC_PRODUCES 0x00000200
  302. #define DIRDB_SYNC_CONSUMES 0x00000400
  303. #define DIRDB_CHICAGO_INCLUDES 0x00000800
  304. #define DIRDB_NEW 0x00001000
  305. #define DIRDB_SCANNED 0x00002000
  306. #define DIRDB_SHOWN 0x00004000
  307. #define DIRDB_GLOBAL_INCLUDES 0x00008000
  308. #define DIRDB_SYNCHRONIZE_BLOCK 0x00010000
  309. #define DIRDB_SYNCHRONIZE_PASS2_BLOCK 0x00020000
  310. #define DIRDB_SYNCHRONIZE_DRAIN 0x00040000
  311. #define DIRDB_SYNCHRONIZE_PASS2_DRAIN 0x00080000
  312. #define DIRDB_COMPILENEEDED 0x00100000
  313. #define DIRDB_COMPILEERRORS 0x00200000
  314. #define DIRDB_SOURCESREAD 0x00400000
  315. #define DIRDB_DLLTARGET 0x00800000
  316. #define DIRDB_LINKNEEDED 0x01000000
  317. #define DIRDB_FORCELINK 0x02000000
  318. #define DIRDB_PASS0NEEDED 0x04000000
  319. #define DIRDB_MAKEFIL1 0x08000000
  320. #define DIRDB_CHECKED_ALT_DIR 0x10000000
  321. #define DIRDB_MANAGED_CODE 0x20000000
  322. #define DIRDB_IDLTYPERPC 0x40000000
  323. // Flags preserved when loading build.dat:
  324. #define DIRDB_DBPRESERVE 0
  325. //
  326. // Dependency structure
  327. //
  328. typedef struct _DEPENDENCY {
  329. struct _DEPENDENCY *Next; // Links together all dependencies
  330. LIST_ENTRY DependencyList; // Links together all dependencies produced by this DIRREC
  331. LIST_ENTRY WaitList; // List of DIRRECs that consume this dependency
  332. PDIRREC Producer; // DIRREC that is going to produce this dependency
  333. HANDLE hEvent; // Signalled when dependency is produced
  334. BOOL Done;
  335. USHORT CheckSum;
  336. char Name[1];
  337. } DEPENDENCY, *PDEPENDENCY;
  338. PDEPENDENCY AllDependencies;
  339. typedef struct _DEPENDENCY_WAIT {
  340. LIST_ENTRY ListEntry; // Links together all dependencies consumed by this DIRREC
  341. PDEPENDENCY Dependency; // Dependency this wait block is waiting for
  342. PDIRREC Consumer; // DIRREC that is waiting on this dependency
  343. } DEPENDENCY_WAIT, *PDEPENDENCY_WAIT;
  344. typedef struct _TARGET {
  345. FILEREC *pfrCompiland;
  346. DIRREC *pdrBuild;
  347. LPSTR pszSourceDirectory;
  348. LPSTR ConditionalIncludes;
  349. ULONG DateTime;
  350. ULONG DirFlags;
  351. char Name[1];
  352. } TARGET, *PTARGET;
  353. #define BUILD_VERSION 0x0422
  354. #define DBMASTER_NAME "build.dat"
  355. #define DB_MAX_PATH_LENGTH 512 // There's some sick people out there using 250 byte paths with 100 byte filenames
  356. #define MAKEPARAMETERS_MAX_LEN 512
  357. // If you change or add any values to this enum,
  358. // also fix MemTab in buildutl.c:
  359. typedef enum _MemType {
  360. MT_TOTALS = 0,
  361. MT_UNKNOWN,
  362. MT_CHILDDATA,
  363. MT_CMDSTRING,
  364. MT_DIRDB,
  365. MT_DIRSUP,
  366. MT_DIRPATH,
  367. MT_DIRSTRING,
  368. MT_EVENTHANDLES,
  369. MT_FILEDB,
  370. MT_FILEREADBUF,
  371. MT_FRBSTRING,
  372. MT_INCLUDEDB,
  373. MT_IOBUFFER,
  374. MT_MACRO,
  375. MT_SOURCEDB,
  376. MT_TARGET,
  377. MT_THREADFILTER,
  378. MT_THREADHANDLES,
  379. MT_THREADSTATE,
  380. MT_DEPENDENCY,
  381. MT_DEPENDENCY_WAIT,
  382. MT_XMLTHREADSTATE,
  383. MT_PXMLTHREADSTATE,
  384. MT_INVALID = 255,
  385. } MemType;
  386. struct _THREADSTATE;
  387. typedef BOOL (*FILTERPROC)(struct _THREADSTATE *ThreadState, LPSTR p);
  388. typedef struct _BUILDMETRICS {
  389. UINT NumberCompileWarnings;
  390. UINT NumberCompileErrors;
  391. UINT NumberCompiles;
  392. UINT NumberLibraries;
  393. UINT NumberLibraryWarnings;
  394. UINT NumberLibraryErrors;
  395. UINT NumberLinks;
  396. UINT NumberLinkWarnings;
  397. UINT NumberLinkErrors;
  398. UINT NumberBSCMakes;
  399. UINT NumberBSCWarnings;
  400. UINT NumberBSCErrors;
  401. UINT NumberVSToolErrors;
  402. UINT NumberVSToolWarnings;
  403. UINT NumberBinplaces;
  404. UINT NumberBinplaceWarnings;
  405. UINT NumberBinplaceErrors;
  406. // XML support and fragments
  407. UINT NumberDirActions;
  408. UINT NumberActWarnings;
  409. UINT NumberActErrors;
  410. } BUILDMETRICS, *PBUILDMETRICS;
  411. typedef struct _THREADSTATE {
  412. USHORT cRowTotal;
  413. USHORT cColTotal;
  414. BOOL IsStdErrTty;
  415. FILE *ChildOutput;
  416. UINT ChildState;
  417. UINT ChildFlags;
  418. LPSTR ChildTarget;
  419. UINT LinesToIgnore;
  420. FILTERPROC FilterProc;
  421. ULONG ThreadIndex;
  422. ULONG XMLThreadIndex;
  423. CHAR UndefinedId[ DB_MAX_PATH_LENGTH ];
  424. CHAR ChildCurrentDirectory[ DB_MAX_PATH_LENGTH ];
  425. CHAR ChildCurrentFile[ DB_MAX_PATH_LENGTH ];
  426. DIRREC *CompileDirDB;
  427. BUILDMETRICS BuildMetrics;
  428. } THREADSTATE, *PTHREADSTATE;
  429. //
  430. // Global Data (uninit will always be FALSE)
  431. //
  432. BOOL fUsage; // Set when usage message is to be displayed
  433. BOOL fStatus; // Set by -s and -S options
  434. BOOL fStatusTree; // Set by -S option
  435. BOOL fShowTree; // Set by -t and -T options
  436. BOOL fShowTreeIncludes; // Set by -T option
  437. BOOL fClean; // Set by -c option
  438. BOOL fCleanLibs; // Set by -C option
  439. BOOL fCleanRestart; // Set by -r option
  440. BOOL fRestartClean; // Set if -c and -r were both given
  441. BOOL fRestartCleanLibs; // Set if -C and -r were both given
  442. BOOL fPause; // Set by -p option
  443. BOOL fParallel; // Set on a multiprocessor machine or by -M
  444. BOOL fPrintElapsed; // Set by -P option
  445. BOOL fQuery; // Set by -q option
  446. BOOL fStopAfterPassZero; // Set by -0 option
  447. BOOL fQuicky; // Set by -z and -Z options
  448. BOOL fQuickZero; // Set by -3
  449. BOOL fSemiQuicky; // Set by -Z option
  450. BOOL fShowOutOfDateFiles; // Set by -o option
  451. BOOL fSyncLink; // Set by -a option
  452. BOOL fForce; // Set by -f option
  453. BOOL fEnableVersionCheck; // Set by -v option
  454. BOOL fSilentDependencies; // Set by -i option
  455. BOOL fKeep; // Set by -k option
  456. BOOL fCompileOnly; // Set by -L option
  457. BOOL fLinkOnly; // Set by -l option
  458. BOOL fErrorLog; // Set by -e option
  459. BOOL fGenerateObjectsDotMacOnly; // Set by -O option
  460. BOOL fShowWarningsOnScreen; // Set by -w option
  461. BOOL fNoisyScan; // Set by -y option
  462. BOOL fFullErrors; // Set by -b option
  463. BOOL fWhyBuild; // Set by -why option
  464. BOOL fChicagoProduct; // Set if CHICAGO_PRODUCT is set in environment
  465. BOOL fLineCleared; // Current line on screen clear?
  466. BOOL fPassZero; // Indicates we've found pass zero dirs
  467. BOOL fFirstScan; // Indicates this is the first scan
  468. BOOL fAlwaysPrintFullPath; // Set by -F option
  469. BOOL fTargetDirs; // Set by -g option
  470. BOOL fAlwaysKeepLogfile; // Set by -E option
  471. BOOL fShowUnusedDirs; // Set by -u option
  472. BOOL fColorConsole; // set by -g option
  473. BOOL fCheckIncludePaths; // Set by -# option
  474. BOOL fErrorBaseline; // Set by -B option
  475. BOOL fXMLOutput; // Set by -X option
  476. BOOL fXMLVerboseOutput; // Set by -Xv option
  477. BOOL fXMLFragment; // Set bu -Xf option
  478. BOOL fNoThreadIndex; // Set by -I option
  479. BOOL fIgnoreSync; // Set by -I option
  480. BOOL fMTScriptSync; // Set when communicating with the MTScript engine
  481. BOOL fBuildAltDirSet; // set when BUILD_ALT_DIR is defined.
  482. BOOL fSuppressOutput; // Set by -h options
  483. #define MAX_INCLUDE_PATTERNS 32
  484. LPSTR AcceptableIncludePatternList[ MAX_INCLUDE_PATTERNS + 1 ];
  485. LPSTR UnacceptableIncludePatternList[ MAX_INCLUDE_PATTERNS + 1 ];
  486. LPSTR MakeProgram;
  487. char MakeParameters[ MAKEPARAMETERS_MAX_LEN ];
  488. LPSTR MakeParametersTail;
  489. char MakeTargets[ 256 ];
  490. char RestartDir[ 256 ];
  491. char NtRoot[ 256 ];
  492. char DbMasterName[ 256 ];
  493. extern const char szNewLine[];
  494. char BaselinePathName[DB_MAX_PATH_LENGTH]; // The file name for -B
  495. BOOL bBaselineFailure; // Indicates if there is a build failure that is not in the baseline file
  496. VOID* pvBaselineContent; // The content of the baseline file
  497. DWORD cbBaselineContentSize; // The size of the baseline file
  498. char XMLFragmentDirectory[DB_MAX_PATH_LENGTH]; // The path for -Xf
  499. char *pszSdkLibDest;
  500. char *pszDdkLibDest;
  501. char *pszPublicInternalPath;
  502. char *pszIncOak;
  503. char *pszIncDdk;
  504. char *pszIncWdm;
  505. char *pszIncSdk;
  506. char *pszIncMfc;
  507. char *pszIncCrt;
  508. char *pszIncPri;
  509. char *pszIncOs2;
  510. char *pszIncPosix;
  511. char *pszIncChicago;
  512. char *szBuildTag;
  513. char *pszObjDir;
  514. char *pszObjDirSlash;
  515. char *pszObjDirSlashStar;
  516. BOOL fCheckedBuild;
  517. ULONG iObjectDir;
  518. extern ULONG NumberProcesses;
  519. CRITICAL_SECTION TTYCriticalSection;
  520. CRITICAL_SECTION XMLCriticalSection;
  521. CHAR const *cmdexe;
  522. LONG TotalFilesToCompile;
  523. LONG TotalFilesCompiled;
  524. LONG TotalLinesToCompile;
  525. LONG TotalLinesCompiled;
  526. ULONG ElapsedCompileTime;
  527. DIRREC *CurrentCompileDirDB;
  528. // Fixed length arrays...
  529. UINT CountTargetMachines;
  530. TARGET_MACHINE_INFO *TargetMachines[MAX_TARGET_MACHINES];
  531. TARGET_MACHINE_INFO *PossibleTargetMachines[MAX_TARGET_MACHINES];
  532. TARGET_MACHINE_INFO i386TargetMachine;
  533. TARGET_MACHINE_INFO ia64TargetMachine;
  534. TARGET_MACHINE_INFO Amd64TargetMachine;
  535. TARGET_MACHINE_INFO ARMTargetMachine;
  536. UINT TargetToPossibleTarget[MAX_TARGET_MACHINES];
  537. #define MAX_OPTIONAL_DIRECTORIES 256
  538. UINT CountOptionalDirs;
  539. LPSTR OptionalDirs[MAX_OPTIONAL_DIRECTORIES];
  540. BOOLEAN OptionalDirsUsed[MAX_OPTIONAL_DIRECTORIES];
  541. BOOL BuildAllOptionalDirs;
  542. #define MAX_EXCLUDE_DIRECTORIES MAX_OPTIONAL_DIRECTORIES
  543. UINT CountExcludeDirs;
  544. LPSTR ExcludeDirs[MAX_EXCLUDE_DIRECTORIES];
  545. BOOLEAN ExcludeDirsUsed[MAX_OPTIONAL_DIRECTORIES];
  546. #define MAX_EXCLUDE_INCS 128
  547. UINT CountExcludeIncs;
  548. LPSTR ExcludeIncs[MAX_EXCLUDE_INCS];
  549. #define MAX_INCLUDE_DIRECTORIES 256
  550. UINT CountIncludeDirs;
  551. UINT CountSystemIncludeDirs;
  552. DIRREC *IncludeDirs[MAX_INCLUDE_DIRECTORIES];
  553. #define MAX_BUILD_DIRECTORIES 8192
  554. UINT CountPassZeroDirs;
  555. DIRREC *PassZeroDirs[MAX_BUILD_DIRECTORIES];
  556. UINT CountCompileDirs;
  557. DIRREC *CompileDirs[MAX_BUILD_DIRECTORIES];
  558. UINT CountLinkDirs;
  559. DIRREC *LinkDirs[MAX_BUILD_DIRECTORIES];
  560. UINT CountShowDirs;
  561. DIRREC *ShowDirs[MAX_BUILD_DIRECTORIES];
  562. DIRREC *AllDirs;
  563. CHAR CurrentDirectory[DB_MAX_PATH_LENGTH];
  564. BOOL AllDirsInitialized;
  565. BOOL AllDirsModified;
  566. USHORT GlobalSequence;
  567. USHORT LocalSequence;
  568. BOOLEAN fConsoleInitialized;
  569. DWORD NewConsoleMode;
  570. LPSTR BuildDefault;
  571. LPSTR BuildParameters;
  572. LPSTR SystemIncludeEnv;
  573. LPSTR LocalIncludeEnv;
  574. LPSTR BigBuf;
  575. UINT BigBufSize;
  576. UINT RecurseLevel;
  577. FILE *LogFile;
  578. FILE *WrnFile;
  579. FILE *ErrFile;
  580. FILE *IPGScriptFile;
  581. FILE *IncFile;
  582. FILE *XMLFile;
  583. BUILDMETRICS PassMetrics;
  584. BUILDMETRICS BuildMetrics;
  585. BUILDMETRICS RunningTotals;
  586. char szAsterisks[];
  587. ULONG BuildStartTime;
  588. WORD DefaultConsoleAttributes;
  589. //
  590. // Global message color settings. MsgColorSettings array defined in build.c.
  591. //
  592. typedef enum _MsgColor {
  593. MSG_COLOR_STATUS = 0,
  594. MSG_COLOR_SUMMARY,
  595. MSG_COLOR_WARNING,
  596. MSG_COLOR_ERROR,
  597. MSG_COLOR_COUNT // keep this at the end
  598. } MsgColor;
  599. typedef struct _MSG_COLOR_SETTINGS
  600. {
  601. LPCSTR EnvVarName;
  602. WORD Color;
  603. } MSG_COLOR_SETTINGS;
  604. extern MSG_COLOR_SETTINGS MsgColorSettings[MSG_COLOR_COUNT];
  605. #define MAKE_MSG_COLOR(index) \
  606. (MsgColorSettings[index].Color | (DefaultConsoleAttributes & (0x00f0)))
  607. #define COLOR_STATUS MAKE_MSG_COLOR(MSG_COLOR_STATUS)
  608. #define COLOR_SUMMARY MAKE_MSG_COLOR(MSG_COLOR_SUMMARY)
  609. #define COLOR_WARNING MAKE_MSG_COLOR(MSG_COLOR_WARNING)
  610. #define COLOR_ERROR MAKE_MSG_COLOR(MSG_COLOR_ERROR)
  611. VOID ReportDirsUsage(VOID);
  612. VOID SetObjDir(BOOL fAlternate);
  613. //
  614. // Stuff defined in buildscr.cpp
  615. //
  616. typedef enum _PROC_EVENTS
  617. {
  618. PE_PASS0_COMPLETE = WM_USER,
  619. PE_PASS1_COMPLETE,
  620. PE_PASS2_COMPLETE,
  621. PE_EXIT
  622. } PROC_EVENTS;
  623. EXTERN_C HANDLE g_hMTThread;
  624. EXTERN_C HANDLE g_hMTEvent;
  625. EXTERN_C DWORD g_dwMTThreadId;
  626. EXTERN_C DWORD WINAPI MTScriptThread(LPVOID pv);
  627. EXTERN_C void WaitForResume(BOOL fPause, PROC_EVENTS pe);
  628. EXTERN_C void ExitMTScriptThread();
  629. //
  630. // Data Base functions defined in builddb.c
  631. //
  632. PDIRREC
  633. LoadDirDB(LPSTR DirName);
  634. #if DBG
  635. VOID
  636. PrintAllDirs(VOID);
  637. #endif
  638. VOID
  639. PrintSourceDBList(SOURCEREC *psr, int i);
  640. VOID
  641. PrintFileDB(FILE *pf, FILEREC *pfr, int DetailLevel);
  642. VOID
  643. PrintDirDB(DIRREC *pdr, int DetailLevel);
  644. FILEREC *
  645. FindSourceFileDB(DIRREC *pdr, LPSTR pszRelPath, DIRREC **ppdr);
  646. DIRREC *
  647. FindSourceDirDB(
  648. LPSTR pszDir, // directory
  649. LPSTR pszRelPath, // relative path
  650. BOOL fTruncateFileName); // TRUE: drop last component of path
  651. SOURCEREC *
  652. FindSourceDB(
  653. SOURCEREC *psr,
  654. FILEREC *pfr);
  655. SOURCEREC *
  656. InsertSourceDB(
  657. SOURCEREC **ppsrNext,
  658. FILEREC *pfr,
  659. UCHAR SubDirMask,
  660. UCHAR SrcFlags);
  661. VOID
  662. FreeSourceDB(SOURCEREC **ppsr);
  663. VOID
  664. UnsnapIncludeFiles(FILEREC *pfr, BOOL fUnsnapGlobal);
  665. VOID
  666. UnsnapAllDirectories(VOID);
  667. VOID
  668. FreeAllDirs(VOID);
  669. PFILEREC
  670. LookupFileDB(
  671. PDIRREC DirDB,
  672. LPSTR FileName);
  673. PFILEREC
  674. InsertFileDB(
  675. PDIRREC DirDB,
  676. LPSTR FileName,
  677. ULONG DateTime,
  678. USHORT Attr,
  679. ULONG FileFlags);
  680. VOID
  681. DeleteUnscannedFiles(PDIRREC DirDB);
  682. PINCLUDEREC
  683. InsertIncludeDB(
  684. PFILEREC FileDB,
  685. LPSTR IncludeFileName,
  686. USHORT IncFlags);
  687. VOID
  688. LinkToCycleRoot(INCLUDEREC *pir, FILEREC *pfrRoot);
  689. VOID
  690. RemoveFromCycleRoot(INCLUDEREC *pir, FILEREC *pfrRoot);
  691. VOID
  692. MergeIncludeFiles(FILEREC *pfr, INCLUDEREC *pirList, FILEREC *pfrRoot);
  693. VOID
  694. MarkIncludeFileRecords(PFILEREC FileDB);
  695. VOID
  696. DeleteIncludeFileRecords(PFILEREC FileDB);
  697. PFILEREC
  698. FindIncludeFileDB(
  699. FILEREC *pfrSource,
  700. FILEREC *pfrCompiland,
  701. DIRREC *pdrBuild,
  702. LPSTR pszSourceDirectory,
  703. INCLUDEREC *IncludeDB);
  704. BOOL
  705. SaveMasterDB(VOID);
  706. void
  707. LoadMasterDB(VOID);
  708. PDIRREC
  709. LoadMasterDirDB(LPSTR s);
  710. PFILEREC
  711. LoadMasterFileDB(LPSTR s);
  712. PINCLUDEREC
  713. LoadMasterIncludeDB(LPSTR s);
  714. USHORT
  715. CheckSum(LPSTR psz);
  716. //
  717. // Scanning functions defined in buildscn.c
  718. //
  719. VOID
  720. AddIncludeDir(DIRREC *pdr, UINT *pui);
  721. VOID
  722. AddShowDir(DIRREC *pdr);
  723. VOID
  724. ScanGlobalIncludeDirectory(LPSTR path);
  725. VOID
  726. ScanIncludeEnv(LPSTR IncludeEnv);
  727. PDIRREC
  728. ScanDirectory(LPSTR DirName);
  729. BOOL
  730. ScanFile(PFILEREC FileDB);
  731. //
  732. // Functions defined in buildmak.c
  733. //
  734. VOID
  735. ScanSourceDirectories(LPSTR DirName);
  736. VOID
  737. CompilePassZeroDirectories(VOID);
  738. VOID
  739. CompileSourceDirectories(VOID);
  740. VOID
  741. LinkSourceDirectories(VOID);
  742. VOID
  743. FreeDirSupData(DIRSUP *pds);
  744. VOID
  745. FreeDirData(DIRREC *pdr);
  746. BOOL
  747. CheckDependencies(
  748. PTARGET Target,
  749. FILEREC *FileDB,
  750. BOOL CheckDate,
  751. FILEREC **ppFileDBRoot);
  752. BOOL
  753. CreateBuildDirectory(LPSTR Name);
  754. VOID
  755. CreatedBuildFile(LPSTR DirName, LPSTR FileName);
  756. VOID
  757. GenerateObjectsDotMac(DIRREC *DirDB, DIRSUP *pds, ULONG DateTimeSources);
  758. VOID
  759. ExpandObjAsterisk(
  760. LPSTR pbuf,
  761. LPSTR pszpath,
  762. LPSTR *ppszObjectDirectory);
  763. //
  764. // Build -# functions defined in buildinc.c
  765. //
  766. LPCTSTR
  767. FindCountedSequenceInString(
  768. IN LPCTSTR String,
  769. IN LPCTSTR Sequence,
  770. IN DWORD Length);
  771. BOOL
  772. DoesInstanceMatchPattern(
  773. IN LPCTSTR Instance,
  774. IN LPCTSTR Pattern);
  775. LPSTR
  776. CombinePaths(
  777. IN LPCSTR ParentPath,
  778. IN LPCSTR ChildPath,
  779. OUT LPSTR TargetPath);
  780. VOID
  781. CreateRelativePath(
  782. IN LPCSTR SourceAbsName,
  783. IN LPCSTR TargetAbsName,
  784. OUT LPSTR RelativePath);
  785. BOOL
  786. ShouldWarnInclude(
  787. IN LPCSTR CompilandFullName,
  788. IN LPCSTR IncludeeFullName);
  789. VOID
  790. CheckIncludeForWarning(
  791. IN LPCSTR CompilandDir,
  792. IN LPCSTR CompilandName,
  793. IN LPCSTR IncluderDir,
  794. IN LPCSTR IncluderName,
  795. IN LPCSTR IncludeeDir,
  796. IN LPCSTR IncludeeName);
  797. //
  798. // Utility functions defined in buildutl.c
  799. //
  800. VOID
  801. AllocMem(size_t cb, VOID **ppv, MemType mt);
  802. VOID
  803. FreeMem(VOID **ppv, MemType mt);
  804. VOID
  805. ReportMemoryUsage(VOID);
  806. BOOL
  807. MyOpenFile(
  808. LPSTR DirName,
  809. LPSTR FileName,
  810. LPSTR Access,
  811. FILE **Stream,
  812. BOOL fBufferedIO);
  813. BOOL
  814. OpenFilePush(
  815. LPSTR pszdir,
  816. LPSTR pszfile,
  817. LPSTR pszCommentToEOL,
  818. FILE **ppf
  819. );
  820. BOOL
  821. SetupReadFile(LPSTR pszdir, LPSTR pszfile, LPSTR pszCommentToEOL,
  822. FILE **ppf);
  823. ULONG
  824. CloseReadFile(UINT *pcline);
  825. LPSTR
  826. ReadLine(FILE *pf);
  827. UINT
  828. ProbeFile(
  829. LPSTR DirName,
  830. LPSTR FileName);
  831. BOOL
  832. EnsureDirectoriesExist(
  833. LPSTR DirName);
  834. ULONG
  835. DateTimeFile(
  836. LPSTR DirName,
  837. LPSTR FileName);
  838. ULONG
  839. DateTimeFile2(
  840. LPSTR DirName,
  841. LPSTR FileName);
  842. ULONG (*pDateTimeFile)(LPSTR, LPSTR);
  843. BOOL (WINAPI * pGetFileAttributesExA)(LPCSTR, GET_FILEEX_INFO_LEVELS, LPVOID);
  844. BOOL
  845. DeleteSingleFile(
  846. LPSTR DirName,
  847. LPSTR FileName,
  848. BOOL QuietFlag);
  849. BOOL
  850. DeleteMultipleFiles(
  851. LPSTR DirName,
  852. LPSTR FilePattern);
  853. BOOL
  854. CloseOrDeleteFile(
  855. FILE **Stream,
  856. LPSTR DirName,
  857. LPSTR FileName,
  858. ULONG SizeThreshold);
  859. LPSTR
  860. PushCurrentDirectory(LPSTR NewCurrentDirectory);
  861. VOID
  862. PopCurrentDirectory(LPSTR OldCurrentDirectory);
  863. UINT
  864. ExecuteProgram(
  865. LPSTR ProgramName,
  866. LPSTR CommandLine,
  867. LPSTR MoreCommandLine,
  868. BOOL MustBeSynchronous,
  869. LPCSTR XMLDir,
  870. LPCSTR XMLAction);
  871. VOID
  872. WaitForParallelThreads(PDIRREC Dir);
  873. VOID
  874. CheckAllConsumer(BOOL);
  875. BOOL
  876. CanonicalizePathName(
  877. LPSTR SourcePath,
  878. UINT Action,
  879. LPSTR FullPath);
  880. #define CANONICALIZE_ONLY 0
  881. #define CANONICALIZE_FILE 1
  882. #define CANONICALIZE_DIR 2
  883. LPSTR
  884. FormatPathName(
  885. LPSTR DirName,
  886. LPSTR FileName);
  887. #if DBG
  888. VOID
  889. AssertPathString(LPSTR pszPath);
  890. #else
  891. #define AssertPathString(p)
  892. #endif
  893. LPSTR
  894. AppendString(
  895. LPSTR Destination,
  896. LPSTR Source,
  897. BOOL PrefixWithSpace);
  898. LPSTR CopyString(LPSTR Destination, LPSTR Source, BOOL fPath);
  899. VOID MakeString(LPSTR *Destination, LPSTR Source, BOOL fPath, MemType mt);
  900. VOID MakeExpandedString(LPSTR *Destination, LPSTR Source);
  901. VOID FreeString(LPSTR *Source, MemType mt);
  902. LPSTR FormatNumber(ULONG Number);
  903. LPSTR FormatTime(ULONG Seconds);
  904. BOOL AToX(LPSTR *pp, ULONG *pul);
  905. BOOL AToD(LPSTR *pp, ULONG *pul);
  906. EXTERN_C VOID __cdecl LogMsg(const char *pszfmt, ...);
  907. EXTERN_C VOID __cdecl BuildMsg(const char *pszfmt, ...);
  908. EXTERN_C VOID __cdecl BuildMsgRaw(const char *pszfmt, ...);
  909. EXTERN_C VOID __cdecl BuildError(const char *pszfmt, ...);
  910. EXTERN_C VOID __cdecl BuildErrorRaw(const char *pszfmt, ...);
  911. EXTERN_C VOID __cdecl BuildColorMsg(WORD, const char *pszfmt, ...);
  912. EXTERN_C VOID __cdecl BuildColorMsgRaw(WORD, const char *pszfmt, ...);
  913. EXTERN_C VOID __cdecl BuildColorError(WORD, const char *pszfmt, ...);
  914. EXTERN_C VOID __cdecl BuildColorErrorRaw(WORD, const char *pszfmt, ...);
  915. VOID*
  916. memfind(VOID* pvWhere, DWORD cbWhere, VOID* pvWhat, DWORD cbWhat);
  917. //
  918. // XML logging
  919. //
  920. UINT NumberPasses;
  921. DWORD XMLStartTicks;
  922. #define XML_THREAD_BUFFER_SIZE (2*1024*1024)
  923. #define XML_LOCAL_BUFFER_SIZE 4096
  924. #define XML_SCHEMA "buildschema.xml"
  925. // general purpose buffer
  926. // initially used to hold the command line
  927. char szXMLBuffer[XML_LOCAL_BUFFER_SIZE];
  928. typedef struct _XMLTHREADSTATE {
  929. BYTE XMLBuffer[XML_THREAD_BUFFER_SIZE];
  930. SIZE_T iXMLBufferPos;
  931. SIZE_T iXMLBufferLen;
  932. SIZE_T iXMLFileStart;
  933. BOOL fXMLInAction; // indicates if the thread has opened action tag
  934. } XMLTHREADSTATE, *PXMLTHREADSTATE;
  935. PXMLTHREADSTATE* PXMLThreadStates;
  936. PXMLTHREADSTATE PXMLGlobalState;
  937. BOOL fXMLInitialized;
  938. // Initializes the XML structures
  939. BOOL
  940. XMLInit(VOID);
  941. // Frees the allocated memory
  942. VOID
  943. XMLUnInit(VOID);
  944. // Prepares XML buffer fot the thread
  945. VOID
  946. XMLThreadInitBuffer(PTHREADSTATE ThreadState);
  947. // writes into the thread's block and then all other threads' blocks
  948. VOID _cdecl
  949. XMLThreadWrite(PTHREADSTATE ThreadState, LPCSTR pszFmt, ...);
  950. // opens tag in the thread's block
  951. VOID _cdecl
  952. XMLThreadOpenTag(PTHREADSTATE ThreadState, LPCSTR pszTag, LPCSTR pszFmt, ...);
  953. // closes the last open tag; the argument is for verification only
  954. VOID
  955. XMLThreadCloseTag(PTHREADSTATE ThreadState, LPCSTR pszTag);
  956. // writes out completely the thread's block and releases it
  957. VOID
  958. XMLThreadReleaseBuffer(PTHREADSTATE ThreadState);
  959. // writes into the global block. It is restricted to not have any threads open
  960. VOID _cdecl
  961. XMLGlobalWrite(LPCSTR pszFmt, ...);
  962. // opens tag in the global block
  963. VOID _cdecl
  964. XMLGlobalOpenTag(LPCSTR pszTag, LPCSTR pszFmt, ...);
  965. // closes the last open tag
  966. VOID
  967. XMLGlobalCloseTag();
  968. VOID
  969. XMLUpdateEndTag(BOOL fCompleted);
  970. LPSTR
  971. XMLEncodeBuiltInEntities(LPSTR pszString, DWORD cbStringSize);
  972. LPSTR
  973. XMLEncodeBuiltInEntitiesCopy(LPSTR pszString, LPSTR pszTarget);
  974. BOOL
  975. XMLScanBackTag(LPSTR pszEnd, LPSTR pszSentinel, LPSTR* ppszStart);
  976. LPSTR
  977. XMLBuildMetricsString(PBUILDMETRICS Metrics);
  978. // XML fragment
  979. VOID _cdecl
  980. XMLWriteFragmentFile(LPCSTR pszBaseFileName, LPCSTR pszFmt, ...);
  981. VOID _cdecl
  982. XMLWriteDirFragmentFile(LPCSTR pszRelPath, PVOID pvBlock, SIZE_T cbCount);
  983. VOID
  984. AddBuildMetrics(PBUILDMETRICS TargetMetrics, PBUILDMETRICS SourceMetrics);
  985. VOID
  986. XMLEnterCriticalSection();
  987. VOID
  988. XMLLeaveCriticalSection();
  989. //
  990. // Functions in buildsrc.c
  991. //
  992. extern DWORD StartTime;
  993. VOID
  994. StartElapsedTime(VOID);
  995. VOID
  996. PrintElapsedTime(VOID);
  997. LPSTR
  998. FormatElapsedTime(DWORD dwStartTime);
  999. LPSTR
  1000. FormatCurrentDateTime();
  1001. BOOL
  1002. ReadDirsFile(DIRREC *DirDB);
  1003. VOID
  1004. ProcessLinkTargets(PDIRREC DirDB, LPSTR CurrentDirectory);
  1005. BOOL
  1006. SplitToken(LPSTR pbuf, char chsep, LPSTR *ppstr);
  1007. BOOL
  1008. MakeMacroString(LPSTR *pp, LPSTR p);
  1009. VOID
  1010. SaveMacro(LPSTR pszName, LPSTR pszValue);
  1011. VOID
  1012. FormatLinkTarget(
  1013. LPSTR path,
  1014. LPSTR *ObjectDirectory,
  1015. LPSTR TargetPath,
  1016. LPSTR TargetName,
  1017. LPSTR TargetExt);
  1018. BOOL
  1019. ReadSourcesFile(DIRREC *DirDB, DIRSUP *pds, ULONG *pDateTimeSources);
  1020. VOID
  1021. PostProcessSources(DIRREC *pdr, DIRSUP *pds);
  1022. VOID
  1023. PrintDirSupData(DIRSUP *pds);
  1024. //+---------------------------------------------------------------------------
  1025. //
  1026. // Function: IsFullPath
  1027. //
  1028. //----------------------------------------------------------------------------
  1029. __inline BOOL
  1030. IsFullPath(char *pszfile)
  1031. {
  1032. return(pszfile[0] == '\\' || (isalpha(pszfile[0]) && pszfile[1] == ':'));
  1033. }
  1034. //
  1035. // List macros stolen from ntrtl.h
  1036. //
  1037. VOID
  1038. FORCEINLINE
  1039. InitializeListHead(
  1040. IN PLIST_ENTRY ListHead
  1041. )
  1042. {
  1043. ListHead->Flink = ListHead->Blink = ListHead;
  1044. }
  1045. //
  1046. // BOOLEAN
  1047. // IsListEmpty(
  1048. // PLIST_ENTRY ListHead
  1049. // );
  1050. //
  1051. #define IsListEmpty(ListHead) \
  1052. ((ListHead)->Flink == (ListHead))
  1053. VOID
  1054. FORCEINLINE
  1055. RemoveEntryList(
  1056. IN PLIST_ENTRY Entry
  1057. )
  1058. {
  1059. PLIST_ENTRY Blink;
  1060. PLIST_ENTRY Flink;
  1061. Flink = Entry->Flink;
  1062. Blink = Entry->Blink;
  1063. Blink->Flink = Flink;
  1064. Flink->Blink = Blink;
  1065. }
  1066. PLIST_ENTRY
  1067. FORCEINLINE
  1068. RemoveHeadList(
  1069. IN PLIST_ENTRY ListHead
  1070. )
  1071. {
  1072. PLIST_ENTRY Flink;
  1073. PLIST_ENTRY Entry;
  1074. Entry = ListHead->Flink;
  1075. Flink = Entry->Flink;
  1076. ListHead->Flink = Flink;
  1077. Flink->Blink = ListHead;
  1078. return Entry;
  1079. }
  1080. PLIST_ENTRY
  1081. FORCEINLINE
  1082. RemoveTailList(
  1083. IN PLIST_ENTRY ListHead
  1084. )
  1085. {
  1086. PLIST_ENTRY Blink;
  1087. PLIST_ENTRY Entry;
  1088. Entry = ListHead->Blink;
  1089. Blink = Entry->Blink;
  1090. ListHead->Blink = Blink;
  1091. Blink->Flink = ListHead;
  1092. return Entry;
  1093. }
  1094. VOID
  1095. FORCEINLINE
  1096. InsertTailList(
  1097. IN PLIST_ENTRY ListHead,
  1098. IN PLIST_ENTRY Entry
  1099. )
  1100. {
  1101. PLIST_ENTRY Blink;
  1102. Blink = ListHead->Blink;
  1103. Entry->Flink = ListHead;
  1104. Entry->Blink = Blink;
  1105. Blink->Flink = Entry;
  1106. ListHead->Blink = Entry;
  1107. }
  1108. VOID
  1109. FORCEINLINE
  1110. InsertHeadList(
  1111. IN PLIST_ENTRY ListHead,
  1112. IN PLIST_ENTRY Entry
  1113. )
  1114. {
  1115. PLIST_ENTRY Flink;
  1116. Flink = ListHead->Flink;
  1117. Entry->Flink = Flink;
  1118. Entry->Blink = ListHead;
  1119. Flink->Blink = Entry;
  1120. ListHead->Flink = Entry;
  1121. }