On Wed, Oct 13, 2010 at 12:11 AM, Christian Ebert <blacktr...@gmx.net>wrote:

> * Trent Piepho on Tuesday, October 12, 2010 at 12:06:45 -0700
> > It looks like the only use of ebx is in the code to detect CPU features
> > using cpuid.  A better way to do it would be to read the /proc/cpuinfo
> file
> > and look for the sse2 or whatever flag.
>
> There is no /proc/ directory on MacOS X.
>

Oh yeah, this isn't on Linux.  OSX probably has some kind of API for
checking if sse2 is available.  Using CPUID isn't enough, because sse
requires OS support that might not be there.  I.e., the cpu supports sse2
but you're not actually able to use it.  Probably not much of issue on OSX.

Easy fix would just be the change the sse detection asm to save and restore
ebx.

__asm__ volatile("pushl %%ebx ; cpuid ; popl %%ebx" : "=d"(d) : "a"(1) :
"ecx");

or better

uint32_t tmp;
__asm__ volatile("movl %%ebx, %1; cpuid; movl %1, %%ebx" : "=d"(d),
"=&g"(tmp) : "a"(1) : "ecx");

The latter is safer in general, as you can't use push or pop around any asm
code that has a parameter with a constraint that allows memory references.
The memory reference might be relative to esp, in which case the push/pop
would move it.  Or it might not be relative to esp, in which case the
push/pop doesn't move it.  So there's no way to adjust for it.
------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
Mjpeg-users mailing list
Mjpeg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mjpeg-users

Reply via email to