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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 579 - (hide annotations) (download)
Tue May 24 19:20:20 2005 UTC (18 years, 10 months ago) by schoenebeck
File size: 3235 byte(s)
* src/network/lscpserver.cpp: fixed segfault
  (patch by Grigor Iliev, fixes #17)
* added man page
* final preparations for the first official release (which will be 0.3.1)

1 schoenebeck 320 /***************************************************************************
2     * *
3     * LinuxSampler - modular, streaming capable sampler *
4     * *
5     * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck *
6 schoenebeck 579 * Copyright (C) 2005 Christian Schoenebeck *
7 schoenebeck 320 * *
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 ARCH_X86
27     bool Features::bMMX(false);
28     bool Features::bSSE(false);
29 persson 425 bool Features::bSSE2(false);
30 schoenebeck 320
31     unsigned int edx = 0;
32     unsigned int eax_temp = 0;
33     unsigned int ebx_temp = 0;
34     unsigned int ecx_temp = 0;
35     unsigned int edx_temp = 0;
36    
37     void Features::detect() {
38     // we store and restore all registers modified by 'cpuid' the old fashioned way
39 schoenebeck 579 __asm__ __volatile__ (
40     "mov %eax,eax_temp\n\t"
41     "mov %ebx,ebx_temp\n\t"
42     "mov %ecx,ecx_temp\n\t"
43     "mov %edx,edx_temp\n\t"
44     "mov $1,%eax\n\t"
45     "cpuid\n\t"
46     "mov %edx,edx\n\t"
47     "mov eax_temp,%eax\n\t"
48     "mov ebx_temp,%ebx\n\t"
49     "mov ecx_temp,%ecx\n\t"
50     "mov edx_temp,%edx\n\t"
51     );
52 schoenebeck 320 bMMX = (edx & 0x00800000);
53     bSSE = (edx & 0x02000000);
54 persson 425 bSSE2 = (edx & 0x04000000);
55 schoenebeck 320 }
56 schoenebeck 361 #else
57     void Features::detect() {}
58 schoenebeck 320 #endif // ARCH_X86
59 schoenebeck 579
60     void Features::enableDenormalsAreZeroMode() {
61     #if ARCH_X86
62     if (supportsSSE2()) {
63     int x;
64     __asm__ __volatile__ (
65     "stmxcsr %0\n\t"
66     "movl %0, %%eax\n\t"
67     "orl $0x40, %%eax\n\t"
68     "movl %%eax, %0\n\t"
69     "ldmxcsr %0\n\t"
70     :: "m" (x)
71     : "%eax"
72     );
73     }
74     #endif // ARCH_X86
75     }
76    
77     String Features::featuresAsString() {
78     String sFeatures = "none";
79     #if ARCH_X86
80     if (supportsMMX()) sFeatures = "MMX";
81     if (supportsSSE()) sFeatures += " SSE";
82     if (supportsSSE2()) sFeatures += " SSE2";
83     #endif // ARCH_X86
84     return sFeatures;
85     }

  ViewVC Help
Powered by ViewVC