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)))) -- Christian "naddy" Weisgerber naddy@mips.inka.de --- >8 ---- List archives: http://www.xiph.org/archives/ Ogg project homepage: http://www.xiph.org/ogg/ To unsubscribe from this list, send a message to 'speex-dev-request@xiph.org' containing only the word 'unsubscribe' in the body. No subject is needed. Unsubscribe messages sent to the list will be ignored/filtered.
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-0001.pgp
Jean-Marc Valin <jean-marc.valin@hermes.usherb.ca> wrote:> Did you really experience problems with the code?I don't remember if I tried, but even if it is functionally fine, it causes gcc to throw a stream of dire warnings and fixing it costs nothing. -- Christian "naddy" Weisgerber naddy@mips.inka.de --- >8 ---- List archives: http://www.xiph.org/archives/ Ogg project homepage: http://www.xiph.org/ogg/ To unsubscribe from this list, send a message to 'speex-dev-request@xiph.org' containing only the word 'unsubscribe' in the body. No subject is needed. Unsubscribe messages sent to the list will be ignored/filtered.