16-byte-aligned malloc()?

Rick Mann rmann@latencyzero.com
Fri Sep 7 16:43:00 GMT 2007


On Sep 6, 2007, at 7:07 PM, Jonathan S. Shapiro wrote:

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

I guess you could say that. Some of the data structures need to be 16- 
byte aligned. For example, the LCD peripheral needs to have the frame  
buffer and the DMA descriptor structures 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

Thanks, I'll take a look.

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

Thanks, I bet this is exactly what I need.

I also discovered the __attribute__ ((__aligned__ (16))) to hang off  
of global data; this should work well for many of my needs, too. I  
don't really want to be mallocing during normal execution, just at  
startup, and so global data is okay, too.

-- 
Rick



More information about the Newlib mailing list