e2fsprogs: add posix_memalign related portability patch from #8508
authorFelix Fietkau <nbd@openwrt.org>
Thu, 7 Jun 2012 15:24:33 +0000 (15:24 +0000)
committerFelix Fietkau <nbd@openwrt.org>
Thu, 7 Jun 2012 15:24:33 +0000 (15:24 +0000)
SVN-Revision: 32112

tools/e2fsprogs/patches/005-posix_memalign.patch [new file with mode: 0644]

diff --git a/tools/e2fsprogs/patches/005-posix_memalign.patch b/tools/e2fsprogs/patches/005-posix_memalign.patch
new file mode 100644 (file)
index 0000000..2ce4ead
--- /dev/null
@@ -0,0 +1,31 @@
+--- a/lib/ext2fs/ext2fs.h
++++ b/lib/ext2fs/ext2fs.h
+@@ -1212,7 +1212,26 @@
+       if (align == 0)
+               align = 8;
+-      if (retval = posix_memalign((void **) ptr, align, size)) {
++#ifdef HAVE_POSIX_MEMALIGN
++      retval = posix_memalign((void **)ptr, align, size);
++#else
++#ifdef HAVE_MEMALIGN
++    if ((*(void **)ptr = (void *)memalign(align, size)) == NULL)
++      retval = errno;
++    else
++      retval = 0;
++#else
++#ifdef HAVE_VALLOC
++    if ((*(void **)ptr = valloc(size)) == NULL)
++      retval = errno;
++    else
++      retval = 0;
++#else
++# error "Impossible to allocate aligned memory!"
++#endif /* HAVE_VALLOC */
++#endif /* HAVE_MEMALIGN */
++#endif /* HAVE_POSIX_MEMALIGN */
++      if (retval) {
+               if (retval == ENOMEM)
+                       return EXT2_ET_NO_MEMORY;
+               return retval;
+--