/[svn]/linuxsampler/trunk/src/common/Features.cpp
ViewVC logotype

Contents of /linuxsampler/trunk/src/common/Features.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1314 - (show annotations) (download)
Fri Aug 31 10:29:13 2007 UTC (12 years, 10 months ago) by schoenebeck
File size: 3055 byte(s)
* minor assembly fix in x86 features detection (don't use the PIC
  register, to avoid relocations in the text segment at runtime)

1 /***************************************************************************
2 * *
3 * LinuxSampler - modular, streaming capable sampler *
4 * *
5 * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck *
6 * Copyright (C) 2005 - 2007 Christian Schoenebeck *
7 * *
8 * This program is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published by *
10 * the Free Software Foundation; either version 2 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This program is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU General Public License *
19 * along with this program; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
21 * MA 02111-1307 USA *
22 ***************************************************************************/
23
24 #include "Features.h"
25
26 #if CONFIG_ASM && ARCH_X86
27 bool Features::bMMX(false);
28 bool Features::bSSE(false);
29 bool Features::bSSE2(false);
30
31 void Features::detect() {
32 int edx;
33 __asm__ __volatile__ (
34 "movl %%ebx,%%edi\n\t" /*save PIC register*/
35 "movl $1,%%eax\n\t"
36 "cpuid\n\t"
37 "movl %%edi,%%ebx\n\t" /*restore PIC register*/
38 : "=d" (edx)
39 : : "%eax", "%ecx", "%edi"
40 );
41 bMMX = (edx & 0x00800000);
42 bSSE = (edx & 0x02000000);
43 bSSE2 = (edx & 0x04000000);
44 }
45 #else
46 void Features::detect() {}
47 #endif // CONFIG_ASM && ARCH_X86
48
49 void Features::enableDenormalsAreZeroMode() {
50 #if CONFIG_ASM && ARCH_X86
51 if (supportsSSE2()) {
52 int x;
53 __asm__ __volatile__ (
54 "stmxcsr %0\n\t"
55 "movl %0, %%eax\n\t"
56 "orl $0x40, %%eax\n\t"
57 "movl %%eax, %0\n\t"
58 "ldmxcsr %0\n\t"
59 :: "m" (x)
60 : "%eax"
61 );
62 }
63 #endif // CONFIG_ASM && ARCH_X86
64 }
65
66 String Features::featuresAsString() {
67 String sFeatures = "none";
68 #if CONFIG_ASM && ARCH_X86
69 if (supportsMMX()) sFeatures = "MMX";
70 if (supportsSSE()) sFeatures += " SSE";
71 if (supportsSSE2()) sFeatures += " SSE2";
72 #else
73 sFeatures = "disabled at compile time";
74 #endif // CONFIG_ASM && ARCH_X86
75 return sFeatures;
76 }

  ViewVC Help
Powered by ViewVC