From patchwork Fri Jan 7 03:32:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Breeds X-Patchwork-Id: 77840 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bilbo.ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 1D560B7106 for ; Fri, 7 Jan 2011 14:32:15 +1100 (EST) Received: by ozlabs.org (Postfix, from userid 1026) id B4F94B70DA; Fri, 7 Jan 2011 14:32:13 +1100 (EST) Date: Fri, 7 Jan 2011 14:32:13 +1100 From: Tony Breeds To: acrux Subject: Re: yaboot does not compile against new e2fsprogs release Message-ID: <20110107033213.GX19615@ozlabs.org> References: <20101229155921.cf81b721.acrux_it@libero.it> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20101229155921.cf81b721.acrux_it@libero.it> User-Agent: Mutt/1.5.20 (2009-06-14) Cc: yaboot-devel@lists.ozlabs.org X-BeenThere: yaboot-devel@lists.ozlabs.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Technical and development discussion regarding yaboot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: yaboot-devel-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Errors-To: yaboot-devel-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org 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 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;