Pack PackedSyncPtr
[folly.git] / folly / PackedSyncPtr.h
index ca9e1215dc60b357ef35e7eed8f6b71e4c3c8fe5..3db7ff1696a70eab40a62997ec9af8f63e30ea5b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2014 Facebook, Inc.
+ * Copyright 2016 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * limitations under the License.
  */
 
-#ifndef FOLLY_PACKEDSYNCPTR_H_
-#define FOLLY_PACKEDSYNCPTR_H_
+#pragma once
 
 #include <folly/Portability.h>
 
-#if !FOLLY_X64
-# error "PackedSyncPtr is x64-specific code."
+#if !FOLLY_X64 && !FOLLY_PPC64
+# error "PackedSyncPtr is x64 and ppc64 specific code."
 #endif
 
 /*
@@ -134,19 +133,15 @@ public:
     data_.setData((uintptr_t(extra) << 48) | ptr);
   }
 
-  // Logically private, but we can't have private data members and
-  // still be considered a POD.  (In C++11 we are still a standard
-  // layout struct if this is private, but it doesn't matter, since
-  // gcc (4.6) won't let us use this with attribute packed still in
-  // that case.)
+ private:
   PicoSpinLock<uintptr_t> data_;
-};
+} FOLLY_PACK_ATTR;
 
+static_assert(
+    std::is_pod<PackedSyncPtr<void>>::value,
+    "PackedSyncPtr must be kept a POD type.");
 static_assert(sizeof(PackedSyncPtr<void>) == 8,
               "PackedSyncPtr should be only 8 bytes---something is "
               "messed up");
 
 }
-
-#endif
-