diff options
author | Roland Dreier <roland@topspin.com> | 2005-04-12 16:37:00 +0000 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2006-11-09 19:57:01 -0800 |
commit | 1dcaaf925b4e7d615a9a579efd0ea7143f06cc90 (patch) | |
tree | 05740d5f0e0d04f1ab1ff816eba606fc8bdc5ee9 | |
parent | 34736ef43b6fd867d0ef0f51c0fcfec9f5963d53 (diff) | |
download | libmthca-1dcaaf925b4e7d615a9a579efd0ea7143f06cc90.tar.gz |
Fix -fstrict-aliasing bugs
Fix 64-bit versions of mthca_write64() and mthca_write_db_rec() so
that they are compiled correctly with -fstrict-aliasing.
Signed-off-by: Roland Dreier <roland@topspin.com>
-rw-r--r-- | src/doorbell.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/doorbell.h b/src/doorbell.h index 5c18748..2384b0d 100644 --- a/src/doorbell.h +++ b/src/doorbell.h @@ -69,14 +69,22 @@ static inline void mthca_write_db_rec(uint32_t val[2], uint32_t *db) #elif SIZEOF_LONG == 8 +#if __BYTE_ORDER == __LITTLE_ENDIAN +# define MTHCA_PAIR_TO_64(val) ((uint64_t) val[1] << 32 | val[0]) +#elif __BYTE_ORDER == __BIG_ENDIAN +# define MTHCA_PAIR_TO_64(val) ((uint64_t) val[0] << 32 | val[1]) +#else +# error __BYTE_ORDER not defined +#endif + static inline void mthca_write64(uint32_t val[2], struct mthca_context *ctx, int offset) { - *(volatile uint64_t *) (ctx->uar + offset) = *(uint64_t *) val; + *(volatile uint64_t *) (ctx->uar + offset) = MTHCA_PAIR_TO_64(val); } static inline void mthca_write_db_rec(uint32_t val[2], uint32_t *db) { - *(volatile uint64_t *) db = *(uint64_t *) val; + *(volatile uint64_t *) db = MTHCA_PAIR_TO_64(val); } #else |