macro for cross platform x64 detection
[folly.git] / folly / small_vector.h
index a339e138cdf9f070a7d345e9b30deab93fa93fa0..06d2a3050ec25ec9c1b340406e27bcfc117f0daf 100644 (file)
@@ -15,7 +15,8 @@
  */
 
 /*
- * For high-level documentation and usage examples see folly/doc/small_vector.md
+ * For high-level documentation and usage examples see
+ * folly/docs/small_vector.md
  *
  * @author Jordan DeLong <delong.j@fb.com>
  */
@@ -47,7 +48,7 @@
 
 #include "folly/Malloc.h"
 
-#if defined(__GNUC__) && defined(__x86_64__)
+#if defined(__GNUC__) && FOLLY_X64
 # include "folly/SmallLocks.h"
 # define FB_PACKED __attribute__((packed))
 #else
@@ -227,7 +228,7 @@ namespace detail {
     IntegralSizePolicy() : size_(0) {}
 
   protected:
-    std::size_t policyMaxSize() const {
+    static constexpr std::size_t policyMaxSize() {
       return SizeType(~kExternMask);
     }
 
@@ -267,7 +268,7 @@ namespace detail {
     SizeType size_;
   };
 
-#ifdef __x86_64__
+#if FOLLY_X64
   template<class SizeType, bool ShouldUseHeap>
   struct OneBitMutexImpl {
     typedef SizeType InternalSizeType;
@@ -281,7 +282,7 @@ namespace detail {
   protected:
     static bool const kShouldUseHeap = ShouldUseHeap;
 
-    std::size_t policyMaxSize() const {
+    static constexpr std::size_t policyMaxSize() {
       return SizeType(~(SizeType(1) << kLockBit | kExternMask));
     }
 
@@ -528,9 +529,9 @@ public:
     return std::lexicographical_compare(begin(), end(), o.begin(), o.end());
   }
 
-  size_type max_size() const {
+  static constexpr size_type max_size() {
     return !BaseType::kShouldUseHeap ? MaxInline
-                                     : this->policyMaxSize();
+                                     : BaseType::policyMaxSize();
   }
 
   size_type size()         const { return this->doSize(); }
@@ -965,7 +966,7 @@ private:
     doConstruct(n, val);
   }
 
-  void makeSize(size_type size, value_type* v = NULL) {
+  void makeSize(size_type size, value_type* v = nullptr) {
     makeSize(size, v, size - 1);
   }
 
@@ -1008,7 +1009,7 @@ private:
         detail::shiftPointer(newh, kHeapifyCapacitySize) :
         newh);
 
-    if (v != NULL) {
+    if (v != nullptr) {
       // move new element
       try {
         new (&newp[pos]) value_type(std::move(*v));
@@ -1099,7 +1100,7 @@ private:
     }
   } FB_PACKED;
 
-#if defined(__x86_64_)
+#if FOLLY_X64
   typedef unsigned char InlineStorageType[sizeof(value_type) * MaxInline];
 #else
   typedef typename std::aligned_storage<