diff mbox

yaboot does not compile against new e2fsprogs release

Message ID 20110107033213.GX19615@ozlabs.org
State Under Review
Headers show

Commit Message

Tony Breeds Jan. 7, 2011, 3:32 a.m. UTC
On Wed, Dec 29, 2010 at 03:59:21PM +0100, acrux wrote:
> 
> hi all,
> it seems that yaboot (1.3.16) does not compile against e2fsprogs > 1.41.12
> It could be the new (from e2fsprogs-1.41.13):
> Added a new function to the ext2fs library, ext2fs_get_memalign().
> 
> but i've not yet investigated...

Please try this compile d but otherwise untested patch.

 

Yours Tony

Comments

acrux Jan. 8, 2011, 12:50 p.m. UTC | #1
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Fri, 7 Jan 2011 14:32:13 +1100
Tony Breeds <tony@bakeyournoodle.com> wrote:

> On Wed, Dec 29, 2010 at 03:59:21PM +0100, acrux wrote:
> > 
> > hi all,
> > it seems that yaboot (1.3.16) does not compile against e2fsprogs >
> > 1.41.12 It could be the new (from e2fsprogs-1.41.13):
> > Added a new function to the ext2fs library, ext2fs_get_memalign().
> > 
> > but i've not yet investigated...
> 
> Please try this compile d but otherwise untested patch.
> 
_cut__


ok, i'll test it asap this week-end. 
 
cheers,
- --nico


- -- 
GNU/Linux on Power Architecture
CRUX PPC - http://cruxppc.org/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.16 (GNU/Linux)

iEYEARECAAYFAk0oXZ8ACgkQxq34tDeO7LgWGgCfez8AYyV/kuIRhjeK5LQ96kXX
KBgAn07qjnyh+E9XCQPiNAkg2Ae8gi5e
=JfSt
-----END PGP SIGNATURE-----
acrux Jan. 10, 2011, 6:39 p.m. UTC | #2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Fri, 7 Jan 2011 14:32:13 +1100
Tony Breeds <tony@bakeyournoodle.com> wrote:

> On Wed, Dec 29, 2010 at 03:59:21PM +0100, acrux wrote:
> > 
> > hi all,
> > it seems that yaboot (1.3.16) does not compile against e2fsprogs >
> > 1.41.12 It could be the new (from e2fsprogs-1.41.13):
> > Added a new function to the ext2fs library, ext2fs_get_memalign().
> > 
> > but i've not yet investigated...
> 
> Please try this compile d but otherwise untested patch.
> 

ok, i just tested it and it compiles fine and works too.
Now there is still the big issue with ofpath that's unable to find
devices on apple's machines using new libata (pata) linux kernel
drivers.

- -- 
GNU/Linux on Power Architecture
CRUX PPC - http://cruxppc.org/

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.16 (GNU/Linux)

iEUEARECAAYFAk0rUmAACgkQxq34tDeO7Li5igCfR/uxq+jaNpmj3lLOUMaO8oAg
gZIAliZS89pbhM+7174lKGBRw5XU8/s=
=dsWf
-----END PGP SIGNATURE-----
diff mbox

Patch

diff --git a/lib/malloc.c b/lib/malloc.c
index 81d7717..0121112 100644
--- a/lib/malloc.c
+++ b/lib/malloc.c
@@ -23,6 +23,10 @@ 
 #include "stddef.h"
 #include "string.h"
 
+/* Copied from asm-generic/errno-base.h */
+#define	ENOMEM		12	/* Out of memory */
+#define	EINVAL		22	/* Invalid argument */
+
 /* Imported functions */
 extern void prom_printf (char *fmt, ...);
 
@@ -60,6 +64,49 @@  void *malloc (unsigned int size)
     return caddr;
 }
 
+/* Do not fall back to the malloc above as posix_memalign is needed by
+ * external libraries not yaboot */
+int posix_memalign(void **memptr, size_t alignment, size_t size)
+{
+    char *caddr;
+    /* size of allocation including the alignment */
+    size_t alloc_size;
+
+    if (!malloc_ptr)
+        return EINVAL;
+
+    /* Minimal aligment is sizeof(void *) */
+    if (alignment < sizeof(void*))
+	alignment = sizeof(void*);
+
+    /* Check for valid alignment and power of 2 */
+    if ((alignment % sizeof(void*) != 0) || ((alignment-1)&alignment))
+        return EINVAL;
+
+    if (size == 0) {
+	*memptr=NULL;
+	return 0;
+    }
+
+    caddr = (char*)(
+             (size_t)((malloc_ptr + sizeof(int))+(alignment-1)) &
+             (~(alignment-1))
+            );
+
+    alloc_size = size + (caddr - (malloc_ptr+sizeof(int)));
+
+    if ((malloc_ptr + alloc_size + sizeof(int)) > malloc_top)
+        return ENOMEM;
+
+    *(int *)(caddr - sizeof(int)) = size;
+    malloc_ptr += alloc_size + sizeof(int);
+    last_alloc = caddr;
+    malloc_ptr = (char *) ((((unsigned int) malloc_ptr) + 3) & (~3));
+    *memptr=(void*)caddr;
+
+    return 0;
+}
+
 void *realloc(void *ptr, unsigned int size)
 {
     char *caddr, *oaddr = ptr;