folly: avoid using atomic operations android can't handle
authorKevin McCray <kmccray@fb.com>
Thu, 24 Mar 2016 19:54:28 +0000 (12:54 -0700)
committerFacebook Github Bot 5 <facebook-github-bot-5-bot@fb.com>
Thu, 24 Mar 2016 20:05:28 +0000 (13:05 -0700)
Summary:On Android, clang 3.8 + libstdc++ doesn't support the full
range of atomic operations.  This diff fixes up the ones we
ran into when building fb4a.

Reviewed By: mzlee

Differential Revision: D3092352

fb-gh-sync-id: 7fea8513e23425fc37050ad14d82aabaceb00352
shipit-source-id: 7fea8513e23425fc37050ad14d82aabaceb00352

folly/experimental/TLRefCount.h

index 6c86bb56e79c3fd491717aa11df2807ea6581193..87734e6ecb074ab494c96c409188be61bcdeb498 100644 (file)
@@ -76,7 +76,7 @@ class TLRefCount {
 
     assert(state_.load() == State::GLOBAL);
 
-    return --globalCount_;
+    return globalCount_-- - 1;
   }
 
   Int operator*() const {
@@ -132,7 +132,7 @@ class TLRefCount {
       }
 
       collectCount_ = count_;
-      refCount_.globalCount_ += collectCount_;
+      refCount_.globalCount_.fetch_add(collectCount_);
       collectGuard_.reset();
     }