os/os_memory_aligned.h: fix memory allocation alignment for 64 bits
authorJosé Fonseca <jfonseca@vmware.com>
Thu, 4 Feb 2010 18:06:55 +0000 (18:06 +0000)
committerJosé Fonseca <jfonseca@vmware.com>
Thu, 4 Feb 2010 18:07:22 +0000 (18:07 +0000)
Based on Andreia Gaita <shana@jitted.com>'s patch.

src/gallium/auxiliary/os/os_memory.h
src/gallium/auxiliary/os/os_memory_aligned.h

index 704aa0762be625700e25de2b626030f038c90a57..556662d35e1f88161a383bc0d8ff6613d1d38b90 100644 (file)
@@ -58,7 +58,7 @@ void *
 os_realloc(void *ptr, size_t old_size, size_t new_size);
 
 void *
-os_malloc_aligned(size_t size, uint alignment);
+os_malloc_aligned(size_t size, size_t alignment);
 
 void
 os_free_aligned(void *ptr);
index d4528f73196a6c9938f7ca27da807646d1d57bc5..72c5cf65b66c8be842390a8bc663954749e27a31 100644 (file)
@@ -43,7 +43,7 @@
  * Return memory on given byte alignment
  */
 static INLINE void *
-os_malloc_aligned(size_t size, uint alignment)
+os_malloc_aligned(size_t size, size_t alignment)
 {
    char *ptr, *buf;
 
@@ -51,7 +51,7 @@ os_malloc_aligned(size_t size, uint alignment)
    if (!ptr)
       return NULL;
 
-   buf = (char *)(((uintptr_t)ptr + sizeof(void *) + alignment - 1) & ~(alignment - 1));
+   buf = (char *)(((uintptr_t)ptr + sizeof(void *) + alignment - 1) & ~((uintptr_t)(alignment - 1)));
    *(char **)(buf - sizeof(void *)) = ptr;
 
    return buf;