Skip to content

Commit

Permalink
Revert "Backport atomic job locking from ksh 93v- beta" (52067c3)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
McDutchie committed Mar 17, 2021
1 parent 82c6922 commit 595a0a5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
14 changes: 8 additions & 6 deletions src/cmd/ksh93/include/jobs.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
# include <signal.h>
#endif /* !SIGINT */
#include "FEATURE/options"
#include <aso.h>

#undef JOBS
#if defined(SIGCLD) && !defined(SIGCHLD)
Expand Down Expand Up @@ -126,13 +125,16 @@ extern struct jobs job;
#define vmbusy() 0
#endif

#define job_lock() asoincint(&job.in_critical)
#define job_lock() (job.in_critical++)
#define job_unlock() \
do { \
int _sig; \
if (asogetint(&job.in_critical) == 1 && (_sig = job.savesig) && !vmbusy()) \
job_reap(_sig); \
asodecint(&job.in_critical); \
int sig; \
if (!--job.in_critical && (sig = job.savesig)) \
{ \
if (!job.in_critical++ && !vmbusy()) \
job_reap(sig); \
job.in_critical--; \
} \
} while(0)

extern const char e_jobusage[];
Expand Down
8 changes: 7 additions & 1 deletion src/cmd/ksh93/sh/jobs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1891,8 +1891,14 @@ static int job_chksave(register pid_t pid)

void *job_subsave(void)
{
struct back_save *bp = new_of(struct back_save,0);
/*
* We must make a lock first before doing anything else,
* otherwise GCC will remove the job locking mechanism
* as a result of compiler optimization.
*/
job_lock();

struct back_save *bp = new_of(struct back_save,0);
*bp = bck;
bp->prev = bck.prev;
bck.count = 0;
Expand Down

0 comments on commit 595a0a5

Please sign in to comment.