diff options
author | Petter Rodhelind <petter.rodhelind@gmail.com> | 2020-06-18 23:57:51 +0200 |
---|---|---|
committer | Petter Rodhelind <petter.rodhelind@gmail.com> | 2020-06-18 23:57:51 +0200 |
commit | 7cda34cf34f3afbd3f2000aa5e2b59ddc319f0f2 (patch) | |
tree | ff18b856a35c80a9cc40573c76899d8a468bedc5 /src/lib9/fmt | |
parent | ea23656f7c3afcfd8516b00c0db09879ae80a09f (diff) | |
parent | 329831171dd6ef81c113f101093c7b4947381003 (diff) | |
download | plan9port-7cda34cf34f3afbd3f2000aa5e2b59ddc319f0f2.tar.gz plan9port-7cda34cf34f3afbd3f2000aa5e2b59ddc319f0f2.tar.bz2 plan9port-7cda34cf34f3afbd3f2000aa5e2b59ddc319f0f2.zip |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'src/lib9/fmt')
-rw-r--r-- | src/lib9/fmt/fmt.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/lib9/fmt/fmt.c b/src/lib9/fmt/fmt.c index a86482c3..47b186a4 100644 --- a/src/lib9/fmt/fmt.c +++ b/src/lib9/fmt/fmt.c @@ -1,7 +1,28 @@ /* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */ #include <stdarg.h> #include <string.h> + +/* + * As of 2020, older systems like RHEL 6 and AIX still do not have C11 atomics. + * On those systems, make the code use volatile int accesses and hope for the best. + * (Most uses of fmtinstall are not actually racing with calls to print that lookup + * formats. The code used volatile here for years without too many problems, + * even though that's technically racy. A mutex is not OK, because we want to + * be able to call print from signal handlers.) + * + * RHEL is using an old GCC (atomics were added in GCC 4.9). + * AIX is using its own IBM compiler (XL C). + */ +#if __IBMC__ || !__clang__ && __GNUC__ && (__GNUC__ < 4 || (__GNUC__==4 && __GNUC_MINOR__<9)) +#warning not using C11 stdatomic on legacy system +#define _Atomic volatile +#define atomic_load(x) (*(x)) +#define atomic_store(x, y) (*(x)=(y)) +#define ATOMIC_VAR_INIT(x) (x) +#else #include <stdatomic.h> +#endif + #include "plan9.h" #include "fmt.h" #include "fmtdef.h" |