Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2472)

Unified Diff: base/compiler_specific.h

Issue 1039823002: Add base::LazyInstance (Closed) Base URL: https://chromium.googlesource.com/chromium/mini_chromium@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/base.gyp ('k') | base/lazy_instance.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/compiler_specific.h
diff --git a/base/compiler_specific.h b/base/compiler_specific.h
index a6d9520311f5d0b818cefe8b02d06b4fb71f328f..dfef541e29fd6f7cbcc11d3e03892ccbee5b19bb 100644
--- a/base/compiler_specific.h
+++ b/base/compiler_specific.h
@@ -56,6 +56,17 @@
#define ALIGNAS(byte_alignment) __attribute__((aligned(byte_alignment)))
#endif
+// Return the byte alignment of the given type (available at compile time). Use
+// sizeof(type) prior to checking __alignof to workaround Visual C++ bug:
+// http://goo.gl/isH0C
+// Use like:
+// ALIGNOF(int32_t) // this would be 4
+#if defined(COMPILER_MSVC)
+#define ALIGNOF(type) (sizeof(type) - sizeof(type) + __alignof(type))
+#elif defined(COMPILER_GCC)
+#define ALIGNOF(type) __alignof__(type)
+#endif
+
#if defined(COMPILER_MSVC)
#define WARN_UNUSED_RESULT
#else
« no previous file with comments | « base/base.gyp ('k') | base/lazy_instance.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698