Move aligned_malloc() to utils
authorDmitri Vorobiev <dmitri.vorobiev@movial.com>
Fri, 17 Sep 2010 14:52:20 +0000 (17:52 +0300)
committerSøren Sandmann Pedersen <ssp@redhat.com>
Tue, 21 Sep 2010 12:50:17 +0000 (08:50 -0400)
The aligned_malloc() routine will be used in more than one test utility.
At least, a low-level blitter benchmark needs it. Therefore, let's make
this function a part of common test utilities code.

test/blitters-test.c
test/utils.c
test/utils.h

index 9dd9163..7ba80eb 100644 (file)
 static pixman_indexed_t rgb_palette[9];
 static pixman_indexed_t y_palette[9];
 
-static void *
-aligned_malloc (size_t align, size_t size)
-{
-    void *result;
-
-#ifdef HAVE_POSIX_MEMALIGN
-    if (posix_memalign (&result, align, size) != 0)
-      result = NULL;
-#else
-    result = malloc (size);
-#endif
-
-    return result;
-}
-
 /* Create random image for testing purposes */
 static pixman_image_t *
 create_random_image (pixman_format_code_t *allowed_formats,
index 580a51d..ccc637e 100644 (file)
@@ -458,3 +458,18 @@ fail_after (int seconds, const char *msg)
 #endif
 #endif
 }
+
+void *
+aligned_malloc (size_t align, size_t size)
+{
+    void *result;
+
+#ifdef HAVE_POSIX_MEMALIGN
+    if (posix_memalign (&result, align, size) != 0)
+      result = NULL;
+#else
+    result = malloc (size);
+#endif
+
+    return result;
+}
index 14e3c8b..06cd857 100644 (file)
@@ -110,3 +110,7 @@ fail_after (int seconds, const char *msg);
     assert (frcd_canary_variable6 == frcd_volatile_constant6); \
     assert (frcd_canary_variable7 == frcd_volatile_constant7); \
     assert (frcd_canary_variable8 == frcd_volatile_constant8);
+
+/* Try to get an aligned memory chunk */
+void *
+aligned_malloc (size_t align, size_t size);