Subject: Re: 8 octets aligned data with malloc ?
To: Allen Briggs <briggs@puma.macbsd.com>
From: Manuel BOUYER <bouyer@antioche.lip6.fr>
List: tech-kern
Date: 10/15/1997 21:48:34
On Oct 15, Allen Briggs wrote
> 
> 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.

Right. 8 bytes aligned on a i386 machine.

> 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).

Chris Torek pointed out that the 4.4bsd malloc always return memory aligned
on the min of ((smaller ^2 > size), pagesize), because of the way he manages
memory chunks that are smaller than pagezise. If so this could be enough for
me, as I malloc memory size which are multiple of 8 bytes. Does someone knows
if NetBSD's malloc behave like that ?

Well, to be safe, I could also malloc (size+7), this will not loose that much
memory ...

--
Manuel Bouyer, LIP6, Universite Paris VI.           Manuel.Bouyer@lip6.fr
--