> > This is a so silly question I feel dumb for not having able to
> > find it myself ... how can I get aligned memory?
> >
> > The problem is I have this structure, 64 bits long which needs
> > to be aligned to 16 bytes (thx, Intel >:), but I cannot find my to do
> > it (except to allocate a lot until I get it aligned, which is quite
> > wasteful :).
> Have a look at the malloc man page. I think it tells you that a block of
> n bytes (n a power of two) is aligned to the nearest higher power of
> two, guarantueed. At least that is the way the Framelist is aligned in
> my code. I do check that in debugging mode but it has not failed up to
> now.
First: malloc gives only the limited guarantee about alignment that the
alignment is sufficient for storing any basic type or structure. Otherwise
constructs like
double *blurb;
blurb = malloc(sizeof(double));
*blurb = 42.0;
might bomb on certain architectures or have to take a serious performance
penalty.
Second: the original poster was asking about allocation of aligned memory
in the kernel. And in the kernel there is no malloc(3).
Ralf
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html