#include "folly/SmallLocks.h"
#include <cassert>
#include <cstdio>
+#include <mutex>
#include <string>
#include <vector>
#include <pthread.h>
}
}
+struct TestClobber {
+ TestClobber() {
+ lock_.init();
+ }
+
+ void go() {
+ std::lock_guard<MicroSpinLock> g(lock_);
+ // This bug depends on gcc register allocation and is very sensitive. We
+ // have to use DCHECK instead of EXPECT_*.
+ DCHECK(!lock_.try_lock());
+ }
+
+ private:
+ MicroSpinLock lock_;
+};
+
}
TEST(SmallLocks, SpinLockCorrectness) {
}
EXPECT_EQ(val.getData(), -8);
}
+
+TEST(SmallLocks, RegClobber) {
+ TestClobber().go();
+}