Skip to content

Commit 1560223

Browse files
committed
Re-backport atomic job locking from 93v- (re: 52067c3, 595a0a5)
[This commit was previously reverted because it seemed to cause the build to fail on Cygwin. But I just re-tested it, and it's fine. It may be that my Cygwin installation at the time was defective.] Something similar was previously done in 07cc71b from a Debian patch, and eventually reverted; it redefined the ast atomic functions asoincint() and asodecint() to be gcc-specific. This imports the upstream version from the ksh 93v- beta instead. This commit is based on an OpenSUSE patch: https://build.opensuse.org/package/view_file/shells/ksh/ksh93-joblock.dif src/cmd/ksh93/include/jobs.h: - Replace job locking mechanism with the 93v- version which uses the atomic libast functions asoincint(), asogetint() and asodecint(). See: src/lib/libast/man/aso.3 src/cmd/ksh93/sh/jobs.c: job_subsave(): - Revert gcc optimiser bug workaround from c258a04. It should now be unnecessary.
1 parent 37d12bc commit 1560223

4 files changed

Lines changed: 11 additions & 16 deletions

File tree

‎src/cmd/ksh93/Mamfile‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,9 @@ make install
400400
make include/jobs.h implicit
401401
prev ${PACKAGE_ast_INCLUDE}/vmalloc.h implicit
402402
prev include/terminal.h implicit
403+
make ${PACKAGE_ast_INCLUDE}/aso.h implicit
404+
prev ${PACKAGE_ast_INCLUDE}/ast_common.h implicit
405+
done ${PACKAGE_ast_INCLUDE}/aso.h implicit
403406
prev FEATURE/options implicit
404407
prev ${PACKAGE_ast_INCLUDE}/sfio.h implicit
405408
prev ${PACKAGE_ast_INCLUDE}/ast.h implicit

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
# include
3131
#endif /* !SIGINT */
3232
#include "FEATURE/options"
33+
#include
3334

3435
#undef JOBS
3536
#if defined(SIGCLD) && !defined(SIGCHLD)
@@ -120,16 +121,13 @@ extern struct jobs job;
120121
#define vmbusy() 0
121122
#endif
122123

123-
#define job_lock() (job.in_critical++)
124+
#define job_lock() asoincint(&job.in_critical)
124125
#define job_unlock() \
125126
do { \
126-
int sig; \
127-
if (!--job.in_critical && (sig = job.savesig)) \
128-
{ \
129-
if (!job.in_critical++ && !vmbusy()) \
130-
job_reap(sig); \
131-
job.in_critical--; \
132-
} \
127+
int _sig; \
128+
if (asogetint(&job.in_critical) == 1 && (_sig = job.savesig) && !vmbusy()) \
129+
job_reap(_sig); \
130+
asodecint(&job.in_critical); \
133131
} while(0)
134132

135133
extern const char e_jobusage[];

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
#define SH_RELEASE_FORK "93u+m" /* only change if you develop a new ksh93 fork */
2020
#define SH_RELEASE_SVER "1.1.0-alpha" /* semantic version number: https://semver.org */
21-
#define SH_RELEASE_DATE "2022-07-28" /* must be in this format for $((.sh.version)) */
21+
#define SH_RELEASE_DATE "2022-07-31" /* must be in this format for $((.sh.version)) */
2222
#define SH_RELEASE_CPYR "(c) 2020-2022 Contributors to ksh " SH_RELEASE_FORK
2323

2424
/* Scripts sometimes field-split ${.sh.version}, so don't change amount of whitespace. */

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1880,14 +1880,8 @@ static int job_chksave(register pid_t pid)
18801880

18811881
void *job_subsave(void)
18821882
{
1883-
/*
1884-
* We must make a lock first before doing anything else,
1885-
* otherwise GCC will remove the job locking mechanism
1886-
* as a result of compiler optimization.
1887-
*/
1888-
job_lock();
1889-
18901883
struct back_save *bp = new_of(struct back_save,0);
1884+
job_lock();
18911885
*bp = bck;
18921886
bp->prev = bck.prev;
18931887
bck.count = 0;

0 commit comments

Comments
 (0)