[Pixman] [PATCH 1/4] Move aligned_malloc() to utils
Dmitri Vorobiev
dmitri.vorobiev at movial.com
Fri Sep 17 07:52:20 PDT 2010
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 | 15 ---------------
test/utils.c | 15 +++++++++++++++
test/utils.h | 4 ++++
3 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/test/blitters-test.c b/test/blitters-test.c
index 9dd9163..7ba80eb 100644
--- a/test/blitters-test.c
+++ b/test/blitters-test.c
@@ -14,21 +14,6 @@
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,
diff --git a/test/utils.c b/test/utils.c
index d95cbc2..b10450e 100644
--- a/test/utils.c
+++ b/test/utils.c
@@ -352,3 +352,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;
+}
diff --git a/test/utils.h b/test/utils.h
index a39af02..5074bb5 100644
--- a/test/utils.h
+++ b/test/utils.h
@@ -101,3 +101,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);
--
1.6.3.3
More information about the Pixman
mailing list