Re: [fpc-pascal] memory aligning

2007-11-05 Thread David Pethes
Hi, Micha Nelissen wrote: function evk_malloc (size: longword): pointer; const ALIGNMENT = 16; var ptr: pointer; begin ptr := getmem(size + ALIGNMENT); result := Align (ptr, ALIGNMENT); if result = ptr then pbyte(result) += 16; Why not use ALIGNMENT here also? Hah, I got stu

Re: [fpc-pascal] memory aligning

2007-11-05 Thread Micha Nelissen
David Pethes wrote: > pointer. So I mixed the two codes and come with something like this: > > function evk_malloc (size: longword): pointer; > const > ALIGNMENT = 16; > var > ptr: pointer; > begin > ptr := getmem(size + ALIGNMENT); > result := Align (ptr, ALIGNMENT); > if result = ptr t

[fpc-pascal] memory aligning

2007-11-05 Thread David Pethes
Hi, I'm writing a video codec. I need some of my memory aligned to 16-byte boundaries, since I'm using SSE2 instructions in asm code, that assume this alignment. I was using a custom getmem, that called classic getmem to get some memory block, then cast the pointer and adjust it to next aligne