Skip to content

Commit 595a0a5

Browse files
committed
Revert "Backport atomic job locking from ksh 93v- beta" (52067c3)
That patch broke the build on Cygwin, where gcc apparently doesn't have the required atomic addition/subtraction compiler builtins. The build fails at link time with those functions not found. As far as I know, ksh was actually working fine (after @JohnoKing's gcc workaround in c258a04), so I'll just revert this for now. If a need for it is demonstrated later, we'll have to add a feature test or find some other way to get it working on Cygwin.
1 parent 82c6922 commit 595a0a5

2 files changed

Lines changed: 15 additions & 7 deletions

File tree

‎src/cmd/ksh93/include/jobs.h‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
# include
3434
#endif /* !SIGINT */
3535
#include "FEATURE/options"
36-
#include
3736

3837
#undef JOBS
3938
#if defined(SIGCLD) && !defined(SIGCHLD)
@@ -126,13 +125,16 @@ extern struct jobs job;
126125
#define vmbusy() 0
127126
#endif
128127

129-
#define job_lock() asoincint(&job.in_critical)
128+
#define job_lock() (job.in_critical++)
130129
#define job_unlock() \
131130
do { \
132-
int _sig; \
133-
if (asogetint(&job.in_critical) == 1 && (_sig = job.savesig) && !vmbusy()) \
134-
job_reap(_sig); \
135-
asodecint(&job.in_critical); \
131+
int sig; \
132+
if (!--job.in_critical && (sig = job.savesig)) \
133+
{ \
134+
if (!job.in_critical++ && !vmbusy()) \
135+
job_reap(sig); \
136+
job.in_critical--; \
137+
} \
136138
} while(0)
137139

138140
extern const char e_jobusage[];

‎src/cmd/ksh93/sh/jobs.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1891,8 +1891,14 @@ static int job_chksave(register pid_t pid)
18911891

18921892
void *job_subsave(void)
18931893
{
1894-
struct back_save *bp = new_of(struct back_save,0);
1894+
/*
1895+
* We must make a lock first before doing anything else,
1896+
* otherwise GCC will remove the job locking mechanism
1897+
* as a result of compiler optimization.
1898+
*/
18951899
job_lock();
1900+
1901+
struct back_save *bp = new_of(struct back_save,0);
18961902
*bp = bck;
18971903
bp->prev = bck.prev;
18981904
bck.count = 0;

0 commit comments

Comments
 (0)