On 05/29/2016 02:31 PM, Andreas Tille wrote: > If you ask me the best solution would be to use -msse2 and just add some > code to throw an error if the machine has a to old FPU. Typically > nobody will use those tools on old hardware anyway - so that's no > practical constraint.
Note that Adam Borowski plans to package something that you'll be able
to depend on that will show a nice error on package installation if
the processor doesn't support SSE2. So in the future you could just
have Depends: sse2-support [i386] in your package, and it wouldn't be
an issue. See Bug.#823672 for details. Unfortunately, that's not
packaged yet.
If you want to figure out if the CPU supports SSE2, you can use the
following piece of code:
int cpu_supports_sse2_or_is_not_x86()
{
#ifdef __i386__
int mode = 1;
int flags = 0;
#ifdef __PIC__
/* Can't automatically clobber %ebx in PIC mode, so save value in
%edi and clobber that. */
asm volatile ("movl %%ebx, %%edi\n\t"
"cpuid\n\t"
"movl %%edi, %%ebx"
: "=d" (flags) : "a" (mode) : "edi", "ecx");
#else
asm volatile ("cpuid"
: "=d" (flags) : "a" (mode) : "ebx", "ecx");
#endif
return (flags & (0x1U << 26)) != 0;
#else
/* either x86_64, which all support sse2, or non-x86, where this
* isn't relevant */
return 1;
#endif
}
Regards,
Christian
signature.asc
Description: OpenPGP digital signature

