1 /********************************************************************
3 * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. *
4 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
5 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
6 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
8 * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2003 *
9 * by the Xiph.Org Foundation http://www.xiph.org/ *
11 ********************************************************************
16 ********************************************************************/
21 cpuid(ogg_int32_t op
, ogg_uint32_t
*out_eax
, ogg_uint32_t
*out_ebx
, ogg_uint32_t
*out_ecx
, ogg_uint32_t
*out_edx
)
24 # if defined(__x86_64__)
25 asm volatile ("pushq %%rbx \n\t"
35 # elif defined(__i386__)
36 asm volatile ("pushl %%ebx \n\t"
47 ogg_uint32_t my_eax
, my_ebx
, my_ecx
, my_edx
;
72 static ogg_uint32_t
cpu_get_flags (void)
74 ogg_uint32_t eax
, ebx
, ecx
, edx
;
75 ogg_uint32_t flags
= 0;
77 /* check for cpuid support on i386 */
79 asm volatile ("pushfl \n\t"
83 "xorl $0x200000,%0 \n\t"
94 if (eax
== ebx
) /* no cpuid */
98 /*cpuid(0, &eax, &ebx, &ecx, &edx); */
100 cpuid(1, &eax
, &ebx
, &ecx
, &edx
);
101 if ((edx
& 0x00800000) == 0)
103 flags
|= CPU_X86_MMX
;
104 if (edx
& 0x02000000)
105 flags
|= CPU_X86_MMXEXT
| CPU_X86_SSE
;
106 if (edx
& 0x04000000)
107 flags
|= CPU_X86_SSE2
;
110 cpuid(0x80000000, &eax
, &ebx
, &ecx
, &edx
);
111 if(eax
>= 0x80000001) {
112 cpuid(0x80000001, &eax
, &ebx
, &ecx
, &edx
);
113 if ((edx
& 0x00800000) != 0) {
114 flags
|= CPU_X86_MMX
;
115 if (edx
& 0x80000000)
116 flags
|= CPU_X86_3DNOW
;
117 if (edx
& 0x40000000)
118 flags
|= CPU_X86_3DNOWEXT
;
119 if (edx
& 0x00400000)
120 flags
|= CPU_X86_MMXEXT
;
127 #else /* no supported cpu architecture */
129 static ogg_uint32_t
cpu_get_flags (void) {
135 ogg_uint32_t
cpu_init (void)
137 ogg_uint32_t cpu_flags
= cpu_get_flags();
141 TH_DEBUG("vectorized instruction sets supported:");
142 if (cpu_flags
& CPU_X86_MMX
) TH_DEBUG(" mmx");
143 if (cpu_flags
& CPU_X86_MMXEXT
) TH_DEBUG(" mmxext");
144 if (cpu_flags
& CPU_X86_SSE
) TH_DEBUG(" sse");
145 if (cpu_flags
& CPU_X86_SSE2
) TH_DEBUG(" sse2");
146 if (cpu_flags
& CPU_X86_3DNOW
) TH_DEBUG(" 3dnow");
147 if (cpu_flags
& CPU_X86_3DNOWEXT
) TH_DEBUG(" 3dnowext");