网上有一些关于如何编写64位原子代码的材料,例如:
How to guarantee 64-bit writes are atomic?
。。但在我走上这条路之前,我更喜欢使用Android / ARM特定的解决方案(如果存在的话)。
我正在移植一个需要32位和64位原子操作的C++引擎。我研究并实现了GCC内置的__sync_*函数,但到了链接的时候,我得到了64位操作的错误:
error: undefined reference to '__sync_fetch_and_or_8'
error: undefined reference to '__sync_lock_test_and_set_8'
error: undefined reference to '__sync_fetch_and_and_8'
error: undefined reference to '__sync_fetch_and_add_8'
error: undefined reference to '__sync_val_compare_and_swap_8'我正在获取armeabi-v7a,我已经阅读了一些64位原子的组装说明(ldrexd/strexd),那么有没有办法通过GCC内置的atomics来访问它们呢?如果没有,其他的选择是什么?
谢谢!
发布于 2013-01-02 19:51:48
自从我提出问题以来,NDK r8d就发布了,它支持内置64位原子。
http://developer.android.com/tools/sdk/ndk/index.html
支持64位内置原子功能的ARM到GCC 4.6.
https://stackoverflow.com/questions/13851565
复制相似问题