Subject: Re: 8 octets aligned data with malloc ?
To: None <tech-kern@NetBSD.ORG>
From: Allen Briggs <briggs@puma.macbsd.com>
List: tech-kern
Date: 10/15/1997 13:51:26
> > > I need to malloc some memory space that should be aligned to 8 bytes.
> > > Is there a better way to do this than:
> > >   p = (malloc(size + 0x7) +0x7) & 0x7;
> 
> The "contract" of malloc is to "Allocate space that is suitably
> aligned for the largest type of access."  (Right?)
> 
> If so, then malloc should align to 8-bytes on that machine.

That's correct for malloc() (based on ALIGNBYTES, probably), but I
think what Manuel wants is to malloc() memory for a controller that
needs memory aligned more strictly than the processor.  If that's
the case, then he needs to do something like what he suggests.  I
don't think there is an ALIGNTO(buffer, alignsize) macro or
MALLOC_ALIGNED(size, alignsize) or equivalent (but bus_space_alloc()
does have an alignment argument).

-allen

-- 
              Allen Briggs - end killing - briggs@macbsd.com