Check for posix_memalign()
authorDavid Schleef <ds@schleef.org>
Wed, 25 Aug 2010 10:28:56 +0000 (03:28 -0700)
committerDavid Schleef <ds@schleef.org>
Wed, 25 Aug 2010 10:30:22 +0000 (03:30 -0700)
configure.ac
orc-test/orcarray.c

index f1e030f..0dda4e8 100644 (file)
@@ -32,6 +32,7 @@ ACLOCAL_AMFLAGS="-I m4 $ACLOCAL_AMFLAGS"
 AC_SUBST(ACLOCAL_AMFLAGS)
 
 AM_CONDITIONAL(CROSS_COMPILING, test "x$cross_compiling" = "xyes")
+AC_CHECK_FUNCS([posix_memalign])
 
 ##################################################
 # Check for gtk-doc.
index 23c8bfa..05754f0 100644 (file)
@@ -26,7 +26,9 @@ orc_array_new (int n, int m, int element_size, int misalignment)
 {
   OrcArray *ar;
   void *data;
+#ifdef HAVE_POSIX_MEMALIGN
   int ret;
+#endif
 
   ar = malloc (sizeof(OrcArray));
   memset (ar, 0, sizeof(OrcArray));
@@ -39,7 +41,11 @@ orc_array_new (int n, int m, int element_size, int misalignment)
   ar->stride = (ar->stride + (ALIGNMENT-1)) & (~(ALIGNMENT-1));
   ar->alloc_len = ar->stride * (m+2*EXTEND_ROWS) + (ALIGNMENT * element_size);
 
+#ifdef HAVE_POSIX_MEMALIGN
   ret = posix_memalign (&data, ALIGNMENT, ar->alloc_len);
+#else
+  data = malloc (ar->alloc_len);
+#endif
   ar->alloc_data = data;
 
   ar->data = ORC_PTR_OFFSET (ar->alloc_data,