~ubuntu-branches/ubuntu/vivid/rtfilter/vivid

« back to all changes in this revision

Viewing changes to src/probesimd.h

  • Committer: Package Import Robot
  • Author(s): Nicolas Bourdaud
  • Date: 2011-12-01 12:09:30 UTC
  • Revision ID: package-import@ubuntu.com-20111201120930-lmia8ytlwmif9yta
Tags: upstream-1.1
ImportĀ upstreamĀ versionĀ 1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    Copyright (C) 2011 Nicolas Bourdaud <nicolas.bourdaud@epfl.ch>
 
3
 
 
4
    This file is part of the rtfilter library
 
5
 
 
6
    The rtfilter library is free software: you can redistribute it and/or
 
7
    modify it under the terms of the version 3 of the GNU Lesser General
 
8
    Public License as published by the Free Software Foundation.
 
9
  
 
10
    This program 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
 
13
    GNU Lesser General Public License for more details.
 
14
    
 
15
    You should have received a copy of the GNU Lesser General Public License
 
16
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
17
*/
 
18
#ifndef PROBESIMD_H
 
19
#define PROBESIMD_H
 
20
 
 
21
#if HAVE_CPUID
 
22
#include <cpuid.h>
 
23
 
 
24
static inline 
 
25
int cputest_sse(void)
 
26
{
 
27
        unsigned int eax, ebx, ecx, edx;
 
28
        if (__get_cpuid(1, &eax, &ebx, &ecx, &edx) && (edx & bit_SSE))
 
29
                return 1;
 
30
        return 0;
 
31
}
 
32
 
 
33
static inline 
 
34
int cputest_sse2(void)
 
35
{
 
36
        unsigned int eax, ebx, ecx, edx;
 
37
        if (__get_cpuid(1, &eax, &ebx, &ecx, &edx) && (edx & bit_SSE))
 
38
                return 1;
 
39
        return 0;
 
40
}
 
41
 
 
42
static inline 
 
43
int cputest_sse3(void)
 
44
{
 
45
        unsigned int eax, ebx, ecx, edx;
 
46
        if (__get_cpuid(1, &eax, &ebx, &ecx, &edx) && (edx & bit_SSE))
 
47
                return 1;
 
48
        return 0;
 
49
}
 
50
 
 
51
#else /* HAVE_CPUID */
 
52
 
 
53
static inline 
 
54
int cputest_sse(void)
 
55
{
 
56
#ifdef __SSE__
 
57
        return 1;
 
58
#else
 
59
        return 0;
 
60
#endif
 
61
}
 
62
 
 
63
static inline 
 
64
int cputest_sse2(void)
 
65
{
 
66
#ifdef __SSE2__
 
67
        return 1;
 
68
#else
 
69
        return 0;
 
70
#endif
 
71
}
 
72
 
 
73
static inline 
 
74
int cputest_sse3(void)
 
75
{
 
76
#ifdef __SSE3__
 
77
        return 1;
 
78
#else
 
79
        return 0;
 
80
#endif
 
81
}
 
82
 
 
83
#endif /* HAVE_CPUID */
 
84
 
 
85
 
 
86
#endif /* PROBESIMD_H */
 
87