From aa2150c25c9b0dd518b058f0c50420417441fd23 Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Fri, 8 Jul 2011 18:12:59 +0200 Subject: VSM data are aligned to 32/64 bit boundary Till now the VSM buffer was aligned to 16 bit boundary which could possibly cause problems on RISC architectures when accessing the message data in unsafe manner. Signed-off-by: Martin Sustrik --- src/msg.hpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/msg.hpp') diff --git a/src/msg.hpp b/src/msg.hpp index 602ae55..2111bf1 100644 --- a/src/msg.hpp +++ b/src/msg.hpp @@ -77,6 +77,10 @@ namespace zmq private: + // Size in bytes of the largest message that is still copied around + // rather than being reference-counted. + enum {max_vsm_size = 29}; + // Shared message buffer. Message data are either allocated in one // continuous block along with this structure - thus avoiding one // malloc/free pair or they are stored in used-supplied memory. @@ -109,21 +113,24 @@ namespace zmq // the union. union { struct { + unsigned char unused [max_vsm_size + 1]; unsigned char type; unsigned char flags; } base; struct { + unsigned char data [max_vsm_size]; + unsigned char size; unsigned char type; unsigned char flags; - unsigned char size; - unsigned char data [max_vsm_size]; } vsm; struct { + content_t *content; + unsigned char unused [max_vsm_size + 1 - sizeof (content_t*)]; unsigned char type; unsigned char flags; - content_t *content; } lmsg; struct { + unsigned char unused [max_vsm_size + 1]; unsigned char type; unsigned char flags; } delimiter; -- cgit v1.2.3