Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
e2fsprogs: add posix_memalign related portability patch from #8508
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@32112 3c298f89-4303-0410-b956-a3cf2f4a3e73
- Loading branch information
nbd
committed
Jun 7, 2012
1 parent
5aab29d
commit 9c88d96
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
-- |