[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bug#823672: ITP: sse-support -- prevent installation on processors without required support



On Sat, May 07, 2016 at 02:37:42PM +0200, Adam Borowski wrote:
> Detection is done via a "boom instruction" rather than grep /proc/cpuinfo,
> because of qemu and /proc-less chroots.

For the dsfmt package I figured out how to detect at run-time
SSE2 (i386) and Altivec (powerpc) without resorting to illegal
instructions, which might also be useful for this package.

/* SSE2 */
#include <cpuid.h>
static int check_sse2() {
    unsigned int eax = 0, ebx = 0, ecx = 0, edx = 0;
    __get_cpuid(1, &eax, &ebx, &ecx, &edx);
    return edx & bit_SSE2 ? 1 : 0;
}

/* Altivec */
#include <sys/auxv.h>
static int check_altivec() {
    unsigned long aux = getauxval(AT_HWCAP);
    return aux & PPC_FEATURE_HAS_ALTIVEC ? 1 : 0;
}

Peter


Reply to: