util: skip AltiVec detection if built with -maltivec
[mesa.git] / src / util / u_vector.h
index 8fa4ec483c942382ae35caea63830f370f0d8a09..95f35c59c7dd8726bc73f158ab98c1baab6eb023 100644 (file)
 
 #include <stdint.h>
 #include <stdlib.h>
-#include "util/u_math.h"
 #include "util/macros.h"
 
 /* TODO - move to u_math.h - name it better etc */
 static inline uint32_t
 u_align_u32(uint32_t v, uint32_t a)
 {
-   assert(a != 0 && a == (a & -a));
+   assert(a != 0 && a == (a & -((int32_t) a)));
    return (v + a - 1) & ~(a - 1);
 }
 
@@ -81,10 +80,14 @@ u_vector_finish(struct u_vector *queue)
    free(queue->data);
 }
 
+#ifndef __GNUC__
+#define __builtin_types_compatible_p(t1, t2) 1
+#endif
+
 #define u_vector_foreach(elem, queue)                                  \
-   static_assert(__builtin_types_compatible_p(__typeof__(queue), struct u_vector *), ""); \
+   STATIC_ASSERT(__builtin_types_compatible_p(__typeof__(queue), struct u_vector *)); \
    for (uint32_t __u_vector_offset = (queue)->tail;                                \
-        elem = (queue)->data + (__u_vector_offset & ((queue)->size - 1)), __u_vector_offset < (queue)->head; \
+        elem = (void *)((char *)(queue)->data + (__u_vector_offset & ((queue)->size - 1))), __u_vector_offset < (queue)->head; \
         __u_vector_offset += (queue)->element_size)