mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-02-15 04:32:24 +00:00
Restore build without __sync_fetch_and_{add,sub} (re: 07cc71b8
)
The more I think about it, the more it seems obvious that commit
07cc71b8
(PR #14) is quite simply a workaround for a GCC optimiser
bug, and (who knows?) possibly an old, long-fixed one, as the bug
report is years old.
The commit also caused ksh to fail to build on HP-UX B.11.11 with
GCC 4.2.3 (hosted at polarhome.com), because it doesn't have
__sync_fetch_and_add() and __sync_fetch_and_sub(). It may fail on
other systems. The GCC documentation says these are legacy:
https://gcc.gnu.org/onlinedocs/gcc/_005f_005fsync-Builtins.html
HELP WANTED: what I would like best is if someone could come up
with some way of detecting this optimiser bug and then error out
with a message along the lines of "please upgrade your broken
compiler". It would probably need to be a new iffe test.
Meanwhile, let's try it this way for a while and see what happens:
src/cmd/ksh93/include/jobs.h:
- Restore original ksh version of job_lock()/job_unlock() macros.
- Use the workaround version only if the compiler has the builtins
__sync_fetch_and_add() and __sync_fetch_and_sub().
This commit is contained in:
parent
f95d3105ef
commit
58560db768
2 changed files with 26 additions and 2 deletions
2
TODO
2
TODO
|
@ -9,7 +9,7 @@ Fix regression test failures:
|
||||||
______
|
______
|
||||||
Fix build system:
|
Fix build system:
|
||||||
|
|
||||||
- ksh does not currently build on NetBSD, AIX, HP-UX, Solaris, or QNX.
|
- ksh does not currently build on NetBSD, AIX, Solaris, or QNX.
|
||||||
- Reimport the removed nmake. It is necessary for changes in Makefiles
|
- Reimport the removed nmake. It is necessary for changes in Makefiles
|
||||||
to take effect. The machine-generated Mamfiles are now used as a fallback,
|
to take effect. The machine-generated Mamfiles are now used as a fallback,
|
||||||
but they are not meant to be edited by hand.
|
but they are not meant to be edited by hand.
|
||||||
|
|
|
@ -149,9 +149,17 @@ extern struct jobs job;
|
||||||
#define vmbusy() 0
|
#define vmbusy() 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Job locking and unlocking macros
|
||||||
|
*/
|
||||||
|
#if defined(__sync_fetch_and_add) && defined(__sync_fetch_and_sub)
|
||||||
|
/*
|
||||||
|
* This version may prevent segfaults due to a GCC optimizer bug.
|
||||||
|
* See: https://bugzilla.redhat.com/show_bug.cgi?id=1112306
|
||||||
|
* https://bugs.launchpad.net/ubuntu/+source/ksh/+bug/1697501
|
||||||
|
*/
|
||||||
#define asoincint(p) __sync_fetch_and_add(p,1)
|
#define asoincint(p) __sync_fetch_and_add(p,1)
|
||||||
#define asodecint(p) __sync_fetch_and_sub(p,1)
|
#define asodecint(p) __sync_fetch_and_sub(p,1)
|
||||||
|
|
||||||
#define job_lock() asoincint(&job.in_critical)
|
#define job_lock() asoincint(&job.in_critical)
|
||||||
#define job_unlock() \
|
#define job_unlock() \
|
||||||
do { \
|
do { \
|
||||||
|
@ -163,6 +171,22 @@ extern struct jobs job;
|
||||||
asodecint(&job.in_critical); \
|
asodecint(&job.in_critical); \
|
||||||
} \
|
} \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
#else
|
||||||
|
/*
|
||||||
|
* Original ksh93 version.
|
||||||
|
*/
|
||||||
|
#define job_lock() (job.in_critical++)
|
||||||
|
#define job_unlock() \
|
||||||
|
do { \
|
||||||
|
int sig; \
|
||||||
|
if (!--job.in_critical && (sig = job.savesig)) \
|
||||||
|
{ \
|
||||||
|
if (!job.in_critical++ && !vmbusy()) \
|
||||||
|
job_reap(sig); \
|
||||||
|
job.in_critical--; \
|
||||||
|
} \
|
||||||
|
} while(0)
|
||||||
|
#endif /* defined(__sync_fetch_and_add) && defined(__sync_fetch_and_sub) */
|
||||||
|
|
||||||
extern const char e_jobusage[];
|
extern const char e_jobusage[];
|
||||||
extern const char e_done[];
|
extern const char e_done[];
|
||||||
|
|
Loading…
Reference in a new issue