diff options
author | 2020-01-13 15:24:31 +0000 | |
---|---|---|
committer | 2020-01-13 15:24:31 +0000 | |
commit | bee8c711c19acfa1f224eb7d27c382e871b11f4d (patch) | |
tree | dcdc08ec20937d7b51f3e05d22ede9d36dbbbb58 | |
parent | make things more complex so that they can become simpler: (diff) | |
download | wireguard-openbsd-bee8c711c19acfa1f224eb7d27c382e871b11f4d.tar.xz wireguard-openbsd-bee8c711c19acfa1f224eb7d27c382e871b11f4d.zip |
unify compat mode and parallelmode a bit: there's no longer a need for
handle_one_job, always go thru Job_Make now.
-rw-r--r-- | usr.bin/make/compat.c | 8 | ||||
-rw-r--r-- | usr.bin/make/engine.c | 22 | ||||
-rw-r--r-- | usr.bin/make/job.c | 60 | ||||
-rw-r--r-- | usr.bin/make/job.h | 6 | ||||
-rw-r--r-- | usr.bin/make/make.c | 10 |
5 files changed, 24 insertions, 82 deletions
diff --git a/usr.bin/make/compat.c b/usr.bin/make/compat.c index e96d0f1fafa..8a42d5ed5ad 100644 --- a/usr.bin/make/compat.c +++ b/usr.bin/make/compat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: compat.c,v 1.89 2020/01/08 14:09:29 espie Exp $ */ +/* $OpenBSD: compat.c,v 1.90 2020/01/13 15:24:31 espie Exp $ */ /* $NetBSD: compat.c,v 1.14 1996/11/06 17:59:01 christos Exp $ */ /* @@ -193,14 +193,12 @@ CompatMake(void *gnp, /* The node to make */ /* copy over what we just did */ gn->built_status = sib->built_status; - if (gn->built_status != ERROR) { - /* If the node was built successfully, mark it so, + if (gn->built_status == REBUILT) { + /* If the node was built successfully, * update its modification time and timestamp all * its parents. * This is to keep its state from affecting that of * its parent. */ - gn->built_status = REBUILT; - sib->built_status = REBUILT; /* This is what Make does and it's actually a good * thing, as it allows rules like * diff --git a/usr.bin/make/engine.c b/usr.bin/make/engine.c index c73a3998b3d..778f165248a 100644 --- a/usr.bin/make/engine.c +++ b/usr.bin/make/engine.c @@ -1,4 +1,4 @@ -/* $OpenBSD: engine.c,v 1.66 2020/01/13 15:15:17 espie Exp $ */ +/* $OpenBSD: engine.c,v 1.67 2020/01/13 15:24:31 espie Exp $ */ /* * Copyright (c) 2012 Marc Espie. * @@ -703,24 +703,8 @@ run_gnode(GNode *gn) if (!gn || (gn->type & OP_DUMMY)) return NOSUCHNODE; - assert(availableJobs != NULL); - j = availableJobs; - availableJobs = availableJobs->next; - job_attach_node(j, gn); - while (j->exit_type == JOB_EXIT_OKAY) { - bool finished = job_run_next(j); - if (finished) - break; - handle_one_job(j); - } - - if (j->flags & JOB_KEEPERROR) { - j->next = errorJobs; - errorJobs = j; - } else { - j->next = availableJobs; - availableJobs = j; - } + Job_Make(gn); + loop_handle_running_jobs(); return gn->built_status; } diff --git a/usr.bin/make/job.c b/usr.bin/make/job.c index 5e7d701288b..bb60fc1e994 100644 --- a/usr.bin/make/job.c +++ b/usr.bin/make/job.c @@ -1,4 +1,4 @@ -/* $OpenBSD: job.c,v 1.153 2020/01/13 15:19:04 espie Exp $ */ +/* $OpenBSD: job.c,v 1.154 2020/01/13 15:24:31 espie Exp $ */ /* $NetBSD: job.c,v 1.16 1996/11/06 17:59:08 christos Exp $ */ /* @@ -143,14 +143,12 @@ static sigset_t sigset, emptyset; static void handle_fatal_signal(int); static void handle_siginfo(void); static void postprocess_job(Job *); -static Job *prepare_job(GNode *); static void determine_job_next_step(Job *); static void may_continue_job(Job *); static Job *reap_finished_job(pid_t); static bool reap_jobs(void); static void may_continue_heldback_jobs(); -static void loop_handle_running_jobs(void); static bool expensive_job(Job *); static bool expensive_command(const char *); static void setup_signal(int); @@ -654,33 +652,6 @@ expensive_command(const char *s) return false; } -static Job * -prepare_job(GNode *gn) -{ - /* a new job is prepared unless its commands are bogus (we don't - * have anything for it), or if we're in touch mode. - * - * Note that even in noexec mode, some commands may still run - * thanks to the +cmd construct. - */ - if (node_find_valid_commands(gn)) { - if (touchFlag) { - Job_Touch(gn); - return NULL; - } else { - Job *job = availableJobs; - - assert(job != NULL); - availableJobs = availableJobs->next; - job_attach_node(job, gn); - return job; - } - } else { - node_failure(gn); - return NULL; - } -} - static void may_continue_job(Job *job) { @@ -713,18 +684,17 @@ may_continue_job(Job *job) void Job_Make(GNode *gn) { - Job *job; + Job *job = availableJobs; - job = prepare_job(gn); - if (!job) - return; + assert(job != NULL); + availableJobs = availableJobs->next; + job_attach_node(job, gn); may_continue_job(job); } static void determine_job_next_step(Job *job) { - bool okay; if (job->flags & JOB_IS_EXPENSIVE) { no_new_jobs = false; if (DEBUG(EXPENSIVE)) @@ -846,26 +816,6 @@ handle_running_jobs(void) } void -handle_one_job(Job *job) -{ - int stat; - int status; - sigset_t old; - - sigprocmask(SIG_BLOCK, &sigset, &old); - while (1) { - handle_all_signals(); - stat = waitpid(job->pid, &status, WNOHANG); - if (stat == job->pid) - break; - sigsuspend(&emptyset); - } - runningJobs = NULL; - handle_job_status(job, status); - sigprocmask(SIG_SETMASK, &old, NULL); -} - -static void loop_handle_running_jobs() { while (runningJobs != NULL) diff --git a/usr.bin/make/job.h b/usr.bin/make/job.h index 535dd34248b..2040fc2eb5d 100644 --- a/usr.bin/make/job.h +++ b/usr.bin/make/job.h @@ -1,7 +1,7 @@ #ifndef _JOB_H_ #define _JOB_H_ -/* $OpenBSD: job.h,v 1.33 2020/01/13 15:19:04 espie Exp $ */ +/* $OpenBSD: job.h,v 1.34 2020/01/13 15:24:31 espie Exp $ */ /* $NetBSD: job.h,v 1.5 1996/11/06 17:59:10 christos Exp $ */ /* @@ -84,6 +84,10 @@ extern void print_errors(void); * or a signal coming in. */ extern void handle_running_jobs(void); +/* loop_handle_running_jobs(); + * handle running jobs until they're finished. + */ +extern void loop_handle_running_jobs(void); /* handle_all_signals(); * if a signal was received, react accordingly. diff --git a/usr.bin/make/make.c b/usr.bin/make/make.c index b47520be739..adec6cb38f4 100644 --- a/usr.bin/make/make.c +++ b/usr.bin/make/make.c @@ -1,4 +1,4 @@ -/* $OpenBSD: make.c,v 1.79 2020/01/13 15:15:17 espie Exp $ */ +/* $OpenBSD: make.c,v 1.80 2020/01/13 15:24:31 espie Exp $ */ /* $NetBSD: make.c,v 1.10 1996/11/06 17:59:15 christos Exp $ */ /* @@ -377,7 +377,13 @@ try_to_make_node(GNode *gn) return true; /* SIB: this is where commands should get prepared */ Make_DoAllVar(gn); - Job_Make(gn); + if (node_find_valid_commands(gn)) { + if (touchFlag) + Job_Touch(gn); + else + Job_Make(gn); + } else + node_failure(gn); } else { if (DEBUG(MAKE)) printf("up-to-date\n"); |