Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make make(1): convert JobState and JobFlags to enum ...



details:   https://anonhg.NetBSD.org/src/rev/1025425df949
branches:  trunk
changeset: 941502:1025425df949
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Oct 23 07:14:32 2020 +0000

description:
make(1): convert JobState and JobFlags to enum types

Both GCC and Clang complained when JobFindPid had its parameter "status"
as an int.  Strangely both compilers complained about a comparison
between unsigned and signed int, even though enums are defined to be
int, not unsigned.

diffstat:

 usr.bin/make/job.c |   6 +++---
 usr.bin/make/job.h |  38 ++++++++++++++++++++++++--------------
 2 files changed, 27 insertions(+), 17 deletions(-)

diffs (89 lines):

diff -r ea8790ad40ab -r 1025425df949 usr.bin/make/job.c
--- a/usr.bin/make/job.c        Fri Oct 23 06:57:41 2020 +0000
+++ b/usr.bin/make/job.c        Fri Oct 23 07:14:32 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: job.c,v 1.270 2020/10/23 05:27:33 rillig Exp $ */
+/*     $NetBSD: job.c,v 1.271 2020/10/23 07:14:32 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -143,7 +143,7 @@
 #include "trace.h"
 
 /*     "@(#)job.c      8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: job.c,v 1.270 2020/10/23 05:27:33 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.271 2020/10/23 07:14:32 rillig Exp $");
 
 # define STATIC static
 
@@ -592,7 +592,7 @@
 }
 
 static Job *
-JobFindPid(int pid, int status, Boolean isJobs)
+JobFindPid(int pid, JobState status, Boolean isJobs)
 {
     Job *job;
 
diff -r ea8790ad40ab -r 1025425df949 usr.bin/make/job.h
--- a/usr.bin/make/job.h        Fri Oct 23 06:57:41 2020 +0000
+++ b/usr.bin/make/job.h        Fri Oct 23 07:14:32 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: job.h,v 1.56 2020/10/19 23:07:22 rillig Exp $  */
+/*     $NetBSD: job.h,v 1.57 2020/10/23 07:14:32 rillig Exp $  */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -117,6 +117,27 @@
 # include "meta.h"
 #endif
 
+typedef enum JobState {
+    JOB_ST_FREE =      0,      /* Job is available */
+    JOB_ST_SETUP =     1,      /* Job is allocated but otherwise invalid */
+    JOB_ST_RUNNING =   3,      /* Job is running, pid valid */
+    JOB_ST_FINISHED =  4       /* Job is done (ie after SIGCHILD) */
+} JobState;
+
+typedef enum JobFlags {
+    /* Ignore non-zero exits */
+    JOB_IGNERR =       0x001,
+    /* no output */
+    JOB_SILENT =       0x002,
+    /* Target is a special one. i.e. run it locally
+     * if we can't export it and maxLocal is 0 */
+    JOB_SPECIAL =      0x004,
+    /* Ignore "..." lines when processing commands */
+    JOB_IGNDOTS        =       0x008,
+    /* we've sent 'set -x' */
+    JOB_TRACED =       0x400
+} JobFlags;
+
 /* A Job manages the shell commands that are run to create a single target.
  * Each job is run in a separate subprocess by a shell.  Several jobs can run
  * in parallel.
@@ -146,22 +167,11 @@
 
     int exit_status;           /* from wait4() in signal handler */
 
-    char job_state;            /* status of the job entry */
-#define JOB_ST_FREE    0       /* Job is available */
-#define JOB_ST_SETUP   1       /* Job is allocated but otherwise invalid */
-#define JOB_ST_RUNNING 3       /* Job is running, pid valid */
-#define JOB_ST_FINISHED        4       /* Job is done (ie after SIGCHILD) */
+    JobState job_state;                /* status of the job entry */
 
     char job_suspended;
 
-    int flags;                 /* Flags to control treatment of job */
-#define        JOB_IGNERR      0x001   /* Ignore non-zero exits */
-#define        JOB_SILENT      0x002   /* no output */
-#define JOB_SPECIAL    0x004   /* Target is a special one. i.e. run it locally
-                                * if we can't export it and maxLocal is 0 */
-#define JOB_IGNDOTS    0x008   /* Ignore "..." lines when processing
-                                * commands */
-#define JOB_TRACED     0x400   /* we've sent 'set -x' */
+    JobFlags flags;            /* Flags to control treatment of job */
 
     int inPipe;                        /* Pipe for reading output from job */
     int outPipe;               /* Pipe for writing control commands */



Home | Main Index | Thread Index | Old Index