Skip to content

Commit facf905

Browse files
committed
make: clean up job handling
1 parent 3d6a502 commit facf905

2 files changed

Lines changed: 10 additions & 41 deletions

File tree

usr.bin/make/job.c

Lines changed: 8 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: job.c,v 1.483 2024/07/22 18:15:04 rillig Exp $ */
1+
/* $NetBSD: job.c,v 1.484 2025/01/03 04:51:42 rillig Exp $ */
22

33
/*
44
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -141,7 +141,7 @@
141141
#include "trace.h"
142142

143143
/* "@(#)job.c 8.2 (Berkeley) 3/19/94" */
144-
MAKE_RCSID("$NetBSD: job.c,v 1.483 2024/07/22 18:15:04 rillig Exp $");
144+
MAKE_RCSID("$NetBSD: job.c,v 1.484 2025/01/03 04:51:42 rillig Exp $");
145145

146146
/*
147147
* A shell defines how the commands are run. All commands for a target are
@@ -257,12 +257,6 @@ static enum { /* Why is the make aborting? */
257257
/* Tracks the number of tokens currently "out" to build jobs. */
258258
int jobTokensRunning = 0;
259259

260-
typedef enum JobStartResult {
261-
JOB_RUNNING, /* Job is running */
262-
JOB_ERROR, /* Error in starting the job */
263-
JOB_FINISHED /* The job is already finished */
264-
} JobStartResult;
265-
266260
/*
267261
* Descriptions for various shells.
268262
*
@@ -1267,7 +1261,7 @@ TouchRegular(GNode *gn)
12671261
}
12681262

12691263
/*
1270-
* Touch the given target. Called by JobStart when the -t flag was given.
1264+
* Touch the given target. Called by Job_Make when the -t flag was given.
12711265
*
12721266
* The modification date of the file is changed.
12731267
* If the file did not exist, it is created.
@@ -1613,22 +1607,8 @@ JobWriteShellCommands(Job *job, GNode *gn, bool *out_run)
16131607
*out_run = JobWriteCommands(job);
16141608
}
16151609

1616-
/*
1617-
* Start a target-creation process going for the target described by gn.
1618-
*
1619-
* Results:
1620-
* JOB_ERROR if there was an error in the commands, JOB_FINISHED
1621-
* if there isn't actually anything left to do for the job and
1622-
* JOB_RUNNING if the job has been started.
1623-
*
1624-
* Details:
1625-
* A new Job node is created and added to the list of running
1626-
* jobs. PMake is forked and a child shell created.
1627-
*
1628-
* NB: The return value is ignored by everyone.
1629-
*/
1630-
static JobStartResult
1631-
JobStart(GNode *gn, bool special)
1610+
void
1611+
Job_Make(GNode *gn)
16321612
{
16331613
Job *job; /* new job descriptor */
16341614
char *argv[10]; /* Argument vector to shell */
@@ -1640,14 +1620,14 @@ JobStart(GNode *gn, bool special)
16401620
break;
16411621
}
16421622
if (job >= job_table_end)
1643-
Punt("JobStart no job slots vacant");
1623+
Punt("Job_Make no job slots vacant");
16441624

16451625
memset(job, 0, sizeof *job);
16461626
job->node = gn;
16471627
job->tailCmds = NULL;
16481628
job->status = JOB_ST_SET_UP;
16491629

1650-
job->special = special || gn->type & OP_SPECIAL;
1630+
job->special = (gn->type & OP_SPECIAL) != OP_NONE;
16511631
job->ignerr = opts.ignoreErrors || gn->type & OP_IGNORE;
16521632
job->echo = !(opts.silent || gn->type & OP_SILENT);
16531633

@@ -1732,7 +1712,7 @@ JobStart(GNode *gn, bool special)
17321712
Make_Update(job->node);
17331713
}
17341714
job->status = JOB_ST_FREE;
1735-
return cmdsOK ? JOB_FINISHED : JOB_ERROR;
1715+
return;
17361716
}
17371717

17381718
/*
@@ -1745,7 +1725,6 @@ JobStart(GNode *gn, bool special)
17451725
JobCreatePipe(job, 3);
17461726

17471727
JobExec(job, argv);
1748-
return JOB_RUNNING;
17491728
}
17501729

17511730
/*
@@ -2104,16 +2083,6 @@ Job_CatchOutput(void)
21042083
}
21052084
}
21062085

2107-
/*
2108-
* Start the creation of a target. Basically a front-end for JobStart used by
2109-
* the Make module.
2110-
*/
2111-
void
2112-
Job_Make(GNode *gn)
2113-
{
2114-
(void)JobStart(gn, false);
2115-
}
2116-
21172086
static void
21182087
InitShellNameAndPath(void)
21192088
{

usr.bin/make/job.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: job.h,v 1.80 2024/07/07 07:50:57 rillig Exp $ */
1+
/* $NetBSD: job.h,v 1.81 2025/01/03 04:51:42 rillig Exp $ */
22

33
/*
44
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -119,7 +119,7 @@ typedef enum JobStatus {
119119
JOB_ST_SET_UP = 1, /* Job is allocated but otherwise invalid */
120120
/* XXX: What about the 2? */
121121
JOB_ST_RUNNING = 3, /* Job is running, pid valid */
122-
JOB_ST_FINISHED = 4 /* Job is done (ie after SIGCHILD) */
122+
JOB_ST_FINISHED = 4 /* Job is done (ie after SIGCHLD) */
123123
} JobStatus;
124124

125125
/*

0 commit comments

Comments
 (0)