summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-07-14 18:45:37 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-07-14 18:45:37 +0000
commitfcfaf2e18aba06dd90b16958ecfbfcfbf59ceb02 (patch)
treec77e8166667f208fb5a106ea0dff7052831b1fa6 /shell
parent8fdc4b7b06ada63a2572f8aff92e8810e52ae841 (diff)
downloadbusybox-w32-fcfaf2e18aba06dd90b16958ecfbfcfbf59ceb02.tar.gz
busybox-w32-fcfaf2e18aba06dd90b16958ecfbfcfbf59ceb02.tar.bz2
busybox-w32-fcfaf2e18aba06dd90b16958ecfbfcfbf59ceb02.zip
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
Diffstat (limited to 'shell')
-rw-r--r--shell/ash.c66
1 files changed, 33 insertions, 33 deletions
diff --git a/shell/ash.c b/shell/ash.c
index ccb1e1a58..6173a2505 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -3141,20 +3141,18 @@ struct job {
3141}; 3141};
3142 3142
3143static pid_t backgndpid; /* pid of last background process */ 3143static pid_t backgndpid; /* pid of last background process */
3144static int job_warning; /* user was warned about stopped jobs */ 3144static smallint job_warning; /* user was warned about stopped jobs (can be 2, 1 or 0). */
3145#if JOBS
3146static int jobctl; /* true if doing job control */
3147#endif
3148 3145
3149static struct job *makejob(union node *, int); 3146static struct job *makejob(union node *, int);
3150static int forkshell(struct job *, union node *, int); 3147static int forkshell(struct job *, union node *, int);
3151static int waitforjob(struct job *); 3148static int waitforjob(struct job *);
3152 3149
3153#if ! JOBS 3150#if !JOBS
3154#define setjobctl(on) /* do nothing */ 3151enum { jobctl = 0 };
3152#define setjobctl(on) do {} while (0)
3155#else 3153#else
3154static smallint jobctl; /* true if doing job control */
3156static void setjobctl(int); 3155static void setjobctl(int);
3157static void showjobs(FILE *, int);
3158#endif 3156#endif
3159 3157
3160/* 3158/*
@@ -3836,11 +3834,32 @@ showjob(FILE *out, struct job *jp, int mode)
3836 } 3834 }
3837} 3835}
3838 3836
3837/*
3838 * Print a list of jobs. If "change" is nonzero, only print jobs whose
3839 * statuses have changed since the last call to showjobs.
3840 */
3841static void
3842showjobs(FILE *out, int mode)
3843{
3844 struct job *jp;
3845
3846 TRACE(("showjobs(%x) called\n", mode));
3847
3848 /* If not even one one job changed, there is nothing to do */
3849 while (dowait(DOWAIT_NORMAL, NULL) > 0)
3850 continue;
3851
3852 for (jp = curjob; jp; jp = jp->prev_job) {
3853 if (!(mode & SHOW_CHANGED) || jp->changed) {
3854 showjob(out, jp, mode);
3855 }
3856 }
3857}
3858
3839static int 3859static int
3840jobscmd(int argc, char **argv) 3860jobscmd(int argc, char **argv)
3841{ 3861{
3842 int mode, m; 3862 int mode, m;
3843 FILE *out;
3844 3863
3845 mode = 0; 3864 mode = 0;
3846 while ((m = nextopt("lp"))) { 3865 while ((m = nextopt("lp"))) {
@@ -3850,38 +3869,16 @@ jobscmd(int argc, char **argv)
3850 mode = SHOW_PGID; 3869 mode = SHOW_PGID;
3851 } 3870 }
3852 3871
3853 out = stdout;
3854 argv = argptr; 3872 argv = argptr;
3855 if (*argv) { 3873 if (*argv) {
3856 do 3874 do
3857 showjob(out, getjob(*argv,0), mode); 3875 showjob(stdout, getjob(*argv,0), mode);
3858 while (*++argv); 3876 while (*++argv);
3859 } else 3877 } else
3860 showjobs(out, mode); 3878 showjobs(stdout, mode);
3861 3879
3862 return 0; 3880 return 0;
3863} 3881}
3864
3865/*
3866 * Print a list of jobs. If "change" is nonzero, only print jobs whose
3867 * statuses have changed since the last call to showjobs.
3868 */
3869static void
3870showjobs(FILE *out, int mode)
3871{
3872 struct job *jp;
3873
3874 TRACE(("showjobs(%x) called\n", mode));
3875
3876 /* If not even one one job changed, there is nothing to do */
3877 while (dowait(DOWAIT_NORMAL, NULL) > 0)
3878 continue;
3879
3880 for (jp = curjob; jp; jp = jp->prev_job) {
3881 if (!(mode & SHOW_CHANGED) || jp->changed)
3882 showjob(out, jp, mode);
3883 }
3884}
3885#endif /* JOBS */ 3882#endif /* JOBS */
3886 3883
3887static int 3884static int
@@ -4043,6 +4040,8 @@ makejob(union node *node, int nprocs)
4043 } 4040 }
4044 memset(jp, 0, sizeof(*jp)); 4041 memset(jp, 0, sizeof(*jp));
4045#if JOBS 4042#if JOBS
4043 /* jp->jobctl is a bitfield.
4044 * "jp->jobctl |= jobctl" likely to give awful code */
4046 if (jobctl) 4045 if (jobctl)
4047 jp->jobctl = 1; 4046 jp->jobctl = 1;
4048#endif 4047#endif
@@ -10883,7 +10882,8 @@ cmdloop(int top)
10883 } 10882 }
10884 numeof++; 10883 numeof++;
10885 } else if (nflag == 0) { 10884 } else if (nflag == 0) {
10886 job_warning = (job_warning == 2) ? 1 : 0; 10885 /* job_warning can only be 2,1,0. Here 2->1, 1/0->0 */
10886 job_warning >>= 1;
10887 numeof = 0; 10887 numeof = 0;
10888 evaltree(n, 0); 10888 evaltree(n, 0);
10889 } 10889 }