From 2b7b903a854a4b8f8bfc62a852a8e9a3d306296c Mon Sep 17 00:00:00 2001 From: Constantine Vetoshev Date: Tue, 16 Aug 2016 13:31:46 -0700 Subject: [PATCH] Fix alignment problem with zmq_msg_t. Problem occurs on SPARC and ARM CPUs. This commit is a backport of https://github.com/zeromq/libzmq/commit/d9fb1d36ff2008966af538f722a1f4ab158dbf64 (from libzmq), first reported in https://github.com/zeromq/libzmq/issues/1325. --- include/zmq.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/zmq.h b/include/zmq.h index 4754c6ff..d610d195 100644 --- a/include/zmq.h +++ b/include/zmq.h @@ -205,7 +205,10 @@ ZMQ_EXPORT int zmq_ctx_destroy (void *context); /* 0MQ message definition. */ /******************************************************************************/ -typedef struct zmq_msg_t {unsigned char _ [64];} zmq_msg_t; +/* union here ensures correct alignment on architectures that require it, e.g. + * SPARC and ARM + */ +typedef union zmq_msg_t { unsigned char _ [64]; void *p; } zmq_msg_t; typedef void (zmq_free_fn) (void *data, void *hint);