Thu Aug 27 06:18:23 2020 UTC ()
make(1): remove unused declarations from job.h


(rillig)
diff -r1.45 -r1.46 src/usr.bin/make/job.h

cvs diff -r1.45 -r1.46 src/usr.bin/make/job.h (switch to unified diff)

--- src/usr.bin/make/job.h 2020/08/22 08:01:34 1.45
+++ src/usr.bin/make/job.h 2020/08/27 06:18:22 1.46
@@ -1,272 +1,269 @@ @@ -1,272 +1,269 @@
1/* $NetBSD: job.h,v 1.45 2020/08/22 08:01:34 rillig Exp $ */ 1/* $NetBSD: job.h,v 1.46 2020/08/27 06:18:22 rillig Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. 4 * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * Adam de Boor. 8 * Adam de Boor.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the 16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution. 17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of the University nor the names of its contributors 18 * 3. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software 19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission. 20 * without specific prior written permission.
21 * 21 *
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE. 32 * SUCH DAMAGE.
33 * 33 *
34 * from: @(#)job.h 8.1 (Berkeley) 6/6/93 34 * from: @(#)job.h 8.1 (Berkeley) 6/6/93
35 */ 35 */
36 36
37/* 37/*
38 * Copyright (c) 1988, 1989 by Adam de Boor 38 * Copyright (c) 1988, 1989 by Adam de Boor
39 * Copyright (c) 1989 by Berkeley Softworks 39 * Copyright (c) 1989 by Berkeley Softworks
40 * All rights reserved. 40 * All rights reserved.
41 * 41 *
42 * This code is derived from software contributed to Berkeley by 42 * This code is derived from software contributed to Berkeley by
43 * Adam de Boor. 43 * Adam de Boor.
44 * 44 *
45 * Redistribution and use in source and binary forms, with or without 45 * Redistribution and use in source and binary forms, with or without
46 * modification, are permitted provided that the following conditions 46 * modification, are permitted provided that the following conditions
47 * are met: 47 * are met:
48 * 1. Redistributions of source code must retain the above copyright 48 * 1. Redistributions of source code must retain the above copyright
49 * notice, this list of conditions and the following disclaimer. 49 * notice, this list of conditions and the following disclaimer.
50 * 2. Redistributions in binary form must reproduce the above copyright 50 * 2. Redistributions in binary form must reproduce the above copyright
51 * notice, this list of conditions and the following disclaimer in the 51 * notice, this list of conditions and the following disclaimer in the
52 * documentation and/or other materials provided with the distribution. 52 * documentation and/or other materials provided with the distribution.
53 * 3. All advertising materials mentioning features or use of this software 53 * 3. All advertising materials mentioning features or use of this software
54 * must display the following acknowledgement: 54 * must display the following acknowledgement:
55 * This product includes software developed by the University of 55 * This product includes software developed by the University of
56 * California, Berkeley and its contributors. 56 * California, Berkeley and its contributors.
57 * 4. Neither the name of the University nor the names of its contributors 57 * 4. Neither the name of the University nor the names of its contributors
58 * may be used to endorse or promote products derived from this software 58 * may be used to endorse or promote products derived from this software
59 * without specific prior written permission. 59 * without specific prior written permission.
60 * 60 *
61 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 61 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
62 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 62 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
63 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 63 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
64 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 64 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
65 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 65 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
66 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 66 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
67 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 67 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
68 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 68 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
69 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 69 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
70 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 70 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
71 * SUCH DAMAGE. 71 * SUCH DAMAGE.
72 * 72 *
73 * from: @(#)job.h 8.1 (Berkeley) 6/6/93 73 * from: @(#)job.h 8.1 (Berkeley) 6/6/93
74 */ 74 */
75 75
76/*- 76/*-
77 * job.h -- 77 * job.h --
78 * Definitions pertaining to the running of jobs in parallel mode. 78 * Definitions pertaining to the running of jobs in parallel mode.
79 */ 79 */
80#ifndef MAKE_JOB_H 80#ifndef MAKE_JOB_H
81#define MAKE_JOB_H 81#define MAKE_JOB_H
82 82
83#define TMPPAT "makeXXXXXX" /* relative to tmpdir */ 83#define TMPPAT "makeXXXXXX" /* relative to tmpdir */
84 84
85#ifdef USE_SELECT 85#ifdef USE_SELECT
86/* 86/*
87 * Emulate poll() in terms of select(). This is not a complete 87 * Emulate poll() in terms of select(). This is not a complete
88 * emulation but it is sufficient for make's purposes. 88 * emulation but it is sufficient for make's purposes.
89 */ 89 */
90 90
91#define poll emul_poll 91#define poll emul_poll
92#define pollfd emul_pollfd 92#define pollfd emul_pollfd
93 93
94struct emul_pollfd { 94struct emul_pollfd {
95 int fd; 95 int fd;
96 short events; 96 short events;
97 short revents; 97 short revents;
98}; 98};
99 99
100#define POLLIN 0x0001 100#define POLLIN 0x0001
101#define POLLOUT 0x0004 101#define POLLOUT 0x0004
102 102
103int 103int
104emul_poll(struct pollfd *fd, int nfd, int timeout); 104emul_poll(struct pollfd *fd, int nfd, int timeout);
105#endif 105#endif
106 106
107/* 107/*
108 * The POLL_MSEC constant determines the maximum number of milliseconds spent 108 * The POLL_MSEC constant determines the maximum number of milliseconds spent
109 * in poll before coming out to see if a child has finished. 109 * in poll before coming out to see if a child has finished.
110 */ 110 */
111#define POLL_MSEC 5000 111#define POLL_MSEC 5000
112 112
113/*- 113/*-
114 * Job Table definitions. 114 * Job Table definitions.
115 * 115 *
116 * Each job has several things associated with it: 116 * Each job has several things associated with it:
117 * 1) The process id of the child shell 117 * 1) The process id of the child shell
118 * 2) The graph node describing the target being made by this job 118 * 2) The graph node describing the target being made by this job
119 * 3) A LstNode for the first command to be saved after the job 119 * 3) A LstNode for the first command to be saved after the job
120 * completes. This is NULL if there was no "..." in the job's 120 * completes. This is NULL if there was no "..." in the job's
121 * commands. 121 * commands.
122 * 4) An FILE* for writing out the commands. This is only 122 * 4) An FILE* for writing out the commands. This is only
123 * used before the job is actually started. 123 * used before the job is actually started.
124 * 5) The output is being caught via a pipe and 124 * 5) The output is being caught via a pipe and
125 * the descriptors of our pipe, an array in which output is line 125 * the descriptors of our pipe, an array in which output is line
126 * buffered and the current position in that buffer are all 126 * buffered and the current position in that buffer are all
127 * maintained for each job. 127 * maintained for each job.
128 * 6) A word of flags which determine how the module handles errors, 128 * 6) A word of flags which determine how the module handles errors,
129 * echoing, etc. for the job 129 * echoing, etc. for the job
130 * 130 *
131 * When a job is finished, the Make_Update function is called on each of the 131 * When a job is finished, the Make_Update function is called on each of the
132 * parents of the node which was just remade. This takes care of the upward 132 * parents of the node which was just remade. This takes care of the upward
133 * traversal of the dependency graph. 133 * traversal of the dependency graph.
134 */ 134 */
135struct pollfd; 135struct pollfd;
136 136
137 137
138#ifdef USE_META 138#ifdef USE_META
139# include "meta.h" 139# include "meta.h"
140#endif 140#endif
141 141
142#define JOB_BUFSIZE 1024 142#define JOB_BUFSIZE 1024
143typedef struct Job { 143typedef struct Job {
144 int pid; /* The child's process ID */ 144 int pid; /* The child's process ID */
145 GNode *node; /* The target the child is making */ 145 GNode *node; /* The target the child is making */
146 LstNode tailCmds; /* The node of the first command to be 146 LstNode tailCmds; /* The node of the first command to be
147 * saved when the job has been run */ 147 * saved when the job has been run */
148 FILE *cmdFILE; /* When creating the shell script, this is 148 FILE *cmdFILE; /* When creating the shell script, this is
149 * where the commands go */ 149 * where the commands go */
150 int exit_status; /* from wait4() in signal handler */ 150 int exit_status; /* from wait4() in signal handler */
151 char job_state; /* status of the job entry */ 151 char job_state; /* status of the job entry */
152#define JOB_ST_FREE 0 /* Job is available */ 152#define JOB_ST_FREE 0 /* Job is available */
153#define JOB_ST_SETUP 1 /* Job is allocated but otherwise invalid */ 153#define JOB_ST_SETUP 1 /* Job is allocated but otherwise invalid */
154#define JOB_ST_RUNNING 3 /* Job is running, pid valid */ 154#define JOB_ST_RUNNING 3 /* Job is running, pid valid */
155#define JOB_ST_FINISHED 4 /* Job is done (ie after SIGCHILD) */ 155#define JOB_ST_FINISHED 4 /* Job is done (ie after SIGCHILD) */
156 char job_suspended; 156 char job_suspended;
157 short flags; /* Flags to control treatment of job */ 157 short flags; /* Flags to control treatment of job */
158#define JOB_IGNERR 0x001 /* Ignore non-zero exits */ 158#define JOB_IGNERR 0x001 /* Ignore non-zero exits */
159#define JOB_SILENT 0x002 /* no output */ 159#define JOB_SILENT 0x002 /* no output */
160#define JOB_SPECIAL 0x004 /* Target is a special one. i.e. run it locally 160#define JOB_SPECIAL 0x004 /* Target is a special one. i.e. run it locally
161 * if we can't export it and maxLocal is 0 */ 161 * if we can't export it and maxLocal is 0 */
162#define JOB_IGNDOTS 0x008 /* Ignore "..." lines when processing 162#define JOB_IGNDOTS 0x008 /* Ignore "..." lines when processing
163 * commands */ 163 * commands */
164#define JOB_TRACED 0x400 /* we've sent 'set -x' */ 164#define JOB_TRACED 0x400 /* we've sent 'set -x' */
165 165
166 int jobPipe[2]; /* Pipe for readind output from job */ 166 int jobPipe[2]; /* Pipe for reading output from job */
167 struct pollfd *inPollfd; /* pollfd associated with inPipe */ 167 struct pollfd *inPollfd; /* pollfd associated with inPipe */
168 char outBuf[JOB_BUFSIZE + 1]; 168 char outBuf[JOB_BUFSIZE + 1];
169 /* Buffer for storing the output of the 169 /* Buffer for storing the output of the
170 * job, line by line */ 170 * job, line by line */
171 int curPos; /* Current position in op_outBuf */ 171 int curPos; /* Current position in op_outBuf */
172 172
173#ifdef USE_META 173#ifdef USE_META
174 struct BuildMon bm; 174 struct BuildMon bm;
175#endif 175#endif
176} Job; 176} Job;
177 177
178#define inPipe jobPipe[0] 178#define inPipe jobPipe[0]
179#define outPipe jobPipe[1] 179#define outPipe jobPipe[1]
180 180
181/*- 181/*-
182 * Shell Specifications: 182 * Shell Specifications:
183 * Each shell type has associated with it the following information: 183 * Each shell type has associated with it the following information:
184 * 1) The string which must match the last character of the shell name 184 * 1) The string which must match the last character of the shell name
185 * for the shell to be considered of this type. The longest match 185 * for the shell to be considered of this type. The longest match
186 * wins. 186 * wins.
187 * 2) A command to issue to turn off echoing of command lines 187 * 2) A command to issue to turn off echoing of command lines
188 * 3) A command to issue to turn echoing back on again 188 * 3) A command to issue to turn echoing back on again
189 * 4) What the shell prints, and its length, when given the echo-off 189 * 4) What the shell prints, and its length, when given the echo-off
190 * command. This line will not be printed when received from the shell 190 * command. This line will not be printed when received from the shell
191 * 5) A boolean to tell if the shell has the ability to control 191 * 5) A boolean to tell if the shell has the ability to control
192 * error checking for individual commands. 192 * error checking for individual commands.
193 * 6) The string to turn this checking on. 193 * 6) The string to turn this checking on.
194 * 7) The string to turn it off. 194 * 7) The string to turn it off.
195 * 8) The command-flag to give to cause the shell to start echoing 195 * 8) The command-flag to give to cause the shell to start echoing
196 * commands right away. 196 * commands right away.
197 * 9) The command-flag to cause the shell to Lib_Exit when an error is 197 * 9) The command-flag to cause the shell to Lib_Exit when an error is
198 * detected in one of the commands. 198 * detected in one of the commands.
199 * 199 *
200 * Some special stuff goes on if a shell doesn't have error control. In such 200 * Some special stuff goes on if a shell doesn't have error control. In such
201 * a case, errCheck becomes a printf template for echoing the command, 201 * a case, errCheck becomes a printf template for echoing the command,
202 * should echoing be on and ignErr becomes another printf template for 202 * should echoing be on and ignErr becomes another printf template for
203 * executing the command while ignoring the return status. Finally errOut 203 * executing the command while ignoring the return status. Finally errOut
204 * is a printf template for running the command and causing the shell to 204 * is a printf template for running the command and causing the shell to
205 * exit on error. If any of these strings are empty when hasErrCtl is FALSE, 205 * exit on error. If any of these strings are empty when hasErrCtl is FALSE,
206 * the command will be executed anyway as is and if it causes an error, so be 206 * the command will be executed anyway as is and if it causes an error, so be
207 * it. Any templates setup to echo the command will escape any '$ ` \ "'i 207 * it. Any templates setup to echo the command will escape any '$ ` \ "'i
208 * characters in the command string to avoid common problems with 208 * characters in the command string to avoid common problems with
209 * echo "%s\n" as a template. 209 * echo "%s\n" as a template.
210 */ 210 */
211typedef struct Shell { 211typedef struct Shell {
212 const char *name; /* the name of the shell. For Bourne and C 212 const char *name; /* the name of the shell. For Bourne and C
213 * shells, this is used only to find the 213 * shells, this is used only to find the
214 * shell description when used as the single 214 * shell description when used as the single
215 * source of a .SHELL target. For user-defined 215 * source of a .SHELL target. For user-defined
216 * shells, this is the full path of the shell. 216 * shells, this is the full path of the shell.
217 */ 217 */
218 Boolean hasEchoCtl; /* True if both echoOff and echoOn defined */ 218 Boolean hasEchoCtl; /* True if both echoOff and echoOn defined */
219 const char *echoOff; /* command to turn off echo */ 219 const char *echoOff; /* command to turn off echo */
220 const char *echoOn; /* command to turn it back on again */ 220 const char *echoOn; /* command to turn it back on again */
221 const char *noPrint; /* command to skip when printing output from 221 const char *noPrint; /* command to skip when printing output from
222 * shell. This is usually the command which 222 * shell. This is usually the command which
223 * was executed to turn off echoing */ 223 * was executed to turn off echoing */
224 int noPLen; /* length of noPrint command */ 224 int noPLen; /* length of noPrint command */
225 Boolean hasErrCtl; /* set if can control error checking for 225 Boolean hasErrCtl; /* set if can control error checking for
226 * individual commands */ 226 * individual commands */
227 const char *errCheck; /* string to turn error checking on */ 227 const char *errCheck; /* string to turn error checking on */
228 const char *ignErr; /* string to turn off error checking */ 228 const char *ignErr; /* string to turn off error checking */
229 const char *errOut; /* string to use for testing exit code */ 229 const char *errOut; /* string to use for testing exit code */
230 const char *newline; /* string literal that results in a newline 230 const char *newline; /* string literal that results in a newline
231 * character when it appears outside of any 231 * character when it appears outside of any
232 * 'quote' or "quote" characters */ 232 * 'quote' or "quote" characters */
233 char commentChar; /* character used by shell for comment lines */ 233 char commentChar; /* character used by shell for comment lines */
234 234
235 /* 235 /*
236 * command-line flags 236 * command-line flags
237 */ 237 */
238 const char *echo; /* echo commands */ 238 const char *echo; /* echo commands */
239 const char *exit; /* exit on error */ 239 const char *exit; /* exit on error */
240} Shell; 240} Shell;
241 241
242extern const char *shellPath; 242extern const char *shellPath;
243extern const char *shellName; 243extern const char *shellName;
244extern char *shellErrFlag; 244extern char *shellErrFlag;
245 245
246extern int jobTokensRunning; /* tokens currently "out" */ 246extern int jobTokensRunning; /* tokens currently "out" */
247extern int maxJobs; /* Max jobs we can run */ 247extern int maxJobs; /* Max jobs we can run */
248 248
249void Shell_Init(void); 249void Shell_Init(void);
250const char *Shell_GetNewline(void); 250const char *Shell_GetNewline(void);
251void Job_Touch(GNode *, Boolean); 251void Job_Touch(GNode *, Boolean);
252Boolean Job_CheckCommands(GNode *, void (*abortProc )(const char *, ...)); 252Boolean Job_CheckCommands(GNode *, void (*abortProc )(const char *, ...));
253#define CATCH_BLOCK 1 
254void Job_CatchChildren(void); 253void Job_CatchChildren(void);
255void Job_CatchOutput(void); 254void Job_CatchOutput(void);
256void Job_Make(GNode *); 255void Job_Make(GNode *);
257void Job_Init(void); 256void Job_Init(void);
258Boolean Job_Full(void); 
259Boolean Job_Empty(void); 257Boolean Job_Empty(void);
260ReturnStatus Job_ParseShell(char *); 258ReturnStatus Job_ParseShell(char *);
261int Job_Finish(void); 259int Job_Finish(void);
262void Job_End(void); 260void Job_End(void);
263void Job_Wait(void); 261void Job_Wait(void);
264void Job_AbortAll(void); 262void Job_AbortAll(void);
265void JobFlagForMigration(int); 
266void Job_TokenReturn(void); 263void Job_TokenReturn(void);
267Boolean Job_TokenWithdraw(void); 264Boolean Job_TokenWithdraw(void);
268void Job_ServerStart(int, int, int); 265void Job_ServerStart(int, int, int);
269void Job_SetPrefix(void); 266void Job_SetPrefix(void);
270Boolean Job_RunTarget(const char *, const char *); 267Boolean Job_RunTarget(const char *, const char *);
271 268
272#endif /* MAKE_JOB_H */ 269#endif /* MAKE_JOB_H */