*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
using folly::PackedSyncPtr;
namespace {
// Compile time check for packability. This requires that
// PackedSyncPtr is a POD struct on gcc.
using folly::PackedSyncPtr;
namespace {
// Compile time check for packability. This requires that
// PackedSyncPtr is a POD struct on gcc.
TEST(PackedSyncPtr, Basic) {
PackedSyncPtr<std::pair<int,int>> sp;
TEST(PackedSyncPtr, Basic) {
PackedSyncPtr<std::pair<int,int>> sp;
EXPECT_EQ(sp.extra(), 0x13);
EXPECT_EQ(sp.get(), newP);
sp.unlock();
EXPECT_EQ(sp.extra(), 0x13);
EXPECT_EQ(sp.get(), newP);
sp.unlock();
void push_back(const T& t) {
base.set((T*) realloc(base.get(),
(base.extra() + 1) * sizeof(T)));
void push_back(const T& t) {
base.set((T*) realloc(base.get(),
(base.extra() + 1) * sizeof(T)));