Coverage Report

Created: 2026-12-01 06:56

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/faac/libfaac/cpu_compute.c
Line
Count
Source
1
/*
2
 * FAAC - Freeware Advanced Audio Coder
3
 * Copyright (C) 2026 Nils Schimmelmann
4
 *
5
 * This library is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU Lesser General Public
7
 * License as published by the Free Software Foundation; either
8
 * version 2.1 of the License, or (at your option) any later version.
9
 *
10
 * This library is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
 * Lesser General Public License for more details.
14
 */
15
16
#include "cpu_compute.h"
17
18
#if defined(SSE2_ARCH)
19
# ifdef _MSC_VER
20
#  include <intrin.h>
21
# elif defined(__GNUC__) || defined(__clang__)
22
#  include <cpuid.h>
23
# endif
24
#endif
25
26
CPUCaps get_cpu_caps(void)
27
2
{
28
2
    CPUCaps caps = CPU_CAP_NONE;
29
30
2
#if defined(SSE2_ARCH)
31
2
    unsigned int eax = 0, ebx = 0, ecx = 0, edx = 0;
32
2
    unsigned int max_leaf = 0;
33
34
# ifdef _MSC_VER
35
    int cpu_info[4] = {0};
36
    __cpuid(cpu_info, 0);
37
    max_leaf = (unsigned int)cpu_info[0];
38
# elif defined(__GNUC__) || defined(__clang__)
39
2
    __cpuid(0, max_leaf, ebx, ecx, edx);
40
2
# endif
41
42
2
    if (max_leaf >= 1) {
43
# ifdef _MSC_VER
44
        __cpuid(cpu_info, 1);
45
        eax = (unsigned int)cpu_info[0];
46
        ebx = (unsigned int)cpu_info[1];
47
        ecx = (unsigned int)cpu_info[2];
48
        edx = (unsigned int)cpu_info[3];
49
# elif defined(__GNUC__) || defined(__clang__)
50
        __get_cpuid(1, &eax, &ebx, &ecx, &edx);
51
2
# endif
52
2
        if (edx & (1 << 26)) // SSE2
53
2
            caps |= CPU_CAP_SSE2;
54
2
    }
55
2
#endif
56
57
2
    return caps;
58
2
}