From: Søren Sandmann Pedersen Date: Wed, 12 Aug 2009 18:08:58 +0000 (-0400) Subject: Check if we have posix_memalign() in configure.ac. [23260, 23261] X-Git-Tag: 1.0_branch~794 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ce966f4d8e8aa9a4465e2ab28666bae891194a72;p=profile%2Fivi%2Fpixman.git Check if we have posix_memalign() in configure.ac. [23260, 23261] Fall back to malloc() in blitters-test.c if we don't. --- 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 #include #include -#include +#include #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++)