Refactor atomic operations for Android compatibility#44
Refactor atomic operations for Android compatibility#44Duron27 wants to merge 3 commits intoOpenMW:3.6from
Conversation
Updated atomic operations to use std::atomic for Android platform.
|
I don't think this is quite the right approach if we're upstreaming this. Just like there are a bunch of existing options like However, I'm not convinced that any C++ changes should be required here at all. The The minimal work to get something mergable would be to:
For bonus points, you could also:
|
src/OpenThreads/common/Atomic.cpp
Outdated
| Atomic::operator++() | ||
| { | ||
| #if defined(_OPENTHREADS_ATOMIC_USE_GCC_BUILTINS) | ||
| #if defined(_OPENTHREADS_ATOMIC_USE_STD_ATOMIC) |
There was a problem hiding this comment.
You're not defining _OPENTHREADS_ATOMIC_USE_LIBRARY_ROUTINES when _OPENTHREADS_ATOMIC_USE_STD_ATOMIC is active, so none of this file is seen by the compiler when you're using the new mode, and you therefore don't need to have any implementation here for the _OPENTHREADS_ATOMIC_USE_STD_ATOMIC approach. You only need the parts of the implementation in include/OpenThreads/Atomic and not the parts on src/OpenThreads/Atomic.cpp.
|
I reversed the changes to Atomic.cpp, this closes the other MR I submitted also. according to our patches there's another small change in two files shown in this patch. I'm still trying to figure out a suitable way to do this. Maybe something like?
|
|
If those values need to be atomic, then it would stand to reason that they'd need to be atomic on all platforms. That might be a bit of a pain to test, though, as on x86, aligned reads and writes under eight bytes are always atomic (although with relaxed ordering), so it might not be a symptomatic problem on desktop machines. If we can confirm it's a real cross-platform issue, then the solution is to use an OpenTheads atomic instead of an STL one. |
|
The only thing I can think of is to build for android without atomic changes and hope to catch a dump from the crash. Would this be a helpful test? |
|
Maybe, although it might be more helpful to build with tsan and see if it yells at us about those variables. |
|
So I'll build everything with |
Updated atomic operations to use std::atomic for Android platform.
This removes a good chunk of one of our patches HERE
Even though some of these look like we should fall under the "else" with the same return as in the android statement we don't. I've build for android not using these changes and the game is very unstable.