Skip to content

Commit

Permalink
Fix C++ Atomic support check (#2126)
Browse files Browse the repository at this point in the history
Summary:
Some platforms need libatomic linked for sub-word operations while others need it for super-word operations. Let's make sure we test for all.

Relates to #1907

Pull Request resolved: #2126

Reviewed By: Gownta

Differential Revision: D52975209

Pulled By: yfeldblum

fbshipit-source-id: 2c8781f817d6cc59fb8c74c1d13812e584187b47
  • Loading branch information
luhenry authored and facebook-github-bot committed Sep 5, 2024
1 parent 0829195 commit 19254c4
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions CMake/folly-deps.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,13 @@ message(STATUS "Setting FOLLY_HAVE_DWARF: ${FOLLY_HAVE_DWARF}")
check_cxx_source_compiles("
#include <atomic>
int main(int argc, char** argv) {
std::atomic<uint8_t> a1;
std::atomic<uint16_t> a2;
std::atomic<uint32_t> a4;
std::atomic<uint64_t> a8;
struct Test { bool val; };
std::atomic<Test> s;
return static_cast<int>(s.is_lock_free());
return a1++ + a2++ + a4++ + a8++ + unsigned(s.is_lock_free());
}"
FOLLY_CPP_ATOMIC_BUILTIN
)
Expand All @@ -200,9 +204,13 @@ if(NOT FOLLY_CPP_ATOMIC_BUILTIN)
check_cxx_source_compiles("
#include <atomic>
int main(int argc, char** argv) {
std::atomic<uint8_t> a1;
std::atomic<uint16_t> a2;
std::atomic<uint32_t> a4;
std::atomic<uint64_t> a8;
struct Test { bool val; };
std::atomic<Test> s2;
return static_cast<int>(s2.is_lock_free());
std::atomic<Test> s;
return a1++ + a2++ + a4++ + a8++ + unsigned(s.is_lock_free());
}"
FOLLY_CPP_ATOMIC_WITH_LIBATOMIC
)
Expand Down

0 comments on commit 19254c4

Please sign in to comment.