mirror of
https://github.com/sheumann/hush.git
synced 2024-09-12 00:55:11 +00:00
ash: small size optimization
function old new delta makejob 263 270 +7 setjobctl 328 332 +4 jobscmd 96 94 -2 stoppedjobs 53 50 -3 jobctl 4 1 -3 job_warning 4 1 -3 forkshell 644 641 -3 cmdloop 422 409 -13 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/6 up/down: 11/-27) Total: -16 bytes text data bss dec hex filename 675392 2740 13968 692100 a8f84 busybox_old 675380 2740 13968 692088 a8f78 busybox_unstripped
This commit is contained in:
parent
8fdc4b7b06
commit
fcfaf2e18a
70
shell/ash.c
70
shell/ash.c
@ -3141,20 +3141,18 @@ struct job {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static pid_t backgndpid; /* pid of last background process */
|
static pid_t backgndpid; /* pid of last background process */
|
||||||
static int job_warning; /* user was warned about stopped jobs */
|
static smallint job_warning; /* user was warned about stopped jobs (can be 2, 1 or 0). */
|
||||||
#if JOBS
|
|
||||||
static int jobctl; /* true if doing job control */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static struct job *makejob(union node *, int);
|
static struct job *makejob(union node *, int);
|
||||||
static int forkshell(struct job *, union node *, int);
|
static int forkshell(struct job *, union node *, int);
|
||||||
static int waitforjob(struct job *);
|
static int waitforjob(struct job *);
|
||||||
|
|
||||||
#if ! JOBS
|
#if !JOBS
|
||||||
#define setjobctl(on) /* do nothing */
|
enum { jobctl = 0 };
|
||||||
|
#define setjobctl(on) do {} while (0)
|
||||||
#else
|
#else
|
||||||
|
static smallint jobctl; /* true if doing job control */
|
||||||
static void setjobctl(int);
|
static void setjobctl(int);
|
||||||
static void showjobs(FILE *, int);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -3836,32 +3834,6 @@ showjob(FILE *out, struct job *jp, int mode)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
jobscmd(int argc, char **argv)
|
|
||||||
{
|
|
||||||
int mode, m;
|
|
||||||
FILE *out;
|
|
||||||
|
|
||||||
mode = 0;
|
|
||||||
while ((m = nextopt("lp"))) {
|
|
||||||
if (m == 'l')
|
|
||||||
mode = SHOW_PID;
|
|
||||||
else
|
|
||||||
mode = SHOW_PGID;
|
|
||||||
}
|
|
||||||
|
|
||||||
out = stdout;
|
|
||||||
argv = argptr;
|
|
||||||
if (*argv) {
|
|
||||||
do
|
|
||||||
showjob(out, getjob(*argv,0), mode);
|
|
||||||
while (*++argv);
|
|
||||||
} else
|
|
||||||
showjobs(out, mode);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Print a list of jobs. If "change" is nonzero, only print jobs whose
|
* Print a list of jobs. If "change" is nonzero, only print jobs whose
|
||||||
* statuses have changed since the last call to showjobs.
|
* statuses have changed since the last call to showjobs.
|
||||||
@ -3878,10 +3850,35 @@ showjobs(FILE *out, int mode)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (jp = curjob; jp; jp = jp->prev_job) {
|
for (jp = curjob; jp; jp = jp->prev_job) {
|
||||||
if (!(mode & SHOW_CHANGED) || jp->changed)
|
if (!(mode & SHOW_CHANGED) || jp->changed) {
|
||||||
showjob(out, jp, mode);
|
showjob(out, jp, mode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
jobscmd(int argc, char **argv)
|
||||||
|
{
|
||||||
|
int mode, m;
|
||||||
|
|
||||||
|
mode = 0;
|
||||||
|
while ((m = nextopt("lp"))) {
|
||||||
|
if (m == 'l')
|
||||||
|
mode = SHOW_PID;
|
||||||
|
else
|
||||||
|
mode = SHOW_PGID;
|
||||||
|
}
|
||||||
|
|
||||||
|
argv = argptr;
|
||||||
|
if (*argv) {
|
||||||
|
do
|
||||||
|
showjob(stdout, getjob(*argv,0), mode);
|
||||||
|
while (*++argv);
|
||||||
|
} else
|
||||||
|
showjobs(stdout, mode);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
#endif /* JOBS */
|
#endif /* JOBS */
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -4043,6 +4040,8 @@ makejob(union node *node, int nprocs)
|
|||||||
}
|
}
|
||||||
memset(jp, 0, sizeof(*jp));
|
memset(jp, 0, sizeof(*jp));
|
||||||
#if JOBS
|
#if JOBS
|
||||||
|
/* jp->jobctl is a bitfield.
|
||||||
|
* "jp->jobctl |= jobctl" likely to give awful code */
|
||||||
if (jobctl)
|
if (jobctl)
|
||||||
jp->jobctl = 1;
|
jp->jobctl = 1;
|
||||||
#endif
|
#endif
|
||||||
@ -10883,7 +10882,8 @@ cmdloop(int top)
|
|||||||
}
|
}
|
||||||
numeof++;
|
numeof++;
|
||||||
} else if (nflag == 0) {
|
} else if (nflag == 0) {
|
||||||
job_warning = (job_warning == 2) ? 1 : 0;
|
/* job_warning can only be 2,1,0. Here 2->1, 1/0->0 */
|
||||||
|
job_warning >>= 1;
|
||||||
numeof = 0;
|
numeof = 0;
|
||||||
evaltree(n, 0);
|
evaltree(n, 0);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user