From: Michael Lee Date: Fri, 11 Mar 2016 00:50:53 +0000 (-0800) Subject: Adding portability to gating PicoSpinLock. X-Git-Tag: 2016.07.26~450 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=b1eb6819f3ffe6b645f39d505ca8ace3116b7873;p=folly.git Adding portability to gating PicoSpinLock. Summary:PicoSpinLock only works on x86_64, Arm64, and ppc64 (i.e., not 32-bit). Add a bit of gating so we can continue to run tests and use headers when compiling for i386. Reviewed By: yfeldblum Differential Revision: D2991328 fb-gh-sync-id: b0d0c229508f65dff62b24fdd9d80c799cd97935 shipit-source-id: b0d0c229508f65dff62b24fdd9d80c799cd97935 --- diff --git a/folly/PicoSpinLock.h b/folly/PicoSpinLock.h index 19472b31..32c5abfb 100644 --- a/folly/PicoSpinLock.h +++ b/folly/PicoSpinLock.h @@ -31,6 +31,7 @@ */ #pragma once +#define FOLLY_PICO_SPIN_LOCK_H_ /* * @author Keith Adams @@ -38,16 +39,16 @@ */ #include +#include #include -#include #include -#include +#include #include -#include +#include +#include #include #include -#include #if !FOLLY_X64 && !FOLLY_A64 && !FOLLY_PPC64 # error "PicoSpinLock.h is currently x64, aarch64 and ppc64 only." diff --git a/folly/SmallLocks.h b/folly/SmallLocks.h index b73932b7..88fefe3e 100644 --- a/folly/SmallLocks.h +++ b/folly/SmallLocks.h @@ -36,6 +36,10 @@ #include #include + +#include +#if FOLLY_X64 || FOLLY_A64 || FOLLY_PPC64 #include +#endif #endif diff --git a/folly/test/SmallLocksTest.cpp b/folly/test/SmallLocksTest.cpp index d7e27578..f33e0231 100644 --- a/folly/test/SmallLocksTest.cpp +++ b/folly/test/SmallLocksTest.cpp @@ -34,9 +34,12 @@ using folly::MSLGuard; using folly::MicroLock; using folly::MicroSpinLock; -using folly::PicoSpinLock; using std::string; +#ifdef FOLLY_PICO_SPIN_LOCK_H_ +using folly::PicoSpinLock; +#endif + namespace { struct LockedVal { @@ -53,10 +56,12 @@ struct LockedVal { // these classes are POD). FOLLY_PACK_PUSH struct ignore1 { MicroSpinLock msl; int16_t foo; } FOLLY_PACK_ATTR; -struct ignore2 { PicoSpinLock psl; int16_t foo; } FOLLY_PACK_ATTR; static_assert(sizeof(ignore1) == 3, "Size check failed"); -static_assert(sizeof(ignore2) == 6, "Size check failed"); static_assert(sizeof(MicroSpinLock) == 1, "Size check failed"); +#ifdef FOLLY_PICO_SPIN_LOCK_H_ +struct ignore2 { PicoSpinLock psl; int16_t foo; } FOLLY_PACK_ATTR; +static_assert(sizeof(ignore2) == 6, "Size check failed"); +#endif FOLLY_PACK_POP LockedVal v; @@ -78,6 +83,7 @@ void splock_test() { } } +#ifdef FOLLY_PICO_SPIN_LOCK_H_ template struct PslTest { PicoSpinLock lock; @@ -109,6 +115,7 @@ void doPslTest() { t.join(); } } +#endif struct TestClobber { TestClobber() { @@ -141,6 +148,7 @@ TEST(SmallLocks, SpinLockCorrectness) { } } +#ifdef FOLLY_PICO_SPIN_LOCK_H_ TEST(SmallLocks, PicoSpinCorrectness) { doPslTest(); doPslTest(); @@ -164,6 +172,7 @@ TEST(SmallLocks, PicoSpinSigned) { } EXPECT_EQ(val.getData(), -8); } +#endif TEST(SmallLocks, RegClobber) { TestClobber().go();