summaryrefslogtreecommitdiffstats
path: root/mojo/system
diff options
context:
space:
mode:
authorviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-21 22:20:51 +0000
committerviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-21 22:20:51 +0000
commitdcef5e0f81871ede0b940b78feb9ce6bafb97716 (patch)
tree5081f685dcfafc1a3528c07597c489424bd08f15 /mojo/system
parent501052ffdae87baa6619ea006dd8d42f1f4dc8e3 (diff)
downloadchromium_src-dcef5e0f81871ede0b940b78feb9ce6bafb97716.zip
chromium_src-dcef5e0f81871ede0b940b78feb9ce6bafb97716.tar.gz
chromium_src-dcef5e0f81871ede0b940b78feb9ce6bafb97716.tar.bz2
Mojo: Move compile-asserts back into .cc file.
(Using an evil trick discussed in https://codereview.chromium.org/174093004/.) R=yzshen@chromium.org Review URL: https://codereview.chromium.org/166423003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@252665 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo/system')
-rw-r--r--mojo/system/message_in_transit.cc13
-rw-r--r--mojo/system/message_in_transit.h13
2 files changed, 16 insertions, 10 deletions
diff --git a/mojo/system/message_in_transit.cc b/mojo/system/message_in_transit.cc
index 815aef8..80ebf08 100644
--- a/mojo/system/message_in_transit.cc
+++ b/mojo/system/message_in_transit.cc
@@ -11,10 +11,23 @@
#include "base/compiler_specific.h"
#include "base/logging.h"
#include "base/memory/aligned_memory.h"
+#include "mojo/system/constants.h"
namespace mojo {
namespace system {
+struct MessageInTransit::PrivateStructForCompileAsserts {
+ // The size of |Header| must be appropriate to maintain alignment of the
+ // following data.
+ COMPILE_ASSERT(sizeof(Header) % kMessageAlignment == 0,
+ sizeof_MessageInTransit_Header_not_a_multiple_of_alignment);
+ // Avoid dangerous situations, but making sure that the size of the "header" +
+ // the size of the data fits into a 31-bit number.
+ COMPILE_ASSERT(static_cast<uint64_t>(sizeof(Header)) + kMaxMessageNumBytes <=
+ 0x7fffffffULL,
+ kMaxMessageNumBytes_too_big);
+};
+
STATIC_CONST_MEMBER_DEFINITION const MessageInTransit::Type
MessageInTransit::kTypeMessagePipeEndpoint;
STATIC_CONST_MEMBER_DEFINITION const MessageInTransit::Type
diff --git a/mojo/system/message_in_transit.h b/mojo/system/message_in_transit.h
index e3f569c..0cec0ae 100644
--- a/mojo/system/message_in_transit.h
+++ b/mojo/system/message_in_transit.h
@@ -8,7 +8,6 @@
#include <stdint.h>
#include "base/macros.h"
-#include "mojo/system/constants.h"
#include "mojo/system/system_impl_export.h"
namespace mojo {
@@ -129,6 +128,9 @@ class MOJO_SYSTEM_IMPL_EXPORT MessageInTransit {
}
private:
+ // To allow us to make assertions about |Header| in the .cc file.
+ struct PrivateStructForCompileAsserts;
+
// "Header" for the data. Must be a multiple of |kMessageAlignment| bytes in
// size. Must be POD.
struct Header {
@@ -146,15 +148,6 @@ class MOJO_SYSTEM_IMPL_EXPORT MessageInTransit {
uint32_t reserved0;
uint32_t reserved1;
};
- // The size of |Header| must be appropriate to maintain alignment of the
- // following data.
- COMPILE_ASSERT(sizeof(Header) % kMessageAlignment == 0,
- sizeof_MessageInTransit_Header_not_a_multiple_of_alignment);
- // Avoid dangerous situations, but making sure that the size of the "header" +
- // the size of the data fits into a 31-bit number.
- COMPILE_ASSERT(static_cast<uint64_t>(sizeof(Header)) + kMaxMessageNumBytes <=
- 0x7fffffffULL,
- kMaxMessageNumBytes_too_big);
const Header* header() const {
return static_cast<const Header*>(main_buffer_);