From 706c8476ab9e4074067eedda2ffeba36ed35089d Mon Sep 17 00:00:00 2001 From: "Charles E. Rolke" Date: Fri, 14 Oct 2011 18:29:57 +0000 Subject: QPID-3540 Typecasting and alignment requirements for various platforms On sparc platform: SchemaHash::update() fails when the hash byte array is cast as two quadwords in a union. This fix uses the union in the definition of the hash byte array to coerce the compiler to place them in quadword alignment when they are created. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1183456 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/qmf/engine/SchemaImpl.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'qpid/cpp/src/qmf/engine/SchemaImpl.h') diff --git a/qpid/cpp/src/qmf/engine/SchemaImpl.h b/qpid/cpp/src/qmf/engine/SchemaImpl.h index 8b079a5ec6..683fb6f8f0 100644 --- a/qpid/cpp/src/qmf/engine/SchemaImpl.h +++ b/qpid/cpp/src/qmf/engine/SchemaImpl.h @@ -35,7 +35,10 @@ namespace engine { // they've been registered. class SchemaHash { - uint8_t hash[16]; + union h { + uint8_t b[16]; + uint64_t q[2]; + } hash; public: SchemaHash(); void encode(qpid::framing::Buffer& buffer) const; @@ -47,7 +50,7 @@ namespace engine { void update(Direction d) { update((uint8_t) d); } void update(Access a) { update((uint8_t) a); } void update(bool b) { update((uint8_t) (b ? 1 : 0)); } - const uint8_t* get() const { return hash; } + const uint8_t* get() const { return hash.b; } bool operator==(const SchemaHash& other) const; bool operator<(const SchemaHash& other) const; bool operator>(const SchemaHash& other) const; -- cgit v1.2.1