[speex-dev] LP64 fix

Jean-Marc Valin jean-marc.valin at hermes.usherb.ca
Wed Jun 11 09:50:25 PDT 2003


Did you really experience problems with the code? Since I only care
about the last bits (because of the & "(size-1)"), I thought it should
work even if sizeof(int) != sizeof(void*). If it doesn't work with int,
I suspect the solution with the long could also fail on some archs.

        Jean-Marc

Le mer 11/06/2003 à 11:56, Christian Weisgerber a écrit :
> Casting a pointer to an int is a bad idea on 64-bit platforms.
> 
> --- libspeex/stack_alloc.h.orig	Wed Jun 11 17:10:53 2003
> +++ libspeex/stack_alloc.h	Wed Jun 11 17:11:12 2003
> @@ -48,7 +48,7 @@
>  #else
>  
>  /*Aligns the stack to a 'size' boundary */
> -#define ALIGN(stack, size) ((stack) += ((size) - (int)(stack)) & ((size) - 1))
> +#define ALIGN(stack, size) ((stack) += ((size) - (long)(stack)) & ((size) - 1))
>  
>  /* Allocates 'size' elements of type 'type' on the stack */
>  #define PUSH(stack, size, type) (ALIGN((stack),sizeof(type)),(stack)+=((size)*sizeof(type)),(type*)((stack)-((size)*sizeof(type))))

-- 
Jean-Marc Valin, M.Sc.A.
LABORIUS (http://www.gel.usherb.ca/laborius)
Université de Sherbrooke, Québec, Canada

<p>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: Ceci est une partie de message numériquement signée
Url : http://lists.xiph.org/pipermail/speex-dev/attachments/20030611/5d37001a/signature.pgp


More information about the Speex-dev mailing list