[FFmpeg-devel] r9017 breaks WMA decoding on Intel Macs
Matthieu CASTET
castet.matthieu
Thu May 31 10:01:55 CEST 2007
Hi,
Trent Piepho <xyzzy <at> speakeasy.org> writes:
> I wouldn't consider it a workaround, but a better way to write the code to
> begin with.
>
> The use of the asm("n+%0" : "m"(foo)) syntax has a bug. The asm block has an
> undeclared input or output. The fact that the existing code works is simply
> luck that gcc's optimizer isn't able to do something to break it.
>
> Consider something like this:
> int main(void)
> {
> int x[2] = {1, 1};
> asm("movl $42, %0 ; movl $42, 4+%0" : "=m"(x[0]));
> printf("%d\n", x[1]);
> }
>
You can declare the memory you are accessing with something like :
int main(void)
{
int x[2] = {1, 1};
struct { int a[2]; } *p = (void *)x;
asm("movl $42, %0 \n\t movl $42, 4+%0" :
"+m" (*p)
);
printf("%d\n", x[1]);
}
Matthieu
PS : gcc manual [1] give a (ugly) syntax to make the struct cast in asm
input/ouput declaration, but I didn't manage to make it work for output.
[1]
If you know how large the accessed memory is, you can add it as input or output
but if this is not known, you should add `memory'. As an example, if you access
ten bytes of a string, you can use a memory input like:
{"m"( ({ struct { char x[10]; } *p = (void *)ptr ; *p; }) )}.
More information about the ffmpeg-devel
mailing list