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