This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: 16-byte-aligned malloc()?


Rick:

Is this a machine where one of the hardware datatypes is 16-byte
aligned?

For the linker script, here is an example of one that does cache line
alignment. Look around line 139

http://dev.eros-os.com/hg/coyotos/file/b6a415342299/src/sys/arch/i386/kernel/ldscript.S

The corresponding declaration support is in

http://dev.eros-os.com/hg/coyotos/file/b6a415342299/src/sys/kerninc/ccs.h

Look at the CACHE_ALIGN macro. Usage is to change the definition (not
the declaration) with:

   CACHE_ALIGN type name;

You should be able to adapt this example to other sizes and use it for
all of your static declarations.


For dynamic allocation, have a look at memalign in the C library.

On Thu, 2007-09-06 at 18:18 -0700, Rick Mann wrote:
> Hi. To make some of the hardware on the PXA320 happy, I need to  
> allocate buffers on 16 byte boundaries (lower four bits of address  
> should be zero. Does anyone have any suggestions on the best way to  
> accomplish this?
> 
> In certain cases, I could probably have the linker script create  
> sections (for example, I need to put a couple of frame buffers in  
> external memory; I think the linker script is expressive enough to  
> let me define a couple symbols with those addresses, and give me the  
> added benefit of preventing BSS data from encroaching into those, but  
> that's really a question for the GCC list).
> 
> In other cases, I need to declare static structures or malloc() space  
> for them. They are much smaller (16 bytes), but still need to be 16  
> byte-aligned.
> 
> Will I need to modify malloc() to do this?
> 
> TIA,
-- 
Jonathan S. Shapiro
Managing Director
The EROS Group, LLC
www.coyotos.org, www.eros-os.org


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]