[Small Record] Atomic plus under ARM64

1. Use atomic_add in the code

  • There is no atomic header file under aarch64
  • Compile errors :
/Users/ahfu/code/android/android-ndk-r14b/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ ....
.. /..//thread_util.cpp:92:7: error: use of undeclared identifier'atomic_add'
atomic_add(&(obj->m_start_idx), 1);

2. Suspect the problem of clang, try changing to gcc to compile

Add a line in Application.mk:
NDK_TOOLCHAIN ​​:= aarch64-linux-android-4.9< br> Compilation appears:

/Users/ahfu/code/android/android-ndk-r14b/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64/bin/aarch64-linux-android -g++ ...
../..//thread_util.cpp:92:40: error:'atomic_add' was not declared in this scope
atomic_add(&(obj->m_start_idx), 1 );

3. When I finally remembered, atomic became a built-in command of gcc

So I changed atomic_add to __sync_fetch_and_add(&(obj->m_start_idx), 1); The problem is solved.

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 5139 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.