summaryrefslogtreecommitdiffstats
path: root/mojo/system
diff options
context:
space:
mode:
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_);