VirtualBox

source: kBuild/trunk/src/kmk/w32/winchildren.h@ 3633

Last change on this file since 3633 was 3313, checked in by bird, 5 years ago

kmk,kWorker: Assign processor groups to kWorker processes. Added --special-env hack for having a mspdbsrv.exe instance per processor group (using _MSPDBSRV_ENDPOINT_). This was complicated by PCH requiring to share .pdb file and therefore mspdbsrv.exe instance, requiring a mspdb100.dll re-init hack to disconnect kWorker from the previous mspdbsrv when switching. fun.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 4.7 KB
Line 
1/* $Id: winchildren.h 3313 2020-03-16 02:31:38Z bird $ */
2/** @file
3 * Child process creation and management for kmk.
4 */
5
6/*
7 * Copyright (c) 2018 knut st. osmundsen <[email protected]>
8 *
9 * This file is part of kBuild.
10 *
11 * kBuild is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * kBuild is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with kBuild. If not, see <http://www.gnu.org/licenses/>
23 *
24 */
25
26#ifndef INCLUDED_WINCHILDREN_H
27#define INCLUDED_WINCHILDREN_H
28
29/** Child processor group allocator state. */
30typedef struct MKWINCHILDCPUGROUPALLOCSTATE
31{
32 /** The group index for the worker allocator.
33 * This is ever increasing and must be modded by g_cProcessorGroups. */
34 unsigned int idxGroup;
35 /** The processor in group index for the worker allocator. */
36 unsigned int idxProcessorInGroup;
37} MKWINCHILDCPUGROUPALLOCSTATE;
38/** Pointer to a CPU group allocator state. */
39typedef MKWINCHILDCPUGROUPALLOCSTATE *PMKWINCHILDCPUGROUPALLOCSTATE;
40
41#ifdef DECLARE_HANDLE
42/**
43 * A childcare worker pipe.
44 */
45typedef struct WINCCWPIPE
46{
47 /** My end of the pipe. */
48 HANDLE hPipeMine;
49 /** The child end of the pipe. */
50 HANDLE hPipeChild;
51 /** The event for asynchronous reading. */
52 HANDLE hEvent;
53 /** Which pipe this is (1 == stdout, 2 == stderr). */
54 unsigned char iWhich;
55 /** Set if we've got a read pending already. */
56 BOOL fReadPending;
57 /** Indicator that we've written out something. This is cleared before
58 * we start catching output from a new child and use in the CL.exe
59 * supression heuristics. */
60 BOOL fHaveWrittenOut;
61 /** Number of bytes at the start of the buffer that we've already
62 * written out. We try write out whole lines. */
63 DWORD cbWritten;
64 /** The buffer offset of the read currently pending. */
65 DWORD offPendingRead;
66 /** Read buffer size. */
67 DWORD cbBuffer;
68 /** The read buffer allocation. */
69 unsigned char *pbBuffer;
70 /** Overlapped I/O structure. */
71 OVERLAPPED Overlapped;
72} WINCCWPIPE;
73#endif
74
75typedef struct WINCCWPIPE *PWINCCWPIPE;
76
77void MkWinChildInit(unsigned int cJobSlot);
78void MkWinChildReExecMake(char **papszArgs, char **papszEnv);
79intptr_t MkWinChildGetCompleteEventHandle(void);
80int MkWinChildCreate(char **papszArgs, char **papszEnv, const char *pszShell, struct child *pMkChild, pid_t *pPid);
81int MkWinChildCreateWithStdOutPipe(char **papszArgs, char **papszEnv, int fdErr, pid_t *pPid, int *pfdReadPipe);
82void MkWinChildInitCpuGroupAllocator(PMKWINCHILDCPUGROUPALLOCSTATE pState);
83unsigned int MkWinChildAllocateCpuGroup(PMKWINCHILDCPUGROUPALLOCSTATE pState);
84
85#ifdef KMK
86struct KMKBUILTINENTRY;
87int MkWinChildCreateBuiltIn(struct KMKBUILTINENTRY const *pBuiltIn, int cArgs, char **papszArgs,
88 char **papszEnv, struct child *pMkChild, pid_t *pPid);
89int MkWinChildCreateAppend(const char *pszFilename, char **ppszAppend, size_t cbAppend, int fTruncate,
90 struct child *pMkChild, pid_t *pPid);
91
92int MkWinChildCreateSubmit(intptr_t hEvent, void *pvSubmitWorker, PWINCCWPIPE pStdOut, PWINCCWPIPE pStdErr,
93 struct child *pMkChild, pid_t *pPid);
94PWINCCWPIPE MkWinChildcareCreateWorkerPipe(unsigned iWhich, unsigned int idxWorker);
95void MkWinChildcareWorkerDrainPipes(struct WINCHILD *pChild, PWINCCWPIPE pStdOut, PWINCCWPIPE pStdErr);
96void MkWinChildcareDeleteWorkerPipe(PWINCCWPIPE pPipe);
97
98int MkWinChildCreateRedirect(intptr_t hProcess, pid_t *pPid);
99# ifdef DECLARE_HANDLE
100int MkWinChildBuiltInExecChild(void *pvWorker, const char *pszExecutable, char **papszArgs, BOOL fQuotedArgv,
101 char **papszEnvVars, const char *pszCwd, BOOL pafReplace[3], HANDLE pahReplace[3]);
102# endif
103#endif /* KMK */
104int MkWinChildKill(pid_t pid, int iSignal, struct child *pMkChild);
105int MkWinChildWait(int fBlock, pid_t *pPid, int *piExitCode, int *piSignal, int *pfCoreDumped, struct child **ppMkChild);
106void MkWinChildExclusiveAcquire(void);
107void MkWinChildExclusiveRelease(void);
108
109#undef CLOSE_ON_EXEC
110#define CLOSE_ON_EXEC(a_fd) MkWinChildUnrelatedCloseOnExec(a_fd)
111int MkWinChildUnrelatedCloseOnExec(int fd);
112
113
114#endif
115
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette