]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
Fix alignment issues (can remove a clang warning, and also makes our code more portable!)
authorDale Weiler <killfieldengine@gmail.com>
Thu, 25 Apr 2013 03:17:52 +0000 (03:17 +0000)
committerDale Weiler <killfieldengine@gmail.com>
Thu, 25 Apr 2013 03:17:52 +0000 (03:17 +0000)
Makefile
gmqcc.h
util.c

index 77c805d1642760bc68eaf418f443027f6275e5a8..b96168d49209314327533312f2062fa4dcbed186 100644 (file)
--- 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 cc952345986c7e6ae2578c73fcc48616ccd258a7..ed371f5716d476c7d0f0063cd0b57b86edb9ef4a 100644 (file)
--- 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 abc102fe4fd33d861d5859ee8ff5c96501bb9836..fa6e79772662e0d24765f6970632491690aa2fdf 100644 (file)
--- 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;