Statistics
| Branch: | Tag: | Revision:

root / gnuradio-core / src / lib / filter / gr_cpu_x86.cc @ fe2e6f80

History | View | Annotate | Download (2.6 kB)

1
/* -*- c++ -*- */
2
/*
3
 * Copyright 2002,2009 Free Software Foundation, Inc.
4
 * 
5
 * This file is part of GNU Radio
6
 * 
7
 * GNU Radio is free software; you can redistribute it and/or modify
8
 * it under the terms of the GNU General Public License as published by
9
 * the Free Software Foundation; either version 3, or (at your option)
10
 * any later version.
11
 * 
12
 * GNU Radio is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 * GNU General Public License for more details.
16
 * 
17
 * You should have received a copy of the GNU General Public License
18
 * along with GNU Radio; see the file COPYING.  If not, write to
19
 * the Free Software Foundation, Inc., 51 Franklin Street,
20
 * Boston, MA 02110-1301, USA.
21
 */
22
23
#include <gr_cpu.h>
24
#include "gcc_x86_cpuid.h"
25
26
/*
27
 * execute CPUID instruction, return EAX, EBX, ECX and EDX values in result
28
 */
29
#define cpuid_x86(op, r) __get_cpuid(op, r+0, r+1, r+2, r+3)
30
31
/*
32
 * CPUID functions returning a single datum
33
 */
34
35
static inline unsigned int cpuid_eax(unsigned int op)
36
{
37
  unsigned int        regs[4] = {0,0,0,0};
38
  cpuid_x86 (op, regs);
39
  return regs[0];
40
}
41
42
static inline unsigned int cpuid_ebx(unsigned int op)
43
{
44
  unsigned int        regs[4] = {0,0,0,0};
45
  cpuid_x86 (op, regs);
46
  return regs[1];
47
}
48
49
static inline unsigned int cpuid_ecx(unsigned int op)
50
{
51
  unsigned int        regs[4] = {0,0,0,0};
52
  cpuid_x86 (op, regs);
53
  return regs[2];
54
}
55
56
static inline unsigned int cpuid_edx(unsigned int op)
57
{
58
  unsigned int        regs[4] = {0,0,0,0};
59
  cpuid_x86 (op, regs);
60
  return regs[3];
61
}
62
63
// ----------------------------------------------------------------
64
65
bool
66
gr_cpu::has_mmx ()
67
{
68
  unsigned int edx = cpuid_edx (1);        // standard features
69
  return (edx & (1 << 23)) != 0;
70
}
71
72
bool
73
gr_cpu::has_sse ()
74
{
75
  unsigned int edx = cpuid_edx (1);        // standard features
76
  return (edx & (1 << 25)) != 0;
77
}
78
79
bool
80
gr_cpu::has_sse2 ()
81
{
82
  unsigned int edx = cpuid_edx (1);        // standard features
83
  return (edx & (1 << 26)) != 0;
84
}
85
86
bool
87
gr_cpu::has_3dnow ()
88
{
89
  unsigned int extended_fct_count = cpuid_eax (0x80000000);
90
  if (extended_fct_count < 0x80000001)
91
    return false;
92
93
  unsigned int extended_features = cpuid_edx (0x80000001);
94
  return (extended_features & (1 << 31)) != 0;
95
}
96
97
bool
98
gr_cpu::has_3dnowext ()
99
{
100
  unsigned int extended_fct_count = cpuid_eax (0x80000000);
101
  if (extended_fct_count < 0x80000001)
102
    return false;
103
104
  unsigned int extended_features = cpuid_edx (0x80000001);
105
  return (extended_features & (1 << 30)) != 0;
106
}
107
108
bool
109
gr_cpu::has_altivec ()
110
{
111
  return false;
112
}
113
114
bool
115
gr_cpu::has_armv7_a ()
116
{
117
  return false;
118
}
119