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 <sustrik@250bpm.com>
This commit is contained in:
Martin Sustrik
2011-07-08 18:12:59 +02:00
parent 1526ff638c
commit aa2150c25c
3 changed files with 16 additions and 7 deletions

View File

@@ -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;