Rev 1905 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1905 | Rev 3960 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | getcpucpuflags: get cpuflags for ia32 |
2 | getcpucpuflags: get cpuflags for ia32 |
3 | 3 | ||
4 | copyright ?-2007 by the mpg123 project - free software under the terms of the LGPL 2.1 |
4 | copyright ?-2007 by the mpg123 project - free software under the terms of the LGPL 2.1 |
5 | see COPYING and AUTHORS files in distribution or http:#mpg123.org |
5 | see COPYING and AUTHORS files in distribution or http:#mpg123.org |
6 | initially written by KIMURA Takuhiro (for 3DNow!) |
6 | initially written by KIMURA Takuhiro (for 3DNow!) |
7 | extended for general use by Thomas Orgis |
7 | extended for general use by Thomas Orgis |
8 | */ |
8 | */ |
9 | 9 | ||
10 | #ifndef MPG123_H_GETCPUFLAGS |
10 | #ifndef MPG123_H_GETCPUFLAGS |
11 | #define MPG123_H_GETCPUFLAGS |
11 | #define MPG123_H_GETCPUFLAGS |
12 | 12 | ||
13 | /* standard level flags part 1 (ECX)*/ |
13 | /* standard level flags part 1 (ECX)*/ |
14 | #define FLAG_SSE3 0x00000001 |
14 | #define FLAG_SSE3 0x00000001 |
15 | 15 | ||
16 | /* standard level flags part 2 (EDX) */ |
16 | /* standard level flags part 2 (EDX) */ |
17 | #define FLAG2_MMX 0x00800000 |
17 | #define FLAG2_MMX 0x00800000 |
18 | #define FLAG2_SSE 0x02000000 |
18 | #define FLAG2_SSE 0x02000000 |
19 | #define FLAG2_SSE2 0x04000000 |
19 | #define FLAG2_SSE2 0x04000000 |
20 | #define FLAG2_FPU 0x00000001 |
20 | #define FLAG2_FPU 0x00000001 |
21 | /* cpuid extended level 1 (AMD) */ |
21 | /* cpuid extended level 1 (AMD) */ |
22 | #define XFLAG_MMX 0x00800000 |
22 | #define XFLAG_MMX 0x00800000 |
23 | #define XFLAG_3DNOW 0x80000000 |
23 | #define XFLAG_3DNOW 0x80000000 |
24 | #define XFLAG_3DNOWEXT 0x40000000 |
24 | #define XFLAG_3DNOWEXT 0x40000000 |
25 | 25 | ||
26 | struct cpuflags |
26 | struct cpuflags |
27 | { |
27 | { |
28 | unsigned int id; |
28 | unsigned int id; |
29 | unsigned int std; |
29 | unsigned int std; |
30 | unsigned int std2; |
30 | unsigned int std2; |
31 | unsigned int ext; |
31 | unsigned int ext; |
32 | }; |
32 | }; |
33 | - | ||
34 | extern struct cpuflags cpu_flags; |
- | |
35 | 33 | ||
36 | unsigned int getcpuflags(struct cpuflags* cf); |
34 | unsigned int getcpuflags(struct cpuflags* cf); |
37 | 35 | ||
38 | /* checks the family */ |
36 | /* checks the family */ |
39 | #define cpu_i586(s) ( ((s.id & 0xf00)>>8) == 0 || ((s.id & 0xf00)>>8) > 4 ) |
37 | #define cpu_i586(s) ( ((s.id & 0xf00)>>8) == 0 || ((s.id & 0xf00)>>8) > 4 ) |
40 | /* checking some flags... */ |
38 | /* checking some flags... */ |
41 | #define cpu_fpu(s) (FLAG2_FPU & s.std2) |
39 | #define cpu_fpu(s) (FLAG2_FPU & s.std2) |
42 | #define cpu_mmx(s) (FLAG2_MMX & s.std2 || XFLAG_MMX & s.ext) |
40 | #define cpu_mmx(s) (FLAG2_MMX & s.std2 || XFLAG_MMX & s.ext) |
43 | #define cpu_3dnow(s) (XFLAG_3DNOW & s.ext) |
41 | #define cpu_3dnow(s) (XFLAG_3DNOW & s.ext) |
44 | #define cpu_3dnowext(s) (XFLAG_3DNOWEXT & s.ext) |
42 | #define cpu_3dnowext(s) (XFLAG_3DNOWEXT & s.ext) |
45 | #define cpu_sse(s) (FLAG2_SSE & s.std2) |
43 | #define cpu_sse(s) (FLAG2_SSE & s.std2) |
46 | #define cpu_sse2(s) (FLAG2_SSE2 & s.std2) |
44 | #define cpu_sse2(s) (FLAG2_SSE2 & s.std2) |
47 | #define cpu_sse3(s) (FLAG_SSE3 & s.std) |
45 | #define cpu_sse3(s) (FLAG_SSE3 & s.std) |
48 | 46 | ||
49 | #endif |
47 | #endif |