Message256214
Is anyone willing to help me a bit to come up with a pull request?
I took some ideas from here:
https://fossies.org/diffs/xscreensaver/5.30_vs_5.32/utils/thread_util.c-diff.html
Citation from that patch:
Clang 3.0 has a partial implementation of GNU atomics; 3.1 rounds it out.
http://llvm.org/viewvc/llvm-project/cfe/tags/RELEASE_30/final/include/clang/Basic/Builtins.def?view=markup
http://llvm.org/viewvc/llvm-project/cfe/tags/RELEASE_31/final/include/clang/Basic/Builtins.def?view=markup
Apple changes the Clang version to track Xcode versions; use
__apple_build_version__ to distinguish between the two.
Xcode 4.3 uses Apple LLVM 3.1, which corresponds to Clang 3.1.
https://en.wikipedia.org/wiki/Xcode
One should probably adapt this into "at least clang 3.3 (or perhaps even 3.4?) is needed". Now, the basic test in configure.ac is the following:
volatile int val = 1;
int main() {
__atomic_load_n(&val, __ATOMIC_SEQ_CST);
return 0;
}
With clang on 10.7 (Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn)) this compiles, runs and returns 0. Evidently a more complex test is needed to trigger the error, but I'm not sure that that test should be since I don't have enough experience with "atomic". If you have a clue what functionality I should test, I will gladly do it and try to come up with a better test.
An alternative could be to blacklist a compiler and this is what I am proposing here as a very naive approach:
volatile int val = 1;
int main() {
__atomic_load_n(&val, __ATOMIC_SEQ_CST);
#define VERSION_CHECK(cc_major, cc_minor, req_major, req_minor) \
((cc_major) > (req_major) || \
(cc_major) == (req_major) && (cc_minor) >= (req_minor))
#if defined(__clang__)
#if defined(__apple_build_version__)
// either one test or the other should work
// #if __apple_build_version__ < 5000000
#if !VERSION_CHECK(__clang_major__, __clang_minor__, 5, 0)
this_should_fail();
#endif
// not sure if this is 3.3 or 3.4
#elif !VERSION_CHECK(__clang_major__, __clang_minor__, 3, 3)
this_should_fail();
#endif
#endif
return 0;
} |
|
Date |
User |
Action |
Args |
2015-12-11 13:33:07 | Mojca Miklavec | set | recipients:
+ Mojca Miklavec, ronaldoussoren, vstinner, larry, benjamin.peterson, ned.deily, dabeaz, yselivanov |
2015-12-11 13:33:07 | Mojca Miklavec | set | messageid: <1449840787.6.0.187813220288.issue24844@psf.upfronthosting.co.za> |
2015-12-11 13:33:07 | Mojca Miklavec | link | issue24844 messages |
2015-12-11 13:33:06 | Mojca Miklavec | create | |
|