From: Dale Weiler Date: Thu, 25 Apr 2013 03:17:52 +0000 (+0000) Subject: Fix alignment issues (can remove a clang warning, and also makes our code more portable!) X-Git-Tag: before-library~4 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=1b5504fb9eae2f1eb2a0ef90afecf35387087bcb;p=xonotic%2Fgmqcc.git Fix alignment issues (can remove a clang warning, and also makes our code more portable!) --- diff --git a/Makefile b/Makefile index 77c805d..b96168d 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,6 @@ ifeq ($(CC), clang) -Wno-conversion \ -Wno-missing-prototypes \ -Wno-float-equal \ - -Wno-cast-align \ -Wno-missing-variable-declarations \ -Wno-unknown-warning-option else diff --git a/gmqcc.h b/gmqcc.h index cc95234..ed371f5 100644 --- a/gmqcc.h +++ b/gmqcc.h @@ -361,7 +361,7 @@ void _util_vec_grow(void **a, size_t i, size_t s); ) /* exposed interface */ -#define vec_meta(A) (((vector_t*)(A)) - 1) +#define vec_meta(A) (((vector_t*)((void*)A)) - 1) #define vec_free(A) ((void)((A) ? (mem_d((void*)vec_meta(A)), (A) = NULL) : 0)) #define vec_push(A,V) (GMQCC_VEC_WILLGROW((A),1), (A)[vec_meta(A)->used++] = (V)) #define vec_size(A) ((A) ? vec_meta(A)->used : 0) diff --git a/util.c b/util.c index abc102f..fa6e797 100644 --- a/util.c +++ b/util.c @@ -465,8 +465,7 @@ GMQCC_INLINE size_t util_hthash(hash_table_t *ht, const char *key) { const unsigned char *data = (const unsigned char*)key; while (size >= 4) { - alias = *(uint32_t*)data; - + alias = (data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24)); alias *= mix; alias ^= alias >> rot; alias *= mix;