Blame SOURCES/ksh-20120801-locking.patch

5a79ad
diff -up ksh-20120801/src/cmd/ksh93/include/jobs.h.locking ksh-20120801/src/cmd/ksh93/include/jobs.h
5a79ad
--- ksh-20120801/src/cmd/ksh93/include/jobs.h.locking	2014-06-27 15:51:07.144923719 +0200
5a79ad
+++ ksh-20120801/src/cmd/ksh93/include/jobs.h	2014-06-27 15:52:56.463272276 +0200
5a79ad
@@ -149,15 +149,18 @@ extern struct jobs job;
5a79ad
 #define vmbusy()	0
5a79ad
 #endif
5a79ad
 
5a79ad
-#define job_lock()	(job.in_critical++)
5a79ad
+#define asoincint(p)  __sync_fetch_and_add(p,1)
5a79ad
+#define asodecint(p)  __sync_fetch_and_sub(p,1)
5a79ad
+
5a79ad
+#define job_lock()	asoincint(&job.in_critical)
5a79ad
 #define job_unlock()	\
5a79ad
 	do { \
5a79ad
 		int	sig; \
5a79ad
-		if (!--job.in_critical && (sig = job.savesig)) \
5a79ad
+		if (asodecint(&job.in_critical)==1 && (sig = job.savesig)) \
5a79ad
 		{ \
5a79ad
-			if (!job.in_critical++ && !vmbusy()) \
5a79ad
+			if (!asoincint(&job.in_critical) && !vmbusy()) \
5a79ad
 				job_reap(sig); \
5a79ad
-			job.in_critical--; \
5a79ad
+			asodecint(&job.in_critical); \
5a79ad
 		} \
5a79ad
 	} while(0)
5a79ad