Blender V2.61 - r43446

cpu.c

Go to the documentation of this file.
00001 /*
00002  *
00003  *
00004  * ***** BEGIN GPL LICENSE BLOCK *****
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version. 
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software Foundation,
00018  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  *
00020  * ***** END GPL LICENSE BLOCK *****
00021  */
00022 
00028 #include "BLI_cpu.h"
00029 
00030 int BLI_cpu_support_sse2(void)
00031 {
00032 #if defined(__x86_64__) || defined(_M_X64)
00033     /* x86_64 always has SSE2 instructions */
00034     return 1;
00035 #elif defined(__GNUC__) && defined(i386)
00036     /* for GCC x86 we check cpuid */
00037     unsigned int d;
00038     __asm__(
00039         "pushl %%ebx\n\t"
00040         "cpuid\n\t"
00041         "popl %%ebx\n\t"
00042           : "=d"(d)
00043           : "a"(1));
00044     return (d & 0x04000000) != 0;
00045 #elif (defined(_MSC_VER) && defined(_M_IX86))
00046     /* also check cpuid for MSVC x86 */
00047     unsigned int d;
00048     __asm {
00049         xor     eax, eax
00050         inc     eax
00051         push    ebx
00052         cpuid
00053         pop     ebx
00054         mov     d, edx
00055     }
00056     return (d & 0x04000000) != 0;
00057 #endif
00058 
00059     return 0;
00060 }
00061