summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Sandmann Pedersen <sandmann@redhat.com>2009-08-12 14:08:58 -0400
committerSøren Sandmann Pedersen <sandmann@redhat.com>2009-08-13 12:46:20 -0400
commitce966f4d8e8aa9a4465e2ab28666bae891194a72 (patch)
tree7ebd1c04568827e443a84b27460074523ed5eb5d
parent29c2ae4a0cf924cb011467687a4c43237fb2316c (diff)
Check if we have posix_memalign() in configure.ac. [23260, 23261]
Fall back to malloc() in blitters-test.c if we don't.
-rw-r--r--configure.ac8
-rw-r--r--test/blitters-test.c18
2 files changed, 24 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac
index 6f9f600..e6c5e8e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -490,6 +490,14 @@ AC_SUBST(GTK_LIBS)
AC_SUBST(DEP_CFLAGS)
AC_SUBST(DEP_LIBS)
+dnl =====================================
+dnl posix_memalign
+
+AC_CHECK_FUNC(posix_memalign, have_posix_memalign=yes, have_posix_memalign=no)
+if test x$have_posix_memalign = xyes; then
+ AC_DEFINE(HAVE_POSIX_MEMALIGN, 1, [Whether we have posix_memalign()])
+fi
+
AC_OUTPUT([pixman-1.pc
pixman-1-uninstalled.pc
Makefile
diff --git a/test/blitters-test.c b/test/blitters-test.c
index 4838e81..23de6c2 100644
--- a/test/blitters-test.c
+++ b/test/blitters-test.c
@@ -24,7 +24,7 @@
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
-#include <malloc.h>
+#include <config.h>
#include "pixman.h"
/* A primitive pseudorandom number generator, taken from POSIX.1-2001 example */
@@ -50,6 +50,20 @@ lcg_rand_n (int max)
return lcg_rand () % max;
}
+static void *
+aligned_malloc (size_t align, size_t size)
+{
+ void *result;
+
+#ifdef HAVE_POSIX_MEMALIGN
+ posix_memalign (&result, align, size);
+#else
+ result = malloc (size);
+#endif
+
+ return result;
+}
+
/*----------------------------------------------------------------------------*\
* CRC-32 version 2.0.0 by Craig Bruce, 2006-04-29.
*
@@ -259,7 +273,7 @@ create_random_image (pixman_format_code_t *allowed_formats,
stride = (stride + 3) & ~3;
/* do the allocation */
- buf = (uint32_t *)memalign (64, stride * height);
+ buf = aligned_malloc (64, stride * height);
/* initialize image with random data */
for (i = 0; i < stride * height; i++)